Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 10376:7196933335d9
[gaim-migrate @ 11601]
Of course, though, I meant this.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 15 Dec 2004 01:56:10 +0000 |
parents | cbfd90f7fa47 |
children | 3cf69ffdc25e |
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 | |
10376 | 381 } else if (!strcmp(encoding, "iso-8859-1")) { |
382 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); | |
383 } else if (!strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
10375 | 384 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
9595 | 385 } else if (!strcmp(encoding, "unicode-2-0")) { |
386 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
387 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
388 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
10096 | 389 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 390 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
391 } | |
392 | |
393 /* | |
394 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
395 * we have been unable to convert the text to utf-8 from the encoding | |
396 * that was specified. So we check if the text is valid utf-8 then | |
397 * just copy it. | |
398 */ | |
399 if (utf8 == NULL) { | |
9638 | 400 if (textlen != 0 && *text != '\0' |
401 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 402 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 403 else |
9481 | 404 utf8 = g_strndup(text, textlen); |
5129 | 405 } |
406 | |
407 return utf8; | |
408 } | |
409 | |
9830 | 410 static gchar * |
9908 | 411 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 412 { |
413 gchar *ret = NULL; | |
414 GError *err = NULL; | |
415 | |
9908 | 416 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
417 return NULL; | |
418 | |
419 if (strcasecmp("UTF-8", charsetstr)) { | |
420 if (fallback) | |
421 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
422 else | |
423 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
424 if (err != NULL) { | |
425 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
426 charsetstr, err->message); | |
427 g_error_free(err); | |
428 } | |
429 } else { | |
430 if (g_utf8_validate(data, datalen, NULL)) | |
431 ret = g_strndup(data, datalen); | |
432 else | |
433 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
434 } | |
435 | |
436 return ret; | |
437 } | |
438 | |
439 /* | |
440 * We try decoding using two different character sets. The charset | |
441 * specified in the IM determines the order in which we attempt to | |
442 * decode. We do this because there are lots of broken ICQ clients | |
443 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
444 * able to deal with that crap, then people complain like banshees. | |
445 * charsetstr1 is always set to what the correct encoding should be. | |
446 */ | |
447 static gchar * | |
448 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
449 { | |
450 gchar *ret = NULL; | |
451 const gchar *charsetstr1, *charsetstr2; | |
452 | |
453 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 454 |
455 if ((datalen == 0) || (data == NULL)) | |
456 return NULL; | |
457 | |
9908 | 458 if (charset == AIM_CHARSET_UNICODE) { |
459 charsetstr1 = "UCS-2BE"; | |
460 charsetstr2 = "UTF-8"; | |
461 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 462 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 463 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 464 else |
9908 | 465 charsetstr1 = "ISO-8859-1"; |
466 charsetstr2 = "UTF-8"; | |
467 } else if (charset == AIM_CHARSET_ASCII) { | |
468 /* Should just be "ASCII" */ | |
9914 | 469 charsetstr1 = "ASCII"; |
9908 | 470 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
471 } else if (charset == 0x000d) { | |
9830 | 472 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 473 charsetstr1 = "ISO-8859-1"; |
474 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
475 } else { | |
9830 | 476 /* Unknown, hope for valid UTF-8... */ |
9908 | 477 charsetstr1 = "UTF-8"; |
478 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
479 } | |
480 | |
481 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
482 if (ret == NULL) | |
483 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
484 if (ret == NULL) | |
485 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 486 |
487 return ret; | |
488 } | |
489 | |
490 static void | |
491 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 492 gchar **msg, int *msglen_int, |
9830 | 493 fu16_t *charset, fu16_t *charsubset) |
494 { | |
495 OscarData *od = gc->proto_data; | |
496 GaimAccount *account = gaim_connection_get_account(gc); | |
497 GError *err = NULL; | |
498 aim_userinfo_t *userinfo = NULL; | |
499 const gchar *charsetstr; | |
10039 | 500 gsize msglen; |
9830 | 501 |
502 /* Attempt to send as ASCII */ | |
10098 | 503 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 504 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 505 *charset = AIM_CHARSET_ASCII; |
9830 | 506 *charsubset = 0x0000; |
10039 | 507 *msglen_int = msglen; |
9830 | 508 return; |
509 } | |
510 | |
511 /* | |
9908 | 512 * If we're sending to an ICQ user, and they are advertising the |
513 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 514 */ |
9975 | 515 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 516 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
517 | |
518 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
10039 | 519 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
9830 | 520 if (*msg != NULL) { |
521 *charset = AIM_CHARSET_UNICODE; | |
522 *charsubset = 0x0000; | |
10039 | 523 *msglen_int = msglen; |
9830 | 524 return; |
525 } | |
526 } | |
527 | |
528 /* | |
529 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
530 * ICQ then attempt to send as the user specified character encoding. | |
531 */ | |
532 charsetstr = "ISO-8859-1"; | |
9975 | 533 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 534 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
535 | |
10097 | 536 /* |
537 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
538 * can be converted to "charsetstr" | |
539 */ | |
10039 | 540 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 541 if (*msg != NULL) { |
542 *charset = AIM_CHARSET_CUSTOM; | |
543 *charsubset = 0x0000; | |
10039 | 544 *msglen_int = msglen; |
9830 | 545 return; |
546 } | |
547 | |
548 /* | |
549 * Nothing else worked, so send as UCS-2BE. | |
550 */ | |
10039 | 551 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 552 if (*msg != NULL) { |
553 *charset = AIM_CHARSET_UNICODE; | |
554 *charsubset = 0x0000; | |
10039 | 555 *msglen_int = msglen; |
9830 | 556 return; |
557 } | |
558 | |
9908 | 559 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 560 g_error_free(err); |
561 | |
562 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
563 *msg = g_strdup(from); | |
10039 | 564 *msglen_int = strlen(*msg); |
9830 | 565 *charset = AIM_CHARSET_ASCII; |
566 *charsubset = 0x0000; | |
567 return; | |
568 } | |
569 | |
9407 | 570 gchar *oscar_caps_to_string(guint caps) |
8701 | 571 { |
9407 | 572 GString *str; |
573 gchar *tmp; | |
8701 | 574 guint bit = 1; |
575 | |
9407 | 576 str = g_string_new(""); |
577 | |
8701 | 578 if (!caps) { |
579 return NULL; | |
580 } else while (bit <= AIM_CAPS_LAST) { | |
581 if (bit & caps) { | |
582 switch (bit) { | |
583 case AIM_CAPS_BUDDYICON: | |
584 tmp = _("Buddy Icon"); | |
585 break; | |
586 case AIM_CAPS_TALK: | |
587 tmp = _("Voice"); | |
588 break; | |
589 case AIM_CAPS_DIRECTIM: | |
590 tmp = _("AIM Direct IM"); | |
591 break; | |
592 case AIM_CAPS_CHAT: | |
593 tmp = _("Chat"); | |
594 break; | |
595 case AIM_CAPS_GETFILE: | |
596 tmp = _("Get File"); | |
597 break; | |
598 case AIM_CAPS_SENDFILE: | |
599 tmp = _("Send File"); | |
600 break; | |
601 case AIM_CAPS_GAMES: | |
602 case AIM_CAPS_GAMES2: | |
603 tmp = _("Games"); | |
604 break; | |
605 case AIM_CAPS_ADDINS: | |
606 tmp = _("Add-Ins"); | |
607 break; | |
608 case AIM_CAPS_SENDBUDDYLIST: | |
609 tmp = _("Send Buddy List"); | |
610 break; | |
611 case AIM_CAPS_ICQ_DIRECT: | |
612 tmp = _("ICQ Direct Connect"); | |
613 break; | |
614 case AIM_CAPS_APINFO: | |
615 tmp = _("AP User"); | |
616 break; | |
617 case AIM_CAPS_ICQRTF: | |
618 tmp = _("ICQ RTF"); | |
619 break; | |
620 case AIM_CAPS_EMPTY: | |
621 tmp = _("Nihilist"); | |
622 break; | |
623 case AIM_CAPS_ICQSERVERRELAY: | |
624 tmp = _("ICQ Server Relay"); | |
625 break; | |
626 case AIM_CAPS_ICQUTF8OLD: | |
627 tmp = _("Old ICQ UTF8"); | |
628 break; | |
629 case AIM_CAPS_TRILLIANCRYPT: | |
630 tmp = _("Trillian Encryption"); | |
631 break; | |
632 case AIM_CAPS_ICQUTF8: | |
633 tmp = _("ICQ UTF8"); | |
634 break; | |
635 case AIM_CAPS_HIPTOP: | |
636 tmp = _("Hiptop"); | |
637 break; | |
638 case AIM_CAPS_SECUREIM: | |
639 tmp = _("Security Enabled"); | |
640 break; | |
641 case AIM_CAPS_VIDEO: | |
642 tmp = _("Video Chat"); | |
643 break; | |
644 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
645 case AIM_CAPS_ICHATAV: | |
646 tmp = _("iChat AV"); | |
647 break; | |
648 case AIM_CAPS_LIVEVIDEO: | |
649 tmp = _("Live Video"); | |
650 break; | |
651 case AIM_CAPS_CAMERA: | |
652 tmp = _("Camera"); | |
653 break; | |
654 default: | |
655 tmp = NULL; | |
656 break; | |
657 } | |
658 if (tmp) | |
9532 | 659 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 660 } |
661 bit <<= 1; | |
662 } | |
9407 | 663 |
664 return g_string_free(str, FALSE); | |
8701 | 665 } |
666 | |
667 static char *oscar_icqstatus(int state) { | |
668 /* Make a cute little string that shows the status of the dude or dudet */ | |
669 if (state & AIM_ICQ_STATE_CHAT) | |
670 return g_strdup_printf(_("Free For Chat")); | |
671 else if (state & AIM_ICQ_STATE_DND) | |
672 return g_strdup_printf(_("Do Not Disturb")); | |
673 else if (state & AIM_ICQ_STATE_OUT) | |
674 return g_strdup_printf(_("Not Available")); | |
675 else if (state & AIM_ICQ_STATE_BUSY) | |
676 return g_strdup_printf(_("Occupied")); | |
677 else if (state & AIM_ICQ_STATE_AWAY) | |
678 return g_strdup_printf(_("Away")); | |
679 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
680 return g_strdup_printf(_("Web Aware")); | |
681 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
682 return g_strdup_printf(_("Invisible")); | |
683 else | |
684 return g_strdup_printf(_("Online")); | |
685 } | |
686 | |
9973 | 687 static void |
688 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 689 { |
690 gchar *utf8; | |
691 | |
692 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 693 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 694 g_free(utf8); |
695 } | |
696 } | |
697 | |
9973 | 698 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 699 { |
10042 | 700 OscarData *od; |
701 GaimAccount *account; | |
702 GaimPresence *presence; | |
703 GaimPresence *buddy_presence; | |
8701 | 704 GaimGroup *g = NULL; |
705 struct buddyinfo *bi = NULL; | |
706 char *tmp; | |
707 | |
10042 | 708 od = gc->proto_data; |
709 account = gaim_connection_get_account(gc); | |
710 presence = gaim_account_get_presence(account); | |
711 buddy_presence = gaim_buddy_get_presence(b); | |
712 | |
713 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 714 return; |
715 | |
716 if (userinfo == NULL) | |
717 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
718 | |
719 if (b == NULL) | |
10042 | 720 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 721 |
722 if (b != NULL) | |
723 g = gaim_find_buddys_group(b); | |
724 | |
725 if (userinfo != NULL) | |
726 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
727 | |
8733 | 728 if (b != NULL) { |
10042 | 729 if (gaim_presence_is_online(buddy_presence)) { |
9975 | 730 if (aim_sn_is_icq(b->name)) { |
8733 | 731 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
732 oscar_string_append(str, newline, _("Status"), tmp); | |
733 g_free(tmp); | |
734 } | |
735 } else { | |
9625 | 736 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 737 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
738 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
739 else | |
740 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 741 } |
8733 | 742 } |
8701 | 743 |
744 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 745 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 746 (bi->ipaddr & 0xff000000) >> 24, |
747 (bi->ipaddr & 0x00ff0000) >> 16, | |
748 (bi->ipaddr & 0x0000ff00) >> 8, | |
749 (bi->ipaddr & 0x000000ff)); | |
750 oscar_string_append(str, newline, _("IP Address"), tmp); | |
751 g_free(tmp); | |
752 } | |
753 | |
754 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
755 tmp = oscar_caps_to_string(userinfo->capabilities); | |
756 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 757 g_free(tmp); |
8701 | 758 } |
759 | |
760 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
761 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
762 if (tmp != NULL) { | |
9625 | 763 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 764 g_free(tmp); |
9625 | 765 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
766 g_free(tmp2); | |
8701 | 767 } |
768 } | |
769 | |
10042 | 770 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_presence_is_available(presence)) { |
8701 | 771 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
772 oscar_string_append(str, newline, _("Available"), tmp); | |
773 g_free(tmp); | |
774 } | |
775 } | |
776 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
777 static char *extract_name(const char *name) { |
4121 | 778 char *tmp, *x; |
2086 | 779 int i, j; |
4120 | 780 |
781 if (!name) | |
4121 | 782 return NULL; |
10042 | 783 |
4120 | 784 x = strchr(name, '-'); |
4121 | 785 |
2086 | 786 if (!x) return NULL; |
787 x = strchr(++x, '-'); | |
788 if (!x) return NULL; | |
789 tmp = g_strdup(++x); | |
790 | |
791 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
792 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
793 if (x[i] != '%') { |
2086 | 794 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
795 continue; |
2086 | 796 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
797 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
798 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
799 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 800 } |
801 | |
802 tmp[j] = 0; | |
803 return tmp; | |
804 } | |
805 | |
5575 | 806 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 807 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 808 struct chat_connection *c = NULL; |
809 | |
810 while (g) { | |
811 c = (struct chat_connection *)g->data; | |
812 if (c->id == id) | |
813 break; | |
814 g = g->next; | |
815 c = NULL; | |
816 } | |
817 | |
818 return c; | |
819 } | |
820 | |
5575 | 821 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
|
822 aim_conn_t *conn) { |
7283 | 823 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 824 struct chat_connection *c = NULL; |
825 | |
826 while (g) { | |
827 c = (struct chat_connection *)g->data; | |
828 if (c->conn == conn) | |
829 break; | |
830 g = g->next; | |
831 c = NULL; | |
832 } | |
833 | |
834 return c; | |
835 } | |
836 | |
8219 | 837 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
838 GaimConversation *conv) { | |
839 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
840 struct chat_connection *c = NULL; | |
841 | |
842 while (g) { | |
843 c = (struct chat_connection *)g->data; | |
8733 | 844 if (c->conv == conv) |
8219 | 845 break; |
846 g = g->next; | |
847 c = NULL; | |
848 } | |
849 | |
850 return c; | |
851 } | |
852 | |
8971 | 853 /***************************************************************************** |
854 * Begin scary direct im stuff | |
855 *****************************************************************************/ | |
856 | |
857 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
858 GSList *d = od->direct_ims; | |
859 struct oscar_direct_im *m = NULL; | |
860 | |
861 while (d) { | |
862 m = (struct oscar_direct_im *)d->data; | |
863 if (!aim_sncmp(who, m->name)) | |
864 return m; | |
865 d = d->next; | |
866 } | |
867 | |
868 return NULL; | |
869 } | |
870 | |
871 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
872 { | |
873 gaim_debug_info("oscar", | |
874 "destroying Direct IM for %s.\n", dim->name); | |
875 | |
876 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 877 if (dim->gpc_pend) { |
878 dim->killme = TRUE; | |
879 return; | |
880 } | |
8971 | 881 if (dim->watcher) |
882 gaim_input_remove(dim->watcher); | |
883 if (dim->conn) { | |
10271 | 884 aim_conn_close(dim->conn); |
8971 | 885 aim_conn_kill(od->sess, &dim->conn); |
886 } | |
887 g_free(dim); | |
888 } | |
889 | |
890 /* the only difference between this and destroy is this writes a conv message */ | |
891 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
892 { | |
893 GaimConversation *conv; | |
894 char buf[256]; | |
895 | |
896 gaim_debug_info("oscar", | |
897 "%s disconnected Direct IM.\n", dim->name); | |
898 | |
899 if (dim->connected) | |
900 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 901 else |
8971 | 902 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
903 | |
10246 | 904 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
905 gaim_connection_get_account(dim->gc)); | |
8971 | 906 if (conv) { |
907 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 908 gaim_conversation_update_progress(conv, 0); |
8971 | 909 } else { |
910 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
911 } | |
912 | |
913 oscar_direct_im_destroy(od, dim); | |
914 | |
915 return; | |
916 } | |
917 | |
918 /* oops i made two of these. this one just calls the other one. */ | |
919 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
920 { | |
921 GaimConnection *gc = sess->aux_data; | |
922 OscarData *od = (OscarData *)gc->proto_data; | |
923 struct oscar_direct_im *dim; | |
924 char *sn; | |
925 | |
926 sn = g_strdup(aim_odc_getsn(conn)); | |
927 dim = oscar_direct_im_find(od, sn); | |
928 oscar_direct_im_disconnect(od, dim); | |
929 g_free(sn); | |
930 } | |
931 | |
932 static void destroy_direct_im_request(struct ask_direct *d) { | |
933 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
934 | |
935 g_free(d->sn); | |
936 g_free(d); | |
937 } | |
938 | |
939 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
940 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
941 struct oscar_direct_im *dim = data; | |
942 GaimConnection *gc = dim->gc; | |
943 OscarData *od = gc->proto_data; | |
944 GaimConversation *conv; | |
945 char buf[256]; | |
946 struct sockaddr name; | |
947 socklen_t name_len = 1; | |
948 | |
949 g_return_if_fail(gc != NULL); | |
950 | |
8978 | 951 dim->gpc_pend = FALSE; |
952 if (dim->killme) { | |
953 oscar_direct_im_destroy(od, dim); | |
954 return; | |
955 } | |
956 | |
8971 | 957 if (!g_list_find(gaim_connections_get_all(), gc)) { |
958 oscar_direct_im_destroy(od, dim); | |
959 return; | |
960 } | |
961 | |
962 if (source < 0) { | |
8984 | 963 if (dim->donttryagain) { |
964 oscar_direct_im_disconnect(od, dim); | |
965 return; | |
966 } else { | |
967 fu8_t cookie[8]; | |
968 char *who = g_strdup(dim->name); | |
969 const char *tmp = aim_odc_getcookie(dim->conn); | |
970 | |
971 memcpy(cookie, tmp, 8); | |
972 oscar_direct_im_destroy(od, dim); | |
973 oscar_direct_im_initiate(gc, who, cookie); | |
974 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
975 g_free(who); | |
976 return; | |
977 } | |
8971 | 978 } |
979 | |
980 dim->conn->fd = source; | |
981 aim_conn_completeconnect(od->sess, dim->conn); | |
982 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
983 | |
984 /* This is the best way to see if we're connected or not */ | |
8983 | 985 /* Is this really needed? */ |
8971 | 986 if (getpeername(source, &name, &name_len) == 0) { |
987 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
988 dim->connected = TRUE; | |
989 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 990 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
991 } else { | |
8984 | 992 if (dim->donttryagain) { |
993 oscar_direct_im_disconnect(od, dim); | |
994 return; | |
995 } else { | |
996 fu8_t cookie[8]; | |
997 char *who = g_strdup(dim->name); | |
998 const char *tmp = aim_odc_getcookie(dim->conn); | |
999 | |
1000 memcpy(cookie, tmp, 8); | |
1001 oscar_direct_im_destroy(od, dim); | |
1002 oscar_direct_im_initiate(gc, who, cookie); | |
1003 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1004 g_free(who); | |
1005 return; | |
1006 } | |
8983 | 1007 } |
1008 | |
1009 | |
8971 | 1010 } |
1011 | |
1012 static void accept_direct_im_request(struct ask_direct *d) { | |
1013 GaimConnection *gc = d->gc; | |
1014 OscarData *od; | |
1015 struct oscar_direct_im *dim; | |
1016 char *host; int port = 5190; | |
1017 int i, rc; | |
8982 | 1018 char *tmp; |
1019 GaimConversation *conv; | |
8971 | 1020 |
1021 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1022 destroy_direct_im_request(d); | |
1023 return; | |
1024 } | |
1025 | |
1026 od = (OscarData *)gc->proto_data; | |
1027 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1028 | |
1029 dim = oscar_direct_im_find(od, d->sn); | |
1030 if (dim && dim->connected) { | |
1031 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1032 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1033 return; | |
1034 } | |
1035 dim = g_new0(struct oscar_direct_im, 1); | |
1036 dim->gc = d->gc; | |
8984 | 1037 dim->donttryagain = d->donttryagain; |
8971 | 1038 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1039 | |
1040 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1041 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1042 if (!dim->conn) { | |
1043 oscar_direct_im_disconnect(od, dim); | |
1044 destroy_direct_im_request(d); | |
1045 return; | |
1046 } | |
1047 | |
1048 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1049 gaim_odc_incoming, 0); | |
1050 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1051 gaim_odc_typing, 0); | |
1052 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1053 gaim_odc_update_ui, 0); | |
1054 | |
1055 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1056 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1057 if (d->ip[i] == ':') { | |
1058 port = atoi(&(d->ip[i+1])); | |
1059 break; | |
1060 } | |
1061 } | |
1062 host = g_strndup(d->ip, i); | |
1063 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1064 dim->gpc_pend = TRUE; |
8971 | 1065 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1066 |
1067 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1068 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1069 port); | |
1070 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1071 g_free(tmp); | |
8983 | 1072 |
8971 | 1073 g_free(host); |
1074 if (rc < 0) { | |
8978 | 1075 dim->gpc_pend = FALSE; |
8971 | 1076 oscar_direct_im_disconnect(od, dim); |
1077 destroy_direct_im_request(d); | |
1078 return; | |
1079 } | |
1080 | |
1081 destroy_direct_im_request(d); | |
1082 | |
1083 return; | |
1084 } | |
1085 | |
1086 /* | |
1087 * We have just established a socket with the other dude, so set up some handlers. | |
1088 */ | |
1089 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1090 GaimConnection *gc = sess->aux_data; |
7283 | 1091 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1092 GaimConversation *conv; |
8971 | 1093 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1094 char buf[256]; |
8971 | 1095 char *sn; |
1096 va_list ap; | |
1097 aim_conn_t *newconn, *listenerconn; | |
1098 | |
1099 va_start(ap, fr); | |
1100 newconn = va_arg(ap, aim_conn_t *); | |
1101 listenerconn = va_arg(ap, aim_conn_t *); | |
1102 va_end(ap); | |
1103 | |
10271 | 1104 aim_conn_close(listenerconn); |
8971 | 1105 aim_conn_kill(sess, &listenerconn); |
1106 | |
1107 sn = g_strdup(aim_odc_getsn(newconn)); | |
1108 | |
1109 gaim_debug_info("oscar", | |
1110 "DirectIM: initiate success to %s\n", sn); | |
1111 dim = oscar_direct_im_find(od, sn); | |
1112 | |
1113 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1114 gaim_input_remove(dim->watcher); | |
1115 dim->conn = newconn; | |
1116 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1117 dim->connected = TRUE; | |
1118 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1119 g_free(sn); | |
1120 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1121 | |
1122 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1123 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1124 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1125 | |
1126 return 1; | |
1127 } | |
1128 | |
1129 /* | |
1130 * This is called when each chunk of an image is received. It can be used to | |
1131 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1132 * nasty, you sicko. | |
1133 */ | |
1134 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1135 va_list ap; | |
1136 char *sn; | |
1137 double percent; | |
1138 GaimConnection *gc = sess->aux_data; | |
1139 OscarData *od = (OscarData *)gc->proto_data; | |
1140 GaimConversation *c; | |
1141 struct oscar_direct_im *dim; | |
1142 | |
1143 va_start(ap, fr); | |
1144 sn = va_arg(ap, char *); | |
1145 percent = va_arg(ap, double); | |
1146 va_end(ap); | |
1147 | |
1148 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1149 return 1; | |
1150 if (dim->watcher) { | |
1151 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1152 /* The callback will callback? I don't get how that would happen here. */ | |
1153 dim->watcher = 0; | |
1154 } | |
1155 | |
10246 | 1156 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1157 gaim_connection_get_account(gc)); | |
8971 | 1158 if (c != NULL) |
1159 gaim_conversation_update_progress(c, percent); | |
1160 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1161 oscar_callback, dim->conn); | |
1162 | |
1163 return 1; | |
1164 } | |
1165 | |
1166 /* | |
1167 * This is called after a direct IM has been received in its entirety. This | |
1168 * function is passed a long chunk of data which contains the IM with any | |
1169 * data chunks (images) appended to it. | |
1170 * | |
1171 * This function rips out all the data chunks and creates an imgstore for | |
1172 * each one. In order to do this, it first goes through the IM and takes | |
1173 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1174 * with one compatible with the imgstore Gaim core code. For each one, we | |
1175 * then read in chunks of data from the end of the message and actually | |
1176 * create the img store using the given data. | |
1177 * | |
1178 * For somewhat easy reference, here's a sample message | |
1179 * (without the whitespace and asterisks): | |
1180 * | |
1181 * <HTML><BODY BGCOLOR="#ffffff"> | |
1182 * <FONT LANG="0"> | |
1183 * This is a really stupid picture:<BR> | |
1184 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1185 * Yeah it is<BR> | |
1186 * Here is another one:<BR> | |
1187 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1188 * </FONT> | |
1189 * </BODY></HTML> | |
1190 * <BINARY> | |
1191 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1192 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1193 * </BINARY> | |
1194 */ | |
1195 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1196 GaimConnection *gc = sess->aux_data; | |
1197 GaimConvImFlags imflags = 0; | |
1198 gchar *utf8; | |
1199 GString *newmsg = g_string_new(""); | |
1200 GSList *images = NULL; | |
1201 va_list ap; | |
1202 const char *sn, *msg, *msgend, *binary; | |
1203 size_t len; | |
1204 int encoding, isawaymsg; | |
1205 | |
1206 va_start(ap, fr); | |
1207 sn = va_arg(ap, const char *); | |
1208 msg = va_arg(ap, const char *); | |
1209 len = va_arg(ap, size_t); | |
1210 encoding = va_arg(ap, int); | |
1211 isawaymsg = va_arg(ap, int); | |
1212 va_end(ap); | |
1213 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1214 |
8660 | 1215 gaim_debug_info("oscar", |
8971 | 1216 "Got DirectIM message from %s\n", sn); |
1217 | |
1218 if (isawaymsg) | |
1219 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1220 | |
1221 /* message has a binary trailer */ | |
1222 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1223 GData *attribs; | |
1224 const char *tmp, *start, *end, *last = NULL; | |
1225 | |
1226 tmp = msg; | |
1227 | |
1228 /* for each valid image tag... */ | |
1229 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1230 const char *id, *src, *datasize; | |
1231 const char *tag = NULL, *data = NULL; | |
1232 size_t size; | |
1233 int imgid = 0; | |
1234 | |
1235 /* update the location of the last img tag */ | |
1236 last = end; | |
1237 | |
1238 /* grab attributes */ | |
1239 id = g_datalist_get_data(&attribs, "id"); | |
1240 src = g_datalist_get_data(&attribs, "src"); | |
1241 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1242 | |
1243 /* if we have id & datasize, build the data tag */ | |
1244 if (id && datasize) | |
1245 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1246 | |
1247 /* if we have a tag, find the start of the data */ | |
1248 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1249 data += strlen(tag); | |
1250 | |
1251 /* check the data is here and store it */ | |
1252 if (data + (size = atoi(datasize)) <= msgend) | |
1253 imgid = gaim_imgstore_add(data, size, src); | |
1254 | |
1255 /* | |
1256 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1257 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1258 */ | |
1259 /* if we have a stored image... */ | |
1260 if (imgid) { | |
1261 /* append the message up to the tag */ | |
1262 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1263 if (utf8 != NULL) { | |
1264 newmsg = g_string_append(newmsg, utf8); | |
1265 g_free(utf8); | |
1266 } | |
1267 | |
1268 /* write the new image tag */ | |
1269 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1270 | |
1271 /* and record the image number */ | |
1272 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1273 } else { | |
1274 /* otherwise, copy up to the end of the tag */ | |
1275 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1276 if (utf8 != NULL) { | |
1277 newmsg = g_string_append(newmsg, utf8); | |
1278 g_free(utf8); | |
1279 } | |
1280 } | |
1281 | |
1282 /* clear the attribute list */ | |
1283 g_datalist_clear(&attribs); | |
1284 | |
1285 /* continue from the end of the tag */ | |
1286 tmp = end + 1; | |
1287 } | |
1288 | |
1289 /* append any remaining message data (without the > :-) */ | |
1290 if (last++ && (last < binary)) | |
1291 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1292 | |
1293 /* set the flag if we caught any images */ | |
1294 if (images) | |
1295 imflags |= GAIM_CONV_IM_IMAGES; | |
1296 } else { | |
1297 g_string_append_len(newmsg, msg, len); | |
1298 } | |
1299 | |
10318 | 1300 /* Convert to UTF8 */ |
1301 /* (This hasn't been tested very much) */ | |
1302 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1303 if (utf8 != NULL) { | |
1304 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1305 g_free(utf8); | |
1306 } | |
1307 | |
1308 /* free the message */ | |
8971 | 1309 g_string_free(newmsg, TRUE); |
1310 | |
1311 /* unref any images we allocated */ | |
1312 if (images) { | |
1313 GSList *tmp; | |
1314 int id; | |
1315 | |
1316 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1317 id = GPOINTER_TO_INT(tmp->data); | |
1318 gaim_imgstore_unref(id); | |
1319 } | |
1320 | |
1321 g_slist_free(images); | |
1322 } | |
1323 | |
1324 return 1; | |
1325 } | |
1326 | |
1327 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1328 va_list ap; | |
1329 char *sn; | |
1330 int typing; | |
1331 GaimConnection *gc = sess->aux_data; | |
1332 | |
1333 va_start(ap, fr); | |
1334 sn = va_arg(ap, char *); | |
1335 typing = va_arg(ap, int); | |
1336 va_end(ap); | |
1337 | |
1338 if (typing == 0x0002) { | |
1339 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1340 gaim_debug_info("oscar", | |
1341 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1342 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1343 } else if (typing == 0x0001) | |
1344 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1345 else | |
1346 serv_got_typing_stopped(gc, sn); | |
1347 return 1; | |
1348 } | |
1349 | |
1350 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1351 char *buf; | |
1352 size_t len; | |
1353 int ret; | |
1354 GString *msg = g_string_new("<HTML><BODY>"); | |
1355 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1356 GData *attribs; | |
1357 const char *start, *end, *last; | |
1358 int oscar_id = 0; | |
1359 | |
1360 last = message; | |
1361 | |
1362 /* for each valid IMG tag... */ | |
1363 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1364 GaimStoredImage *image = NULL; | |
1365 const char *id; | |
1366 | |
1367 if (start - last) { | |
1368 g_string_append_len(msg, last, start - last); | |
1369 } | |
1370 | |
1371 id = g_datalist_get_data(&attribs, "id"); | |
1372 | |
1373 /* ... if it refers to a valid gaim image ... */ | |
1374 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1375 /* ... append the message from start to the tag ... */ | |
9126 | 1376 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1377 const char *filename = gaim_imgstore_get_filename(image); |
1378 gpointer imgdata = gaim_imgstore_get_data(image); | |
1379 | |
1380 oscar_id++; | |
1381 | |
1382 /* ... insert a new img tag with the oscar id ... */ | |
1383 if (filename) | |
1384 g_string_append_printf(msg, | |
9126 | 1385 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1386 filename, oscar_id, size); |
1387 else | |
1388 g_string_append_printf(msg, | |
9126 | 1389 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1390 oscar_id, size); |
1391 | |
1392 /* ... and append the data to the binary section ... */ | |
9126 | 1393 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1394 oscar_id, size); |
1395 data = g_string_append_len(data, imgdata, size); | |
1396 data = g_string_append(data, "</DATA>"); | |
1397 } | |
1398 /* If the tag is invalid, skip it, thus no else here */ | |
1399 | |
1400 g_datalist_clear(&attribs); | |
1401 | |
1402 /* continue from the end of the tag */ | |
1403 last = end + 1; | |
1404 } | |
1405 | |
1406 /* append any remaining message data (without the > :-) */ | |
1407 if (last && *last) | |
1408 msg = g_string_append(msg, last); | |
1409 | |
1410 /* if we inserted any images in the binary section, append it */ | |
1411 if (oscar_id) { | |
1412 msg = g_string_append_len(msg, data->str, data->len); | |
1413 msg = g_string_append(msg, "</BINARY>"); | |
1414 } | |
1415 | |
1416 len = msg->len; | |
1417 buf = msg->str; | |
1418 g_string_free(msg, FALSE); | |
1419 g_string_free(data, TRUE); | |
1420 | |
1421 | |
1422 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1423 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1424 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1425 else | |
1426 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1427 | |
1428 g_free(buf); | |
1429 | |
1430 return ret; | |
1431 } | |
1432 | |
1433 struct ask_do_dir_im { | |
1434 char *who; | |
1435 GaimConnection *gc; | |
1436 }; | |
1437 | |
1438 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1439 g_free(data->who); | |
1440 g_free(data); | |
1441 } | |
1442 | |
8983 | 1443 /* this function is used to initiate a direct im session with someone. |
1444 * we start listening on a port and send a request. they either connect | |
1445 * or send some kind of reply. If they can't connect, they ask us to | |
1446 * connect to them, and so we do that. | |
1447 * | |
1448 * this function will also get called if the other side initiate's a direct | |
1449 * im and we try to connect and fail. in that case cookie will not be null. | |
1450 * | |
1451 * note that cookie is an 8 byte string that isn't NULL terminated | |
1452 */ | |
1453 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1454 OscarData *od; |
1455 struct oscar_direct_im *dim; | |
1456 int listenfd; | |
8982 | 1457 const char *ip; |
8971 | 1458 |
1459 od = (OscarData *)gc->proto_data; | |
1460 | |
8983 | 1461 dim = oscar_direct_im_find(od, who); |
8971 | 1462 if (dim) { |
1463 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1464 oscar_direct_im_disconnect(od, dim); | |
1465 gaim_debug_info("oscar", | |
1466 "Gave up on old direct IM, trying again\n"); | |
1467 } else { | |
1468 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1469 return; |
8971 | 1470 } |
1471 } | |
1472 dim = g_new0(struct oscar_direct_im, 1); | |
1473 dim->gc = gc; | |
8983 | 1474 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1475 |
1476 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1477 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1478 if (listenfd >= 0) |
1479 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1480 if (dim->conn != NULL) { |
8982 | 1481 char *tmp; |
1482 GaimConversation *conv; | |
1483 | |
8971 | 1484 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1485 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1486 oscar_callback, dim->conn); | |
1487 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1488 gaim_odc_initiate, 0); | |
8982 | 1489 |
8983 | 1490 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1491 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1492 gaim_network_get_port_from_fd(listenfd)); |
1493 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1494 g_free(tmp); | |
8971 | 1495 } else { |
1496 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1497 oscar_direct_im_destroy(od, dim); | |
1498 } | |
8983 | 1499 } |
1500 | |
1501 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1502 GaimConnection *gc = data->gc; | |
1503 | |
1504 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1505 g_free(data->who); | |
1506 g_free(data); | |
1507 return; | |
1508 } | |
1509 | |
1510 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1511 g_free(data->who); |
1512 g_free(data); | |
1513 } | |
1514 | |
1515 /* this is the right click menu cb thingy */ | |
9030 | 1516 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1517 | |
1518 GaimBuddy *buddy; | |
1519 GaimConnection *gc; | |
8971 | 1520 gchar *buf; |
9030 | 1521 struct ask_do_dir_im *data; |
1522 | |
1523 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1524 | |
1525 buddy = (GaimBuddy *) node; | |
1526 gc = gaim_account_get_connection(buddy->account); | |
1527 | |
1528 data = g_new0(struct ask_do_dir_im, 1); | |
1529 data->who = g_strdup(buddy->name); | |
8971 | 1530 data->gc = gc; |
9030 | 1531 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1532 buddy->name); | |
8971 | 1533 |
1534 gaim_request_action(gc, NULL, buf, | |
9030 | 1535 _("Because this reveals your IP address, it " |
1536 "may be considered a privacy risk. Do you " | |
1537 "wish to continue?"), | |
1538 0, data, 2, | |
1539 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1540 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1541 g_free(buf); |
1542 } | |
1543 | |
1544 /***************************************************************************** | |
1545 * End scary direct im stuff | |
1546 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1547 |
4617 | 1548 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1549 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1550 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1551 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1552 OscarData *od; |
2086 | 1553 |
1554 if (!gc) { | |
8660 | 1555 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1556 "oscar callback for closed connection (1).\n"); |
2086 | 1557 return; |
1558 } | |
1559 | |
7283 | 1560 od = (OscarData *)gc->proto_data; |
2086 | 1561 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1562 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1563 /* oh boy. this is probably bad. i guess the only thing we |
1564 * can really do is return? */ | |
8660 | 1565 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1566 "oscar callback for closed connection (2).\n"); |
8660 | 1567 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1568 return; |
1569 } | |
1570 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1571 if (condition & GAIM_INPUT_READ) { |
4617 | 1572 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1573 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1574 "got information on rendezvous listener\n"); |
4617 | 1575 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1576 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1577 "connection error (rendezvous listener)\n"); |
4617 | 1578 aim_conn_kill(od->sess, &conn); |
8446 | 1579 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1580 } |
1581 } else { | |
4617 | 1582 if (aim_get_command(od->sess, conn) >= 0) { |
1583 aim_rxdispatch(od->sess); | |
6029 | 1584 if (od->killme) { |
8660 | 1585 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1586 return; |
1587 } | |
2086 | 1588 } else { |
1589 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1590 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1591 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1592 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1593 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1594 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1595 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1596 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1597 char *buf; |
8660 | 1598 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1599 "disconnected from chat room %s\n", c->name); |
2086 | 1600 c->conn = NULL; |
1601 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1602 gaim_input_remove(c->inpa); |
2086 | 1603 c->inpa = 0; |
1604 c->fd = -1; | |
4617 | 1605 aim_conn_kill(od->sess, &conn); |
5420 | 1606 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1607 if (conv) |
1608 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1609 else | |
1610 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1611 g_free(buf); |
2086 | 1612 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1613 if (od->cnpa > 0) |
1614 gaim_input_remove(od->cnpa); | |
1615 od->cnpa = 0; | |
8660 | 1616 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1617 "removing chatnav input watcher\n"); |
4617 | 1618 while (od->create_rooms) { |
1619 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1620 g_free(cr->name); |
4617 | 1621 od->create_rooms = |
1622 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1623 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1624 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1625 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1626 NULL); |
2086 | 1627 } |
4617 | 1628 aim_conn_kill(od->sess, &conn); |
2086 | 1629 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1630 if (od->paspa > 0) |
1631 gaim_input_remove(od->paspa); | |
1632 od->paspa = 0; | |
8660 | 1633 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1634 "removing authconn input watcher\n"); |
4617 | 1635 aim_conn_kill(od->sess, &conn); |
3694 | 1636 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1637 if (od->emlpa > 0) |
1638 gaim_input_remove(od->emlpa); | |
1639 od->emlpa = 0; | |
8660 | 1640 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1641 "removing email input watcher\n"); |
4617 | 1642 aim_conn_kill(od->sess, &conn); |
4804 | 1643 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1644 if (od->icopa > 0) | |
1645 gaim_input_remove(od->icopa); | |
1646 od->icopa = 0; | |
8660 | 1647 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1648 "removing icon input watcher\n"); |
4804 | 1649 aim_conn_kill(od->sess, &conn); |
2086 | 1650 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1651 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1652 gaim_odc_disconnect(od->sess, conn); |
1653 aim_conn_kill(od->sess, &conn); | |
2086 | 1654 } else { |
8660 | 1655 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1656 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1657 conn->type); |
4617 | 1658 aim_conn_kill(od->sess, &conn); |
2086 | 1659 } |
1660 } | |
1661 } | |
1662 } | |
1663 } | |
1664 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1665 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1666 GaimConnection *gc = sess->aux_data; |
7285 | 1667 gchar *s = g_strdup_vprintf(format, va); |
1668 gchar *buf; | |
1669 | |
1670 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1671 gaim_debug_info("oscar", buf); |
7285 | 1672 if (buf[strlen(buf)-1] != '\n') |
8660 | 1673 gaim_debug_info(NULL, "\n"); |
7285 | 1674 g_free(buf); |
2086 | 1675 g_free(s); |
1676 } | |
1677 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1678 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1679 { |
5575 | 1680 GaimConnection *gc = data; |
7283 | 1681 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1682 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1683 aim_conn_t *conn; |
2086 | 1684 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1685 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1686 close(source); |
1687 return; | |
1688 } | |
1689 | |
4617 | 1690 od = gc->proto_data; |
1691 sess = od->sess; | |
2086 | 1692 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1693 conn->fd = source; |
2086 | 1694 |
1695 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1696 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1697 return; |
1698 } | |
1699 | |
1700 aim_conn_completeconnect(sess, conn); | |
4617 | 1701 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1702 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1703 | |
8660 | 1704 gaim_debug_info("oscar", |
7282 | 1705 "Screen name sent, waiting for response\n"); |
7283 | 1706 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1707 ck[1] = 0x65; |
2086 | 1708 } |
1709 | |
5575 | 1710 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1711 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1712 aim_conn_t *conn; |
5575 | 1713 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1714 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1715 |
8660 | 1716 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1717 |
8437 | 1718 if (!aim_snvalid(gaim_account_get_username(account))) { |
1719 gchar *buf; | |
8590 | 1720 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 | 1721 gaim_connection_error(gc, buf); |
1722 g_free(buf); | |
1723 } | |
1724 | |
9975 | 1725 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1726 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1727 } else { |
6622 | 1728 gc->flags |= GAIM_CONNECTION_HTML; |
1729 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1730 } |
5836 | 1731 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1732 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1733 sess = g_new0(aim_session_t, 1); |
10329 | 1734 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1735 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1736 /* |
1737 * We need an immediate queue because we don't use a while-loop | |
1738 * to see if things need to be sent. | |
1739 */ | |
2086 | 1740 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1741 od->sess = sess; |
2086 | 1742 sess->aux_data = gc; |
1743 | |
9935 | 1744 /* Connect to core Gaim signals */ |
10087 | 1745 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1746 |
2086 | 1747 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1748 if (conn == NULL) { | |
8660 | 1749 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1750 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1751 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1752 return; |
1753 } | |
1754 | |
4649 | 1755 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1756 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1757 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1758 | |
1759 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1760 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1761 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1762 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1763 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1764 return; |
1765 } | |
7282 | 1766 |
7283 | 1767 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1768 ck[0] = 0x5a; |
5575 | 1769 } |
1770 | |
1771 static void oscar_close(GaimConnection *gc) { | |
7283 | 1772 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1773 |
1774 while (od->oscar_chats) { | |
1775 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1776 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1777 gaim_input_remove(n->inpa); |
2086 | 1778 g_free(n->name); |
1779 g_free(n->show); | |
4617 | 1780 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1781 g_free(n); |
1782 } | |
4617 | 1783 while (od->direct_ims) { |
8971 | 1784 struct oscar_direct_im *n = od->direct_ims->data; |
1785 oscar_direct_im_destroy(od, n); | |
2086 | 1786 } |
4617 | 1787 /* BBB */ |
1788 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1789 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1790 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1791 gaim_xfer_cancel_local(xfer); |
3630 | 1792 } |
4804 | 1793 while (od->requesticon) { |
1794 char *sn = od->requesticon->data; | |
1795 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1796 free(sn); | |
1797 } | |
4738 | 1798 g_hash_table_destroy(od->buddyinfo); |
4617 | 1799 while (od->create_rooms) { |
1800 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1801 g_free(cr->name); |
4617 | 1802 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1803 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1804 } |
4617 | 1805 if (od->email) |
1806 g_free(od->email); | |
1807 if (od->newp) | |
1808 g_free(od->newp); | |
1809 if (od->oldp) | |
1810 g_free(od->oldp); | |
2086 | 1811 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1812 gaim_input_remove(gc->inpa); |
4617 | 1813 if (od->cnpa > 0) |
1814 gaim_input_remove(od->cnpa); | |
1815 if (od->paspa > 0) | |
1816 gaim_input_remove(od->paspa); | |
1817 if (od->emlpa > 0) | |
1818 gaim_input_remove(od->emlpa); | |
4804 | 1819 if (od->icopa > 0) |
1820 gaim_input_remove(od->icopa); | |
6907 | 1821 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1822 gaim_timeout_remove(od->icontimer); |
8341 | 1823 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1824 gaim_timeout_remove(od->getblisttimer); |
8341 | 1825 if (od->getinfotimer > 0) |
1826 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1827 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1828 |
4617 | 1829 aim_session_kill(od->sess); |
1830 g_free(od->sess); | |
1831 od->sess = NULL; | |
2086 | 1832 g_free(gc->proto_data); |
1833 gc->proto_data = NULL; | |
8660 | 1834 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1835 } |
1836 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1837 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1838 GaimConnection *gc = data; |
7283 | 1839 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1840 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1841 aim_conn_t *bosconn; |
2086 | 1842 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1843 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1844 close(source); |
1845 return; | |
1846 } | |
1847 | |
4617 | 1848 od = gc->proto_data; |
1849 sess = od->sess; | |
1850 bosconn = od->conn; | |
4366 | 1851 bosconn->fd = source; |
2086 | 1852 |
1853 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1854 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1855 return; |
1856 } | |
1857 | |
1858 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1859 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1860 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1861 gaim_connection_update_progress(gc, |
7283 | 1862 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1863 ck[4] = 0x61; |
2086 | 1864 } |
1865 | |
4617 | 1866 /* BBB */ |
4656 | 1867 /* |
1868 * This little area in oscar.c is the nexus of file transfer code, | |
1869 * so I wrote a little explanation of what happens. I am such a | |
1870 * ninja. | |
1871 * | |
1872 * The series of events for a file send is: | |
1873 * -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
|
1874 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1875 * listening socket, then asks the remote user to connect to us (and |
1876 * gives them the file name, port, IP, etc.) | |
1877 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1878 * in oscar_sendfile_estblsh) | |
1879 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1880 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1881 * connection. | |
1882 * -We get drunk because file transfer kicks ass. | |
1883 * | |
1884 * The series of events for a file receive is: | |
1885 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1886 * -Gaim user selects file to name and location to save file to and | |
1887 * oscar_xfer_init is called | |
1888 * -It connects to the remote user using the IP they gave us earlier | |
1889 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1890 * them an AIM_CB_OFT_ACK. | |
1891 * -They begin to send us lots of raw data. | |
1892 * -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
|
1893 * the connection. |
4656 | 1894 */ |
1895 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1896 | |
8446 | 1897 /* |
1898 * Miscellaneous xfer functions | |
1899 */ | |
1900 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1901 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1902 GaimXfer *xfer; |
5146 | 1903 struct aim_oft_info *oft_info; |
4656 | 1904 |
1905 while (fts) { | |
1906 xfer = fts->data; | |
5146 | 1907 oft_info = xfer->data; |
1908 | |
8446 | 1909 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1910 return xfer; |
1911 | |
1912 fts = g_slist_next(fts); | |
1913 } | |
1914 | |
1915 return NULL; | |
1916 } | |
1917 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1918 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1919 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1920 GaimXfer *xfer; |
5146 | 1921 struct aim_oft_info *oft_info; |
4656 | 1922 |
1923 while (fts) { | |
1924 xfer = fts->data; | |
5146 | 1925 oft_info = xfer->data; |
1926 | |
1927 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1928 return xfer; |
1929 | |
1930 fts = g_slist_next(fts); | |
1931 } | |
1932 | |
1933 return NULL; | |
1934 } | |
1935 | |
8446 | 1936 static void oscar_xfer_end(GaimXfer *xfer) |
1937 { | |
1938 struct aim_oft_info *oft_info = xfer->data; | |
1939 GaimConnection *gc = oft_info->sess->aux_data; | |
1940 OscarData *od = gc->proto_data; | |
1941 | |
8660 | 1942 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1943 |
1944 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1945 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1946 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1947 } | |
1948 | |
1949 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1950 aim_oft_destroyinfo(oft_info); | |
1951 xfer->data = NULL; | |
1952 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1953 } | |
1954 | |
1955 /* | |
1956 * xfer functions used when receiving files | |
1957 */ | |
1958 | |
1959 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1960 { | |
1961 struct aim_oft_info *oft_info = xfer->data; | |
1962 GaimConnection *gc = oft_info->sess->aux_data; | |
1963 OscarData *od = gc->proto_data; | |
1964 | |
8660 | 1965 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1966 |
1967 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1968 if (oft_info->conn) { | |
1969 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1970 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1971 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1972 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1973 if (xfer->fd == -1) { | |
1974 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1975 _("Unable to establish file descriptor.")); | |
1976 gaim_xfer_cancel_local(xfer); | |
1977 } | |
1978 } else { | |
1979 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1980 _("Unable to create new connection.")); | |
1981 gaim_xfer_cancel_local(xfer); | |
1982 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1983 } | |
1984 | |
1985 } | |
1986 | |
1987 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1988 { | |
1989 struct aim_oft_info *oft_info = xfer->data; | |
1990 GaimConnection *gc = oft_info->sess->aux_data; | |
1991 OscarData *od = gc->proto_data; | |
1992 | |
8660 | 1993 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1994 |
9771 | 1995 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1996 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1997 |
1998 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1999 aim_oft_destroyinfo(oft_info); | |
2000 xfer->data = NULL; | |
2001 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2002 } | |
2003 | |
2004 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
2005 { | |
2006 struct aim_oft_info *oft_info = xfer->data; | |
2007 | |
2008 /* Update our rolling checksum. Like Walmart, yo. */ | |
2009 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2010 } | |
2011 | |
2012 /* | |
2013 * xfer functions used when sending files | |
2014 */ | |
2015 | |
2016 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2017 { | |
2018 struct aim_oft_info *oft_info = xfer->data; | |
2019 GaimConnection *gc = oft_info->sess->aux_data; | |
2020 OscarData *od = gc->proto_data; | |
2021 int listenfd; | |
2022 | |
8660 | 2023 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2024 |
2025 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2026 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2027 oft_info->fh.name[63] = '\0'; | |
2028 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2029 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2030 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2031 | |
2032 /* Create a listening socket and an associated libfaim conn */ | |
2033 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2034 gaim_xfer_cancel_local(xfer); | |
2035 return; | |
2036 } | |
2037 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2038 oft_info->port = xfer->local_port; | |
2039 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2040 gaim_xfer_cancel_local(xfer); | |
2041 return; | |
2042 } | |
8660 | 2043 gaim_debug_misc("oscar", |
8446 | 2044 "port is %hu, ip is %s\n", |
2045 xfer->local_port, oft_info->clientip); | |
2046 if (oft_info->conn) { | |
2047 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2048 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2049 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2050 } else { | |
2051 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2052 _("Unable to establish listener socket.")); | |
2053 gaim_xfer_cancel_local(xfer); | |
2054 } | |
2055 } | |
2056 | |
2057 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2058 { | |
2059 struct aim_oft_info *oft_info = xfer->data; | |
2060 GaimConnection *gc = oft_info->sess->aux_data; | |
2061 OscarData *od = gc->proto_data; | |
2062 | |
8660 | 2063 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2064 |
9771 | 2065 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2066 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2067 |
2068 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2069 aim_oft_destroyinfo(oft_info); | |
2070 xfer->data = NULL; | |
2071 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2072 } | |
2073 | |
2074 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2075 { | |
2076 struct aim_oft_info *oft_info = xfer->data; | |
2077 | |
2078 /* I'm not sure I like how we do this. --marv | |
2079 * I do. AIM file transfers aren't really meant to be thought | |
2080 * of as a transferring just a single file. The rendezvous | |
2081 * establishes a connection between two computers, and then | |
2082 * those computers can use the same connection for transferring | |
2083 * multiple files. So we don't want the Gaim core up and closing | |
2084 * the socket all willy-nilly. We want to do that in the oscar | |
2085 * prpl, whenever one side or the other says they're finished | |
2086 * using the connection. There might be a better way to intercept | |
2087 * the socket from the core, however... --KingAnt | |
2088 */ | |
2089 | |
2090 /* | |
2091 * If we're done sending, intercept the socket from the core ft code | |
2092 * and wait for the other guy to send the "done" OFT packet. | |
2093 */ | |
2094 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2095 gaim_input_remove(xfer->watcher); | |
2096 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2097 xfer->fd = 0; | |
2098 gaim_xfer_set_completed(xfer, TRUE); | |
2099 } | |
2100 } | |
2101 | |
9466 | 2102 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2103 gboolean can_receive = FALSE; | |
2104 OscarData *od = gc->proto_data; | |
2105 | |
2106 if (!od->icq) { | |
2107 aim_userinfo_t *userinfo; | |
2108 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2109 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2110 can_receive = TRUE; | |
2111 } | |
2112 | |
2113 return can_receive; | |
2114 } | |
2115 | |
2116 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2117 |
2118 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2119 GaimXfer *xfer; |
5146 | 2120 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2121 const char *ip; |
3752 | 2122 |
9030 | 2123 od = (OscarData *)gc->proto_data; |
2124 | |
4617 | 2125 /* You want to send a file to someone else, you're so generous */ |
2126 | |
2127 /* Build the file transfer handle */ | |
9466 | 2128 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2129 |
5146 | 2130 /* Create the oscar-specific data */ |
8838 | 2131 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2132 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2133 xfer->data = oft_info; |
2134 | |
4617 | 2135 /* Setup our I/O op functions */ |
8446 | 2136 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2137 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2138 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2139 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2140 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2141 |
2142 /* Keep track of this transfer for later */ | |
2143 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2144 | |
2145 /* Now perform the request */ | |
9466 | 2146 if (file) |
2147 gaim_xfer_request_accepted(xfer, file); | |
2148 else | |
2149 gaim_xfer_request(xfer); | |
3630 | 2150 } |
2151 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2152 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2153 GaimConnection *gc = sess->aux_data; |
7283 | 2154 OscarData *od = gc->proto_data; |
6029 | 2155 GaimAccount *account = gc->account; |
2156 aim_conn_t *bosconn; | |
2157 char *host; int port; | |
2158 int i, rc; | |
2086 | 2159 va_list ap; |
2704 | 2160 struct aim_authresp_info *info; |
6029 | 2161 |
5575 | 2162 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2163 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2164 va_start(ap, fr); |
2704 | 2165 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2166 va_end(ap); |
2167 | |
8660 | 2168 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2169 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2170 |
4293 | 2171 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2172 char buf[256]; |
2704 | 2173 switch (info->errorcode) { |
2086 | 2174 case 0x05: |
2175 /* Incorrect nick/password */ | |
6498 | 2176 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2177 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2178 break; |
2179 case 0x11: | |
2180 /* Suspended account */ | |
6498 | 2181 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2182 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2183 break; |
3498 | 2184 case 0x14: |
2185 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2186 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2187 break; |
2086 | 2188 case 0x18: |
2189 /* connecting too frequently */ | |
6498 | 2190 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2191 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 | 2192 break; |
2193 case 0x1c: | |
2194 /* client too old */ | |
6498 | 2195 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2196 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
|
2197 gaim_connection_error(gc, buf); |
2086 | 2198 break; |
2199 default: | |
6623 | 2200 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2201 break; |
2202 } | |
8660 | 2203 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2204 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2205 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2206 "Error URL: %s\n", info->errorurl); |
2086 | 2207 od->killme = TRUE; |
2208 return 1; | |
2209 } | |
2210 | |
2211 | |
9992 | 2212 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2213 |
2704 | 2214 if (info->email) { |
8660 | 2215 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2216 } else { |
8660 | 2217 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2218 } |
10042 | 2219 |
8660 | 2220 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2221 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2222 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2223 aim_conn_kill(sess, &fr->conn); |
2086 | 2224 |
2225 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2226 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2227 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2228 od->killme = TRUE; |
2229 return 0; | |
2230 } | |
2231 | |
4649 | 2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2234 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2244 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2245 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2248 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2249 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2250 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2251 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2252 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2253 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2254 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
|
2255 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2256 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2257 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2258 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2259 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2260 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2261 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
|
2262 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
|
2263 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
|
2264 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2265 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2266 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2267 #ifndef NOSSI |
4642 | 2268 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2269 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2270 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2271 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2272 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2273 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2274 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2275 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2276 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2277 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2278 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2279 |
7283 | 2280 od->conn = bosconn; |
2704 | 2281 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2282 if (info->bosip[i] == ':') { | |
2283 port = atoi(&(info->bosip[i+1])); | |
2086 | 2284 break; |
2285 } | |
2286 } | |
2704 | 2287 host = g_strndup(info->bosip, i); |
2086 | 2288 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2289 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2290 g_free(host); |
4366 | 2291 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2292 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2293 od->killme = TRUE; |
2294 return 0; | |
2295 } | |
4293 | 2296 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2297 gaim_input_remove(gc->inpa); |
2704 | 2298 |
7283 | 2299 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2300 ck[3] = 0x64; |
7282 | 2301 |
2086 | 2302 return 1; |
2303 } | |
2304 | |
7285 | 2305 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2306 struct pieceofcrap { |
5575 | 2307 GaimConnection *gc; |
2086 | 2308 unsigned long offset; |
2309 unsigned long len; | |
2310 char *modname; | |
2311 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2312 aim_conn_t *conn; |
2086 | 2313 unsigned int inpa; |
2314 }; | |
2315 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2316 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2317 { |
2318 struct pieceofcrap *pos = data; | |
7283 | 2319 OscarData *od = pos->gc->proto_data; |
2086 | 2320 char in = '\0'; |
2321 int x = 0; | |
2322 unsigned char m[17]; | |
2323 | |
2324 while (read(pos->fd, &in, 1) == 1) { | |
2325 if (in == '\n') | |
2326 x++; | |
2327 else if (in != '\r') | |
2328 x = 0; | |
2329 if (x == 2) | |
2330 break; | |
2331 in = '\0'; | |
2332 } | |
2333 if (in != '\n') { | |
4056 | 2334 char buf[256]; |
2335 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
|
2336 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2337 gaim_notify_warning(pos->gc, NULL, |
7422 | 2338 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2339 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2340 gaim_input_remove(pos->inpa); |
2086 | 2341 close(pos->fd); |
2342 g_free(pos); | |
2343 return; | |
2344 } | |
2345 read(pos->fd, m, 16); | |
2346 m[16] = '\0'; | |
8660 | 2347 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2348 for (x = 0; x < 16; x++) |
8660 | 2349 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2350 | |
2351 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2352 gaim_input_remove(pos->inpa); |
2086 | 2353 close(pos->fd); |
2354 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2355 g_free(pos); | |
2356 } | |
2357 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2358 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2359 struct pieceofcrap *pos = data; |
5420 | 2360 gchar *buf; |
2086 | 2361 |
4366 | 2362 pos->fd = source; |
2363 | |
2086 | 2364 if (source < 0) { |
5420 | 2365 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
|
2366 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2367 gaim_notify_warning(pos->gc, NULL, |
7422 | 2368 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2369 buf); |
5420 | 2370 g_free(buf); |
2086 | 2371 if (pos->modname) |
2372 g_free(pos->modname); | |
2373 g_free(pos); | |
2374 return; | |
2375 } | |
2376 | |
5420 | 2377 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2378 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2379 write(pos->fd, buf, strlen(buf)); | |
5420 | 2380 g_free(buf); |
2086 | 2381 if (pos->modname) |
2382 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2383 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2384 return; |
2385 } | |
2386 | |
2387 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2388 #define AIM_MAX_FILE_SIZE 98304 | |
2389 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2390 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2391 va_list ap; |
2392 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2393 fu32_t offset, len; |
2086 | 2394 char *modname; |
2395 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2396 va_start(ap, fr); |
4200 | 2397 offset = va_arg(ap, fu32_t); |
2398 len = va_arg(ap, fu32_t); | |
2086 | 2399 modname = va_arg(ap, char *); |
2400 va_end(ap); | |
2401 | |
8660 | 2402 gaim_debug_misc("oscar", |
5556 | 2403 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2404 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2405 |
2086 | 2406 if (len == 0) { |
8660 | 2407 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2408 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2409 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2410 return 1; | |
2411 } | |
9625 | 2412 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2413 #if 0 | |
2086 | 2414 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2415 char *buf; | |
2416 int i = 8; | |
2417 if (modname) | |
2418 i += strlen(modname); | |
2419 buf = g_malloc(i); | |
2420 i = 0; | |
2421 if (modname) { | |
2422 memcpy(buf, modname, strlen(modname)); | |
2423 i += strlen(modname); | |
2424 } | |
2425 buf[i++] = offset & 0xff; | |
2426 buf[i++] = (offset >> 8) & 0xff; | |
2427 buf[i++] = (offset >> 16) & 0xff; | |
2428 buf[i++] = (offset >> 24) & 0xff; | |
2429 buf[i++] = len & 0xff; | |
2430 buf[i++] = (len >> 8) & 0xff; | |
2431 buf[i++] = (len >> 16) & 0xff; | |
2432 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2433 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2434 "hashing request\n"); |
2086 | 2435 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2436 g_free(buf); | |
2437 return 1; | |
2438 } | |
9625 | 2439 #endif |
2086 | 2440 |
2441 pos = g_new0(struct pieceofcrap, 1); | |
2442 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2443 pos->conn = fr->conn; |
2086 | 2444 |
2445 pos->offset = offset; | |
2446 pos->len = len; | |
2447 pos->modname = modname ? g_strdup(modname) : NULL; | |
2448 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2449 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2450 char buf[256]; |
2086 | 2451 if (pos->modname) |
2452 g_free(pos->modname); | |
2453 g_free(pos); | |
4056 | 2454 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
|
2455 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2456 gaim_notify_warning(pos->gc, NULL, |
7422 | 2457 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2458 buf); |
2086 | 2459 } |
2460 | |
2461 return 1; | |
2462 } | |
2463 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2464 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2465 GaimConnection *gc = sess->aux_data; |
7283 | 2466 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2467 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2468 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2469 #if 0 |
2470 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2471 #endif | |
7011 | 2472 va_list ap; |
2473 char *key; | |
2086 | 2474 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2475 va_start(ap, fr); |
2086 | 2476 key = va_arg(ap, char *); |
2477 va_end(ap); | |
2478 | |
4617 | 2479 if (od->icq) { |
3458 | 2480 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2481 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2482 gaim_account_get_password(account), &info, key); |
3458 | 2483 } else { |
2484 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2485 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2486 gaim_account_get_password(account), &info, key); |
3458 | 2487 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2488 |
7283 | 2489 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2490 ck[2] = 0x6c; |
7282 | 2491 |
2086 | 2492 return 1; |
2493 } | |
2494 | |
2675 | 2495 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2496 GaimConnection *gc = sess->aux_data; |
2647 | 2497 struct chat_connection *chatcon; |
2498 static int id = 1; | |
2499 | |
6905 | 2500 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
|
2501 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
|
2502 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
|
2503 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
|
2504 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2505 |
2672 | 2506 aim_clientready(sess, fr->conn); |
2675 | 2507 |
2647 | 2508 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2509 chatcon->id = id; | |
8733 | 2510 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2511 |
2512 return 1; | |
2513 } | |
2514 | |
2675 | 2515 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2516 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2517 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2518 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2519 |
2520 aim_clientready(sess, fr->conn); | |
2521 | |
2522 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2523 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2524 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2525 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2526 |
3694 | 2527 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2528 | |
2529 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2530 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2531 | |
7282 | 2532 aim_email_sendcookies(sess); |
2533 aim_email_activate(sess); | |
3694 | 2534 aim_clientready(sess, fr->conn); |
2535 | |
2536 return 1; | |
2537 } | |
2538 | |
4804 | 2539 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2540 GaimConnection *gc = sess->aux_data; |
7283 | 2541 OscarData *od = gc->proto_data; |
4804 | 2542 |
2543 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2544 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2545 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2546 | |
2547 aim_clientready(sess, fr->conn); | |
2548 | |
4823 | 2549 od->iconconnecting = FALSE; |
2550 | |
4804 | 2551 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2552 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2553 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2554 |
2555 return 1; | |
2556 } | |
2557 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2558 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2559 GaimConnection *gc = data; |
7283 | 2560 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2561 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2562 aim_conn_t *tstconn; |
2086 | 2563 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2564 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2565 close(source); |
2566 return; | |
2567 } | |
2568 | |
4617 | 2569 od = gc->proto_data; |
2570 sess = od->sess; | |
2086 | 2571 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2572 tstconn->fd = source; |
2086 | 2573 |
2574 if (source < 0) { | |
2575 aim_conn_kill(sess, &tstconn); | |
8660 | 2576 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2577 "unable to connect to chatnav server\n"); |
2086 | 2578 return; |
2579 } | |
2580 | |
2581 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2582 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2583 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2584 } |
2585 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2586 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2587 { |
5575 | 2588 GaimConnection *gc = data; |
7283 | 2589 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2590 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2591 aim_conn_t *tstconn; |
2086 | 2592 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2593 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2594 close(source); |
2595 return; | |
2596 } | |
2597 | |
4617 | 2598 od = gc->proto_data; |
2599 sess = od->sess; | |
2086 | 2600 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2601 tstconn->fd = source; |
2086 | 2602 |
2603 if (source < 0) { | |
2604 aim_conn_kill(sess, &tstconn); | |
8660 | 2605 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2606 "unable to connect to authorizer\n"); |
2086 | 2607 return; |
2608 } | |
2609 | |
2610 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2611 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2612 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2613 } |
2614 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2615 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2616 { |
2617 struct chat_connection *ccon = data; | |
5575 | 2618 GaimConnection *gc = ccon->gc; |
7283 | 2619 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2620 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2621 aim_conn_t *tstconn; |
2086 | 2622 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2623 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2624 close(source); |
2625 g_free(ccon->show); | |
2626 g_free(ccon->name); | |
2627 g_free(ccon); | |
2628 return; | |
2629 } | |
2630 | |
4617 | 2631 od = gc->proto_data; |
2632 sess = od->sess; | |
2086 | 2633 tstconn = ccon->conn; |
4366 | 2634 tstconn->fd = source; |
2086 | 2635 |
2636 if (source < 0) { | |
2637 aim_conn_kill(sess, &tstconn); | |
2638 g_free(ccon->show); | |
2639 g_free(ccon->name); | |
2640 g_free(ccon); | |
2641 return; | |
2642 } | |
2643 | |
2644 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2645 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2646 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2647 } |
2648 | |
3694 | 2649 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2650 GaimConnection *gc = data; |
7283 | 2651 OscarData *od; |
3694 | 2652 aim_session_t *sess; |
2653 aim_conn_t *tstconn; | |
2654 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2655 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2656 close(source); |
2657 return; | |
2658 } | |
2659 | |
4617 | 2660 od = gc->proto_data; |
2661 sess = od->sess; | |
3694 | 2662 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2663 tstconn->fd = source; |
3694 | 2664 |
2665 if (source < 0) { | |
2666 aim_conn_kill(sess, &tstconn); | |
8660 | 2667 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2668 "unable to connect to email server\n"); |
3694 | 2669 return; |
2670 } | |
2671 | |
2672 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2673 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2674 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2675 "email: connected\n"); |
3694 | 2676 } |
2677 | |
4804 | 2678 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2679 GaimConnection *gc = data; |
7283 | 2680 OscarData *od; |
4804 | 2681 aim_session_t *sess; |
2682 aim_conn_t *tstconn; | |
2683 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2684 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2685 close(source); |
2686 return; | |
2687 } | |
2688 | |
2689 od = gc->proto_data; | |
2690 sess = od->sess; | |
2691 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2692 tstconn->fd = source; | |
2693 | |
2694 if (source < 0) { | |
2695 aim_conn_kill(sess, &tstconn); | |
8660 | 2696 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2697 "unable to connect to icon server\n"); |
4804 | 2698 return; |
2699 } | |
2700 | |
2701 aim_conn_completeconnect(sess, tstconn); | |
2702 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2703 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2704 } |
2705 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2706 /* 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
|
2707 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2708 GaimConnection *gc = sess->aux_data; |
2709 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2710 aim_conn_t *tstconn; |
4452 | 2711 int i; |
2086 | 2712 char *host; |
2713 int port; | |
4821 | 2714 va_list ap; |
2715 struct aim_redirect_data *redir; | |
2086 | 2716 |
5575 | 2717 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2718 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2719 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2720 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2721 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2722 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2723 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2724 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2725 port = atoi(&(redir->ip[i+1])); |
2086 | 2726 break; |
2727 } | |
2728 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2729 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2730 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2731 switch(redir->group) { |
2086 | 2732 case 0x7: /* Authorizer */ |
8660 | 2733 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2734 "Reconnecting with authorizor...\n"); |
2086 | 2735 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2736 if (tstconn == NULL) { | |
8660 | 2737 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2738 "unable to reconnect with authorizer\n"); |
2086 | 2739 g_free(host); |
2740 return 1; | |
2741 } | |
4649 | 2742 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2743 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2744 |
2745 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2746 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2747 aim_conn_kill(sess, &tstconn); |
8660 | 2748 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2749 "unable to reconnect with authorizer\n"); |
2086 | 2750 g_free(host); |
2751 return 1; | |
2752 } | |
4293 | 2753 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2754 break; |
2755 | |
2086 | 2756 case 0xd: /* ChatNav */ |
2757 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2758 if (tstconn == NULL) { | |
8660 | 2759 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2760 "unable to connect to chatnav server\n"); |
2086 | 2761 g_free(host); |
2762 return 1; | |
2763 } | |
4649 | 2764 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2765 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2766 |
2767 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2768 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2769 aim_conn_kill(sess, &tstconn); |
8660 | 2770 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2771 "unable to connect to chatnav server\n"); |
2086 | 2772 g_free(host); |
2773 return 1; | |
2774 } | |
4293 | 2775 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2776 break; |
2777 | |
2778 case 0xe: { /* Chat */ | |
2086 | 2779 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2780 |
2086 | 2781 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2782 if (tstconn == NULL) { | |
8660 | 2783 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2784 "unable to connect to chat server\n"); |
2086 | 2785 g_free(host); |
2786 return 1; | |
2787 } | |
2788 | |
4649 | 2789 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2790 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2791 | |
2086 | 2792 ccon = g_new0(struct chat_connection, 1); |
2793 ccon->conn = tstconn; | |
2794 ccon->gc = gc; | |
2795 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2796 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2797 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2798 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2799 ccon->show = extract_name(redir->chat.room); |
4634 | 2800 |
2086 | 2801 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2802 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2803 aim_conn_kill(sess, &tstconn); |
8660 | 2804 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2805 "unable to connect to chat server\n"); |
2086 | 2806 g_free(host); |
2807 g_free(ccon->show); | |
2808 g_free(ccon->name); | |
2809 g_free(ccon); | |
2810 return 1; | |
2811 } | |
4293 | 2812 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2813 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2814 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2815 ccon->name, ccon->exchange); |
4194 | 2816 } break; |
3694 | 2817 |
4804 | 2818 case 0x0010: { /* icon */ |
2819 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2820 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2821 "unable to connect to icon server\n"); |
4804 | 2822 g_free(host); |
2823 return 1; | |
2824 } | |
2825 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2826 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2827 | |
2828 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2829 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2830 aim_conn_kill(sess, &tstconn); |
8660 | 2831 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2832 "unable to connect to icon server\n"); |
4804 | 2833 g_free(host); |
2834 return 1; | |
2835 } | |
2836 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2837 } break; | |
2838 | |
3694 | 2839 case 0x0018: { /* email */ |
2840 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2841 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2842 "unable to connect to email server\n"); |
3694 | 2843 g_free(host); |
2844 return 1; | |
2845 } | |
4649 | 2846 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2847 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2848 | |
2849 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2850 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2851 aim_conn_kill(sess, &tstconn); |
8660 | 2852 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2853 "unable to connect to email server\n"); |
3694 | 2854 g_free(host); |
2855 return 1; | |
2856 } | |
4293 | 2857 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2858 } break; |
2859 | |
2086 | 2860 default: /* huh? */ |
8660 | 2861 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2862 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2863 redir->group); |
2086 | 2864 break; |
2865 } | |
2866 | |
2867 g_free(host); | |
2868 return 1; | |
2869 } | |
2870 | |
10042 | 2871 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2872 { | |
2873 GaimConnection *gc; | |
2874 GaimAccount *account; | |
2875 OscarData *od; | |
4738 | 2876 struct buddyinfo *bi; |
2993 | 2877 time_t time_idle = 0, signon = 0; |
2878 int type = 0; | |
2879 int caps = 0; | |
2086 | 2880 va_list ap; |
4738 | 2881 aim_userinfo_t *info; |
10042 | 2882 gboolean buddy_is_away = FALSE; |
2883 | |
2884 gc = sess->aux_data; | |
2885 account = gaim_connection_get_account(gc); | |
2886 od = gc->proto_data; | |
4194 | 2887 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2888 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2889 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2890 va_end(ap); |
2891 | |
10130 | 2892 g_return_val_if_fail(info != NULL, 1); |
2893 g_return_val_if_fail(info->sn != NULL, 1); | |
2894 | |
2993 | 2895 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2896 caps = info->capabilities; | |
3267 | 2897 |
4766 | 2898 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2899 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2900 buddy_is_away = TRUE; |
2901 } | |
2902 | |
2993 | 2903 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2904 type = (info->icqinfo.status << 16); |
3013 | 2905 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2906 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 2907 buddy_is_away = TRUE; |
3013 | 2908 } |
2993 | 2909 } |
2910 | |
7141 | 2911 if (caps & AIM_CAPS_ICQ_DIRECT) |
2912 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2913 |
2914 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2915 time(&time_idle); |
2916 time_idle -= info->idletime*60; | |
9295 | 2917 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2918 } |
2919 | |
5836 | 2920 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2921 signon = info->onlinesince; | |
2922 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2923 signon = time(NULL) - info->sessionlen; |
2086 | 2924 |
9982 | 2925 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) |
5575 | 2926 gaim_connection_set_display_name(gc, info->sn); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2927 |
9982 | 2928 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 2929 if (!bi) { |
2930 bi = g_new0(struct buddyinfo, 1); | |
9982 | 2931 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 2932 } |
4739 | 2933 bi->typingnot = FALSE; |
2934 bi->ico_informed = FALSE; | |
6857 | 2935 bi->ipaddr = info->icqinfo.ipaddr; |
2936 | |
2937 /* Available message stuff */ | |
6292 | 2938 free(bi->availmsg); |
7011 | 2939 if (info->avail != NULL) |
8225 | 2940 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2941 else |
6292 | 2942 bi->availmsg = NULL; |
4732 | 2943 |
4804 | 2944 /* Server stored icon stuff */ |
4853 | 2945 if (info->iconcsumlen) { |
7125 | 2946 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2947 char *b16 = NULL, *filepath = NULL; |
7093 | 2948 GaimBuddy *b = NULL; |
4853 | 2949 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2950 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 2951 b = gaim_find_buddy(account, info->sn); |
7093 | 2952 /* |
2953 * If for some reason the checksum is valid, but cached file is not.. | |
2954 * we want to know. | |
2955 */ | |
7693 | 2956 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2957 if (filename != NULL) { |
2958 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2959 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2960 "icon_checksum"); | |
9801 | 2961 else { |
2962 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2963 filename, NULL); | |
2964 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2965 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2966 "icon_checksum"); | |
2967 g_free(filepath); | |
2968 } | |
7093 | 2969 } else |
2970 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2971 |
4853 | 2972 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2973 GSList *cur = od->requesticon; | |
2974 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2975 cur = cur->next; | |
2976 if (!cur) { | |
9982 | 2977 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 2978 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2979 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2980 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2981 } |
2982 } | |
6053 | 2983 g_free(b16); |
4853 | 2984 } |
2985 | |
10042 | 2986 /* XXX - Represent other ICQ statuses */ |
2987 if (buddy_is_away == TRUE) | |
2988 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
2989 else | |
2990 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
9982 | 2991 gaim_prpl_got_user_login_time(account, info->sn, signon); |
2992 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); | |
2993 | |
2994 if (time_idle > 0) | |
2995 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 2996 else |
2997 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 2998 |
2999 return 1; | |
3000 } | |
3001 | |
8341 | 3002 static void gaim_check_comment(OscarData *od, const char *str) { |
3003 if ((str == NULL) || strcmp(str, ck)) | |
3004 aim_locate_setcaps(od->sess, caps_aim); | |
3005 else | |
3006 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3007 } | |
3008 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3009 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3010 GaimConnection *gc = sess->aux_data; |
7283 | 3011 OscarData *od = gc->proto_data; |
9982 | 3012 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3013 va_list ap; |
4739 | 3014 aim_userinfo_t *info; |
2086 | 3015 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3016 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3017 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3018 va_end(ap); |
3019 | |
9982 | 3020 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3021 |
7261 | 3022 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3023 |
2086 | 3024 return 1; |
3025 } | |
3026 | |
4617 | 3027 /* BBB */ |
3952 | 3028 /* |
4617 | 3029 * This is called after a remote AIM user has connected to us. We |
3030 * want to do some voodoo with the socket file descriptors, add a | |
3031 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3032 */ |
4656 | 3033 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3034 GaimConnection *gc = sess->aux_data; |
7283 | 3035 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3036 GaimXfer *xfer; |
5146 | 3037 struct aim_oft_info *oft_info; |
3630 | 3038 va_list ap; |
3039 aim_conn_t *conn, *listenerconn; | |
4656 | 3040 |
8660 | 3041 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3042 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3043 va_start(ap, fr); |
3044 conn = va_arg(ap, aim_conn_t *); | |
3045 listenerconn = va_arg(ap, aim_conn_t *); | |
3046 va_end(ap); | |
3047 | |
4617 | 3048 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3049 return 1; | |
3050 | |
5146 | 3051 if (!(oft_info = xfer->data)) |
4617 | 3052 return 1; |
3053 | |
3630 | 3054 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3055 gaim_input_remove(xfer->watcher); |
3630 | 3056 aim_conn_kill(sess, &listenerconn); |
3057 | |
5146 | 3058 oft_info->conn = conn; |
3059 xfer->fd = oft_info->conn->fd; | |
3060 | |
3061 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3062 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3063 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3064 |
3065 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3066 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3067 |
3068 return 0; | |
3069 } | |
3070 | |
3952 | 3071 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3072 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3073 * user in order to transfer a file. |
3952 | 3074 */ |
4617 | 3075 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
|
3076 GaimXfer *xfer; |
5146 | 3077 struct aim_oft_info *oft_info; |
4656 | 3078 |
8660 | 3079 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3080 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3081 if (!(xfer = data)) |
3082 return; | |
5146 | 3083 if (!(oft_info = xfer->data)) |
3630 | 3084 return; |
8446 | 3085 if (source < 0) { |
3086 gaim_xfer_cancel_remote(xfer); | |
4617 | 3087 return; |
8446 | 3088 } |
4617 | 3089 |
3090 xfer->fd = source; | |
5146 | 3091 oft_info->conn->fd = source; |
3092 | |
3093 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3094 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3095 |
3096 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3097 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3098 |
3099 return; | |
3630 | 3100 } |
3101 | |
3952 | 3102 /* |
4617 | 3103 * This is called when a buddy sends us some file info. This happens when they |
3104 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3105 * You should send them the exact same info except use the real cookie. We also |
4617 | 3106 * get like totally ready to like, receive the file, kay? |
3952 | 3107 */ |
4617 | 3108 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3109 GaimConnection *gc = sess->aux_data; |
7283 | 3110 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3111 GaimXfer *xfer; |
5146 | 3112 struct aim_oft_info *oft_info; |
4617 | 3113 va_list ap; |
3114 aim_conn_t *conn; | |
3115 fu8_t *cookie; | |
3116 struct aim_fileheader_t *fh; | |
4656 | 3117 |
8660 | 3118 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3119 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3120 va_start(ap, fr); |
3121 conn = va_arg(ap, aim_conn_t *); | |
3122 cookie = va_arg(ap, fu8_t *); | |
3123 fh = va_arg(ap, struct aim_fileheader_t *); | |
3124 va_end(ap); | |
3125 | |
3126 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3127 return 1; | |
3128 | |
5146 | 3129 if (!(oft_info = xfer->data)) |
4617 | 3130 return 1; |
3131 | |
3132 /* We want to stop listening with a normal thingy */ | |
3133 gaim_input_remove(xfer->watcher); | |
3134 xfer->watcher = 0; | |
3135 | |
5146 | 3136 /* They sent us some information about the file they're sending */ |
3137 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3138 | |
3139 /* Fill in the cookie */ | |
3140 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3141 | |
4617 | 3142 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3143 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3144 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3145 | |
3146 return 0; | |
3630 | 3147 } |
3148 | |
3952 | 3149 /* |
4657 | 3150 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3151 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3152 */ |
4617 | 3153 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3154 GaimConnection *gc = sess->aux_data; |
7283 | 3155 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3156 GaimXfer *xfer; |
4617 | 3157 va_list ap; |
3158 aim_conn_t *conn; | |
3159 fu8_t *cookie; | |
3160 struct aim_fileheader_t *fh; | |
4656 | 3161 |
8660 | 3162 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3163 va_start(ap, fr); |
3164 conn = va_arg(ap, aim_conn_t *); | |
3165 cookie = va_arg(ap, fu8_t *); | |
3166 fh = va_arg(ap, struct aim_fileheader_t *); | |
3167 va_end(ap); | |
3168 | |
3169 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3170 return 1; | |
3171 | |
4656 | 3172 /* We want to stop listening with a normal thingy */ |
3173 gaim_input_remove(xfer->watcher); | |
3174 xfer->watcher = 0; | |
3175 | |
4617 | 3176 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3177 | |
3178 return 0; | |
3630 | 3179 } |
4617 | 3180 |
3181 /* | |
3182 * We just sent a file to someone. They said they got it and everything, | |
3183 * so we can close our direct connection and what not. | |
3184 */ | |
3185 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3186 GaimConnection *gc = sess->aux_data; |
7283 | 3187 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3188 GaimXfer *xfer; |
4617 | 3189 va_list ap; |
3190 aim_conn_t *conn; | |
3191 fu8_t *cookie; | |
3192 struct aim_fileheader_t *fh; | |
4656 | 3193 |
8660 | 3194 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3195 va_start(ap, fr); |
3196 conn = va_arg(ap, aim_conn_t *); | |
3197 cookie = va_arg(ap, fu8_t *); | |
3198 fh = va_arg(ap, struct aim_fileheader_t *); | |
3199 va_end(ap); | |
3200 | |
3201 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3202 return 1; | |
3203 | |
4656 | 3204 xfer->fd = conn->fd; |
4617 | 3205 gaim_xfer_end(xfer); |
3206 | |
3207 return 0; | |
3208 } | |
3630 | 3209 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3210 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3211 GaimConnection *gc = sess->aux_data; |
7283 | 3212 OscarData *od = gc->proto_data; |
8708 | 3213 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3214 GaimConvImFlags flags = 0; |
4738 | 3215 struct buddyinfo *bi; |
5575 | 3216 const char *iconfile; |
9806 | 3217 GString *message; |
3218 gchar *tmp; | |
3219 aim_mpmsg_section_t *curpart; | |
3220 | |
3221 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3222 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3223 |
8708 | 3224 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3225 if (!bi) { |
3226 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3227 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3228 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3229 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3230 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3231 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3232 |
4738 | 3233 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3234 bi->typingnot = TRUE; | |
3235 else | |
3236 bi->typingnot = FALSE; | |
3237 | |
4380 | 3238 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3239 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3240 "%s has an icon\n", userinfo->sn); |
4738 | 3241 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3242 bi->ico_need = TRUE; | |
3243 bi->ico_len = args->iconlen; | |
3244 bi->ico_csum = args->iconsum; | |
3245 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3246 } |
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 |
8708 | 3249 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3250 (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
|
3251 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3252 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3253 |
5575 | 3254 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3255 char *buf = g_malloc(st.st_size); |
5575 | 3256 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3257 if (file) { |
9532 | 3258 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3259 int len = fread(buf, 1, st.st_size, file); |
8660 | 3260 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3261 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3262 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3263 userinfo->sn, len, st.st_size); |
4617 | 3264 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3265 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3266 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3267 } else |
8660 | 3268 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3269 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3270 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3271 } else |
8660 | 3272 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3273 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3274 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3275 |
9806 | 3276 message = g_string_new(""); |
3277 curpart = args->mpmsg.parts; | |
3278 while (curpart != NULL) { | |
9908 | 3279 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3280 curpart->data, curpart->datalen); |
3281 if (tmp != NULL) { | |
3282 g_string_append(message, tmp); | |
3283 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3284 } |
9806 | 3285 |
3286 curpart = curpart->next; | |
3287 } | |
3288 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3289 |
8666 | 3290 /* |
8995 | 3291 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3292 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3293 * so any HTML we receive is intended to be displayed |
3294 * | |
3295 * Note: There *may* be some clients which send messages as HTML formatted - | |
3296 * they need to be special-cased somehow. | |
8666 | 3297 */ |
9982 | 3298 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3299 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3300 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3301 g_free(tmp); |
3302 tmp = tmp2; | |
3303 } | |
3304 | |
6982 | 3305 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3306 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3307 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3308 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3309 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3310 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3311 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3312 GaimConnection *gc; |
9933 | 3313 GaimAccount *account; |
9070 | 3314 OscarData *od; |
9933 | 3315 const char *username = NULL; |
3316 char *message = NULL; | |
9070 | 3317 |
3318 g_return_val_if_fail(sess != NULL, 0); | |
3319 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3320 | |
3321 gc = sess->aux_data; | |
9933 | 3322 account = gaim_connection_get_account(gc); |
9070 | 3323 od = gc->proto_data; |
9933 | 3324 username = gaim_account_get_username(account); |
3325 | |
3326 if (args == NULL) | |
4121 | 3327 return 0; |
4194 | 3328 |
9933 | 3329 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3330 userinfo->sn, args->status); | |
3331 | |
3332 if (args->msg != NULL) | |
3333 { | |
3334 if (args->encoding != NULL) | |
3335 { | |
3336 char *encoding = NULL; | |
3337 encoding = oscar_encoding_extract(args->encoding); | |
3338 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3339 g_free(encoding); | |
3340 } else { | |
3341 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3342 message = g_strdup(args->msg); | |
3343 } | |
3344 } | |
2869 | 3345 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3346 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3347 char *name; |
5234 | 3348 GHashTable *components; |
3349 | |
9933 | 3350 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3351 g_free(message); | |
4121 | 3352 return 1; |
9933 | 3353 } |
5234 | 3354 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3355 g_free); | |
4121 | 3356 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3357 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3358 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
|
3359 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3360 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3361 userinfo->sn, |
9933 | 3362 message, |
5234 | 3363 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3364 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3365 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3366 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3367 /* BBB */ |
3368 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3369 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3370 GaimXfer *xfer; |
5146 | 3371 struct aim_oft_info *oft_info; |
3372 | |
3373 if (!args->cookie || !args->port || !args->verifiedip || | |
3374 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3375 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3376 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3377 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3378 "information.\n", userinfo->sn); |
5146 | 3379 if (args->proxyip) |
8660 | 3380 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3381 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3382 "does not support this yet.\n"); |
9933 | 3383 g_free(message); |
4617 | 3384 return 1; |
4656 | 3385 } |
4617 | 3386 |
3387 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3388 /* 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
|
3389 * directory -- remove the star and trailing slash so we don't save |
4617 | 3390 * directories that look like 'dirname\*' -- arl */ |
3391 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3392 if (tmp && (tmp[1] == '*')) { | |
3393 tmp[0] = '\0'; | |
3394 } | |
8660 | 3395 gaim_debug_warning("oscar", |
8446 | 3396 "We're receiving a whole directory! What fun! " |
3397 "Especially since we don't support that!\n"); | |
4617 | 3398 } |
3399 | |
3400 /* Build the file transfer handle */ | |
3401 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3402 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3403 xfer->remote_port = args->port; |
4617 | 3404 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3405 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3406 gaim_xfer_set_message(xfer, message); |
5146 | 3407 |
3408 /* Create the oscar-specific data */ | |
5163 | 3409 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3410 if (args->proxyip) |
5146 | 3411 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3412 if (args->verifiedip) |
5146 | 3413 oft_info->verifiedip = g_strdup(args->verifiedip); |
3414 xfer->data = oft_info; | |
4617 | 3415 |
3416 /* Setup our I/O op functions */ | |
8446 | 3417 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3418 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3419 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
|
3420 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3421 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3422 |
3423 /* Keep track of this transfer for later */ | |
3424 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3425 | |
3426 /* Now perform the request */ | |
3427 gaim_xfer_request(xfer); | |
3428 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3429 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3430 GaimXfer *xfer; |
8660 | 3431 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3432 "AAA - File transfer canceled by remote user\n"); |
4617 | 3433 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
|
3434 gaim_xfer_cancel_remote(xfer); |
4617 | 3435 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3436 /* | |
3437 * This gets sent by the receiver of a file | |
3438 * as they connect directly to us. If we don't | |
3439 * get this, then maybe a third party connected | |
3440 * to us, and we shouldn't send them anything. | |
3441 */ | |
3442 } else { | |
8660 | 3443 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3444 "unknown rendezvous status!\n"); |
3630 | 3445 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3446 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3447 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3448 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3449 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3450 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3451 args->info.icon.length); |
6871 | 3452 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3453 /* 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
|
3454 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3455 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
|
3456 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3457 |
4212 | 3458 if (!args->verifiedip) { |
8983 | 3459 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3460 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3461 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3462 g_free(message); |
4650 | 3463 return 1; |
4212 | 3464 } |
3465 | |
8660 | 3466 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3467 "%s received direct im request from %s (%s)\n", |
8983 | 3468 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3469 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3470 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3471 d->sn = g_strdup(userinfo->sn); |
8983 | 3472 /* Let's use the clientip here, because I think that's what AIM does. |
3473 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3474 * and then ask them to connect to us. */ | |
3475 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
|
3476 memcpy(d->cookie, args->cookie, 8); |
9070 | 3477 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3478 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3479 | |
8971 | 3480 oscar_direct_im_destroy(od, dim); |
8984 | 3481 d->donttryagain = TRUE; |
8971 | 3482 accept_direct_im_request(d); |
3483 } else { | |
8983 | 3484 if (dim && !dim->connected) |
8971 | 3485 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3486 "already connected to that buddy!"); | |
5575 | 3487 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
|
3488 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3489 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3490 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3491 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3492 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3493 "revealed, this may be considered a privacy " |
9972 | 3494 "risk."), |
3495 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3496 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3497 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3498 /* FIXME: we should actually send a packet on cancel */ | |
3499 } | |
8708 | 3500 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3501 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
|
3502 } else { |
8660 | 3503 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3504 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3505 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3506 |
9933 | 3507 g_free(message); |
3508 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3509 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3510 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3511 |
3453 | 3512 /* |
4230 | 3513 * Authorization Functions |
3514 * Most of these are callbacks from dialogs. They're used by both | |
3515 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3516 */ |
4269 | 3517 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3518 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3519 GaimConnection *gc = data->gc; |
4244 | 3520 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3521 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3522 OscarData *od = gc->proto_data; |
6695 | 3523 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3524 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3525 if (buddy && group) { |
8660 | 3526 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3527 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3528 buddy->name, group->name); |
4889 | 3529 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3530 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3531 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3532 } |
4230 | 3533 } |
4337 | 3534 } |
3535 | |
3536 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3537 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3538 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3539 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3540 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3541 data); |
4230 | 3542 } |
3543 | |
3544 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3545 GaimConnection *gc = data->gc; |
4244 | 3546 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3547 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3548 /* Remove from local list */ |
3549 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3550 gaim_blist_remove_buddy(b); | |
4244 | 3551 } |
3552 | |
5836 | 3553 oscar_free_name_data(data); |
4230 | 3554 } |
3555 | |
9030 | 3556 |
3557 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3558 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3559 GaimBuddy *buddy; |
4269 | 3560 gchar *dialog_msg, *nombre; |
3561 | |
4687 | 3562 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3563 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3564 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3565 else |
4830 | 3566 nombre = NULL; |
3567 | |
3568 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 | 3569 data->gc = gc; |
3570 data->name = g_strdup(name); | |
3571 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3572 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3573 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3574 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3575 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3576 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3577 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3578 |
3579 g_free(dialog_msg); | |
3580 g_free(nombre); | |
3581 } | |
3582 | |
9030 | 3583 |
3584 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3585 GaimBuddy *buddy; | |
3586 GaimConnection *gc; | |
3587 | |
3588 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3589 | |
3590 buddy = (GaimBuddy *) node; | |
3591 gc = gaim_account_get_connection(buddy->account); | |
3592 gaim_auth_sendrequest(gc, buddy->name); | |
3593 } | |
3594 | |
4230 | 3595 /* When other people ask you for authorization */ |
3596 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3597 GaimConnection *gc = data->gc; |
4244 | 3598 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3599 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3600 OscarData *od = gc->proto_data; |
4236 | 3601 #ifdef NOSSI |
6695 | 3602 GaimBuddy *buddy; |
4244 | 3603 gchar message; |
3604 message = 0; | |
4687 | 3605 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3606 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3607 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3608 #else |
4889 | 3609 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3610 #endif |
4244 | 3611 } |
3612 | |
5836 | 3613 oscar_free_name_data(data); |
3141 | 3614 } |
3615 | |
4230 | 3616 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3617 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3618 GaimConnection *gc = data->gc; |
4244 | 3619 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3620 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3621 OscarData *od = gc->proto_data; |
4230 | 3622 #ifdef NOSSI |
4617 | 3623 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3624 #else |
4889 | 3625 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3626 #endif |
4244 | 3627 } |
4337 | 3628 } |
3629 | |
3630 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3631 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3632 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3633 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3634 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3635 data); |
3141 | 3636 } |
3637 | |
7023 | 3638 /* When someone sends you buddies */ |
3639 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3640 GaimConnection *gc = data->gc; |
4244 | 3641 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3642 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3643 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3644 } |
3645 | |
5836 | 3646 oscar_free_name_data(data); |
3453 | 3647 } |
3648 | |
4075 | 3649 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 | 3650 GaimConnection *gc = sess->aux_data; |
9908 | 3651 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3652 gchar **msg1, **msg2; |
6051 | 3653 int i, numtoks; |
4076 | 3654 |
4121 | 3655 if (!args->type || !args->msg || !args->uin) |
3656 return 1; | |
4194 | 3657 |
8660 | 3658 gaim_debug_info("oscar", |
9908 | 3659 "Received a channel 4 message of type 0x%02hhx.\n", |
3660 args->type); | |
4076 | 3661 |
9919 | 3662 /* |
3663 * Split up the message at the delimeter character, then convert each | |
3664 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3665 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3666 * character in whatever encoding the message was sent in. Type 1 | |
3667 * messages are always made up of only one part, so we can easily account | |
3668 * for this suck-ass part of the protocol by splitting the string into at | |
3669 * most 1 baby string. | |
3670 */ | |
3671 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3672 for (numtoks=0; msg1[numtoks]; numtoks++); |
3673 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3674 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3675 gaim_str_strip_cr(msg1[i]); |
9908 | 3676 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3677 } |
3678 msg2[i] = NULL; | |
3679 | |
3952 | 3680 switch (args->type) { |
4173 | 3681 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3682 if (i >= 1) { |
5556 | 3683 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3684 gchar *tmp; |
3685 | |
3686 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3687 tmp = gaim_escape_html(msg2[0]); |
8493 | 3688 |
4076 | 3689 if (t) { /* This is an offline message */ |
9680 | 3690 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3691 #ifdef HAVE_TM_GMTOFF |
9724 | 3692 time_t now; |
3693 struct tm *tm; | |
3694 now = time(NULL); | |
3695 tm = localtime(&now); | |
3696 t += tm->tm_gmtoff; | |
9698 | 3697 #else |
3698 # ifdef HAVE_TIMEZONE | |
9680 | 3699 tzset(); |
3700 t -= timezone; | |
9698 | 3701 # endif |
3702 #endif | |
8514 | 3703 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3704 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3705 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3706 } |
3707 g_free(uin); | |
8493 | 3708 g_free(tmp); |
4075 | 3709 } |
3316 | 3710 } break; |
3711 | |
4173 | 3712 case 0x04: { /* Someone sent you a URL */ |
4076 | 3713 if (i >= 2) { |
7385 | 3714 if (msg2[1] != NULL) { |
3715 gchar *uin = g_strdup_printf("%u", args->uin); | |
3716 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3717 msg2[1], | |
3718 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3719 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3720 g_free(uin); | |
3721 g_free(message); | |
3722 } | |
3453 | 3723 } |
3724 } break; | |
3725 | |
4173 | 3726 case 0x06: { /* Someone requested authorization */ |
4076 | 3727 if (i >= 6) { |
4230 | 3728 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3729 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 | 3730 gaim_debug_info("oscar", |
5556 | 3731 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3732 args->uin); |
4076 | 3733 data->gc = gc; |
5556 | 3734 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3735 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3736 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3737 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3738 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3739 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3740 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3741 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3742 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3743 g_free(dialog_msg); |
3744 } | |
3141 | 3745 } break; |
3746 | |
4173 | 3747 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3748 if (i >= 1) { |
7023 | 3749 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
|
3750 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3751 dialog_msg); |
4076 | 3752 g_free(dialog_msg); |
3753 } | |
3141 | 3754 } break; |
3755 | |
4173 | 3756 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3757 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
|
3758 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3759 dialog_msg); |
3141 | 3760 g_free(dialog_msg); |
3761 } break; | |
3762 | |
4333 | 3763 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3764 if (i >= 5) { | |
3765 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
|
3766 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3767 g_free(dialog_msg); |
3768 } | |
3769 } break; | |
3770 | |
4173 | 3771 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3772 if (i >= 6) { |
4194 | 3773 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
|
3774 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3775 g_free(dialog_msg); |
3776 } | |
4075 | 3777 } break; |
3778 | |
4173 | 3779 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3780 if (i >= 6) { |
4308 | 3781 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
|
3782 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3783 g_free(dialog_msg); |
3784 } | |
4075 | 3785 } break; |
3786 | |
4173 | 3787 case 0x12: { |
3141 | 3788 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3789 /* Someone added you to their buddy list? */ |
3141 | 3790 } break; |
3791 | |
7023 | 3792 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3793 guint i, num; |
3453 | 3794 gchar **text; |
4173 | 3795 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3796 if (text) { |
3797 num = 0; | |
3798 for (i=0; i<strlen(text[0]); i++) | |
3799 num = num*10 + text[0][i]-48; | |
3800 for (i=0; i<num; i++) { | |
4230 | 3801 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3802 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 | 3803 data->gc = gc; |
4790 | 3804 data->name = g_strdup(text[i*2+1]); |
3805 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3806 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3807 gaim_request_action(gc, NULL, message, |
7023 | 3808 _("Do you want to add this buddy " |
3809 "to your buddy list?"), | |
9972 | 3810 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3811 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3812 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3813 g_free(message); |
3814 } | |
3815 g_strfreev(text); | |
3816 } | |
3817 } break; | |
3818 | |
7023 | 3819 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3820 /* This is boring and silly. */ |
3821 } break; | |
3822 | |
3141 | 3823 default: { |
8660 | 3824 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3825 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3826 "(type 0x%02hhx).\n", args->type); |
3141 | 3827 } break; |
3828 } | |
3829 | |
4076 | 3830 g_strfreev(msg1); |
3831 g_strfreev(msg2); | |
3832 | |
3141 | 3833 return 1; |
3834 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3835 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3836 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3837 fu16_t channel; |
3838 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3839 aim_userinfo_t *userinfo; |
2086 | 3840 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3841 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3842 va_start(ap, fr); |
4200 | 3843 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3844 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3845 |
3141 | 3846 switch (channel) { |
3847 case 1: { /* standard message */ | |
3848 struct aim_incomingim_ch1_args *args; | |
3849 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3850 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3851 } break; | |
3852 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3853 case 2: { /* rendezvous */ |
3141 | 3854 struct aim_incomingim_ch2_args *args; |
3855 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3856 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3857 } break; | |
3858 | |
3859 case 4: { /* ICQ */ | |
3860 struct aim_incomingim_ch4_args *args; | |
3861 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3862 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3863 } break; |
3864 | |
3865 default: { | |
8660 | 3866 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3867 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3868 "0x%04hx).", channel); |
3141 | 3869 } break; |
2086 | 3870 } |
3871 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3872 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3873 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3874 return ret; |
2086 | 3875 } |
3876 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3877 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3878 GaimConnection *gc = sess->aux_data; |
3879 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3880 char *buf; |
2086 | 3881 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3882 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3883 aim_userinfo_t *userinfo; |
2086 | 3884 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3885 va_start(ap, fr); |
4200 | 3886 chan = (fu16_t)va_arg(ap, unsigned int); |
3887 userinfo = va_arg(ap, aim_userinfo_t *); | |
3888 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3889 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3890 va_end(ap); |
3891 | |
3892 switch(reason) { | |
5420 | 3893 case 0: /* Invalid (0) */ |
3894 buf = g_strdup_printf( | |
3895 ngettext( | |
4276 | 3896 "You missed %hu message from %s because it was invalid.", |
3897 "You missed %hu messages from %s because they were invalid.", | |
3898 nummissed), | |
4282 | 3899 nummissed, |
3900 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3901 break; |
5420 | 3902 case 1: /* Message too large */ |
3903 buf = g_strdup_printf( | |
3904 ngettext( | |
4276 | 3905 "You missed %hu message from %s because it was too large.", |
3906 "You missed %hu messages from %s because they were too large.", | |
3907 nummissed), | |
4282 | 3908 nummissed, |
3909 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3910 break; |
5420 | 3911 case 2: /* Rate exceeded */ |
3912 buf = g_strdup_printf( | |
3913 ngettext( | |
4276 | 3914 "You missed %hu message from %s because the rate limit has been exceeded.", |
3915 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3916 nummissed), | |
4282 | 3917 nummissed, |
3918 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3919 break; |
5420 | 3920 case 3: /* Evil Sender */ |
3921 buf = g_strdup_printf( | |
3922 ngettext( | |
4276 | 3923 "You missed %hu message from %s because he/she was too evil.", |
3924 "You missed %hu messages from %s because he/she was too evil.", | |
3925 nummissed), | |
4282 | 3926 nummissed, |
3927 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3928 break; |
5420 | 3929 case 4: /* Evil Receiver */ |
3930 buf = g_strdup_printf( | |
3931 ngettext( | |
4276 | 3932 "You missed %hu message from %s because you are too evil.", |
3933 "You missed %hu messages from %s because you are too evil.", | |
3934 nummissed), | |
4282 | 3935 nummissed, |
3936 userinfo->sn); | |
2086 | 3937 break; |
3938 default: | |
5420 | 3939 buf = g_strdup_printf( |
3940 ngettext( | |
4276 | 3941 "You missed %hu message from %s for an unknown reason.", |
3942 "You missed %hu messages from %s for an unknown reason.", | |
3943 nummissed), | |
4282 | 3944 nummissed, |
3945 userinfo->sn); | |
2086 | 3946 break; |
3947 } | |
8733 | 3948 |
9627 | 3949 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3950 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3951 g_free(buf); |
2086 | 3952 |
3953 return 1; | |
3954 } | |
3955 | |
4194 | 3956 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3957 GaimConnection *gc = sess->aux_data; |
7283 | 3958 OscarData *od = gc->proto_data; |
4617 | 3959 |
3960 /* BBB */ | |
3630 | 3961 switch (reason) { |
4151 | 3962 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3963 GaimXfer *xfer; |
8971 | 3964 struct oscar_direct_im *dim; |
3965 | |
8660 | 3966 gaim_debug_info("oscar", |
9070 | 3967 "AAA - Other user declined some sort of direct " |
8971 | 3968 "connect attempt (automaticly?)\n"); |
4617 | 3969 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
|
3970 gaim_xfer_cancel_remote(xfer); |
8971 | 3971 else if ((dim = oscar_direct_im_find(od, who))) { |
3972 /* AAA should use find by cookie or something here */ | |
3973 oscar_direct_im_disconnect(od, dim); | |
3974 } | |
4151 | 3975 } break; |
3976 | |
3977 default: { | |
8660 | 3978 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3979 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3980 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3981 } |
3630 | 3982 |
3983 } | |
3984 | |
3985 return 0; | |
3986 } | |
3987 | |
4194 | 3988 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3989 GaimConnection *gc = sess->aux_data; |
4151 | 3990 |
3991 switch(reason) { | |
3992 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3993 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3994 | |
3995 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3996 |
3997 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3998 statusmsg = oscar_icqstatus(state); |
4151 | 3999 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4000 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4001 g_free(statusmsg); | |
4151 | 4002 g_strfreev(splitmsg); |
9244 | 4003 |
9797 | 4004 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4005 |
4006 g_free(title); | |
4007 g_free(dialogmsg); | |
4151 | 4008 } break; |
4009 | |
4010 default: { | |
8660 | 4011 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4012 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4013 "Type 0x%04hx\n", who, reason); |
4151 | 4014 } break; |
4015 } /* end of switch */ | |
4016 | |
4017 return 0; | |
4018 } | |
4019 | |
3212 | 4020 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4021 va_list ap; | |
4022 fu16_t chan, reason; | |
4023 char *who; | |
4024 | |
4025 va_start(ap, fr); | |
4200 | 4026 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4027 who = va_arg(ap, char *); |
4200 | 4028 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4029 |
3952 | 4030 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4031 char *cookie = va_arg(ap, char *); |
4151 | 4032 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4033 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4034 fu32_t state = 0; |
4151 | 4035 char *msg = NULL; |
4036 if (reason == 0x0003) { | |
4200 | 4037 state = va_arg(ap, fu32_t); |
4151 | 4038 msg = va_arg(ap, char *); |
4039 } | |
4040 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4041 } | |
3952 | 4042 |
3212 | 4043 va_end(ap); |
4044 | |
4045 return 1; | |
4046 } | |
4047 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4048 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4049 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4050 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4051 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4052 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4053 va_start(ap, fr); |
4199 | 4054 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4055 va_end(ap); |
4056 | |
8660 | 4057 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4058 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4059 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4060 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4061 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4062 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4063 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4064 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4065 |
2086 | 4066 return 1; |
4067 } | |
4068 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4069 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4070 GaimConnection *gc = sess->aux_data; |
4617 | 4071 #if 0 |
7283 | 4072 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4073 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4074 #endif |
4617 | 4075 va_list ap; |
4076 fu16_t reason; | |
4077 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4078 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4079 va_start(ap, fr); |
4617 | 4080 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4081 data = va_arg(ap, char *); |
2086 | 4082 va_end(ap); |
4083 | |
8660 | 4084 gaim_debug_error("oscar", |
10130 | 4085 "Message error with data %s and reason %hu\n", |
4086 (data != NULL ? data : ""), reason); | |
4617 | 4087 |
4088 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4089 #if 0 |
4617 | 4090 /* If this was a file transfer request, data is a cookie */ |
4091 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
|
4092 gaim_xfer_cancel_remote(xfer); |
3630 | 4093 return 1; |
4094 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4095 #endif |
3630 | 4096 |
4617 | 4097 /* Data is assumed to be the destination sn */ |
9826 | 4098 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4099 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4100 g_free(buf); | |
4101 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4102 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4103 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4104 } | |
4105 g_free(buf); | |
4106 | |
2086 | 4107 return 1; |
4108 } | |
4109 | |
3595 | 4110 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4111 GaimConnection *gc = sess->aux_data; |
3595 | 4112 va_list ap; |
4113 fu16_t type1, type2; | |
4114 char *sn; | |
4115 | |
4116 va_start(ap, fr); | |
4199 | 4117 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4118 sn = va_arg(ap, char *); |
4199 | 4119 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4120 va_end(ap); |
4121 | |
4122 switch (type2) { | |
4123 case 0x0000: { /* Text has been cleared */ | |
4124 serv_got_typing_stopped(gc, sn); | |
4125 } break; | |
4126 | |
4127 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4128 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4129 } break; |
4130 | |
4131 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4132 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4133 } break; |
4134 | |
4135 default: { | |
8660 | 4136 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 | 4137 } break; |
4138 } | |
4139 | |
4140 return 1; | |
4141 } | |
4142 | |
7141 | 4143 /* |
4144 * We get this error when there was an error in the locate family. This | |
7259 | 4145 * happens when you request info of someone who is offline. |
7141 | 4146 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4147 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4148 gchar *buf; |
2086 | 4149 va_list ap; |
5420 | 4150 fu16_t reason; |
2086 | 4151 char *destn; |
4152 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4153 va_start(ap, fr); |
4199 | 4154 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4155 destn = va_arg(ap, char *); |
4156 va_end(ap); | |
4157 | |
7781 | 4158 if (destn == NULL) |
7793 | 4159 return 1; |
9627 | 4160 |
9826 | 4161 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4162 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4163 g_free(buf); | |
9627 | 4164 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4165 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4166 } | |
4167 g_free(buf); | |
2086 | 4168 |
4169 return 1; | |
4170 } | |
4171 | |
7011 | 4172 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4173 GaimConnection *gc = sess->aux_data; |
8700 | 4174 GaimAccount *account = gaim_connection_get_account(gc); |
4175 GString *str; | |
9244 | 4176 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4177 va_list ap; |
7011 | 4178 aim_userinfo_t *userinfo; |
2086 | 4179 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4180 va_start(ap, fr); |
7011 | 4181 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4182 va_end(ap); |
4183 | |
8700 | 4184 str = g_string_new(""); |
4185 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4186 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4187 |
10116 | 4188 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4189 time_t t = userinfo->onlinesince; | |
4190 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); | |
4191 } | |
4192 | |
4193 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4194 time_t t = userinfo->membersince; | |
4195 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); | |
4196 } | |
7011 | 4197 |
4198 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4199 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4200 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4201 g_free(tmp); |
4202 } | |
4203 | |
8701 | 4204 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4205 |
4206 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4207 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4208 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4209 g_free(tmp); | |
7011 | 4210 if (away_utf8 != NULL) { |
8700 | 4211 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4212 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4213 } |
7011 | 4214 } |
4215 | |
4216 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4217 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4218 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4219 g_free(tmp); | |
7011 | 4220 if (info_utf8 != NULL) { |
8700 | 4221 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4222 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4223 } |
7011 | 4224 } |
4225 | |
8701 | 4226 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4227 g_string_free(str, TRUE); |
9244 | 4228 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4229 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4230 g_free(title); |
8700 | 4231 g_free(tmp); |
4151 | 4232 |
2086 | 4233 return 1; |
4234 } | |
4235 | |
8341 | 4236 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4237 { | |
4238 aim_session_t *sess = data; | |
4239 GaimConnection *gc = sess->aux_data; | |
4240 OscarData *od = (OscarData *)gc->proto_data; | |
4241 | |
4242 aim_locate_dorequest(data); | |
4243 od->getinfotimer = 0; | |
4244 | |
4245 return FALSE; | |
4246 } | |
4247 | |
4248 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4249 { | |
4250 GaimConnection *gc = sess->aux_data; | |
4251 OscarData *od = (OscarData *)gc->proto_data; | |
4252 | |
4253 /* | |
4254 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4255 * us from hitting the rate limit due to request away messages and info | |
4256 * too quickly. | |
4257 */ | |
4258 if (od->getinfotimer == 0) | |
10198 | 4259 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4260 |
4261 return 1; | |
4262 } | |
4263 | |
4264 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4265 { | |
2086 | 4266 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4267 fu16_t id; |
2086 | 4268 va_list ap; |
4269 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4270 va_start(ap, fr); |
4199 | 4271 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4272 msg = va_arg(ap, char *); |
4273 va_end(ap); | |
4274 | |
8660 | 4275 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4276 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4277 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4278 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4279 _("Your AIM connection may be lost."), NULL); |
2086 | 4280 |
4281 return 1; | |
4282 } | |
4283 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4284 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4285 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4286 fu16_t type; |
5575 | 4287 GaimConnection *gc = sess->aux_data; |
7283 | 4288 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4289 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4290 va_start(ap, fr); |
4199 | 4291 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4292 |
4293 switch(type) { | |
4294 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4295 fu8_t maxrooms; |
2086 | 4296 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4297 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4298 |
4199 | 4299 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4300 exchangecount = va_arg(ap, int); |
4301 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4302 | |
8660 | 4303 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4304 "chat info: Chat Rights:\n"); |
8660 | 4305 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4306 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4307 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4308 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4309 for (i = 0; i < exchangecount; i++) |
8660 | 4310 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4311 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4312 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4313 while (od->create_rooms) { |
4314 struct create_room *cr = od->create_rooms->data; | |
8660 | 4315 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4316 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4317 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4318 g_free(cr->name); |
4617 | 4319 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4320 g_free(cr); |
2086 | 4321 } |
4322 } | |
4323 break; | |
4324 case 0x0008: { | |
4325 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4326 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4327 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4328 fu32_t createtime; |
2086 | 4329 |
4330 fqcn = va_arg(ap, char *); | |
4200 | 4331 instance = (fu16_t)va_arg(ap, unsigned int); |
4332 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4333 flags = (fu16_t)va_arg(ap, unsigned int); | |
4334 createtime = va_arg(ap, fu32_t); | |
4335 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4336 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4337 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4338 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4339 name = va_arg(ap, char *); | |
4340 ck = va_arg(ap, char *); | |
4194 | 4341 |
8660 | 4342 gaim_debug_misc("oscar", |
5556 | 4343 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4344 fqcn, |
4345 exchange, instance, flags, | |
4346 createtime, | |
4347 maxmsglen, maxoccupancy, createperms, unknown, | |
4348 name, ck); | |
4617 | 4349 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4350 } |
4351 break; | |
4352 default: | |
8660 | 4353 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4354 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4355 break; |
4356 } | |
4194 | 4357 |
4358 va_end(ap); | |
4359 | |
2086 | 4360 return 1; |
4361 } | |
4362 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4363 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4364 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4365 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4366 aim_userinfo_t *info; |
5575 | 4367 GaimConnection *g = sess->aux_data; |
2086 | 4368 |
4369 struct chat_connection *c = NULL; | |
4370 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4371 va_start(ap, fr); |
2086 | 4372 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4373 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4374 va_end(ap); |
4375 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4376 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4377 if (!c) |
4378 return 1; | |
4379 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4380 for (i = 0; i < count; i++) |
9846 | 4381 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4382 |
4383 return 1; | |
4384 } | |
4385 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4386 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4387 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4388 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4389 aim_userinfo_t *info; |
5575 | 4390 GaimConnection *g = sess->aux_data; |
2086 | 4391 |
4392 struct chat_connection *c = NULL; | |
4393 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4394 va_start(ap, fr); |
2086 | 4395 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4396 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4397 va_end(ap); |
4398 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4399 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4400 if (!c) |
4401 return 1; | |
4402 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4403 for (i = 0; i < count; i++) |
8733 | 4404 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4405 |
4406 return 1; | |
4407 } | |
4408 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4409 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
|
4410 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4411 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4412 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4413 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4414 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4415 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4416 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4417 fu32_t creationtime; |
5575 | 4418 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4419 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
|
4420 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4421 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4422 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4423 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4424 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4425 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4426 roomdesc = va_arg(ap, char *); |
4200 | 4427 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4428 creationtime = va_arg(ap, fu32_t); | |
4429 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4430 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4431 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4432 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4433 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4434 |
8660 | 4435 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4436 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4437 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4438 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4439 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4440 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4441 |
2086 | 4442 return 1; |
4443 } | |
4444 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4445 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4446 GaimConnection *gc = sess->aux_data; |
8225 | 4447 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4448 gchar *utf8; | |
2086 | 4449 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4450 aim_userinfo_t *info; |
8225 | 4451 int len; |
2086 | 4452 char *msg; |
8219 | 4453 char *charset; |
2086 | 4454 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4455 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4456 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4457 len = va_arg(ap, int); |
4194 | 4458 msg = va_arg(ap, char *); |
8219 | 4459 charset = va_arg(ap, char *); |
4194 | 4460 va_end(ap); |
2086 | 4461 |
8225 | 4462 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4463 if (utf8 == NULL) |
4464 /* The conversion failed! */ | |
8668 | 4465 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4466 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4467 g_free(utf8); | |
2086 | 4468 |
4469 return 1; | |
4470 } | |
4471 | |
3694 | 4472 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4473 va_list ap; | |
5575 | 4474 GaimConnection *gc = sess->aux_data; |
3694 | 4475 struct aim_emailinfo *emailinfo; |
3725 | 4476 int havenewmail; |
7297 | 4477 char *alertitle, *alerturl; |
3694 | 4478 |
4479 va_start(ap, fr); | |
4480 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4481 havenewmail = va_arg(ap, int); |
7301 | 4482 alertitle = va_arg(ap, char *); |
4483 alerturl = va_arg(ap, char *); | |
3694 | 4484 va_end(ap); |
4485 | |
9661 | 4486 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4487 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4488 emailinfo->domain ? "@" : "", | |
4489 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4490 if (emailinfo->unread && havenewmail) |
4491 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4492 g_free(to); |
3694 | 4493 } |
10157 | 4494 |
7301 | 4495 if (alertitle) |
8660 | 4496 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4497 |
4498 return 1; | |
4499 } | |
4500 | |
4804 | 4501 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4502 GaimConnection *gc = sess->aux_data; |
7283 | 4503 OscarData *od = gc->proto_data; |
4804 | 4504 char *sn; |
4505 | |
4506 sn = od->requesticon->data; | |
8660 | 4507 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4508 "removing %s from hash table\n", sn); |
4804 | 4509 od->requesticon = g_slist_remove(od->requesticon, sn); |
4510 free(sn); | |
4511 | |
4512 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4513 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4514 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4515 |
4516 return 1; | |
4517 } | |
4518 | |
4519 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4520 GaimConnection *gc = sess->aux_data; |
7283 | 4521 OscarData *od = gc->proto_data; |
4804 | 4522 GSList *cur; |
4523 va_list ap; | |
4524 char *sn; | |
4853 | 4525 fu8_t *iconcsum, *icon; |
4526 fu16_t iconcsumlen, iconlen; | |
4804 | 4527 |
4528 va_start(ap, fr); | |
4529 sn = va_arg(ap, char *); | |
4853 | 4530 iconcsum = va_arg(ap, fu8_t *); |
4531 iconcsumlen = va_arg(ap, int); | |
4804 | 4532 icon = va_arg(ap, fu8_t *); |
4533 iconlen = va_arg(ap, int); | |
4534 va_end(ap); | |
4535 | |
4853 | 4536 if (iconlen > 0) { |
4537 char *b16; | |
6695 | 4538 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4539 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4540 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4541 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4542 if (b16) { |
7693 | 4543 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4544 g_free(b16); |
5129 | 4545 } |
4853 | 4546 } |
4804 | 4547 |
4548 cur = od->requesticon; | |
4549 while (cur) { | |
4550 char *cursn = cur->data; | |
4551 if (!aim_sncmp(cursn, sn)) { | |
4552 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4553 free(cursn); | |
4554 cur = od->requesticon; | |
4555 } else | |
4556 cur = cur->next; | |
4557 } | |
4558 | |
4559 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4560 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4561 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4562 |
4563 return 1; | |
4564 } | |
4565 | |
4566 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4567 GaimConnection *gc = data; |
7283 | 4568 OscarData *od = gc->proto_data; |
7011 | 4569 aim_userinfo_t *userinfo; |
4804 | 4570 aim_conn_t *conn; |
4571 | |
4572 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4573 if (!conn) { |
4574 if (!od->iconconnecting) { | |
4575 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4576 od->iconconnecting = TRUE; | |
4577 } | |
4804 | 4578 return FALSE; |
4579 } | |
4580 | |
5842 | 4581 if (od->set_icon) { |
6039 | 4582 struct stat st; |
4583 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4584 if (iconfile == NULL) { | |
8363 | 4585 aim_ssi_delicon(od->sess); |
6039 | 4586 } else if (!stat(iconfile, &st)) { |
4587 char *buf = g_malloc(st.st_size); | |
4588 FILE *file = fopen(iconfile, "rb"); | |
4589 if (file) { | |
9532 | 4590 /* XXX - Use g_file_get_contents()? */ |
6039 | 4591 fread(buf, 1, st.st_size, file); |
4592 fclose(file); | |
8660 | 4593 gaim_debug_info("oscar", |
6039 | 4594 "Uploading icon to icon server\n"); |
6879 | 4595 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4596 } else |
8660 | 4597 gaim_debug_error("oscar", |
6039 | 4598 "Can't open buddy icon file!\n"); |
4599 g_free(buf); | |
4600 } else { | |
8660 | 4601 gaim_debug_error("oscar", |
6039 | 4602 "Can't stat buddy icon file!\n"); |
5842 | 4603 } |
4604 od->set_icon = FALSE; | |
4605 } | |
4606 | |
4607 if (!od->requesticon) { | |
8660 | 4608 gaim_debug_misc("oscar", |
5842 | 4609 "no more icons to request\n"); |
4610 return FALSE; | |
4611 } | |
4612 | |
7045 | 4613 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4614 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4615 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4616 return FALSE; |
4617 } else { | |
4618 char *sn = od->requesticon->data; | |
4619 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4620 free(sn); | |
4621 } | |
4622 | |
4623 return TRUE; | |
4624 } | |
4625 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4626 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4627 * 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
|
4628 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4629 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4630 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4631 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4632 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4634 va_start(ap, fr); |
4199 | 4635 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4636 sn = va_arg(ap, char *); |
4637 va_end(ap); | |
4638 | |
8660 | 4639 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4640 |
4641 return 1; | |
4642 } | |
4643 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4644 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
|
4645 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4646 "invalid", |
4194 | 4647 "change", |
4648 "warning", | |
4649 "limit", | |
4650 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4651 }; |
2086 | 4652 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4653 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4654 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4655 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4656 va_start(ap, fr); |
4200 | 4657 code = (fu16_t)va_arg(ap, unsigned int); |
4658 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4659 windowsize = va_arg(ap, fu32_t); | |
4660 clear = va_arg(ap, fu32_t); | |
4661 alert = va_arg(ap, fu32_t); | |
4662 limit = va_arg(ap, fu32_t); | |
4663 disconnect = va_arg(ap, fu32_t); | |
4664 currentavg = va_arg(ap, fu32_t); | |
4665 maxavg = va_arg(ap, fu32_t); | |
2086 | 4666 va_end(ap); |
4667 | |
8660 | 4668 gaim_debug_misc("oscar", |
5556 | 4669 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4670 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4671 (code < 5) ? codes[code] : codes[0], |
4672 rateclass, | |
4673 currentavg, maxavg, | |
4674 alert, clear, | |
4675 limit, disconnect, | |
4676 windowsize); | |
4677 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4678 /* XXX fix these values */ |
2086 | 4679 if (code == AIM_RATE_CODE_CHANGE) { |
4680 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4681 aim_conn_setlatency(fr->conn, 0); |
2086 | 4682 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4683 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4684 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4685 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4686 _("The last action you attempted could not be " |
4687 "performed because you are over the rate limit. " | |
4688 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4689 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4690 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4691 aim_conn_setlatency(fr->conn, 0); |
2086 | 4692 } |
4693 | |
4694 return 1; | |
4695 } | |
4696 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4697 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4698 GaimConnection *gc = sess->aux_data; |
4699 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4700 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4701 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4702 aim_userinfo_t *userinfo; |
2086 | 4703 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4704 va_start(ap, fr); |
4199 | 4705 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4706 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4707 va_end(ap); |
4708 | |
9982 | 4709 /* XXX - What's with the + 0.5? */ |
4710 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4711 |
4712 return 1; | |
4713 } | |
4714 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4715 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4716 GaimConnection *gc = sess->aux_data; |
4717 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4718 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4719 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4720 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4721 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4722 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4723 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4724 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4725 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4726 |
9982 | 4727 warning_level = info->warnlevel/10.0 + 0.5; |
4728 | |
10152 | 4729 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4730 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4731 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4732 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4733 |
4649 | 4734 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4735 GaimConnection *gc = sess->aux_data; |
7283 | 4736 OscarData *od = gc->proto_data; |
4649 | 4737 va_list ap; |
4738 fu16_t code; | |
4739 char *msg; | |
4740 | |
4741 va_start(ap, fr); | |
4742 code = (fu16_t)va_arg(ap, int); | |
4743 msg = va_arg(ap, char *); | |
4744 va_end(ap); | |
4745 | |
8660 | 4746 gaim_debug_info("oscar", |
10130 | 4747 "Disconnected. Code is 0x%04x and msg is %s\n", code, |
4748 (msg != NULL ? msg : "")); | |
4749 | |
4649 | 4750 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4751 if (code == 0x0001) { |
6113 | 4752 gc->wants_to_die = TRUE; |
5579 | 4753 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4754 } else { |
5579 | 4755 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4756 } |
4666 | 4757 od->killme = TRUE; |
4649 | 4758 } |
4759 | |
4760 return 1; | |
4761 } | |
4762 | |
2675 | 4763 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4764 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4765 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4766 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4767 |
4768 #ifndef NOSSI | |
8660 | 4769 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4770 aim_ssi_reqrights(sess); |
6350 | 4771 aim_ssi_reqdata(sess); |
4230 | 4772 #endif |
4773 | |
7011 | 4774 aim_locate_reqrights(sess); |
7285 | 4775 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4776 aim_im_reqparams(sess); |
7334 | 4777 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4778 |
4779 #ifdef NOSSI | |
8660 | 4780 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4781 aim_bos_reqrights(sess, fr->conn); |
4230 | 4782 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4783 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4784 #endif | |
2086 | 4785 |
7283 | 4786 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4787 | |
2086 | 4788 return 1; |
4789 } | |
4790 | |
2675 | 4791 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4792 GaimConnection *gc = sess->aux_data; |
7283 | 4793 OscarData *od = gc->proto_data; |
2647 | 4794 |
6905 | 4795 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4796 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4797 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4798 | |
2672 | 4799 aim_clientready(sess, fr->conn); |
8660 | 4800 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4801 |
2647 | 4802 if (od->chpass) { |
8660 | 4803 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4804 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4805 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4806 od->oldp = NULL; |
2647 | 4807 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4808 od->newp = NULL; |
2647 | 4809 od->chpass = FALSE; |
4810 } | |
2979 | 4811 if (od->setnick) { |
8660 | 4812 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4813 aim_admin_setnick(sess, fr->conn, od->newsn); |
4814 g_free(od->newsn); | |
4815 od->newsn = NULL; | |
4816 od->setnick = FALSE; | |
4817 } | |
2647 | 4818 if (od->conf) { |
8660 | 4819 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4820 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4821 od->conf = FALSE; |
4822 } | |
4823 if (od->reqemail) { | |
8660 | 4824 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4825 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4826 od->reqemail = FALSE; |
4827 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4828 if (od->setemail) { |
8660 | 4829 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4830 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4831 g_free(od->email); |
5497 | 4832 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4833 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4834 } |
2647 | 4835 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4836 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4837 } |
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 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
|
4840 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4841 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4842 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4843 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4844 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4845 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4846 |
4194 | 4847 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4848 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4849 "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
|
4850 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4851 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4852 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4853 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4854 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4855 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4856 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4857 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4858 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4859 |
4617 | 4860 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4861 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4862 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4863 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4864 |
2993 | 4865 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4866 { | |
5575 | 4867 GaimConnection *gc = sess->aux_data; |
7283 | 4868 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4869 va_list ap; |
4870 fu16_t maxsiglen; | |
2993 | 4871 |
4872 va_start(ap, fr); | |
4199 | 4873 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4874 va_end(ap); |
4875 | |
8660 | 4876 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4877 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4878 |
4617 | 4879 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4880 | |
4881 if (od->icq) | |
7334 | 4882 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4883 else |
7334 | 4884 aim_locate_setcaps(od->sess, caps_aim); |
4885 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4886 |
4887 return 1; | |
4888 } | |
4889 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4890 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
|
4891 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4892 fu16_t maxbuddies, maxwatchers; |
5575 | 4893 GaimConnection *gc = sess->aux_data; |
7283 | 4894 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4895 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4896 va_start(ap, fr); |
4199 | 4897 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4898 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4899 va_end(ap); |
4900 | |
8660 | 4901 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4902 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4903 |
4617 | 4904 od->rights.maxbuddies = (guint)maxbuddies; |
4905 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4906 |
2086 | 4907 return 1; |
4908 } | |
4909 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4910 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4911 GaimConnection *gc = sess->aux_data; |
7283 | 4912 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4913 va_list ap; |
4914 fu16_t maxpermits, maxdenies; | |
2086 | 4915 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4916 va_start(ap, fr); |
4199 | 4917 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4918 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4919 va_end(ap); |
4920 | |
8660 | 4921 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4922 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4923 |
4617 | 4924 od->rights.maxpermits = (guint)maxpermits; |
4925 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4926 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4927 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4928 serv_finish_login(gc); |
4929 | |
8660 | 4930 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4931 |
2672 | 4932 aim_clientready(sess, fr->conn); |
5948 | 4933 aim_srv_setavailmsg(sess, NULL); |
7474 | 4934 aim_srv_setidle(sess, 0); |
4617 | 4935 |
4664 | 4936 if (od->icq) { |
4937 aim_icq_reqofflinemsgs(sess); | |
4938 aim_icq_hideip(sess); | |
4939 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4940 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4941 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4942 if (sess->authinfo->email) |
4943 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4944 |
4945 return 1; | |
4946 } | |
4947 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4948 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
|
4949 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4950 struct aim_icq_offlinemsg *msg; |
4075 | 4951 struct aim_incomingim_ch4_args args; |
4952 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4953 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4954 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4955 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4956 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4957 |
8660 | 4958 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4959 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4960 args.uin = msg->sender; |
4961 args.type = msg->type; | |
4173 | 4962 args.flags = msg->flags; |
4076 | 4963 args.msglen = msg->msglen; |
4075 | 4964 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4965 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4966 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4967 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4968 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4969 } |
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 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
|
4972 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4973 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4974 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4975 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4976 |
7388 | 4977 #if 0 |
4978 /* | |
7465 | 4979 * Update, 2003-11-09: |
4980 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4981 * | |
7388 | 4982 * It may not be my place to do this, but... |
4983 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4984 * stupid, and should not exist for % switches (%x in our case) that request | |
4985 * a year in the preferred representation for the current locale. For that | |
4986 * reason I've chosen to not use this workaround (n., see kluge). | |
4987 * | |
4988 * I have a date. I want to show it to the user in the "preferred" way. | |
4989 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4990 * what the locale wanted. | |
4991 * | |
4992 * If I have a necessity for a full representation of the year in the current | |
4993 * locale, then I'll use a switch that returns a full representation of the | |
4994 * year. | |
4995 * | |
4996 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4997 * (because you're anal, or whatever), then change the f***ing locale. | |
4998 * | |
4999 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5000 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5001 * |
5002 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5003 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5004 */ |
5005 | |
5006 /* | |
5007 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5008 * "last 2 digits" warning. |
5009 */ | |
10157 | 5010 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5011 const struct tm *tm) |
5012 { | |
5013 return strftime(s, max, fmt, tm); | |
5014 } | |
7388 | 5015 #endif |
7386 | 5016 |
4624 | 5017 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
|
5018 { |
5575 | 5019 GaimConnection *gc = sess->aux_data; |
8670 | 5020 OscarData *od = (OscarData *)gc->proto_data; |
5021 GaimBuddy *buddy; | |
8853 | 5022 struct buddyinfo *bi = NULL; |
4624 | 5023 gchar who[16]; |
8670 | 5024 GString *str; |
5025 gchar *primary, *utf8; | |
9634 | 5026 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5027 va_list ap; |
4151 | 5028 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5029 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5030 va_start(ap, fr); |
4151 | 5031 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5032 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5033 |
4664 | 5034 if (!info->uin) |
5035 return 0; | |
5036 | |
8670 | 5037 str = g_string_sized_new(100); |
5556 | 5038 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5039 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5040 if (buddy != NULL) | |
5041 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5042 | |
5043 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5044 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5045 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5046 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5047 (bi->ipaddr & 0xff000000) >> 24, | |
5048 (bi->ipaddr & 0x00ff0000) >> 16, | |
5049 (bi->ipaddr & 0x0000ff00) >> 8, | |
5050 (bi->ipaddr & 0x000000ff)); | |
8701 | 5051 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5052 g_free(tstr); |
5053 } | |
8701 | 5054 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5055 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5056 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5057 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5058 g_free(utf8); | |
4625 | 5059 } |
5060 if (info->numaddresses && info->email2) { | |
5061 int i; | |
5062 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5063 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5064 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5065 g_free(utf8); | |
4643 | 5066 } |
4625 | 5067 } |
4624 | 5068 } |
8701 | 5069 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5070 if (info->gender != 0) |
5071 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5072 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5073 char date[30]; |
5074 struct tm tm; | |
5075 tm.tm_mday = (int)info->birthday; | |
5076 tm.tm_mon = (int)info->birthmonth-1; | |
5077 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5078 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5079 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5080 } |
4624 | 5081 if (info->age) { |
5082 char age[5]; | |
5083 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5084 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5085 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5086 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5087 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5088 g_free(utf8); | |
4819 | 5089 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5090 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5091 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5092 g_free(utf8); | |
5093 } | |
5094 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5095 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5096 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5097 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5098 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5099 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5100 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5101 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5102 } |
4641 | 5103 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5104 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5105 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5106 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5107 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5108 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5109 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5110 } |
4641 | 5111 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5112 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5113 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5114 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5115 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5116 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5117 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5118 g_free(utf8); | |
4624 | 5119 } |
8670 | 5120 g_string_append_printf(str, "\n<hr>\n"); |
5121 } | |
5122 | |
9634 | 5123 if (buddy != NULL) |
5124 alias = gaim_buddy_get_alias(buddy); | |
5125 else | |
5126 alias = who; | |
5127 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5128 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5129 g_free(primary); |
8670 | 5130 g_string_free(str, TRUE); |
4151 | 5131 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5132 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5133 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5134 |
4759 | 5135 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5136 { | |
5575 | 5137 GaimConnection *gc = sess->aux_data; |
4820 | 5138 gchar who[16], *utf8; |
6695 | 5139 GaimBuddy *b; |
4759 | 5140 va_list ap; |
5141 struct aim_icq_info *info; | |
5142 | |
5143 va_start(ap, fr); | |
5144 info = va_arg(ap, struct aim_icq_info *); | |
5145 va_end(ap); | |
5146 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5147 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5148 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5149 serv_got_alias(gc, who, utf8); |
4759 | 5150 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5151 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5152 } |
4820 | 5153 g_free(utf8); |
4759 | 5154 } |
5155 | |
5156 return 1; | |
5157 } | |
5158 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5159 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
|
5160 { |
7032 | 5161 GaimConnection *gc = sess->aux_data; |
5162 gchar *text; | |
5163 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5164 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5165 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5166 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5167 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5168 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5169 url = va_arg(ap, char *); |
4199 | 5170 wid = (fu16_t) va_arg(ap, int); |
5171 hei = (fu16_t) va_arg(ap, int); | |
5172 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5173 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5174 |
7032 | 5175 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5176 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5177 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5178 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5179 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5180 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5181 |
7032 | 5182 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5183 { | |
6873 | 5184 GaimConnection *gc = sess->aux_data; |
5185 gchar *secondary; | |
5186 GString *text; | |
5187 int i, num; | |
2086 | 5188 va_list ap; |
6873 | 5189 char *email, *SNs; |
2086 | 5190 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5191 va_start(ap, fr); |
6873 | 5192 email = va_arg(ap, char *); |
2086 | 5193 num = va_arg(ap, int); |
5194 SNs = va_arg(ap, char *); | |
5195 va_end(ap); | |
5196 | |
8152 | 5197 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5198 text = g_string_new(""); |
2086 | 5199 for (i = 0; i < num; i++) |
6873 | 5200 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5201 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5202 | |
5203 g_free(secondary); | |
5204 g_string_free(text, TRUE); | |
2086 | 5205 |
5206 return 1; | |
5207 } | |
5208 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5209 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5210 va_list ap; |
6873 | 5211 char *email; |
5420 | 5212 char *buf; |
2086 | 5213 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5214 va_start(ap, fr); |
6873 | 5215 email = va_arg(ap, char *); |
2086 | 5216 va_end(ap); |
5217 | |
6873 | 5218 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
|
5219 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5220 g_free(buf); |
2086 | 5221 |
5222 return 1; | |
5223 } | |
5224 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5225 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5226 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5227 fu16_t status; |
2086 | 5228 va_list ap; |
5229 char msg[256]; | |
5230 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5231 va_start(ap, fr); |
4199 | 5232 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5233 va_end(ap); |
5234 | |
8660 | 5235 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5236 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5237 status ? "unknown" : "email sent"); |
5238 if (!status) { | |
5302 | 5239 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5240 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5241 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5242 } |
5243 | |
5244 return 1; | |
5245 } | |
5246 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5247 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5248 GaimConnection *gc = sess->aux_data; |
2086 | 5249 va_list ap; |
3912 | 5250 fu16_t perms, err; |
5251 char *url, *sn, *email; | |
5252 int change; | |
2086 | 5253 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5254 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5255 change = va_arg(ap, int); |
4199 | 5256 perms = (fu16_t) va_arg(ap, unsigned int); |
5257 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5258 url = va_arg(ap, char *); |
5259 sn = va_arg(ap, char *); | |
5260 email = va_arg(ap, char *); | |
2086 | 5261 va_end(ap); |
5262 | |
8660 | 5263 gaim_debug_misc("oscar", |
9626 | 5264 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5265 change ? "change" : "request", perms, err, | |
5266 (url != NULL) ? url : "(null)", | |
5267 (sn != NULL) ? sn : "(null)", | |
5268 (email != NULL) ? email : "(null)"); | |
5269 | |
5270 if ((err > 0) && (url != NULL)) { | |
3912 | 5271 char *dialog_msg; |
5272 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5273 switch (err) { | |
5274 case 0x0001: { | |
5275 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5276 } break; | |
5277 case 0x0006: { | |
5278 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5279 } break; | |
5280 case 0x000b: { | |
5281 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5282 } break; | |
5283 case 0x001d: { | |
5284 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); | |
5285 } break; | |
5286 case 0x0021: { | |
5287 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); | |
5288 } break; | |
5289 case 0x0023: { | |
5290 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5291 } break; | |
5292 default: { | |
5293 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5294 } break; | |
5295 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5296 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5297 g_free(dialog_top); |
5298 g_free(dialog_msg); | |
5299 return 1; | |
5300 } | |
5301 | |
9626 | 5302 if (sn != NULL) { |
4585 | 5303 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
|
5304 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5305 g_free(dialog_msg); |
5306 } | |
5307 | |
9626 | 5308 if (email != NULL) { |
5575 | 5309 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5310 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5311 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5312 g_free(dialog_msg); |
2086 | 5313 } |
5314 | |
5315 return 1; | |
5316 } | |
5317 | |
5575 | 5318 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5319 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5320 aim_flap_nop(od->sess, od->conn); |
2086 | 5321 } |
5322 | |
6059 | 5323 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5324 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5325 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5326 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5327 if (typing == GAIM_TYPING) |
4870 | 5328 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5329 else if (typing == GAIM_TYPED) |
4870 | 5330 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5331 else | |
5332 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5333 else { |
5300 | 5334 /* Don't send if this turkey is in our deny list */ |
5335 GSList *list; | |
5336 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5337 if (!list) { | |
7261 | 5338 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5339 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5340 if (typing == GAIM_TYPING) |
5300 | 5341 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5342 else if (typing == GAIM_TYPED) |
5300 | 5343 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5344 else | |
5345 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5346 } | |
3595 | 5347 } |
5348 } | |
2993 | 5349 return 0; |
5350 } | |
9030 | 5351 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5352 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
|
5353 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5354 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5355 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5356 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5357 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
|
5358 int ret = 0; |
10246 | 5359 const char *iconfile = gaim_account_get_buddy_icon(account); |
8800 | 5360 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5361 |
4838 | 5362 if (dim && dim->connected) { |
5363 /* If we're directly connected, send a direct IM */ | |
6982 | 5364 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5365 } else { |
4738 | 5366 struct buddyinfo *bi; |
3008 | 5367 struct aim_sendimext_args args; |
5368 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5369 gsize len; |
10246 | 5370 GaimConversation *conv; |
5371 | |
5372 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5373 |
5374 if (strstr(message, "<IMG ")) | |
5375 gaim_conversation_write(conv, "", | |
5376 _("Your IM Image was not sent. " | |
5377 "You must be Direct Connected to send IM Images."), | |
5378 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5379 |
10246 | 5380 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5381 if (!bi) { |
5382 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5383 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5384 } |
5385 | |
3008 | 5386 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5387 if (od->icq) { |
5388 args.features = features_icq; | |
5389 args.featureslen = sizeof(features_icq); | |
3008 | 5390 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5391 } else { |
5392 args.features = features_aim; | |
5393 args.featureslen = sizeof(features_aim); | |
4972 | 5394 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5395 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5396 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5397 } |
4269 | 5398 |
4738 | 5399 if (bi->ico_need) { |
8660 | 5400 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5401 "Sending buddy icon request with message\n"); |
3008 | 5402 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5403 bi->ico_need = FALSE; |
3008 | 5404 } |
4269 | 5405 |
5575 | 5406 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5407 FILE *file = fopen(iconfile, "rb"); |
3008 | 5408 if (file) { |
5409 char *buf = g_malloc(st.st_size); | |
9532 | 5410 /* XXX - Use g_file_get_contents()? */ |
3008 | 5411 fread(buf, 1, st.st_size, file); |
6039 | 5412 fclose(file); |
4269 | 5413 |
3008 | 5414 args.iconlen = st.st_size; |
4617 | 5415 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5416 args.iconstamp = st.st_mtime; |
5417 | |
7406 | 5418 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5419 bi->ico_informed = FALSE; |
7406 | 5420 bi->ico_sent = FALSE; |
5421 } | |
4738 | 5422 |
5423 if (!bi->ico_informed) { | |
8660 | 5424 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5425 "Claiming to have a buddy icon\n"); |
4738 | 5426 args.flags |= AIM_IMFLAGS_HASICON; |
5427 bi->ico_me_len = args.iconlen; | |
5428 bi->ico_me_csum = args.iconsum; | |
5429 bi->ico_me_time = args.iconstamp; | |
5430 bi->ico_informed = TRUE; | |
5431 } | |
5432 | |
3008 | 5433 g_free(buf); |
2086 | 5434 } |
5435 } | |
4269 | 5436 |
3008 | 5437 args.destsn = name; |
4269 | 5438 |
8985 | 5439 /* |
5440 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5441 * strip all HTML | |
5442 */ | |
9975 | 5443 if (aim_sn_is_icq(name) ) { |
8995 | 5444 /* being sent to an ICQ user */ |
10246 | 5445 if (!aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5446 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5447 tmpmsg = gaim_str_add_cr(message); | |
5448 } else { | |
5449 /* from an ICQ user - do nothing */ | |
5450 tmpmsg = g_strdup(message); | |
5451 } | |
5452 } else { | |
5453 /* being sent to an AIM user */ | |
10246 | 5454 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5455 /* from an ICQ user */ |
5456 tmpmsg2 = gaim_strdup_withhtml(message); | |
5457 tmpmsg = gaim_escape_html(tmpmsg2); | |
5458 g_free(tmpmsg2); | |
5459 } else | |
5460 tmpmsg = gaim_strdup_withhtml(message); | |
5461 } | |
6310 | 5462 len = strlen(tmpmsg); |
5463 | |
9830 | 5464 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5465 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5466 args.charset, args.charsubset, args.msglen); | |
4617 | 5467 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5468 g_free((char *)args.msg); |
2086 | 5469 } |
4838 | 5470 |
6310 | 5471 g_free(tmpmsg); |
5472 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5473 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5474 return 1; |
6310 | 5475 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5476 return ret; |
2086 | 5477 } |
5478 | |
7011 | 5479 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5480 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5481 |
9975 | 5482 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5483 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5484 else |
7235 | 5485 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5486 } |
5487 | |
8950 | 5488 #if 0 |
7011 | 5489 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5490 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5491 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5492 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5493 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5494 maiden, NULL, NULL, city, state, NULL, 0, web); |
5495 } | |
8950 | 5496 #endif |
2086 | 5497 |
5575 | 5498 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5499 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5500 aim_srv_setidle(od->sess, time); |
2086 | 5501 } |
5502 | |
5954 | 5503 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5504 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5505 int charset = 0; |
6019 | 5506 char *text_html = NULL; |
5129 | 5507 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5508 gsize msglen = 0; |
2993 | 5509 |
4617 | 5510 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5511 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5512 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5513 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5514 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5515 "again when you are fully connected.")); |
4617 | 5516 |
7334 | 5517 if (!text) { |
5518 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5519 return; | |
5520 } | |
10097 | 5521 |
7334 | 5522 text_html = gaim_strdup_withhtml(text); |
9807 | 5523 charset = oscar_charset_check(text_html); |
9826 | 5524 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5525 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5526 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5527 g_free(msg); | |
9826 | 5528 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5529 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5530 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5531 g_free(msg); | |
5532 } else { | |
5533 msglen = strlen(text_html); | |
5534 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5535 } | |
5536 | |
5537 if (msglen > od->rights.maxsiglen) { | |
5538 gchar *errstr; | |
5539 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5540 "has been exceeded. Gaim has truncated it for you.", | |
5541 "The maximum profile length of %d bytes " | |
5542 "has been exceeded. Gaim has truncated it for you.", | |
5543 od->rights.maxsiglen), od->rights.maxsiglen); | |
5544 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5545 g_free(errstr); | |
5546 } | |
5547 | |
5548 g_free(text_html); | |
2993 | 5549 |
5550 return; | |
2086 | 5551 } |
5552 | |
9991 | 5553 static void |
5554 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5555 { |
9991 | 5556 GaimConnection *gc = gaim_account_get_connection(account); |
5557 OscarData *od = (OscarData *)gc->proto_data; | |
9992 | 5558 GaimStatusType *status_type; |
9991 | 5559 GaimStatusPrimitive primitive; |
5560 GaimPresence *presence; | |
5561 const gchar *status_id; | |
9807 | 5562 int charset = 0; |
10196 | 5563 const gchar *text_html = NULL; |
5129 | 5564 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5565 gsize msglen = 0; |
2993 | 5566 |
9992 | 5567 status_type = gaim_status_get_type(status); |
5568 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5569 status_id = gaim_status_get_id(status); |
5570 presence = gaim_account_get_presence(account); | |
5571 | |
10196 | 5572 gaim_debug_info("oscar", "Setting status to %s\n", status_id); |
5573 | |
2993 | 5574 if (od->rights.maxawaymsglen == 0) |
9991 | 5575 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
|
5576 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5577 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5578 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5579 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5580 "fully connected.")); |
5129 | 5581 |
9992 | 5582 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5583 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5584 | |
7334 | 5585 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5586 |
5587 text_html = gaim_status_get_attr_string(status, "message"); | |
5588 if (text_html != NULL) { | |
5589 aim_srv_setavailmsg(od->sess, text_html); | |
5590 } | |
10196 | 5591 |
5592 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5593 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5594 | |
10196 | 5595 text_html = gaim_status_get_attr_string(status, "message"); |
5596 | |
5597 if (text_html == NULL) { | |
5598 text_html = _("Away"); | |
5599 } | |
5600 | |
5601 charset = oscar_charset_check(text_html); | |
5602 if (charset == AIM_CHARSET_UNICODE) { | |
5603 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5604 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5605 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5606 g_free(msg); | |
5607 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5608 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5609 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5610 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5611 g_free(msg); | |
5612 } else { | |
5613 msglen = strlen(text_html); | |
5614 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5615 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5616 } | |
5617 | |
5618 if (msglen > od->rights.maxawaymsglen) { | |
5619 gchar *errstr; | |
5620 | |
5621 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5622 "has been exceeded. Gaim has truncated it for you.", | |
5623 "The maximum away message length of %d bytes " | |
5624 "has been exceeded. Gaim has truncated it for you.", | |
5625 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5626 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5627 g_free(errstr); | |
5628 } | |
5629 | |
10197 | 5630 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5631 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5632 | |
5129 | 5633 } else { |
10196 | 5634 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5635 | |
5636 } | |
2993 | 5637 } |
5638 | |
9991 | 5639 static void |
5640 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5641 { |
9991 | 5642 GaimConnection *gc = gaim_account_get_connection(account); |
5643 OscarData *od = (OscarData *)gc->proto_data; | |
5644 const gchar *status_id = gaim_status_get_id(status); | |
5645 | |
5646 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5647 account->perm_deny = 4; |
8265 | 5648 else |
5575 | 5649 account->perm_deny = 3; |
9991 | 5650 |
8265 | 5651 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5652 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5653 |
9991 | 5654 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5655 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5656 |
5657 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5658 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5659 |
5660 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5661 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5662 |
5663 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5664 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5665 |
5666 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5667 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5668 |
5669 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5670 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5671 |
5672 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5673 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5674 |
5675 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5676 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5677 |
5678 return; | |
5679 } | |
5680 | |
9991 | 5681 static void |
5682 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5683 { |
9991 | 5684 GaimConnection *gc = gaim_account_get_connection(account); |
5685 OscarData *od = (OscarData *)gc->proto_data; | |
2993 | 5686 |
5687 if (od->icq) | |
9988 | 5688 oscar_set_status_icq(account, status); |
2993 | 5689 else |
9988 | 5690 oscar_set_status_aim(account, status); |
2993 | 5691 |
5692 return; | |
2086 | 5693 } |
5694 | |
9991 | 5695 static void |
5696 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5697 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5698 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5699 } |
5700 | |
9285 | 5701 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5702 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5703 |
5704 if (!aim_snvalid(buddy->name)) { | |
8092 | 5705 gchar *buf; |
9285 | 5706 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 | 5707 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5708 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5709 g_free(buf); |
8150 | 5710 |
5711 /* Remove from local list */ | |
9285 | 5712 gaim_blist_remove_buddy(buddy); |
8150 | 5713 |
8092 | 5714 return; |
5715 } | |
5716 | |
4230 | 5717 #ifdef NOSSI |
9285 | 5718 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5719 #else |
9285 | 5720 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5721 if (buddy && group) { | |
8660 | 5722 gaim_debug_info("oscar", |
9285 | 5723 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5724 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5725 } |
5726 } | |
5727 #endif | |
8150 | 5728 |
10157 | 5729 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5730 if (od->icq) |
9285 | 5731 aim_icq_getalias(od->sess, buddy->name); |
5732 } | |
5733 | |
5734 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5735 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5736 #ifdef NOSSI |
5737 char buf[MSG_LEN]; | |
5738 int n=0; | |
9285 | 5739 |
4230 | 5740 while (buddies) { |
9381 | 5741 GaimBuddy *buddy = buddies->data; |
4230 | 5742 if (n > MSG_LEN - 18) { |
7285 | 5743 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5744 n = 0; |
3092 | 5745 } |
9381 | 5746 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5747 buddies = buddies->next; |
5748 } | |
7285 | 5749 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5750 #else |
9285 | 5751 |
4230 | 5752 if (od->sess->ssi.received_data) { |
9285 | 5753 GList *curb = buddies; |
5754 GList *curg = groups; | |
5755 while ((curb != NULL) && (curg != NULL)) { | |
5756 GaimBuddy *buddy = curb->data; | |
5757 GaimGroup *group = curg->data; | |
5758 oscar_add_buddy(gc, buddy, group); | |
5759 curb = curb->next; | |
5760 curg = curg->next; | |
4230 | 5761 } |
5762 } | |
5763 #endif | |
5764 } | |
5765 | |
9285 | 5766 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5767 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5768 |
4230 | 5769 #ifdef NOSSI |
9285 | 5770 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5771 #else |
5772 if (od->sess->ssi.received_data) { | |
8660 | 5773 gaim_debug_info("oscar", |
9285 | 5774 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5775 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5776 } |
5777 #endif | |
5778 } | |
5779 | |
9285 | 5780 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5781 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5782 |
4230 | 5783 #ifdef NOSSI |
9285 | 5784 for (cur = buddies; cur != NULL; cur = cur->next) { |
5785 GaimBuddy *buddy = cur->data; | |
5786 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5787 } | |
4230 | 5788 #else |
5789 if (od->sess->ssi.received_data) { | |
9285 | 5790 GList *curb = buddies; |
5791 GList *curg = groups; | |
5792 while ((curb != NULL) && (curg != NULL)) { | |
5793 GaimBuddy *buddy = curb->data; | |
5794 GaimGroup *group = curg->data; | |
5795 oscar_remove_buddy(gc, buddy, group); | |
5796 curb = curb->next; | |
5797 curg = curg->next; | |
3092 | 5798 } |
4230 | 5799 } |
5800 #endif | |
5801 } | |
5802 | |
5803 #ifndef NOSSI | |
5575 | 5804 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5805 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5806 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5807 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5808 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5809 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5810 } |
5811 } | |
5812 | |
5575 | 5813 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5814 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5815 if (od->sess->ssi.received_data) { |
5816 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5817 if (gname) { | |
8660 | 5818 gaim_debug_info("oscar", |
9586 | 5819 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5820 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5821 } |
5822 } | |
5823 } | |
5824 | |
9285 | 5825 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5826 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5827 |
5828 if (od->sess->ssi.received_data) { | |
9285 | 5829 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5830 GList *cur, *groups = NULL; | |
5831 | |
5832 /* Make a list of what the groups each buddy is in */ | |
5833 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5834 GaimBlistNode *node = cur->data; | |
5835 groups = g_list_append(groups, node->parent); | |
5836 } | |
5837 | |
5838 oscar_remove_buddies(gc, moved_buddies, groups); | |
5839 oscar_add_buddies(gc, moved_buddies, groups); | |
5840 g_list_free(groups); | |
8660 | 5841 gaim_debug_info("oscar", |
9285 | 5842 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5843 } else { |
9285 | 5844 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5845 gaim_debug_info("oscar", |
9285 | 5846 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5847 } |
5848 } | |
5849 } | |
5850 | |
5968 | 5851 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5852 aim_session_t *sess = data; | |
6350 | 5853 aim_ssi_reqdata(sess); |
5968 | 5854 return FALSE; |
5855 } | |
5856 | |
4642 | 5857 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5858 GaimConnection *gc = sess->aux_data; |
7283 | 5859 OscarData *od = gc->proto_data; |
4642 | 5860 va_list ap; |
5861 fu16_t reason; | |
5862 | |
5863 va_start(ap, fr); | |
5864 reason = (fu16_t)va_arg(ap, unsigned int); | |
5865 va_end(ap); | |
5866 | |
8660 | 5867 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5868 |
5869 if (reason == 0x0005) { | |
5892 | 5870 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5871 _("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
|
5872 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5873 } |
5874 | |
5875 /* Activate SSI */ | |
5876 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5877 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5878 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5879 aim_ssi_enable(od->sess); |
5880 | |
5881 return 1; | |
5882 } | |
5883 | |
2991 | 5884 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5885 GaimConnection *gc = sess->aux_data; |
7283 | 5886 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5887 int i; |
5888 va_list ap; | |
5889 int numtypes; | |
4230 | 5890 fu16_t *maxitems; |
2991 | 5891 |
5892 va_start(ap, fr); | |
4230 | 5893 numtypes = va_arg(ap, int); |
5894 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5895 va_end(ap); |
5896 | |
8660 | 5897 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5898 |
4230 | 5899 for (i=0; i<numtypes; i++) |
8660 | 5900 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5901 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5902 |
8660 | 5903 gaim_debug_misc(NULL, "\n"); |
4230 | 5904 |
5905 if (numtypes >= 0) | |
5906 od->rights.maxbuddies = maxitems[0]; | |
5907 if (numtypes >= 1) | |
5908 od->rights.maxgroups = maxitems[1]; | |
5909 if (numtypes >= 2) | |
5910 od->rights.maxpermits = maxitems[2]; | |
5911 if (numtypes >= 3) | |
5912 od->rights.maxdenies = maxitems[3]; | |
2991 | 5913 |
5914 return 1; | |
5915 } | |
5916 | |
5917 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5918 GaimConnection *gc = sess->aux_data; |
5919 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 5920 GaimStatus *status; |
7283 | 5921 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5922 GaimGroup *g; |
5923 GaimBuddy *b; | |
2995 | 5924 struct aim_ssi_item *curitem; |
2991 | 5925 int tmp; |
4230 | 5926 va_list ap; |
8219 | 5927 fu16_t fmtver, numitems; |
5928 struct aim_ssi_item *items; | |
5929 fu32_t timestamp; | |
4230 | 5930 |
5931 va_start(ap, fr); | |
5932 fmtver = (fu16_t)va_arg(ap, int); | |
5933 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5934 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5935 timestamp = va_arg(ap, fu32_t); |
8219 | 5936 va_end(ap); |
2991 | 5937 |
8660 | 5938 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5939 "ssi: syncing local list and server list\n"); |
2991 | 5940 |
8219 | 5941 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5942 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 | 5943 return 1; |
5944 } | |
5945 | |
2991 | 5946 /* Clean the buddy list */ |
4889 | 5947 aim_ssi_cleanlist(sess); |
2991 | 5948 |
8150 | 5949 { /* If not in server list then prune from local list */ |
5950 GaimBlistNode *gnode, *cnode, *bnode; | |
5951 GaimBuddyList *blist; | |
9539 | 5952 GSList *cur, *next; |
8150 | 5953 |
5954 /* Buddies */ | |
5955 cur = NULL; | |
5956 if ((blist = gaim_get_blist()) != NULL) { | |
5957 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5958 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5959 continue; | |
5960 g = (GaimGroup *)gnode; | |
5961 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5962 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5963 continue; | |
5964 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5965 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5966 continue; | |
5967 b = (GaimBuddy *)bnode; | |
5968 if (b->account == gc->account) { | |
5969 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5970 /* If the buddy is an ICQ user then load his nickname */ | |
5971 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5972 char *alias; |
8150 | 5973 if (servernick) |
5974 serv_got_alias(gc, b->name, servernick); | |
5975 | |
5976 /* Store local alias on server */ | |
8214 | 5977 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5978 if (!alias && b->alias && strlen(b->alias)) |
5979 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5980 free(alias); | |
5981 } else { | |
8660 | 5982 gaim_debug_info("oscar", |
8150 | 5983 "ssi: removing buddy %s from local list\n", b->name); |
5984 /* We can't actually remove now because it will screw up our looping */ | |
5985 cur = g_slist_prepend(cur, b); | |
5986 } | |
5987 } | |
5988 } | |
5989 } | |
5990 } | |
5991 } | |
8175 | 5992 |
8150 | 5993 while (cur != NULL) { |
5994 b = cur->data; | |
5995 cur = g_slist_remove(cur, b); | |
5996 gaim_blist_remove_buddy(b); | |
5997 } | |
5998 | |
5999 /* Permit list */ | |
6000 if (gc->account->permit) { | |
9539 | 6001 next = gc->account->permit; |
6002 while (next != NULL) { | |
6003 cur = next; | |
6004 next = next->next; | |
8150 | 6005 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6006 gaim_debug_info("oscar", |
8150 | 6007 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6008 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6009 } | |
9539 | 6010 } |
8150 | 6011 } |
6012 | |
6013 /* Deny list */ | |
6014 if (gc->account->deny) { | |
9539 | 6015 next = gc->account->deny; |
6016 while (next != NULL) { | |
6017 cur = next; | |
6018 next = next->next; | |
8150 | 6019 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6020 gaim_debug_info("oscar", |
8150 | 6021 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6022 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6023 } | |
9539 | 6024 } |
8150 | 6025 } |
6026 /* Presence settings (idle time visibility) */ | |
6027 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6028 if (!(tmp & 0x400)) | |
6029 aim_ssi_setpresence(sess, tmp | 0x400); | |
6030 } /* end pruning buddies from local list */ | |
6031 | |
2991 | 6032 /* Add from server list to local list */ |
4230 | 6033 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6034 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6035 switch (curitem->type) { |
4230 | 6036 case 0x0000: { /* Buddy */ |
4251 | 6037 if (curitem->name) { |
4292 | 6038 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6039 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6040 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6041 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6042 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6043 /* Should gname be freed here? -- elb */ |
4754 | 6044 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6045 free(alias); |
8150 | 6046 if (b) { |
4292 | 6047 /* Get server stored alias */ |
4705 | 6048 if (alias_utf8) { |
8150 | 6049 g_free(b->alias); |
6050 b->alias = g_strdup(alias_utf8); | |
4705 | 6051 } |
4282 | 6052 } else { |
8150 | 6053 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6054 |
4754 | 6055 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6056 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6057 gaim_blist_add_group(g, NULL); |
6058 } | |
5146 | 6059 |
8660 | 6060 gaim_debug_info("oscar", |
9285 | 6061 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6062 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6063 } |
8341 | 6064 if (!aim_sncmp(curitem->name, account->username)) { |
6065 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6066 gaim_check_comment(od, comment); | |
6067 free(comment); | |
6068 } | |
7162 | 6069 g_free(gname_utf8); |
6070 g_free(alias_utf8); | |
2991 | 6071 } |
4230 | 6072 } break; |
6073 | |
6074 case 0x0001: { /* Group */ | |
4282 | 6075 /* Shouldn't add empty groups */ |
4230 | 6076 } break; |
6077 | |
6078 case 0x0002: { /* Permit buddy */ | |
2991 | 6079 if (curitem->name) { |
4230 | 6080 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6081 GSList *list; |
5575 | 6082 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6083 if (!list) { |
8660 | 6084 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6085 "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
|
6086 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6087 } |
6088 } | |
4230 | 6089 } break; |
6090 | |
6091 case 0x0003: { /* Deny buddy */ | |
2991 | 6092 if (curitem->name) { |
6093 GSList *list; | |
5575 | 6094 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6095 if (!list) { |
8660 | 6096 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6097 "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
|
6098 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6099 } |
6100 } | |
4230 | 6101 } break; |
6102 | |
6103 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6104 if (curitem->data) { |
6105 fu8_t permdeny; | |
5575 | 6106 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6107 gaim_debug_info("oscar", |
5575 | 6108 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6109 account->perm_deny = permdeny; | |
6110 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6111 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6112 } |
2991 | 6113 } |
6114 } | |
4230 | 6115 } break; |
6116 | |
6117 case 0x0005: { /* Presence setting */ | |
3109 | 6118 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6119 } break; |
2991 | 6120 } /* End of switch on curitem->type */ |
6121 } /* End of for loop */ | |
4230 | 6122 |
9991 | 6123 /* |
6124 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6125 * this. We probably want the SSI status setting to override the local | |
6126 * setting. | |
6127 */ | |
9982 | 6128 status = gaim_presence_get_active_status(account->presence); |
6129 if (gaim_status_is_available(status)) | |
4901 | 6130 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6131 | |
4342 | 6132 /* Activate SSI */ |
6133 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6134 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6135 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6136 "ssi: activating server-stored buddy list\n"); |
4642 | 6137 aim_ssi_enable(sess); |
4342 | 6138 |
2991 | 6139 return 1; |
2086 | 6140 } |
4230 | 6141 |
6142 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6143 GaimConnection *gc = sess->aux_data; |
4230 | 6144 va_list ap; |
6145 struct aim_ssi_tmp *retval; | |
6146 | |
6147 va_start(ap, fr); | |
6148 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6149 va_end(ap); | |
6150 | |
6151 while (retval) { | |
8660 | 6152 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6153 "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 | 6154 |
6155 if (retval->ack != 0xffff) | |
6156 switch (retval->ack) { | |
6157 case 0x0000: { /* added successfully */ | |
6158 } break; | |
6159 | |
4829 | 6160 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6161 gchar *buf; | |
6162 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 | 6163 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6164 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6165 g_free(buf); |
6166 } | |
6167 | |
7023 | 6168 case 0x000e: { /* buddy requires authorization */ |
4828 | 6169 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6170 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6171 } break; |
6172 | |
6173 default: { /* La la la */ | |
5197 | 6174 gchar *buf; |
8660 | 6175 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6176 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 | 6177 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6178 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6179 g_free(buf); |
4230 | 6180 } break; |
6181 } | |
6182 | |
6183 retval = retval->next; | |
6184 } | |
6185 | |
6186 return 1; | |
6187 } | |
6188 | |
8227 | 6189 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6190 GaimConnection *gc = sess->aux_data; | |
6191 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6192 GaimBuddy *b; | |
6193 GaimGroup *g; | |
6194 va_list ap; | |
6195 fu16_t type; | |
6196 const char *name; | |
6197 | |
6198 va_start(ap, fr); | |
6199 type = (fu16_t)va_arg(ap, int); | |
6200 name = va_arg(ap, char *); | |
6201 va_end(ap); | |
6202 | |
6203 if ((type != 0x0000) || (name == NULL)) | |
6204 return 1; | |
6205 | |
6206 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6207 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6208 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6209 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6210 b = gaim_find_buddy(gc->account, name); | |
6211 free(alias); | |
6212 | |
6213 if (b) { | |
6214 /* Get server stored alias */ | |
6215 if (alias_utf8) { | |
6216 g_free(b->alias); | |
6217 b->alias = g_strdup(alias_utf8); | |
6218 } | |
6219 } else { | |
6220 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6221 | |
6222 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6223 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6224 gaim_blist_add_group(g, NULL); | |
6225 } | |
6226 | |
8660 | 6227 gaim_debug_info("oscar", |
9285 | 6228 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6229 gaim_blist_add_buddy(b, NULL, g, NULL); |
6230 } | |
6231 g_free(gname_utf8); | |
6232 g_free(alias_utf8); | |
6233 | |
6234 return 1; | |
6235 } | |
6236 | |
4230 | 6237 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6238 GaimConnection *gc = sess->aux_data; |
4230 | 6239 va_list ap; |
6240 char *sn, *msg; | |
4236 | 6241 gchar *dialog_msg, *nombre; |
4230 | 6242 struct name_data *data; |
6695 | 6243 GaimBuddy *buddy; |
4230 | 6244 |
6245 va_start(ap, fr); | |
6246 sn = va_arg(ap, char *); | |
6247 msg = va_arg(ap, char *); | |
6248 va_end(ap); | |
6249 | |
8660 | 6250 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6251 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6252 |
4687 | 6253 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6254 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6255 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6256 else |
6257 nombre = g_strdup(sn); | |
6258 | |
6259 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 | 6260 data = g_new(struct name_data, 1); |
6261 data->gc = gc; | |
6262 data->name = g_strdup(sn); | |
6263 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6264 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6265 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6266 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6267 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6268 G_CALLBACK(oscar_free_name_data)); |
4236 | 6269 |
4230 | 6270 g_free(dialog_msg); |
4236 | 6271 g_free(nombre); |
4230 | 6272 |
6273 return 1; | |
6274 } | |
6275 | |
6276 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6277 GaimConnection *gc = sess->aux_data; |
4230 | 6278 va_list ap; |
6279 char *sn, *msg; | |
4236 | 6280 gchar *dialog_msg, *nombre; |
4230 | 6281 struct name_data *data; |
6695 | 6282 GaimBuddy *buddy; |
4230 | 6283 |
6284 va_start(ap, fr); | |
6285 sn = va_arg(ap, char *); | |
6286 msg = va_arg(ap, char *); | |
6287 va_end(ap); | |
6288 | |
8660 | 6289 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6290 "ssi: received authorization request from %s\n", sn); |
4230 | 6291 |
4687 | 6292 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6293 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6294 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6295 else |
6296 nombre = g_strdup(sn); | |
6297 | |
4337 | 6298 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 | 6299 data = g_new(struct name_data, 1); |
6300 data->gc = gc; | |
6301 data->name = g_strdup(sn); | |
6302 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6303 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6304 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6305 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6306 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6307 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6308 |
4230 | 6309 g_free(dialog_msg); |
4236 | 6310 g_free(nombre); |
4230 | 6311 |
6312 return 1; | |
6313 } | |
6314 | |
6315 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6316 GaimConnection *gc = sess->aux_data; |
4230 | 6317 va_list ap; |
6318 char *sn, *msg; | |
4236 | 6319 gchar *dialog_msg, *nombre; |
4230 | 6320 fu8_t reply; |
6695 | 6321 GaimBuddy *buddy; |
4230 | 6322 |
6323 va_start(ap, fr); | |
6324 sn = va_arg(ap, char *); | |
6325 reply = (fu8_t)va_arg(ap, int); | |
6326 msg = va_arg(ap, char *); | |
6327 va_end(ap); | |
6328 | |
8660 | 6329 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6330 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6331 |
4687 | 6332 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6333 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6334 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6335 else |
6336 nombre = g_strdup(sn); | |
6337 | |
4230 | 6338 if (reply) { |
6339 /* Granted */ | |
7023 | 6340 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
|
6341 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6342 } else { |
6343 /* Denied */ | |
7023 | 6344 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
|
6345 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6346 } |
6347 g_free(dialog_msg); | |
4236 | 6348 g_free(nombre); |
4230 | 6349 |
6350 return 1; | |
6351 } | |
6352 | |
6353 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6354 GaimConnection *gc = sess->aux_data; |
4230 | 6355 va_list ap; |
6356 char *sn; | |
6695 | 6357 GaimBuddy *buddy; |
4230 | 6358 |
6359 va_start(ap, fr); | |
6360 sn = va_arg(ap, char *); | |
6361 va_end(ap); | |
6362 | |
4687 | 6363 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6364 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6365 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6366 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6367 |
6368 return 1; | |
6369 } | |
4269 | 6370 #endif |
2086 | 6371 |
5575 | 6372 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6373 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6374 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6375 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6376 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6377 pce->label = _("_Room:"); |
5234 | 6378 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6379 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6380 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6381 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6382 pce->label = _("_Exchange:"); |
5234 | 6383 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6384 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6385 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6386 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6387 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6388 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6389 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6390 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6391 |
9754 | 6392 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6393 { | |
6394 GHashTable *defaults; | |
6395 | |
6396 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6397 | |
6398 if (chat_name != NULL) | |
6399 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6400 | |
6401 return defaults; | |
6402 } | |
6403 | |
9917 | 6404 static char *oscar_get_chat_name(GHashTable *data) { |
6405 return g_strdup(g_hash_table_lookup(data, "room")); | |
6406 } | |
6407 | |
8308 | 6408 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6409 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6410 aim_conn_t *cur; |
5234 | 6411 char *name, *exchange; |
6412 | |
6413 name = g_hash_table_lookup(data, "room"); | |
6414 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6415 |
8660 | 6416 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6417 "Attempting to join chat room %s.\n", name); |
8308 | 6418 |
6419 if ((name == NULL) || (*name == '\0')) { | |
6420 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6421 return; | |
6422 } | |
6423 | |
4617 | 6424 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6425 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6426 "chatnav exists, creating room\n"); |
5234 | 6427 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6428 } else { |
6429 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6430 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6431 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6432 "chatnav does not exist, opening chatnav\n"); |
5234 | 6433 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6434 cr->name = g_strdup(name); |
4617 | 6435 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6436 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6437 } |
6438 } | |
6439 | |
8308 | 6440 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6441 OscarData *od = (OscarData *)gc->proto_data; | |
6442 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6443 |
6444 if (!ccon) | |
6445 return; | |
6446 | |
8225 | 6447 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6448 ccon->exchange, ccon->name, 0x0); |
6449 } | |
6450 | |
8308 | 6451 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6452 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6453 GSList *bcs = gc->buddy_chats; | |
5679 | 6454 GaimConversation *b = NULL; |
2086 | 6455 struct chat_connection *c = NULL; |
6456 int count = 0; | |
6457 | |
6458 while (bcs) { | |
6459 count++; | |
5679 | 6460 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6461 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6462 break; |
6463 bcs = bcs->next; | |
6464 b = NULL; | |
6465 } | |
6466 | |
6467 if (!b) | |
6468 return; | |
6469 | |
8660 | 6470 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6471 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6472 |
8308 | 6473 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6474 if (c != NULL) { |
4617 | 6475 if (od) |
6476 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6477 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6478 gaim_input_remove(c->inpa); |
8308 | 6479 if (gc && od->sess) |
4617 | 6480 aim_conn_kill(od->sess, &c->conn); |
2086 | 6481 g_free(c->name); |
6482 g_free(c->show); | |
6483 g_free(c); | |
6484 } | |
6485 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6486 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6487 } |
6488 | |
8219 | 6489 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6490 OscarData *od = (OscarData *)gc->proto_data; | |
6491 GaimConversation *conv = NULL; | |
2086 | 6492 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6493 char *buf, *buf2; |
9830 | 6494 fu16_t charset, charsubset; |
9807 | 6495 char *charsetstr = NULL; |
10111 | 6496 int len; |
8219 | 6497 |
6498 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6499 return -EINVAL; |
2086 | 6500 |
8219 | 6501 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6502 return -EINVAL; |
2086 | 6503 |
8219 | 6504 buf = gaim_strdup_withhtml(message); |
6505 len = strlen(buf); | |
6506 | |
8962 | 6507 if (strstr(buf, "<IMG ")) |
6508 gaim_conversation_write(conv, "", | |
6509 _("Your IM Image was not sent. " | |
6510 "You cannot send IM Images in AIM chats."), | |
6511 GAIM_MESSAGE_ERROR, time(NULL)); | |
6512 | |
9830 | 6513 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6514 if ((len > c->maxlen) || (len > c->maxvis)) { |
6515 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6516 return -E2BIG; |
8359 | 6517 } |
6518 | |
9831 | 6519 if (charset == AIM_CHARSET_ASCII) |
6520 charsetstr = "us-ascii"; | |
6521 else if (charset == AIM_CHARSET_UNICODE) | |
6522 charsetstr = "unicode-2-0"; | |
6523 else if (charset == AIM_CHARSET_CUSTOM) | |
6524 charsetstr = "iso-8859-1"; | |
9807 | 6525 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6526 g_free(buf2); |
8359 | 6527 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6528 return 0; |
2086 | 6529 } |
6530 | |
10042 | 6531 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6532 { | |
4766 | 6533 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6534 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6535 return "icq"; |
6536 else | |
6537 return "aim"; | |
6538 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6539 |
9975 | 6540 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6541 return "icq"; |
6542 return "aim"; | |
6543 } | |
6544 | |
9972 | 6545 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6546 { |
7334 | 6547 GaimConnection *gc = NULL; |
6548 OscarData *od = NULL; | |
10042 | 6549 GaimAccount *account = NULL; |
6550 GaimPresence *presence; | |
6551 GaimStatus *status; | |
6552 const char *status_id; | |
4687 | 6553 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6554 int i = 0; | |
7334 | 6555 aim_userinfo_t *userinfo = NULL; |
6556 | |
6557 if (b != NULL) | |
6558 account = b->account; | |
6559 if (account != NULL) | |
6560 gc = account->gc; | |
6561 if (gc != NULL) | |
6562 od = gc->proto_data; | |
7945 | 6563 if (od != NULL) |
6564 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6565 |
10042 | 6566 presence = gaim_buddy_get_presence(b); |
6567 status = gaim_presence_get_active_status(presence); | |
6568 status_id = gaim_status_get_id(status); | |
6569 | |
6570 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6571 char *gname; |
7334 | 6572 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6573 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6574 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6575 emblems[i++] = "notauthorized"; | |
6576 } else { | |
6577 emblems[i++] = "offline"; | |
6578 } | |
6579 } | |
4916 | 6580 |
10042 | 6581 if (b->name && aim_sn_is_icq(b->name)) { |
6582 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6583 emblems[i++] = "invisible"; | |
6584 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6585 emblems[i++] = "freeforchat"; |
10042 | 6586 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6587 emblems[i++] = "dnd"; |
10042 | 6588 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6589 emblems[i++] = "na"; |
10042 | 6590 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6591 emblems[i++] = "occupied"; |
10042 | 6592 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6593 emblems[i++] = "away"; |
10042 | 6594 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6595 emblems[i++] = "away"; | |
6596 } | |
6597 | |
6598 if (userinfo != NULL ) { | |
6599 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6600 emblems[i++] = "unconfirmed"; */ | |
6601 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6602 emblems[i++] = "admin"; | |
6603 if (userinfo->flags & AIM_FLAG_AOL) | |
6604 emblems[i++] = "aol"; | |
6605 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6606 emblems[i++] = "wireless"; | |
6607 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6608 emblems[i++] = "activebuddy"; | |
6609 | |
6610 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6611 emblems[i++] = "hiptop"; |
6612 | |
10042 | 6613 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6614 emblems[i++] = "secure"; |
10042 | 6615 } |
7334 | 6616 |
4687 | 6617 *se = emblems[0]; |
6618 *sw = emblems[1]; | |
6619 *nw = emblems[2]; | |
6620 *ne = emblems[3]; | |
6621 } | |
6622 | |
6695 | 6623 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6624 GaimConnection *gc = b->account->gc; |
7283 | 6625 OscarData *od = gc->proto_data; |
7045 | 6626 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6627 GString *str = g_string_new(""); |
5131 | 6628 |
6629 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6630 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6631 |
6632 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6633 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6634 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6635 g_free(charset); |
7011 | 6636 if (away_utf8 != NULL) { |
7091 | 6637 gchar *tmp1, *tmp2; |
9627 | 6638 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6639 g_free(away_utf8); |
8571 | 6640 tmp1 = gaim_escape_html(tmp2); |
7091 | 6641 g_free(tmp2); |
8700 | 6642 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6643 g_free(tmp1); |
8701 | 6644 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6645 g_free(tmp2); |
5836 | 6646 } |
5131 | 6647 } |
8701 | 6648 } |
6649 | |
6650 return g_string_free(str, FALSE); | |
5131 | 6651 } |
6652 | |
10042 | 6653 static char *oscar_status_text(GaimBuddy *b) |
6654 { | |
6655 GaimConnection *gc; | |
6656 OscarData *od; | |
6657 GaimStatus *status; | |
5167 | 6658 gchar *ret = NULL; |
6659 | |
10042 | 6660 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6661 od = gc->proto_data; | |
6662 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6663 | |
6664 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6665 if (aim_sn_is_icq(b->name)) |
8701 | 6666 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6667 else |
6668 ret = g_strdup(_("Away")); | |
5836 | 6669 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6670 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6671 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6672 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6673 } else { |
5167 | 6674 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6675 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6676 ret = g_strdup(_("Not Authorized")); | |
6677 else | |
6678 ret = g_strdup(_("Offline")); | |
6679 } | |
6680 | |
6681 return ret; | |
6682 } | |
6683 | |
5842 | 6684 |
5844 | 6685 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6686 GaimConnection *gc = sess->aux_data; |
7283 | 6687 OscarData *od = gc->proto_data; |
5892 | 6688 va_list ap; |
5842 | 6689 fu16_t type; |
5892 | 6690 fu8_t flags = 0, length = 0; |
6691 char *md5 = NULL; | |
6692 | |
7334 | 6693 |
5842 | 6694 va_start(ap, fr); |
6695 type = va_arg(ap, int); | |
5892 | 6696 |
6697 switch(type) { | |
6698 case 0x0000: | |
6699 case 0x0001: { | |
6700 flags = va_arg(ap, int); | |
6701 length = va_arg(ap, int); | |
6702 md5 = va_arg(ap, char *); | |
6703 | |
6704 if (flags == 0x41) { | |
6705 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6706 od->iconconnecting = TRUE; | |
6707 od->set_icon = TRUE; | |
6708 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6709 } else { | |
6039 | 6710 struct stat st; |
6711 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6712 if (iconfile == NULL) { | |
8363 | 6713 aim_ssi_delicon(od->sess); |
6039 | 6714 } else if (!stat(iconfile, &st)) { |
6715 char *buf = g_malloc(st.st_size); | |
6716 FILE *file = fopen(iconfile, "rb"); | |
6717 if (file) { | |
9532 | 6718 /* XXX - Use g_file_get_contents()? */ |
6039 | 6719 fread(buf, 1, st.st_size, file); |
6720 fclose(file); | |
8660 | 6721 gaim_debug_info("oscar", |
10042 | 6722 "Uploading icon to icon server\n"); |
6879 | 6723 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6724 } else |
8660 | 6725 gaim_debug_error("oscar", |
10042 | 6726 "Can't open buddy icon file!\n"); |
6039 | 6727 g_free(buf); |
6728 } else { | |
8660 | 6729 gaim_debug_error("oscar", |
10042 | 6730 "Can't stat buddy icon file!\n"); |
5892 | 6731 } |
6732 } | |
8363 | 6733 } else if (flags == 0x81) { |
6734 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6735 if (iconfile == NULL) | |
6736 aim_ssi_delicon(od->sess); | |
6737 else | |
6738 aim_ssi_seticon(od->sess, md5, length); | |
6739 } | |
5892 | 6740 } break; |
6741 | |
6742 case 0x0002: { /* We just set an "available" message? */ | |
6743 } break; | |
6744 } | |
6745 | |
5842 | 6746 va_end(ap); |
5844 | 6747 |
6748 return 0; | |
5842 | 6749 } |
5892 | 6750 |
5575 | 6751 static void oscar_set_permit_deny(GaimConnection *gc) { |
6752 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6753 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6754 #ifdef NOSSI |
8143 | 6755 GSList *list; |
4230 | 6756 char buf[MAXMSGLEN]; |
6757 int at; | |
6758 | |
5575 | 6759 switch(account->perm_deny) { |
8175 | 6760 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6761 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6762 break; |
8175 | 6763 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6764 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6765 break; |
8175 | 6766 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6767 list = account->permit; |
4230 | 6768 at = 0; |
6769 while (list) { | |
6770 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6771 list = list->next; | |
6772 } | |
6773 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6774 break; | |
8175 | 6775 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6776 list = account->deny; |
4230 | 6777 at = 0; |
6778 while (list) { | |
6779 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6780 list = list->next; | |
6781 } | |
6782 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6783 break; | |
6784 default: | |
6785 break; | |
2086 | 6786 } |
4230 | 6787 #else |
8175 | 6788 if (od->sess->ssi.received_data) { |
6789 switch (account->perm_deny) { | |
6790 case GAIM_PRIVACY_ALLOW_ALL: | |
6791 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6792 break; | |
6793 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6794 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6795 break; | |
6796 case GAIM_PRIVACY_ALLOW_USERS: | |
6797 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6798 break; | |
6799 case GAIM_PRIVACY_DENY_ALL: | |
6800 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6801 break; | |
6802 case GAIM_PRIVACY_DENY_USERS: | |
6803 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6804 break; | |
6805 default: | |
6806 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6807 break; | |
6808 } | |
6809 } | |
4230 | 6810 #endif |
2086 | 6811 } |
6812 | |
5575 | 6813 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6814 #ifdef NOSSI |
8143 | 6815 if (gc->account->perm_deny == 3) |
4269 | 6816 oscar_set_permit_deny(gc); |
6817 #else | |
7283 | 6818 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6819 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6820 if (od->sess->ssi.received_data) |
4889 | 6821 aim_ssi_addpermit(od->sess, who); |
4230 | 6822 #endif |
2086 | 6823 } |
6824 | |
5575 | 6825 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6826 #ifdef NOSSI |
8143 | 6827 if (gc->account->perm_deny == 4) |
4269 | 6828 oscar_set_permit_deny(gc); |
6829 #else | |
7283 | 6830 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6831 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6832 if (od->sess->ssi.received_data) |
4889 | 6833 aim_ssi_adddeny(od->sess, who); |
4230 | 6834 #endif |
2086 | 6835 } |
6836 | |
5575 | 6837 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6838 #ifdef NOSSI |
8143 | 6839 if (gc->account->perm_deny == 3) |
4269 | 6840 oscar_set_permit_deny(gc); |
6841 #else | |
7283 | 6842 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6843 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6844 if (od->sess->ssi.received_data) |
4889 | 6845 aim_ssi_delpermit(od->sess, who); |
4230 | 6846 #endif |
2086 | 6847 } |
6848 | |
5575 | 6849 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6850 #ifdef NOSSI |
8143 | 6851 if (gc->account->perm_deny == 4) |
4269 | 6852 oscar_set_permit_deny(gc); |
6853 #else | |
7283 | 6854 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6855 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6856 if (od->sess->ssi.received_data) |
4889 | 6857 aim_ssi_deldeny(od->sess, who); |
4230 | 6858 #endif |
2086 | 6859 } |
6860 | |
9975 | 6861 static GList * |
6862 oscar_status_types(GaimAccount *account) | |
2086 | 6863 { |
9975 | 6864 GList *status_types = NULL; |
6865 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6866 |
9973 | 6867 g_return_val_if_fail(account != NULL, NULL); |
6868 | |
10042 | 6869 /* Oscar-common status types */ |
9991 | 6870 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6871 OSCAR_STATUS_ID_OFFLINE, | |
6872 _("Offline"), FALSE, FALSE, FALSE); | |
9976 | 6873 status_types = g_list_append(status_types, type); |
6874 | |
9991 | 6875 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6876 OSCAR_STATUS_ID_ONLINE, | |
6877 _("Online"), FALSE, FALSE, FALSE); | |
9976 | 6878 status_types = g_list_append(status_types, type); |
6879 | |
10198 | 6880 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
6881 OSCAR_STATUS_ID_AVAILABLE, | |
6882 _("Available"), TRUE, TRUE, FALSE, | |
6883 "message", _("Message"), | |
6884 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 6885 status_types = g_list_append(status_types, type); |
6886 | |
10195 | 6887 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
6888 OSCAR_STATUS_ID_AWAY, | |
6889 _("Away"), TRUE, TRUE, FALSE, | |
6890 "message", _("Message"), | |
6891 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 6892 status_types = g_list_append(status_types, type); |
6893 | |
6894 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6895 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 6896 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 6897 status_types = g_list_append(status_types, type); |
6898 | |
6899 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
6900 return status_types; | |
6901 | |
6902 /* ICQ-specific status types */ | |
6903 | |
9991 | 6904 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6905 OSCAR_STATUS_ID_FREE4CHAT, | |
6906 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6907 status_types = g_list_append(status_types, type); |
6908 | |
9991 | 6909 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6910 OSCAR_STATUS_ID_OCCUPIED, | |
6911 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6912 status_types = g_list_append(status_types, type); |
6913 | |
9991 | 6914 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6915 OSCAR_STATUS_ID_DND, | |
6916 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6917 status_types = g_list_append(status_types, type); |
6918 | |
9991 | 6919 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6920 OSCAR_STATUS_ID_NA, | |
6921 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6922 status_types = g_list_append(status_types, type); |
9975 | 6923 |
6924 return status_types; | |
4333 | 6925 } |
6926 | |
7172 | 6927 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6928 GaimConnection *gc = data->gc; |
6929 OscarData *od = gc->proto_data; | |
7172 | 6930 GaimBuddy *b; |
6931 GaimGroup *g; | |
6932 | |
6933 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6934 oscar_free_name_data(data); | |
6935 return; | |
6936 } | |
6937 | |
6938 if (!(g = gaim_find_buddys_group(b))) { | |
6939 oscar_free_name_data(data); | |
6940 return; | |
6941 } | |
6942 | |
6943 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6944 |
6945 if (!aim_sncmp(data->name, gc->account->username)) | |
6946 gaim_check_comment(od, text); | |
6947 | |
7172 | 6948 oscar_free_name_data(data); |
6949 } | |
6950 | |
9030 | 6951 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6952 | |
6953 GaimBuddy *buddy; | |
6954 GaimConnection *gc; | |
6955 OscarData *od; | |
6956 struct name_data *data; | |
7172 | 6957 GaimGroup *g; |
6958 char *comment; | |
6959 gchar *comment_utf8; | |
9631 | 6960 gchar *title; |
7172 | 6961 |
9030 | 6962 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6963 | |
6964 buddy = (GaimBuddy *) node; | |
6965 gc = gaim_account_get_connection(buddy->account); | |
6966 od = gc->proto_data; | |
6967 | |
6968 data = g_new(struct name_data, 1); | |
6969 | |
6970 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6971 return; |
9030 | 6972 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6973 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6974 | |
6975 data->gc = gc; | |
9030 | 6976 data->name = g_strdup(buddy->name); |
7172 | 6977 data->nick = NULL; |
6978 | |
9631 | 6979 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6980 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6981 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6982 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6983 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6984 data); | |
9631 | 6985 g_free(title); |
7172 | 6986 |
6987 free(comment); | |
6988 g_free(comment_utf8); | |
6989 } | |
6990 | |
9030 | 6991 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6992 | |
6993 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6994 OscarData *od = gc->proto_data; |
9030 | 6995 |
4333 | 6996 GList *m = NULL; |
9030 | 6997 GaimBlistNodeAction *act; |
6998 | |
6999 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
7000 oscar_buddycb_edit_comment, NULL); | |
7001 m = g_list_append(m, act); | |
7172 | 7002 |
4333 | 7003 if (od->icq) { |
4624 | 7004 #if 0 |
9030 | 7005 act = gaim_blist_node_action_new(_("Get Status Msg"), |
7006 oscar_get_icqstatusmsg, NULL); | |
7007 m = g_list_append(m, act); | |
4624 | 7008 #endif |
4333 | 7009 } else { |
7011 | 7010 aim_userinfo_t *userinfo; |
9030 | 7011 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7012 | |
7013 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7014 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7015 | |
7011 | 7016 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7017 act = gaim_blist_node_action_new(_("Direct IM"), |
7018 oscar_ask_direct_im, NULL); | |
7019 m = g_list_append(m, act); | |
5917 | 7020 } |
9466 | 7021 #if 0 |
7011 | 7022 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7023 act = gaim_blist_node_action_new(_("Get File"), |
7024 oscar_ask_getfile, NULL); | |
7025 m = g_list_append(m, act); | |
5917 | 7026 } |
4826 | 7027 #endif |
4333 | 7028 } |
5131 | 7029 } |
5197 | 7030 |
5131 | 7031 if (od->sess->ssi.received_data) { |
9030 | 7032 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7033 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7034 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7035 gaim_auth_sendrequest_menu, NULL); | |
7036 m = g_list_append(m, act); | |
4333 | 7037 } |
4916 | 7038 } |
10157 | 7039 |
4333 | 7040 return m; |
7041 } | |
7042 | |
9030 | 7043 |
7044 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7045 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7046 return oscar_buddy_menu((GaimBuddy *) node); | |
7047 } else { | |
7048 return NULL; | |
7049 } | |
7050 } | |
7051 | |
7052 | |
5575 | 7053 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7054 OscarData *od = gc->proto_data; |
5575 | 7055 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7056 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7057 od->setnick = TRUE; | |
7058 od->newsn = g_strdup(nick); | |
7059 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7060 } else { | |
7061 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7062 } | |
7063 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7064 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7065 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7066 } |
7067 } | |
7068 | |
9015 | 7069 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7070 { |
9015 | 7071 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7072 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7073 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7074 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7075 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7076 gc); |
4333 | 7077 } |
7078 | |
9015 | 7079 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7080 { |
9015 | 7081 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7082 OscarData *od = gc->proto_data; |
4333 | 7083 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7084 | |
7085 if (conn) { | |
7086 aim_admin_reqconfirm(od->sess, conn); | |
7087 } else { | |
7088 od->conf = TRUE; | |
7089 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7090 } | |
7091 } | |
7092 | |
9015 | 7093 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7094 { |
9015 | 7095 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7096 OscarData *od = gc->proto_data; |
4333 | 7097 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7098 | |
7099 if (conn) { | |
7100 aim_admin_getinfo(od->sess, conn, 0x11); | |
7101 } else { | |
7102 od->reqemail = TRUE; | |
7103 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7104 } | |
7105 } | |
7106 | |
5575 | 7107 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7108 { |
7283 | 7109 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7110 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
|
7111 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7112 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7113 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7114 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7115 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7116 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7117 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7118 } |
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 |
9015 | 7121 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7122 { |
9015 | 7123 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7124 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7125 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7126 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7127 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7128 gc); |
4333 | 7129 } |
7130 | |
9015 | 7131 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7132 { |
9015 | 7133 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7134 OscarData *od = gc->proto_data; |
4333 | 7135 gchar *nombre, *text, *tmp; |
6695 | 7136 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7137 int num=0; |
7138 | |
6873 | 7139 text = g_strdup(""); |
4333 | 7140 |
4785 | 7141 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7142 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7143 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7144 continue; | |
6695 | 7145 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7146 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7147 continue; |
6695 | 7148 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7149 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7150 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7151 continue; | |
7152 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7153 if (gaim_buddy_get_alias_only(buddy)) |
7154 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7155 else |
7156 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7157 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7158 g_free(text); |
7159 text = tmp; | |
7160 g_free(nombre); | |
7161 num++; | |
7162 } | |
4333 | 7163 } |
2979 | 7164 } |
4333 | 7165 } |
7166 | |
7167 if (!num) { | |
7168 g_free(text); | |
6873 | 7169 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7170 } | |
7171 | |
7172 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7173 "the following buddies"), _("You can re-request " | |
7174 "authorization from these buddies by " | |
7175 "right-clicking on them and selecting " | |
7176 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7177 g_free(text); |
2979 | 7178 } |
7179 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7180 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7181 { |
8950 | 7182 OscarData *od = (OscarData *)gc->proto_data; |
7183 | |
7184 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7185 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7186 |
9015 | 7187 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7188 { |
9015 | 7189 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7190 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7191 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7192 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7193 "searching for."), |
8697 | 7194 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7195 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7196 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7197 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7198 |
9015 | 7199 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7200 { |
9015 | 7201 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7202 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7203 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7204 |
9015 | 7205 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7206 { |
9015 | 7207 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7208 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7209 } |
7210 | |
9015 | 7211 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7212 { |
9015 | 7213 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7214 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7215 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7216 |
9015 | 7217 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7218 { |
9015 | 7219 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7220 OscarData *od = gc->proto_data; |
5575 | 7221 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
|
7222 gaim_notify_uri(gc, substituted); |
5517 | 7223 g_free(substituted); |
4333 | 7224 } |
7225 | |
9015 | 7226 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7227 { |
9015 | 7228 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7229 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7230 } |
7231 | |
5842 | 7232 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7233 { | |
7283 | 7234 OscarData *od = gc->proto_data; |
5844 | 7235 aim_session_t *sess = od->sess; |
5842 | 7236 FILE *file; |
7237 struct stat st; | |
5844 | 7238 |
6039 | 7239 if (iconfile == NULL) { |
8363 | 7240 aim_ssi_delicon(od->sess); |
6039 | 7241 } else if (!stat(iconfile, &st)) { |
5842 | 7242 char *buf = g_malloc(st.st_size); |
7243 file = fopen(iconfile, "rb"); | |
7244 if (file) { | |
6052 | 7245 md5_state_t *state; |
6039 | 7246 char md5[16]; |
9532 | 7247 /* XXX - Use g_file_get_contents()? */ |
5842 | 7248 int len = fread(buf, 1, st.st_size, file); |
6039 | 7249 fclose(file); |
6052 | 7250 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7251 md5_init(state); |
7252 md5_append(state, buf, len); | |
7253 md5_finish(state, md5); | |
7254 g_free(state); | |
7255 aim_ssi_seticon(sess, md5, 16); | |
7256 } else | |
8660 | 7257 gaim_debug_error("oscar", |
5842 | 7258 "Can't open buddy icon file!\n"); |
7259 g_free(buf); | |
7260 } else | |
8660 | 7261 gaim_debug_error("oscar", |
5842 | 7262 "Can't stat buddy icon file!\n"); |
7263 } | |
7264 | |
7265 | |
9015 | 7266 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7267 { |
9015 | 7268 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7269 OscarData *od = gc->proto_data; |
4333 | 7270 GList *m = NULL; |
9015 | 7271 GaimPluginAction *act; |
7272 | |
7273 act = gaim_plugin_action_new(_("Set User Info..."), | |
7274 oscar_show_set_info); | |
7275 m = g_list_append(m, act); | |
4333 | 7276 |
8576 | 7277 if (od->icq) { |
9015 | 7278 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7279 oscar_show_set_info_icqurl); | |
7280 m = g_list_append(m, act); | |
8576 | 7281 } |
7282 | |
9015 | 7283 act = gaim_plugin_action_new(_("Change Password..."), |
7284 oscar_change_pass); | |
7285 m = g_list_append(m, act); | |
4617 | 7286 |
7287 if (od->sess->authinfo->chpassurl) { | |
9015 | 7288 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7289 oscar_show_chpassurl); | |
7290 m = g_list_append(m, act); | |
7291 | |
7292 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7293 oscar_show_imforwardingurl); | |
7294 m = g_list_append(m, act); | |
7026 | 7295 } |
7296 | |
5238 | 7297 if (!od->icq) { |
4617 | 7298 /* AIM actions */ |
7299 m = g_list_append(m, NULL); | |
4333 | 7300 |
9015 | 7301 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7302 oscar_show_format_screenname); | |
7303 m = g_list_append(m, act); | |
7304 | |
7305 act = gaim_plugin_action_new(_("Confirm Account"), | |
7306 oscar_confirm_account); | |
7307 m = g_list_append(m, act); | |
7308 | |
7309 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7310 oscar_show_email); | |
7311 m = g_list_append(m, act); | |
7312 | |
7313 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7314 oscar_show_change_email); | |
7315 m = g_list_append(m, act); | |
2086 | 7316 } |
4333 | 7317 |
7318 m = g_list_append(m, NULL); | |
7319 | |
9015 | 7320 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7321 oscar_show_awaitingauth); | |
7322 m = g_list_append(m, act); | |
4333 | 7323 |
2086 | 7324 m = g_list_append(m, NULL); |
4333 | 7325 |
9015 | 7326 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7327 oscar_show_find_email); | |
7328 m = g_list_append(m, act); | |
4333 | 7329 |
8591 | 7330 #if 0 |
9015 | 7331 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7332 show_find_info); | |
7333 m = g_list_append(m, act); | |
8591 | 7334 #endif |
2086 | 7335 |
7336 return m; | |
7337 } | |
7338 | |
5575 | 7339 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7340 { |
7283 | 7341 OscarData *od = gc->proto_data; |
4617 | 7342 |
7343 if (od->icq) { | |
7344 aim_icq_changepasswd(od->sess, new); | |
2086 | 7345 } else { |
4617 | 7346 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7347 if (conn) { | |
7348 aim_admin_changepasswd(od->sess, conn, new, old); | |
7349 } else { | |
7350 od->chpass = TRUE; | |
7351 od->oldp = g_strdup(old); | |
7352 od->newp = g_strdup(new); | |
7353 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7354 } | |
2086 | 7355 } |
7356 } | |
7357 | |
6059 | 7358 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7359 { |
7283 | 7360 OscarData *od = gc->proto_data; |
8971 | 7361 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
|
7362 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7363 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7364 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7365 |
8971 | 7366 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7367 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7368 |
9935 | 7369 static void |
7370 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7371 { | |
7372 GaimConnection *gc = data; | |
7373 OscarData *od = gc->proto_data; | |
7374 aim_session_t *sess = od->sess; | |
7375 fu32_t presence; | |
7376 | |
7377 presence = aim_ssi_getpresence(sess->ssi.local); | |
7378 | |
7379 if (value) { | |
9992 | 7380 /* Based on the packet capture I thought it was the first one */ |
7381 /* Stu thinks it's the second one. */ | |
7382 /* presence |= 0x00400000; */ | |
9971 | 7383 presence &= ~0x00020000; |
9935 | 7384 aim_ssi_setpresence(sess, presence); |
7385 } else { | |
9992 | 7386 /* presence &= ~0x00400000; */ |
9971 | 7387 presence |= 0x00020000; |
9935 | 7388 aim_ssi_setpresence(sess, presence); |
7389 } | |
7390 } | |
7391 | |
7392 static GaimPluginPrefFrame * | |
9936 | 7393 get_plugin_pref_frame(GaimPlugin *plugin) |
7394 { | |
9935 | 7395 GaimPluginPrefFrame *frame; |
7396 GaimPluginPref *ppref; | |
7397 | |
7398 frame = gaim_plugin_pref_frame_new(); | |
7399 | |
7400 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7401 gaim_plugin_pref_frame_add(frame, ppref); | |
7402 | |
7403 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7404 gaim_plugin_pref_frame_add(frame, ppref); | |
7405 | |
7406 return frame; | |
7407 } | |
7408 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7409 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7410 { |
9308 | 7411 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7412 NULL, /* user_splits */ |
7413 NULL, /* protocol_options */ | |
7414 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7415 oscar_list_icon, /* list_icon */ | |
7416 oscar_list_emblems, /* list_emblems */ | |
7417 oscar_status_text, /* status_text */ | |
7418 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7419 oscar_status_types, /* status_types */ |
9475 | 7420 oscar_blist_node_menu, /* blist_node_menu */ |
7421 oscar_chat_info, /* chat_info */ | |
9754 | 7422 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7423 oscar_login, /* login */ |
7424 oscar_close, /* close */ | |
7425 oscar_send_im, /* send_im */ | |
7426 oscar_set_info, /* set_info */ | |
7427 oscar_send_typing, /* send_typing */ | |
7428 oscar_get_info, /* get_info */ | |
9973 | 7429 oscar_set_status, /* set_status */ |
9475 | 7430 oscar_set_idle, /* set_idle */ |
7431 oscar_change_passwd, /* change_passwd */ | |
7432 oscar_add_buddy, /* add_buddy */ | |
7433 oscar_add_buddies, /* add_buddies */ | |
7434 oscar_remove_buddy, /* remove_buddy */ | |
7435 oscar_remove_buddies, /* remove_buddies */ | |
7436 oscar_add_permit, /* add_permit */ | |
7437 oscar_add_deny, /* add_deny */ | |
7438 oscar_rem_permit, /* rem_permit */ | |
7439 oscar_rem_deny, /* rem_deny */ | |
7440 oscar_set_permit_deny, /* set_permit_deny */ | |
7441 oscar_warn, /* warn */ | |
7442 oscar_join_chat, /* join_chat */ | |
7443 NULL, /* reject_chat */ | |
9973 | 7444 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7445 oscar_chat_invite, /* chat_invite */ |
7446 oscar_chat_leave, /* chat_leave */ | |
7447 NULL, /* chat_whisper */ | |
7448 oscar_send_chat, /* chat_send */ | |
7449 oscar_keepalive, /* keepalive */ | |
7450 NULL, /* register_user */ | |
7451 NULL, /* get_cb_info */ | |
7452 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7453 #ifndef NOSSI |
9475 | 7454 oscar_alias_buddy, /* alias_buddy */ |
7455 oscar_move_buddy, /* group_buddy */ | |
7456 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7457 #else |
9475 | 7458 NULL, /* alias_buddy */ |
7459 NULL, /* group_buddy */ | |
7460 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7461 #endif |
9475 | 7462 NULL, /* buddy_free */ |
7463 oscar_convo_closed, /* convo_closed */ | |
7464 NULL, /* normalize */ | |
7465 oscar_set_icon, /* set_buddy_icon */ | |
7466 NULL, /* remove_group */ | |
7467 NULL, /* get_cb_real_name */ | |
7468 NULL, /* set_chat_topic */ | |
7469 NULL, /* find_blist_chat */ | |
7470 NULL, /* roomlist_get_list */ | |
7471 NULL, /* roomlist_cancel */ | |
7472 NULL, /* roomlist_expand_category */ | |
7473 oscar_can_receive_file, /* can_receive_file */ | |
7474 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7475 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7476 |
9935 | 7477 static GaimPluginUiInfo prefs_info = { |
7478 get_plugin_pref_frame | |
7479 }; | |
7480 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7481 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7482 { |
9943 | 7483 GAIM_PLUGIN_MAGIC, |
7484 GAIM_MAJOR_VERSION, | |
7485 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7486 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7487 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7488 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7489 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7490 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7491 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7492 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7493 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7494 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7495 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7496 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7497 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7498 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7499 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7500 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7501 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7502 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7503 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7504 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7505 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7506 NULL, /**< ui_info */ |
8993 | 7507 &prpl_info, /**< extra_info */ |
9935 | 7508 &prefs_info, /**< prefs_info */ |
9015 | 7509 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7510 }; |
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 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7513 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7514 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7515 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7516 |
9830 | 7517 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7518 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7519 | |
7520 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7521 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7522 | |
7523 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7524 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
|
7525 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7526 my_protocol = plugin; |
9935 | 7527 |
7528 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7529 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7530 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7531 } |
7532 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7533 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |