Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 8660:7dfd4b16c937
[gaim-migrate @ 9412]
This is going to break patches left and everywhere, but I felt compelled.
I replaced gaim_debug(GAIM_DEBUB_WHATEVER,
with the corresponding gaim_debug_whatever(
For what it's worth, it makes oscar.c 2KB smaller. But really, I just
think it's prettier.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 14 Apr 2004 04:10:26 +0000 |
parents | f0275c2b6281 |
children | 7a99cfed1996 |
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 | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
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" |
8476 | 31 #include "away.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
34 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "ft.h" |
6982 | 37 #include "imgstore.h" |
2086 | 38 #include "multi.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
39 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
41 #include "privacy.h" |
2086 | 42 #include "prpl.h" |
4889 | 43 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
46 |
2086 | 47 #include "aim.h" |
5842 | 48 #include "md5.h" |
2086 | 49 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
50 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
51 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
52 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
53 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
54 #define UC_AB 0x20 |
3079 | 55 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
56 |
2086 | 57 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
58 | |
7283 | 59 #define OSCAR_CONNECT_STEPS 6 |
60 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
61 static GaimPlugin *my_protocol = NULL; |
4249 | 62 |
7376 | 63 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
64 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 65 |
4665 | 66 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
67 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 68 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 69 |
7283 | 70 typedef struct _OscarData OscarData; |
71 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
72 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
73 aim_conn_t *conn; |
2086 | 74 |
75 guint cnpa; | |
76 guint paspa; | |
3694 | 77 guint emlpa; |
4804 | 78 guint icopa; |
2086 | 79 |
4823 | 80 gboolean iconconnecting; |
5842 | 81 gboolean set_icon; |
4823 | 82 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
83 GSList *create_rooms; |
2086 | 84 |
85 gboolean conf; | |
86 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
87 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
88 char *email; |
2979 | 89 gboolean setnick; |
90 char *newsn; | |
2086 | 91 gboolean chpass; |
92 char *oldp; | |
93 char *newp; | |
5842 | 94 |
2086 | 95 GSList *oscar_chats; |
96 GSList *direct_ims; | |
3630 | 97 GSList *file_transfers; |
4738 | 98 GHashTable *buddyinfo; |
4804 | 99 GSList *requesticon; |
2086 | 100 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
101 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
102 gboolean icq; |
4804 | 103 guint icontimer; |
5968 | 104 guint getblisttimer; |
8341 | 105 guint getinfotimer; |
2993 | 106 |
107 struct { | |
4230 | 108 guint maxwatchers; /* max users who can watch you */ |
2993 | 109 guint maxbuddies; /* max users you can watch */ |
4230 | 110 guint maxgroups; /* max groups in server list */ |
2993 | 111 guint maxpermits; /* max users on permit list */ |
112 guint maxdenies; /* max users on deny list */ | |
113 guint maxsiglen; /* max size (bytes) of profile */ | |
114 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
115 } rights; | |
2086 | 116 }; |
117 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
118 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
119 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
120 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
121 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 |
2086 | 123 struct chat_connection { |
124 char *name; | |
125 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
126 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
127 fu16_t instance; |
2086 | 128 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
|
129 aim_conn_t *conn; |
2086 | 130 int inpa; |
131 int id; | |
5575 | 132 GaimConnection *gc; /* i hate this. */ |
5679 | 133 GaimConversation *cnv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
134 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
135 int maxvis; |
2086 | 136 }; |
137 | |
138 struct direct_im { | |
5575 | 139 GaimConnection *gc; |
2086 | 140 char name[80]; |
141 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
142 aim_conn_t *conn; |
3008 | 143 gboolean connected; |
2086 | 144 }; |
145 | |
146 struct ask_direct { | |
5575 | 147 GaimConnection *gc; |
2086 | 148 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
149 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
150 fu8_t cookie[8]; |
2086 | 151 }; |
152 | |
7011 | 153 /* |
154 * Various PRPL-specific buddy info that we want to keep track of | |
155 * Some other info is maintained by locate.c, and I'd like to move | |
156 * the rest of this to libfaim, mostly im.c | |
157 */ | |
4738 | 158 struct buddyinfo { |
159 gboolean typingnot; | |
6292 | 160 gchar *availmsg; |
6857 | 161 fu32_t ipaddr; |
5836 | 162 |
163 unsigned long ico_me_len; | |
164 unsigned long ico_me_csum; | |
165 time_t ico_me_time; | |
166 gboolean ico_informed; | |
4738 | 167 |
168 unsigned long ico_len; | |
169 unsigned long ico_csum; | |
170 time_t ico_time; | |
171 gboolean ico_need; | |
7406 | 172 gboolean ico_sent; |
2086 | 173 }; |
174 | |
4230 | 175 struct name_data { |
5575 | 176 GaimConnection *gc; |
4230 | 177 gchar *name; |
3453 | 178 gchar *nick; |
3141 | 179 }; |
180 | |
5129 | 181 static char *msgerrreason[] = { |
182 N_("Invalid error"), | |
183 N_("Invalid SNAC"), | |
184 N_("Rate to host"), | |
185 N_("Rate to client"), | |
186 N_("Not logged in"), | |
187 N_("Service unavailable"), | |
188 N_("Service not defined"), | |
189 N_("Obsolete SNAC"), | |
190 N_("Not supported by host"), | |
191 N_("Not supported by client"), | |
192 N_("Refused by client"), | |
193 N_("Reply too big"), | |
194 N_("Responses lost"), | |
195 N_("Request denied"), | |
196 N_("Busted SNAC payload"), | |
197 N_("Insufficient rights"), | |
198 N_("In local permit/deny"), | |
199 N_("Too evil (sender)"), | |
200 N_("Too evil (receiver)"), | |
201 N_("User temporarily unavailable"), | |
202 N_("No match"), | |
203 N_("List overflow"), | |
204 N_("Request ambiguous"), | |
205 N_("Queue full"), | |
206 N_("Not while on AOL") | |
207 }; | |
208 static int msgerrreasonlen = 25; | |
209 | |
210 /* All the libfaim->gaim callback functions */ | |
211 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
212 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
213 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
214 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
215 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
216 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
217 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
218 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
219 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
220 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 221 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 222 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 223 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
224 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
|
225 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
|
226 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
|
227 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
|
228 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 229 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
230 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 232 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 233 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
234 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
237 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
238 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
239 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
240 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
241 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
242 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
243 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
244 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
245 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
250 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
251 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
260 #ifndef NOSSI | |
261 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 265 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 266 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
267 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
270 #endif | |
271 | |
272 /* for DirectIM/image transfer */ | |
273 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 276 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 277 |
278 /* for file transfer */ | |
279 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
280 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
281 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
282 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
283 | |
284 /* for icons */ | |
285 static gboolean gaim_icon_timerfunc(gpointer data); | |
286 | |
8076 | 287 /* remove these at some point? */ |
7282 | 288 /* Because I don't like forward declarations? I think that was why... */ |
5954 | 289 static void oscar_set_info(GaimConnection *gc, const char *text); |
8076 | 290 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message); |
5306 | 291 |
5836 | 292 static void oscar_free_name_data(struct name_data *data) { |
4230 | 293 g_free(data->name); |
294 g_free(data->nick); | |
295 g_free(data); | |
296 } | |
297 | |
5836 | 298 static void oscar_free_buddyinfo(void *data) { |
299 struct buddyinfo *bi = data; | |
6292 | 300 g_free(bi->availmsg); |
5836 | 301 g_free(bi); |
302 } | |
303 | |
5129 | 304 static fu32_t oscar_encoding_check(const char *utf8) |
305 { | |
306 int i = 0; | |
307 fu32_t encodingflag = 0; | |
308 | |
309 /* Determine how we can send this message. Per the warnings elsewhere | |
310 * in this file, these little checks determine the simplest encoding | |
311 * we can use for a given message send using it. */ | |
312 while (utf8[i]) { | |
313 if ((unsigned char)utf8[i] > 0x7f) { | |
314 /* not ASCII! */ | |
315 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
316 break; | |
317 } | |
318 i++; | |
319 } | |
320 while (utf8[i]) { | |
321 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
322 * followed by 0xc0-0xc3 in the second */ | |
323 if ((unsigned char)utf8[i] < 0x80) { | |
324 i++; | |
325 continue; | |
326 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
327 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
328 i += 2; | |
329 continue; | |
330 } | |
331 encodingflag = AIM_IMFLAGS_UNICODE; | |
332 break; | |
333 } | |
334 | |
335 return encodingflag; | |
336 } | |
337 | |
8225 | 338 /* |
339 * Take a string of the form charset="bleh" where bleh is | |
340 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
341 * return a newly allocated string containing bleh. | |
342 */ | |
343 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 344 { |
8225 | 345 gchar *ret = NULL; |
346 char *begin, *end; | |
347 | |
348 /* Make sure encoding begings with charset= */ | |
349 if (strncmp(encoding, "text/aolrtf; charset=", 21)) | |
350 return NULL; | |
351 | |
352 begin = strchr(encoding, '"'); | |
353 end = strrchr(encoding, '"'); | |
354 | |
355 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
356 return NULL; | |
357 | |
358 ret = g_strndup(begin+1, (end-1) - begin); | |
359 | |
360 return ret; | |
361 } | |
362 | |
363 /* | |
364 * Return the flag specifying the given encoding. | |
365 */ | |
366 static fu32_t oscar_encoding_parse(const char *encoding) | |
367 { | |
368 if ((encoding == NULL) || encoding[0] == '\0') { | |
8660 | 369 gaim_debug_warning("oscar", "Empty encoding, assuming ASCII\n"); |
5129 | 370 return 0; |
371 } | |
8225 | 372 |
373 if (!strcmp(encoding, "us-ascii") || !strcmp(encoding, "utf-8")) { | |
374 /* UTF-8 is our native encoding, ASCII is a proper subset */ | |
5129 | 375 return 0; |
8225 | 376 } else if (!strcmp(encoding, "iso-8859-1")) { |
5129 | 377 return AIM_IMFLAGS_ISO_8859_1; |
8225 | 378 } else if (!strcmp(encoding, "unicode-2-0")) { |
5129 | 379 return AIM_IMFLAGS_UNICODE; |
380 } else { | |
8660 | 381 gaim_debug_warning("oscar", |
8250 | 382 "Unrecognized character encoding '%s', attempting to convert to utf8 anyway\n", encoding); |
383 return 99; | |
5129 | 384 } |
385 } | |
386 | |
8233 | 387 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) |
5129 | 388 { |
389 gchar *utf8 = NULL; | |
390 int flags = oscar_encoding_parse(encoding); | |
391 | |
392 switch (flags) { | |
393 case 0: | |
8250 | 394 utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL); |
5129 | 395 break; |
396 case AIM_IMFLAGS_ISO_8859_1: | |
397 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
398 break; | |
399 case AIM_IMFLAGS_UNICODE: | |
400 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
401 break; | |
8250 | 402 case 99: |
403 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
404 if (utf8 == NULL) { | |
405 utf8 = g_convert(text, textlen, "UTF-8", "UTF-8", NULL, NULL, NULL); | |
406 } | |
407 break; | |
5129 | 408 } |
409 | |
410 return utf8; | |
411 } | |
412 | |
7283 | 413 static struct direct_im *find_direct_im(OscarData *od, const char *who) { |
2086 | 414 GSList *d = od->direct_ims; |
415 struct direct_im *m = NULL; | |
416 | |
417 while (d) { | |
418 m = (struct direct_im *)d->data; | |
4355 | 419 if (!aim_sncmp(who, m->name)) |
4269 | 420 return m; |
2086 | 421 d = d->next; |
422 } | |
423 | |
4269 | 424 return NULL; |
2086 | 425 } |
426 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
427 static char *extract_name(const char *name) { |
4121 | 428 char *tmp, *x; |
2086 | 429 int i, j; |
4120 | 430 |
431 if (!name) | |
4121 | 432 return NULL; |
433 | |
4120 | 434 x = strchr(name, '-'); |
4121 | 435 |
2086 | 436 if (!x) return NULL; |
437 x = strchr(++x, '-'); | |
438 if (!x) return NULL; | |
439 tmp = g_strdup(++x); | |
440 | |
441 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
442 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
443 if (x[i] != '%') { |
2086 | 444 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
445 continue; |
2086 | 446 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
447 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
448 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
449 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 450 } |
451 | |
452 tmp[j] = 0; | |
453 return tmp; | |
454 } | |
455 | |
5575 | 456 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 457 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 458 struct chat_connection *c = NULL; |
459 | |
460 while (g) { | |
461 c = (struct chat_connection *)g->data; | |
462 if (c->id == id) | |
463 break; | |
464 g = g->next; | |
465 c = NULL; | |
466 } | |
467 | |
468 return c; | |
469 } | |
470 | |
5575 | 471 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
|
472 aim_conn_t *conn) { |
7283 | 473 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 474 struct chat_connection *c = NULL; |
475 | |
476 while (g) { | |
477 c = (struct chat_connection *)g->data; | |
478 if (c->conn == conn) | |
479 break; | |
480 g = g->next; | |
481 c = NULL; | |
482 } | |
483 | |
484 return c; | |
485 } | |
486 | |
8219 | 487 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
488 GaimConversation *conv) { | |
489 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
490 struct chat_connection *c = NULL; | |
491 | |
492 while (g) { | |
493 c = (struct chat_connection *)g->data; | |
494 if (c->cnv == conv) | |
495 break; | |
496 g = g->next; | |
497 c = NULL; | |
498 } | |
499 | |
500 return c; | |
501 } | |
502 | |
4617 | 503 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
5575 | 504 GaimConnection *gc = sess->aux_data; |
7283 | 505 OscarData *od = (OscarData *)gc->proto_data; |
5679 | 506 GaimConversation *cnv; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
507 struct direct_im *dim; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
508 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
509 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
510 |
4617 | 511 sn = g_strdup(aim_odc_getsn(conn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
512 |
8660 | 513 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
514 "%s disconnected Direct IM.\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
515 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
516 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
517 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
518 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
519 |
3008 | 520 if (dim->connected) |
521 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
522 else | |
523 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn); | |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
524 |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
525 cnv = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); |
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
526 if (cnv) |
6982 | 527 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
528 |
5579 | 529 gaim_conversation_update_progress(cnv, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
530 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
531 g_free(dim); /* I guess? I don't see it anywhere else... -- mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
532 g_free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
533 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
534 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
535 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
536 |
4617 | 537 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
538 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
539 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 540 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 541 OscarData *od; |
2086 | 542 |
543 if (!gc) { | |
8660 | 544 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
545 "oscar callback for closed connection (1).\n"); |
2086 | 546 return; |
547 } | |
548 | |
7283 | 549 od = (OscarData *)gc->proto_data; |
2086 | 550 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
551 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 552 /* oh boy. this is probably bad. i guess the only thing we |
553 * can really do is return? */ | |
8660 | 554 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
555 "oscar callback for closed connection (2).\n"); |
8660 | 556 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 557 return; |
558 } | |
559 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
560 if (condition & GAIM_INPUT_READ) { |
4617 | 561 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 562 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
563 "got information on rendezvous listener\n"); |
4617 | 564 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 565 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
566 "connection error (rendezvous listener)\n"); |
4617 | 567 aim_conn_kill(od->sess, &conn); |
8446 | 568 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 569 } |
570 } else { | |
4617 | 571 if (aim_get_command(od->sess, conn) >= 0) { |
572 aim_rxdispatch(od->sess); | |
6029 | 573 if (od->killme) { |
8660 | 574 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 575 return; |
576 } | |
2086 | 577 } else { |
578 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 579 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 580 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
581 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
582 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 583 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
584 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
5420 | 585 char *buf; |
8660 | 586 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
587 "disconnected from chat room %s\n", c->name); |
2086 | 588 c->conn = NULL; |
589 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
590 gaim_input_remove(c->inpa); |
2086 | 591 c->inpa = 0; |
592 c->fd = -1; | |
4617 | 593 aim_conn_kill(od->sess, &conn); |
5420 | 594 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
595 gaim_notify_error(gc, NULL, buf, NULL); |
5420 | 596 g_free(buf); |
2086 | 597 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 598 if (od->cnpa > 0) |
599 gaim_input_remove(od->cnpa); | |
600 od->cnpa = 0; | |
8660 | 601 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
602 "removing chatnav input watcher\n"); |
4617 | 603 while (od->create_rooms) { |
604 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
605 g_free(cr->name); |
4617 | 606 od->create_rooms = |
607 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
608 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
609 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
610 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
611 NULL); |
2086 | 612 } |
4617 | 613 aim_conn_kill(od->sess, &conn); |
2086 | 614 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 615 if (od->paspa > 0) |
616 gaim_input_remove(od->paspa); | |
617 od->paspa = 0; | |
8660 | 618 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
619 "removing authconn input watcher\n"); |
4617 | 620 aim_conn_kill(od->sess, &conn); |
3694 | 621 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 622 if (od->emlpa > 0) |
623 gaim_input_remove(od->emlpa); | |
624 od->emlpa = 0; | |
8660 | 625 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
626 "removing email input watcher\n"); |
4617 | 627 aim_conn_kill(od->sess, &conn); |
4804 | 628 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
629 if (od->icopa > 0) | |
630 gaim_input_remove(od->icopa); | |
631 od->icopa = 0; | |
8660 | 632 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
633 "removing icon input watcher\n"); |
4804 | 634 aim_conn_kill(od->sess, &conn); |
2086 | 635 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
636 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 637 gaim_odc_disconnect(od->sess, conn); |
638 aim_conn_kill(od->sess, &conn); | |
2086 | 639 } else { |
8660 | 640 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
641 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
642 conn->type); |
4617 | 643 aim_conn_kill(od->sess, &conn); |
2086 | 644 } |
645 } | |
646 } | |
647 } | |
648 } | |
649 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
650 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 651 GaimConnection *gc = sess->aux_data; |
7285 | 652 gchar *s = g_strdup_vprintf(format, va); |
653 gchar *buf; | |
654 | |
655 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 656 gaim_debug_info("oscar", buf); |
7285 | 657 if (buf[strlen(buf)-1] != '\n') |
8660 | 658 gaim_debug_info(NULL, "\n"); |
7285 | 659 g_free(buf); |
2086 | 660 g_free(s); |
661 } | |
662 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
663 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 664 { |
5575 | 665 GaimConnection *gc = data; |
7283 | 666 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
667 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
668 aim_conn_t *conn; |
2086 | 669 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
670 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 671 close(source); |
672 return; | |
673 } | |
674 | |
4617 | 675 od = gc->proto_data; |
676 sess = od->sess; | |
2086 | 677 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 678 conn->fd = source; |
2086 | 679 |
680 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
681 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 682 return; |
683 } | |
684 | |
685 aim_conn_completeconnect(sess, conn); | |
4617 | 686 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 687 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
688 | |
8660 | 689 gaim_debug_info("oscar", |
7282 | 690 "Screen name sent, waiting for response\n"); |
7283 | 691 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 692 ck[1] = 0x65; |
2086 | 693 } |
694 | |
5575 | 695 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
696 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
697 aim_conn_t *conn; |
5575 | 698 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 699 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 700 |
8660 | 701 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
702 |
8437 | 703 if (!aim_snvalid(gaim_account_get_username(account))) { |
704 gchar *buf; | |
8590 | 705 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 | 706 gaim_connection_error(gc, buf); |
707 g_free(buf); | |
708 } | |
709 | |
5575 | 710 if (isdigit(*(gaim_account_get_username(account)))) { |
4617 | 711 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
712 } else { |
6622 | 713 gc->flags |= GAIM_CONNECTION_HTML; |
714 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
715 } |
5836 | 716 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 717 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
718 sess = g_new0(aim_session_t, 1); |
7285 | 719 aim_session_init(sess, TRUE, 0); |
2086 | 720 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 721 /* |
722 * We need an immediate queue because we don't use a while-loop | |
723 * to see if things need to be sent. | |
724 */ | |
2086 | 725 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 726 od->sess = sess; |
2086 | 727 sess->aux_data = gc; |
728 | |
729 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
730 if (conn == NULL) { | |
8660 | 731 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
732 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
733 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 734 return; |
735 } | |
736 | |
4649 | 737 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 738 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
739 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
740 | |
741 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
742 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 743 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
744 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
745 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 746 return; |
747 } | |
7282 | 748 |
7283 | 749 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 750 ck[0] = 0x5a; |
5575 | 751 } |
752 | |
753 static void oscar_close(GaimConnection *gc) { | |
7283 | 754 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 755 |
756 while (od->oscar_chats) { | |
757 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 758 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
759 gaim_input_remove(n->inpa); |
2086 | 760 g_free(n->name); |
761 g_free(n->show); | |
4617 | 762 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 763 g_free(n); |
764 } | |
4617 | 765 while (od->direct_ims) { |
766 struct direct_im *n = od->direct_ims->data; | |
2086 | 767 if (n->watcher > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
768 gaim_input_remove(n->watcher); |
4617 | 769 od->direct_ims = g_slist_remove(od->direct_ims, n); |
2086 | 770 g_free(n); |
771 } | |
4617 | 772 /* BBB */ |
773 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
774 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
775 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 776 gaim_xfer_cancel_local(xfer); |
3630 | 777 } |
4804 | 778 while (od->requesticon) { |
779 char *sn = od->requesticon->data; | |
780 od->requesticon = g_slist_remove(od->requesticon, sn); | |
781 free(sn); | |
782 } | |
4738 | 783 g_hash_table_destroy(od->buddyinfo); |
4617 | 784 while (od->create_rooms) { |
785 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
786 g_free(cr->name); |
4617 | 787 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
788 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
789 } |
4617 | 790 if (od->email) |
791 g_free(od->email); | |
792 if (od->newp) | |
793 g_free(od->newp); | |
794 if (od->oldp) | |
795 g_free(od->oldp); | |
2086 | 796 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
797 gaim_input_remove(gc->inpa); |
4617 | 798 if (od->cnpa > 0) |
799 gaim_input_remove(od->cnpa); | |
800 if (od->paspa > 0) | |
801 gaim_input_remove(od->paspa); | |
802 if (od->emlpa > 0) | |
803 gaim_input_remove(od->emlpa); | |
4804 | 804 if (od->icopa > 0) |
805 gaim_input_remove(od->icopa); | |
6907 | 806 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
807 gaim_timeout_remove(od->icontimer); |
8341 | 808 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
809 gaim_timeout_remove(od->getblisttimer); |
8341 | 810 if (od->getinfotimer > 0) |
811 gaim_timeout_remove(od->getinfotimer); | |
4617 | 812 aim_session_kill(od->sess); |
813 g_free(od->sess); | |
814 od->sess = NULL; | |
2086 | 815 g_free(gc->proto_data); |
816 gc->proto_data = NULL; | |
8660 | 817 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 818 } |
819 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
820 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 821 GaimConnection *gc = data; |
7283 | 822 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
823 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
824 aim_conn_t *bosconn; |
2086 | 825 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
826 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 827 close(source); |
828 return; | |
829 } | |
830 | |
4617 | 831 od = gc->proto_data; |
832 sess = od->sess; | |
833 bosconn = od->conn; | |
4366 | 834 bosconn->fd = source; |
2086 | 835 |
836 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
837 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 838 return; |
839 } | |
840 | |
841 aim_conn_completeconnect(sess, bosconn); | |
4617 | 842 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 843 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
844 gaim_connection_update_progress(gc, |
7283 | 845 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 846 ck[4] = 0x61; |
2086 | 847 } |
848 | |
4617 | 849 /* BBB */ |
4656 | 850 /* |
851 * This little area in oscar.c is the nexus of file transfer code, | |
852 * so I wrote a little explanation of what happens. I am such a | |
853 * ninja. | |
854 * | |
855 * The series of events for a file send is: | |
856 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
857 * -User chooses a file and oscar_xfer_init is called. It establishs a | |
858 * listening socket, then asks the remote user to connect to us (and | |
859 * gives them the file name, port, IP, etc.) | |
860 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
861 * in oscar_sendfile_estblsh) | |
862 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
863 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
864 * connection. | |
865 * -We get drunk because file transfer kicks ass. | |
866 * | |
867 * The series of events for a file receive is: | |
868 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
869 * -Gaim user selects file to name and location to save file to and | |
870 * oscar_xfer_init is called | |
871 * -It connects to the remote user using the IP they gave us earlier | |
872 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
873 * them an AIM_CB_OFT_ACK. | |
874 * -They begin to send us lots of raw data. | |
875 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
876 * the connectionn. | |
877 */ | |
878 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
879 | |
8446 | 880 /* |
881 * Miscellaneous xfer functions | |
882 */ | |
883 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 884 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
885 GaimXfer *xfer; |
5146 | 886 struct aim_oft_info *oft_info; |
4656 | 887 |
888 while (fts) { | |
889 xfer = fts->data; | |
5146 | 890 oft_info = xfer->data; |
891 | |
8446 | 892 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 893 return xfer; |
894 | |
895 fts = g_slist_next(fts); | |
896 } | |
897 | |
898 return NULL; | |
899 } | |
900 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
901 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 902 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
903 GaimXfer *xfer; |
5146 | 904 struct aim_oft_info *oft_info; |
4656 | 905 |
906 while (fts) { | |
907 xfer = fts->data; | |
5146 | 908 oft_info = xfer->data; |
909 | |
910 if (oft_info && (conn == oft_info->conn)) | |
4656 | 911 return xfer; |
912 | |
913 fts = g_slist_next(fts); | |
914 } | |
915 | |
916 return NULL; | |
917 } | |
918 | |
8446 | 919 static void oscar_xfer_end(GaimXfer *xfer) |
920 { | |
921 struct aim_oft_info *oft_info = xfer->data; | |
922 GaimConnection *gc = oft_info->sess->aux_data; | |
923 OscarData *od = gc->proto_data; | |
924 | |
8660 | 925 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 926 |
927 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
928 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
929 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
930 } | |
931 | |
932 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
933 aim_oft_destroyinfo(oft_info); | |
934 xfer->data = NULL; | |
935 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
936 } | |
937 | |
938 /* | |
939 * xfer functions used when receiving files | |
940 */ | |
941 | |
942 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
943 { | |
944 struct aim_oft_info *oft_info = xfer->data; | |
945 GaimConnection *gc = oft_info->sess->aux_data; | |
946 OscarData *od = gc->proto_data; | |
947 | |
8660 | 948 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 949 |
950 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
951 if (oft_info->conn) { | |
952 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
953 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
954 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
955 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
956 if (xfer->fd == -1) { | |
957 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
958 _("Unable to establish file descriptor.")); | |
959 gaim_xfer_cancel_local(xfer); | |
960 } | |
961 } else { | |
962 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
963 _("Unable to create new connection.")); | |
964 gaim_xfer_cancel_local(xfer); | |
965 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
966 } | |
967 | |
968 } | |
969 | |
970 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
971 { | |
972 struct aim_oft_info *oft_info = xfer->data; | |
973 GaimConnection *gc = oft_info->sess->aux_data; | |
974 OscarData *od = gc->proto_data; | |
975 | |
8660 | 976 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 977 |
978 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
979 | |
980 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
981 aim_oft_destroyinfo(oft_info); | |
982 xfer->data = NULL; | |
983 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
984 } | |
985 | |
986 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
987 { | |
988 struct aim_oft_info *oft_info = xfer->data; | |
989 | |
990 /* Update our rolling checksum. Like Walmart, yo. */ | |
991 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
992 } | |
993 | |
994 /* | |
995 * xfer functions used when sending files | |
996 */ | |
997 | |
998 static void oscar_xfer_init_send(GaimXfer *xfer) | |
999 { | |
1000 struct aim_oft_info *oft_info = xfer->data; | |
1001 GaimConnection *gc = oft_info->sess->aux_data; | |
1002 OscarData *od = gc->proto_data; | |
1003 int listenfd; | |
1004 | |
8660 | 1005 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 1006 |
1007 xfer->filename = g_path_get_basename(xfer->local_filename); | |
1008 strncpy(oft_info->fh.name, xfer->filename, 64); | |
1009 oft_info->fh.name[63] = '\0'; | |
1010 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
1011 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
1012 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
1013 | |
1014 /* Create a listening socket and an associated libfaim conn */ | |
1015 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
1016 gaim_xfer_cancel_local(xfer); | |
1017 return; | |
1018 } | |
1019 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
1020 oft_info->port = xfer->local_port; | |
1021 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
1022 gaim_xfer_cancel_local(xfer); | |
1023 return; | |
1024 } | |
8660 | 1025 gaim_debug_misc("oscar", |
8446 | 1026 "port is %hu, ip is %s\n", |
1027 xfer->local_port, oft_info->clientip); | |
1028 if (oft_info->conn) { | |
1029 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
1030 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
1031 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
1032 } else { | |
1033 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
1034 _("Unable to establish listener socket.")); | |
1035 gaim_xfer_cancel_local(xfer); | |
1036 } | |
1037 } | |
1038 | |
1039 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
1040 { | |
1041 struct aim_oft_info *oft_info = xfer->data; | |
1042 GaimConnection *gc = oft_info->sess->aux_data; | |
1043 OscarData *od = gc->proto_data; | |
1044 | |
8660 | 1045 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 1046 |
1047 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
1048 | |
1049 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1050 aim_oft_destroyinfo(oft_info); | |
1051 xfer->data = NULL; | |
1052 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1053 } | |
1054 | |
1055 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
1056 { | |
1057 struct aim_oft_info *oft_info = xfer->data; | |
1058 | |
1059 /* I'm not sure I like how we do this. --marv | |
1060 * I do. AIM file transfers aren't really meant to be thought | |
1061 * of as a transferring just a single file. The rendezvous | |
1062 * establishes a connection between two computers, and then | |
1063 * those computers can use the same connection for transferring | |
1064 * multiple files. So we don't want the Gaim core up and closing | |
1065 * the socket all willy-nilly. We want to do that in the oscar | |
1066 * prpl, whenever one side or the other says they're finished | |
1067 * using the connection. There might be a better way to intercept | |
1068 * the socket from the core, however... --KingAnt | |
1069 */ | |
1070 | |
1071 /* | |
1072 * If we're done sending, intercept the socket from the core ft code | |
1073 * and wait for the other guy to send the "done" OFT packet. | |
1074 */ | |
1075 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
1076 gaim_input_remove(xfer->watcher); | |
1077 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
1078 xfer->fd = 0; | |
1079 gaim_xfer_set_completed(xfer, TRUE); | |
1080 } | |
1081 } | |
1082 | |
5575 | 1083 static void oscar_ask_sendfile(GaimConnection *gc, const char *destsn) { |
7283 | 1084 OscarData *od = (OscarData *)gc->proto_data; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
1085 GaimAccount *account = gaim_connection_get_account(gc); |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1086 GaimXfer *xfer; |
5146 | 1087 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
1088 const char *ip; |
3752 | 1089 |
4617 | 1090 /* You want to send a file to someone else, you're so generous */ |
1091 | |
1092 /* Build the file transfer handle */ | |
5575 | 1093 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, destsn); |
4617 | 1094 |
5146 | 1095 /* Create the oscar-specific data */ |
8240 | 1096 ip = gaim_network_get_ip_for_account(account, od->conn ? od->conn->fd : -1); |
1097 oft_info = aim_oft_createinfo(od->sess, NULL, destsn, ip, 0, 0, 0, NULL); | |
5146 | 1098 xfer->data = oft_info; |
1099 | |
4617 | 1100 /* Setup our I/O op functions */ |
8446 | 1101 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 1102 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1103 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 1104 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
1105 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 1106 |
1107 /* Keep track of this transfer for later */ | |
1108 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
1109 | |
1110 /* Now perform the request */ | |
1111 gaim_xfer_request(xfer); | |
3630 | 1112 } |
1113 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1114 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 1115 GaimConnection *gc = sess->aux_data; |
7283 | 1116 OscarData *od = gc->proto_data; |
6029 | 1117 GaimAccount *account = gc->account; |
1118 aim_conn_t *bosconn; | |
1119 char *host; int port; | |
1120 int i, rc; | |
2086 | 1121 va_list ap; |
2704 | 1122 struct aim_authresp_info *info; |
6029 | 1123 |
5575 | 1124 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1125 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1126 va_start(ap, fr); |
2704 | 1127 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 1128 va_end(ap); |
1129 | |
8660 | 1130 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1131 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 1132 |
4293 | 1133 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 1134 char buf[256]; |
2704 | 1135 switch (info->errorcode) { |
2086 | 1136 case 0x05: |
1137 /* Incorrect nick/password */ | |
6498 | 1138 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1139 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 1140 break; |
1141 case 0x11: | |
1142 /* Suspended account */ | |
6498 | 1143 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1144 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 1145 break; |
3498 | 1146 case 0x14: |
1147 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1148 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 1149 break; |
2086 | 1150 case 0x18: |
1151 /* connecting too frequently */ | |
6498 | 1152 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1153 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 | 1154 break; |
1155 case 0x1c: | |
1156 /* client too old */ | |
6498 | 1157 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
1158 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
|
1159 gaim_connection_error(gc, buf); |
2086 | 1160 break; |
1161 default: | |
6623 | 1162 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 1163 break; |
1164 } | |
8660 | 1165 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1166 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 1167 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1168 "Error URL: %s\n", info->errorurl); |
2086 | 1169 od->killme = TRUE; |
1170 return 1; | |
1171 } | |
1172 | |
1173 | |
8660 | 1174 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1175 "Reg status: %hu\n", info->regstatus); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1176 |
2704 | 1177 if (info->email) { |
8660 | 1178 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 1179 } else { |
8660 | 1180 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1181 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1182 |
8660 | 1183 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
1184 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1185 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1186 aim_conn_kill(sess, &fr->conn); |
2086 | 1187 |
1188 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
1189 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1190 gaim_connection_error(gc, _("Internal Error")); |
2086 | 1191 od->killme = TRUE; |
1192 return 0; | |
1193 } | |
1194 | |
4649 | 1195 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1196 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 1197 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
1198 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
1199 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 1200 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 1201 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
1202 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
1203 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
1204 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
1205 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
1206 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 1207 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 1208 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
1209 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
1210 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
1211 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
1212 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 1213 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 1214 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 1215 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 1216 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
1217 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
|
1218 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 1219 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
1220 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
1221 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
1222 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
1223 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 1224 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
|
1225 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
|
1226 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
|
1227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 1228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 1229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 1230 #ifndef NOSSI |
4642 | 1231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 1232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
1233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
1234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 1235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 1236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 1237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
1238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
1239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
1240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
1241 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1242 |
7283 | 1243 od->conn = bosconn; |
2704 | 1244 for (i = 0; i < (int)strlen(info->bosip); i++) { |
1245 if (info->bosip[i] == ':') { | |
1246 port = atoi(&(info->bosip[i+1])); | |
2086 | 1247 break; |
1248 } | |
1249 } | |
2704 | 1250 host = g_strndup(info->bosip, i); |
2086 | 1251 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1252 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 1253 g_free(host); |
4366 | 1254 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1255 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1256 od->killme = TRUE; |
1257 return 0; | |
1258 } | |
4293 | 1259 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1260 gaim_input_remove(gc->inpa); |
2704 | 1261 |
7283 | 1262 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 1263 ck[3] = 0x64; |
7282 | 1264 |
2086 | 1265 return 1; |
1266 } | |
1267 | |
7285 | 1268 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 1269 struct pieceofcrap { |
5575 | 1270 GaimConnection *gc; |
2086 | 1271 unsigned long offset; |
1272 unsigned long len; | |
1273 char *modname; | |
1274 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1275 aim_conn_t *conn; |
2086 | 1276 unsigned int inpa; |
1277 }; | |
1278 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1279 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 1280 { |
1281 struct pieceofcrap *pos = data; | |
7283 | 1282 OscarData *od = pos->gc->proto_data; |
2086 | 1283 char in = '\0'; |
1284 int x = 0; | |
1285 unsigned char m[17]; | |
1286 | |
1287 while (read(pos->fd, &in, 1) == 1) { | |
1288 if (in == '\n') | |
1289 x++; | |
1290 else if (in != '\r') | |
1291 x = 0; | |
1292 if (x == 2) | |
1293 break; | |
1294 in = '\0'; | |
1295 } | |
1296 if (in != '\n') { | |
4056 | 1297 char buf[256]; |
1298 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
|
1299 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1300 gaim_notify_warning(pos->gc, NULL, |
7422 | 1301 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1302 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1303 gaim_input_remove(pos->inpa); |
2086 | 1304 close(pos->fd); |
1305 g_free(pos); | |
1306 return; | |
1307 } | |
1308 read(pos->fd, m, 16); | |
1309 m[16] = '\0'; | |
8660 | 1310 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 1311 for (x = 0; x < 16; x++) |
8660 | 1312 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
1313 | |
1314 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1315 gaim_input_remove(pos->inpa); |
2086 | 1316 close(pos->fd); |
1317 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
1318 g_free(pos); | |
1319 } | |
1320 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1321 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 1322 struct pieceofcrap *pos = data; |
5420 | 1323 gchar *buf; |
2086 | 1324 |
4366 | 1325 pos->fd = source; |
1326 | |
2086 | 1327 if (source < 0) { |
5420 | 1328 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
|
1329 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1330 gaim_notify_warning(pos->gc, NULL, |
7422 | 1331 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1332 buf); |
5420 | 1333 g_free(buf); |
2086 | 1334 if (pos->modname) |
1335 g_free(pos->modname); | |
1336 g_free(pos); | |
1337 return; | |
1338 } | |
1339 | |
5420 | 1340 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 1341 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
1342 write(pos->fd, buf, strlen(buf)); | |
5420 | 1343 g_free(buf); |
2086 | 1344 if (pos->modname) |
1345 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1346 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 1347 return; |
1348 } | |
1349 | |
1350 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
1351 #define AIM_MAX_FILE_SIZE 98304 | |
1352 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1353 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1354 va_list ap; |
1355 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1356 fu32_t offset, len; |
2086 | 1357 char *modname; |
1358 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1359 va_start(ap, fr); |
4200 | 1360 offset = va_arg(ap, fu32_t); |
1361 len = va_arg(ap, fu32_t); | |
2086 | 1362 modname = va_arg(ap, char *); |
1363 va_end(ap); | |
1364 | |
8660 | 1365 gaim_debug_misc("oscar", |
5556 | 1366 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1367 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1368 |
2086 | 1369 if (len == 0) { |
8660 | 1370 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1371 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 1372 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1373 return 1; | |
1374 } | |
1375 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
1376 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
1377 char *buf; | |
1378 int i = 8; | |
1379 if (modname) | |
1380 i += strlen(modname); | |
1381 buf = g_malloc(i); | |
1382 i = 0; | |
1383 if (modname) { | |
1384 memcpy(buf, modname, strlen(modname)); | |
1385 i += strlen(modname); | |
1386 } | |
1387 buf[i++] = offset & 0xff; | |
1388 buf[i++] = (offset >> 8) & 0xff; | |
1389 buf[i++] = (offset >> 16) & 0xff; | |
1390 buf[i++] = (offset >> 24) & 0xff; | |
1391 buf[i++] = len & 0xff; | |
1392 buf[i++] = (len >> 8) & 0xff; | |
1393 buf[i++] = (len >> 16) & 0xff; | |
1394 buf[i++] = (len >> 24) & 0xff; | |
8660 | 1395 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1396 "hashing request\n"); |
2086 | 1397 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1398 g_free(buf); | |
1399 return 1; | |
1400 } | |
1401 */ | |
1402 | |
1403 pos = g_new0(struct pieceofcrap, 1); | |
1404 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1405 pos->conn = fr->conn; |
2086 | 1406 |
1407 pos->offset = offset; | |
1408 pos->len = len; | |
1409 pos->modname = modname ? g_strdup(modname) : NULL; | |
1410 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1411 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 1412 char buf[256]; |
2086 | 1413 if (pos->modname) |
1414 g_free(pos->modname); | |
1415 g_free(pos); | |
4056 | 1416 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
|
1417 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1418 gaim_notify_warning(pos->gc, NULL, |
7422 | 1419 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1420 buf); |
2086 | 1421 } |
1422 | |
1423 return 1; | |
1424 } | |
1425 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1426 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1427 GaimConnection *gc = sess->aux_data; |
7283 | 1428 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1429 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 1430 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 1431 #if 0 |
1432 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
1433 #endif | |
7011 | 1434 va_list ap; |
1435 char *key; | |
2086 | 1436 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1437 va_start(ap, fr); |
2086 | 1438 key = va_arg(ap, char *); |
1439 va_end(ap); | |
1440 | |
4617 | 1441 if (od->icq) { |
3458 | 1442 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1443 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1444 gaim_account_get_password(account), &info, key); |
3458 | 1445 } else { |
1446 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1447 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
1448 gaim_account_get_password(account), &info, key); |
3458 | 1449 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1450 |
7283 | 1451 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 1452 ck[2] = 0x6c; |
7282 | 1453 |
2086 | 1454 return 1; |
1455 } | |
1456 | |
2675 | 1457 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1458 GaimConnection *gc = sess->aux_data; |
2647 | 1459 struct chat_connection *chatcon; |
1460 static int id = 1; | |
1461 | |
6905 | 1462 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
|
1463 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
|
1464 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
|
1465 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
|
1466 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 1467 |
2672 | 1468 aim_clientready(sess, fr->conn); |
2675 | 1469 |
2647 | 1470 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
1471 chatcon->id = id; | |
1472 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
1473 | |
1474 return 1; | |
1475 } | |
1476 | |
2675 | 1477 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
1478 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1479 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 1480 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 1481 |
1482 aim_clientready(sess, fr->conn); | |
1483 | |
1484 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1485 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1486 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1487 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1488 |
3694 | 1489 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
1490 | |
1491 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1492 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
1493 | |
7282 | 1494 aim_email_sendcookies(sess); |
1495 aim_email_activate(sess); | |
3694 | 1496 aim_clientready(sess, fr->conn); |
1497 | |
1498 return 1; | |
1499 } | |
1500 | |
4804 | 1501 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1502 GaimConnection *gc = sess->aux_data; |
7283 | 1503 OscarData *od = gc->proto_data; |
4804 | 1504 |
1505 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1506 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
1507 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
1508 | |
1509 aim_clientready(sess, fr->conn); | |
1510 | |
4823 | 1511 od->iconconnecting = FALSE; |
1512 | |
4804 | 1513 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1514 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
1515 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 1516 |
1517 return 1; | |
1518 } | |
1519 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1520 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1521 GaimConnection *gc = data; |
7283 | 1522 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1523 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1524 aim_conn_t *tstconn; |
2086 | 1525 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1526 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1527 close(source); |
1528 return; | |
1529 } | |
1530 | |
4617 | 1531 od = gc->proto_data; |
1532 sess = od->sess; | |
2086 | 1533 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 1534 tstconn->fd = source; |
2086 | 1535 |
1536 if (source < 0) { | |
1537 aim_conn_kill(sess, &tstconn); | |
8660 | 1538 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1539 "unable to connect to chatnav server\n"); |
2086 | 1540 return; |
1541 } | |
1542 | |
1543 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1544 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 1545 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 1546 } |
1547 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1548 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1549 { |
5575 | 1550 GaimConnection *gc = data; |
7283 | 1551 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1552 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1553 aim_conn_t *tstconn; |
2086 | 1554 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1555 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1556 close(source); |
1557 return; | |
1558 } | |
1559 | |
4617 | 1560 od = gc->proto_data; |
1561 sess = od->sess; | |
2086 | 1562 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1563 tstconn->fd = source; |
2086 | 1564 |
1565 if (source < 0) { | |
1566 aim_conn_kill(sess, &tstconn); | |
8660 | 1567 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1568 "unable to connect to authorizer\n"); |
2086 | 1569 return; |
1570 } | |
1571 | |
1572 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1573 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 1574 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 1575 } |
1576 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1577 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1578 { |
1579 struct chat_connection *ccon = data; | |
5575 | 1580 GaimConnection *gc = ccon->gc; |
7283 | 1581 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1582 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1583 aim_conn_t *tstconn; |
2086 | 1584 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1585 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1586 close(source); |
1587 g_free(ccon->show); | |
1588 g_free(ccon->name); | |
1589 g_free(ccon); | |
1590 return; | |
1591 } | |
1592 | |
4617 | 1593 od = gc->proto_data; |
1594 sess = od->sess; | |
2086 | 1595 tstconn = ccon->conn; |
4366 | 1596 tstconn->fd = source; |
2086 | 1597 |
1598 if (source < 0) { | |
1599 aim_conn_kill(sess, &tstconn); | |
1600 g_free(ccon->show); | |
1601 g_free(ccon->name); | |
1602 g_free(ccon); | |
1603 return; | |
1604 } | |
1605 | |
1606 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 1607 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
1608 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 1609 } |
1610 | |
3694 | 1611 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1612 GaimConnection *gc = data; |
7283 | 1613 OscarData *od; |
3694 | 1614 aim_session_t *sess; |
1615 aim_conn_t *tstconn; | |
1616 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1617 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 1618 close(source); |
1619 return; | |
1620 } | |
1621 | |
4617 | 1622 od = gc->proto_data; |
1623 sess = od->sess; | |
3694 | 1624 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 1625 tstconn->fd = source; |
3694 | 1626 |
1627 if (source < 0) { | |
1628 aim_conn_kill(sess, &tstconn); | |
8660 | 1629 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1630 "unable to connect to email server\n"); |
3694 | 1631 return; |
1632 } | |
1633 | |
1634 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1635 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 1636 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1637 "email: connected\n"); |
3694 | 1638 } |
1639 | |
4804 | 1640 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1641 GaimConnection *gc = data; |
7283 | 1642 OscarData *od; |
4804 | 1643 aim_session_t *sess; |
1644 aim_conn_t *tstconn; | |
1645 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1646 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 1647 close(source); |
1648 return; | |
1649 } | |
1650 | |
1651 od = gc->proto_data; | |
1652 sess = od->sess; | |
1653 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
1654 tstconn->fd = source; | |
1655 | |
1656 if (source < 0) { | |
1657 aim_conn_kill(sess, &tstconn); | |
8660 | 1658 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1659 "unable to connect to icon server\n"); |
4804 | 1660 return; |
1661 } | |
1662 | |
1663 aim_conn_completeconnect(sess, tstconn); | |
1664 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 1665 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 1666 } |
1667 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1668 /* 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
|
1669 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1670 GaimConnection *gc = sess->aux_data; |
1671 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1672 aim_conn_t *tstconn; |
4452 | 1673 int i; |
2086 | 1674 char *host; |
1675 int port; | |
4821 | 1676 va_list ap; |
1677 struct aim_redirect_data *redir; | |
2086 | 1678 |
5575 | 1679 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 1680 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1681 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1682 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1683 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1684 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1685 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1686 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1687 port = atoi(&(redir->ip[i+1])); |
2086 | 1688 break; |
1689 } | |
1690 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1691 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1692 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1693 switch(redir->group) { |
2086 | 1694 case 0x7: /* Authorizer */ |
8660 | 1695 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1696 "Reconnecting with authorizor...\n"); |
2086 | 1697 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1698 if (tstconn == NULL) { | |
8660 | 1699 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1700 "unable to reconnect with authorizer\n"); |
2086 | 1701 g_free(host); |
1702 return 1; | |
1703 } | |
4649 | 1704 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1705 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 1706 |
1707 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1708 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 1709 aim_conn_kill(sess, &tstconn); |
8660 | 1710 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1711 "unable to reconnect with authorizer\n"); |
2086 | 1712 g_free(host); |
1713 return 1; | |
1714 } | |
4293 | 1715 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1716 break; |
1717 | |
2086 | 1718 case 0xd: /* ChatNav */ |
1719 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1720 if (tstconn == NULL) { | |
8660 | 1721 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1722 "unable to connect to chatnav server\n"); |
2086 | 1723 g_free(host); |
1724 return 1; | |
1725 } | |
4649 | 1726 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1727 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 1728 |
1729 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1730 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 1731 aim_conn_kill(sess, &tstconn); |
8660 | 1732 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1733 "unable to connect to chatnav server\n"); |
2086 | 1734 g_free(host); |
1735 return 1; | |
1736 } | |
4293 | 1737 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1738 break; |
1739 | |
1740 case 0xe: { /* Chat */ | |
2086 | 1741 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1742 |
2086 | 1743 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1744 if (tstconn == NULL) { | |
8660 | 1745 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1746 "unable to connect to chat server\n"); |
2086 | 1747 g_free(host); |
1748 return 1; | |
1749 } | |
1750 | |
4649 | 1751 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1752 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
1753 | |
2086 | 1754 ccon = g_new0(struct chat_connection, 1); |
1755 ccon->conn = tstconn; | |
1756 ccon->gc = gc; | |
1757 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1758 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1759 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1760 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1761 ccon->show = extract_name(redir->chat.room); |
4634 | 1762 |
2086 | 1763 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1764 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 1765 aim_conn_kill(sess, &tstconn); |
8660 | 1766 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1767 "unable to connect to chat server\n"); |
2086 | 1768 g_free(host); |
1769 g_free(ccon->show); | |
1770 g_free(ccon->name); | |
1771 g_free(ccon); | |
1772 return 1; | |
1773 } | |
4293 | 1774 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 1775 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1776 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1777 ccon->name, ccon->exchange); |
4194 | 1778 } break; |
3694 | 1779 |
4804 | 1780 case 0x0010: { /* icon */ |
1781 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 1782 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1783 "unable to connect to icon server\n"); |
4804 | 1784 g_free(host); |
1785 return 1; | |
1786 } | |
1787 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
1788 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
1789 | |
1790 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1791 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 1792 aim_conn_kill(sess, &tstconn); |
8660 | 1793 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1794 "unable to connect to icon server\n"); |
4804 | 1795 g_free(host); |
1796 return 1; | |
1797 } | |
1798 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
1799 } break; | |
1800 | |
3694 | 1801 case 0x0018: { /* email */ |
1802 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 1803 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1804 "unable to connect to email server\n"); |
3694 | 1805 g_free(host); |
1806 return 1; | |
1807 } | |
4649 | 1808 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 1809 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
1810 | |
1811 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1812 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 1813 aim_conn_kill(sess, &tstconn); |
8660 | 1814 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1815 "unable to connect to email server\n"); |
3694 | 1816 g_free(host); |
1817 return 1; | |
1818 } | |
4293 | 1819 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 1820 } break; |
1821 | |
2086 | 1822 default: /* huh? */ |
8660 | 1823 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1824 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1825 redir->group); |
2086 | 1826 break; |
1827 } | |
1828 | |
1829 g_free(host); | |
1830 return 1; | |
1831 } | |
1832 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1833 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1834 GaimConnection *gc = sess->aux_data; |
7283 | 1835 OscarData *od = gc->proto_data; |
4738 | 1836 struct buddyinfo *bi; |
2993 | 1837 time_t time_idle = 0, signon = 0; |
1838 int type = 0; | |
1839 int caps = 0; | |
2086 | 1840 va_list ap; |
4738 | 1841 aim_userinfo_t *info; |
4194 | 1842 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1843 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1844 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1845 va_end(ap); |
1846 | |
2993 | 1847 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
1848 caps = info->capabilities; | |
3267 | 1849 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
1850 type |= UC_AB; | |
1851 | |
4766 | 1852 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
1853 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
1854 type |= UC_UNCONFIRMED; | |
1855 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
1856 type |= UC_ADMIN; | |
1857 if (info->flags & AIM_FLAG_AOL) | |
1858 type |= UC_AOL; | |
1859 if (info->flags & AIM_FLAG_FREE) | |
1860 type |= UC_NORMAL; | |
1861 if (info->flags & AIM_FLAG_AWAY) | |
1862 type |= UC_UNAVAILABLE; | |
1863 if (info->flags & AIM_FLAG_WIRELESS) | |
1864 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1865 } |
2993 | 1866 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 1867 type = (info->icqinfo.status << 16); |
3013 | 1868 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
1869 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 1870 type |= UC_UNAVAILABLE; |
3013 | 1871 } |
2993 | 1872 } |
1873 | |
7141 | 1874 if (caps & AIM_CAPS_ICQ_DIRECT) |
1875 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 1876 |
1877 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 1878 time(&time_idle); |
1879 time_idle -= info->idletime*60; | |
2993 | 1880 } |
1881 | |
5836 | 1882 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
1883 signon = info->onlinesince; | |
1884 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 1885 signon = time(NULL) - info->sessionlen; |
2086 | 1886 |
5575 | 1887 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
1888 gaim_connection_set_display_name(gc, info->sn); | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1889 |
7261 | 1890 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
4738 | 1891 if (!bi) { |
1892 bi = g_new0(struct buddyinfo, 1); | |
7261 | 1893 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
4738 | 1894 } |
4739 | 1895 bi->typingnot = FALSE; |
1896 bi->ico_informed = FALSE; | |
6857 | 1897 bi->ipaddr = info->icqinfo.ipaddr; |
1898 | |
1899 /* Available message stuff */ | |
6292 | 1900 free(bi->availmsg); |
7011 | 1901 if (info->avail != NULL) |
8225 | 1902 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 1903 else |
6292 | 1904 bi->availmsg = NULL; |
4732 | 1905 |
4804 | 1906 /* Server stored icon stuff */ |
4853 | 1907 if (info->iconcsumlen) { |
7125 | 1908 const char *filename = NULL, *saved_b16 = NULL; |
1909 char *b16 = NULL; | |
7093 | 1910 GaimBuddy *b = NULL; |
4853 | 1911 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
1912 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
4853 | 1913 b = gaim_find_buddy(gc->account, info->sn); |
7093 | 1914 /* |
1915 * If for some reason the checksum is valid, but cached file is not.. | |
1916 * we want to know. | |
1917 */ | |
7693 | 1918 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 1919 if (filename != NULL) { |
1920 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 1921 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
1922 "icon_checksum"); | |
7093 | 1923 } else |
1924 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
1925 |
4853 | 1926 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
1927 GSList *cur = od->requesticon; | |
1928 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
1929 cur = cur->next; | |
1930 if (!cur) { | |
7475 | 1931 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
4853 | 1932 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1933 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
1934 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 1935 } |
1936 } | |
6053 | 1937 g_free(b16); |
4853 | 1938 } |
1939 | |
5628 | 1940 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
2086 | 1941 |
1942 return 1; | |
1943 } | |
1944 | |
8341 | 1945 static void gaim_check_comment(OscarData *od, const char *str) { |
1946 if ((str == NULL) || strcmp(str, ck)) | |
1947 aim_locate_setcaps(od->sess, caps_aim); | |
1948 else | |
1949 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
1950 } | |
1951 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1952 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 1953 GaimConnection *gc = sess->aux_data; |
7283 | 1954 OscarData *od = gc->proto_data; |
2086 | 1955 va_list ap; |
4739 | 1956 aim_userinfo_t *info; |
2086 | 1957 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1958 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1959 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1960 va_end(ap); |
1961 | |
4732 | 1962 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 1963 |
7261 | 1964 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 1965 |
2086 | 1966 return 1; |
1967 } | |
1968 | |
3730 | 1969 static void cancel_direct_im(struct ask_direct *d) { |
8660 | 1970 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); |
2086 | 1971 |
1972 g_free(d->sn); | |
1973 g_free(d); | |
1974 } | |
1975 | |
4617 | 1976 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1977 struct direct_im *dim = data; |
5575 | 1978 GaimConnection *gc = dim->gc; |
7283 | 1979 OscarData *od = gc->proto_data; |
5679 | 1980 GaimConversation *cnv; |
2086 | 1981 char buf[256]; |
3008 | 1982 struct sockaddr name; |
1983 socklen_t name_len = 1; | |
1984 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1985 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1986 g_free(dim); |
1987 return; | |
1988 } | |
1989 | |
1990 if (source < 0) { | |
1991 g_free(dim); | |
1992 return; | |
1993 } | |
1994 | |
4366 | 1995 dim->conn->fd = source; |
2086 | 1996 aim_conn_completeconnect(od->sess, dim->conn); |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
1997 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); |
3008 | 1998 |
1999 /* This is the best way to see if we're connected or not */ | |
2000 if (getpeername(source, &name, &name_len) == 0) { | |
2001 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
2002 dim->connected = TRUE; | |
6982 | 2003 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
3008 | 2004 } |
2086 | 2005 od->direct_ims = g_slist_append(od->direct_ims, dim); |
3008 | 2006 |
4617 | 2007 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
2086 | 2008 } |
2009 | |
4617 | 2010 /* BBB */ |
3952 | 2011 /* |
4617 | 2012 * This is called after a remote AIM user has connected to us. We |
2013 * want to do some voodoo with the socket file descriptors, add a | |
2014 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 2015 */ |
4656 | 2016 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2017 GaimConnection *gc = sess->aux_data; |
7283 | 2018 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2019 GaimXfer *xfer; |
5146 | 2020 struct aim_oft_info *oft_info; |
3630 | 2021 va_list ap; |
2022 aim_conn_t *conn, *listenerconn; | |
4656 | 2023 |
8660 | 2024 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2025 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 2026 va_start(ap, fr); |
2027 conn = va_arg(ap, aim_conn_t *); | |
2028 listenerconn = va_arg(ap, aim_conn_t *); | |
2029 va_end(ap); | |
2030 | |
4617 | 2031 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
2032 return 1; | |
2033 | |
5146 | 2034 if (!(oft_info = xfer->data)) |
4617 | 2035 return 1; |
2036 | |
3630 | 2037 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 2038 gaim_input_remove(xfer->watcher); |
3630 | 2039 aim_conn_kill(sess, &listenerconn); |
2040 | |
5146 | 2041 oft_info->conn = conn; |
2042 xfer->fd = oft_info->conn->fd; | |
2043 | |
2044 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
2045 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
2046 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 2047 |
2048 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 2049 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 2050 |
2051 return 0; | |
2052 } | |
2053 | |
3952 | 2054 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2055 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 2056 * user in order to transfer a file. |
3952 | 2057 */ |
4617 | 2058 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
|
2059 GaimXfer *xfer; |
5146 | 2060 struct aim_oft_info *oft_info; |
4656 | 2061 |
8660 | 2062 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2063 "AAA - in oscar_sendfile_connected\n"); |
4617 | 2064 if (!(xfer = data)) |
2065 return; | |
5146 | 2066 if (!(oft_info = xfer->data)) |
3630 | 2067 return; |
8446 | 2068 if (source < 0) { |
2069 gaim_xfer_cancel_remote(xfer); | |
4617 | 2070 return; |
8446 | 2071 } |
4617 | 2072 |
2073 xfer->fd = source; | |
5146 | 2074 oft_info->conn->fd = source; |
2075 | |
2076 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
2077 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 2078 |
2079 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 2080 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 2081 |
2082 return; | |
3630 | 2083 } |
2084 | |
3952 | 2085 /* |
4617 | 2086 * This is called when a buddy sends us some file info. This happens when they |
2087 * are sending a file to you, and you have just established a connection to them. | |
4650 | 2088 * You should send them the exact same info except use the real cookie. We also |
4617 | 2089 * get like totally ready to like, receive the file, kay? |
3952 | 2090 */ |
4617 | 2091 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2092 GaimConnection *gc = sess->aux_data; |
7283 | 2093 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2094 GaimXfer *xfer; |
5146 | 2095 struct aim_oft_info *oft_info; |
4617 | 2096 va_list ap; |
2097 aim_conn_t *conn; | |
2098 fu8_t *cookie; | |
2099 struct aim_fileheader_t *fh; | |
4656 | 2100 |
8660 | 2101 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2102 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 2103 va_start(ap, fr); |
2104 conn = va_arg(ap, aim_conn_t *); | |
2105 cookie = va_arg(ap, fu8_t *); | |
2106 fh = va_arg(ap, struct aim_fileheader_t *); | |
2107 va_end(ap); | |
2108 | |
2109 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2110 return 1; | |
2111 | |
5146 | 2112 if (!(oft_info = xfer->data)) |
4617 | 2113 return 1; |
2114 | |
2115 /* We want to stop listening with a normal thingy */ | |
2116 gaim_input_remove(xfer->watcher); | |
2117 xfer->watcher = 0; | |
2118 | |
5146 | 2119 /* They sent us some information about the file they're sending */ |
2120 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
2121 | |
2122 /* Fill in the cookie */ | |
2123 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
2124 | |
4617 | 2125 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 2126 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 2127 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2128 | |
2129 return 0; | |
3630 | 2130 } |
2131 | |
3952 | 2132 /* |
4657 | 2133 * We are sending a file to someone else. They have just acknowledged our |
4617 | 2134 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 2135 */ |
4617 | 2136 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2137 GaimConnection *gc = sess->aux_data; |
7283 | 2138 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2139 GaimXfer *xfer; |
4617 | 2140 va_list ap; |
2141 aim_conn_t *conn; | |
2142 fu8_t *cookie; | |
2143 struct aim_fileheader_t *fh; | |
4656 | 2144 |
8660 | 2145 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 2146 va_start(ap, fr); |
2147 conn = va_arg(ap, aim_conn_t *); | |
2148 cookie = va_arg(ap, fu8_t *); | |
2149 fh = va_arg(ap, struct aim_fileheader_t *); | |
2150 va_end(ap); | |
2151 | |
2152 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
2153 return 1; | |
2154 | |
4656 | 2155 /* We want to stop listening with a normal thingy */ |
2156 gaim_input_remove(xfer->watcher); | |
2157 xfer->watcher = 0; | |
2158 | |
4617 | 2159 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
2160 | |
2161 return 0; | |
3630 | 2162 } |
4617 | 2163 |
2164 /* | |
2165 * We just sent a file to someone. They said they got it and everything, | |
2166 * so we can close our direct connection and what not. | |
2167 */ | |
2168 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 2169 GaimConnection *gc = sess->aux_data; |
7283 | 2170 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2171 GaimXfer *xfer; |
4617 | 2172 va_list ap; |
2173 aim_conn_t *conn; | |
2174 fu8_t *cookie; | |
2175 struct aim_fileheader_t *fh; | |
4656 | 2176 |
8660 | 2177 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 2178 va_start(ap, fr); |
2179 conn = va_arg(ap, aim_conn_t *); | |
2180 cookie = va_arg(ap, fu8_t *); | |
2181 fh = va_arg(ap, struct aim_fileheader_t *); | |
2182 va_end(ap); | |
2183 | |
2184 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2185 return 1; | |
2186 | |
4656 | 2187 xfer->fd = conn->fd; |
4617 | 2188 gaim_xfer_end(xfer); |
2189 | |
2190 return 0; | |
2191 } | |
3630 | 2192 |
4244 | 2193 static void accept_direct_im(struct ask_direct *d) { |
5575 | 2194 GaimConnection *gc = d->gc; |
7283 | 2195 OscarData *od; |
2086 | 2196 struct direct_im *dim; |
8240 | 2197 char *host; int port = 5190; |
4366 | 2198 int i, rc; |
2086 | 2199 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2200 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4244 | 2201 cancel_direct_im(d); |
2202 return; | |
2203 } | |
2204 | |
7283 | 2205 od = (OscarData *)gc->proto_data; |
8660 | 2206 gaim_debug_info("oscar", "Accepted DirectIM.\n"); |
2086 | 2207 |
2208 dim = find_direct_im(od, d->sn); | |
2209 if (dim) { | |
3730 | 2210 cancel_direct_im(d); /* 40 */ |
4244 | 2211 return; |
2086 | 2212 } |
2213 dim = g_new0(struct direct_im, 1); | |
2214 dim->gc = d->gc; | |
2215 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
2216 | |
4617 | 2217 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2218 if (!dim->conn) { |
2086 | 2219 g_free(dim); |
3730 | 2220 cancel_direct_im(d); |
4244 | 2221 return; |
2086 | 2222 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2223 |
2086 | 2224 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
4617 | 2225 gaim_odc_incoming, 0); |
2086 | 2226 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, |
4617 | 2227 gaim_odc_typing, 0); |
3033 | 2228 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
6982 | 2229 gaim_odc_update_ui, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2230 for (i = 0; i < (int)strlen(d->ip); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2231 if (d->ip[i] == ':') { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2232 port = atoi(&(d->ip[i+1])); |
2086 | 2233 break; |
2234 } | |
2235 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2236 host = g_strndup(d->ip, i); |
2086 | 2237 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2238 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
2086 | 2239 g_free(host); |
4366 | 2240 if (rc < 0) { |
2086 | 2241 aim_conn_kill(od->sess, &dim->conn); |
2242 g_free(dim); | |
3730 | 2243 cancel_direct_im(d); |
4244 | 2244 return; |
2086 | 2245 } |
2246 | |
3730 | 2247 cancel_direct_im(d); |
2086 | 2248 |
4244 | 2249 return; |
2086 | 2250 } |
2251 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2252 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 2253 GaimConnection *gc = sess->aux_data; |
7283 | 2254 OscarData *od = gc->proto_data; |
7475 | 2255 gchar *tmp; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2256 GaimConvImFlags flags = 0; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
2257 gsize convlen; |
3659 | 2258 GError *err = NULL; |
4738 | 2259 struct buddyinfo *bi; |
5575 | 2260 const char *iconfile; |
4738 | 2261 |
7261 | 2262 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, userinfo->sn)); |
4738 | 2263 if (!bi) { |
2264 bi = g_new0(struct buddyinfo, 1); | |
7261 | 2265 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, userinfo->sn)), bi); |
4738 | 2266 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2267 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2268 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2269 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2270 |
4738 | 2271 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
2272 bi->typingnot = TRUE; | |
2273 else | |
2274 bi->typingnot = FALSE; | |
2275 | |
4380 | 2276 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 2277 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2278 "%s has an icon\n", userinfo->sn); |
4738 | 2279 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
2280 bi->ico_need = TRUE; | |
2281 bi->ico_len = args->iconlen; | |
2282 bi->ico_csum = args->iconsum; | |
2283 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2284 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2285 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2286 |
5575 | 2287 if ((iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc))) && |
7406 | 2288 (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
|
2289 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2290 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2291 |
5575 | 2292 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2293 char *buf = g_malloc(st.st_size); |
5575 | 2294 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2295 if (file) { |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2296 int len = fread(buf, 1, st.st_size, file); |
8660 | 2297 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2298 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2299 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2300 userinfo->sn, len, st.st_size); |
4617 | 2301 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
2302 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2303 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2304 } else |
8660 | 2305 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2306 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2307 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2308 } else |
8660 | 2309 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2310 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2311 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2312 |
8660 | 2313 gaim_debug_misc("oscar", |
8623 | 2314 "Received message from %s with charset %hu %hu\n", |
2315 userinfo->sn, args->charset, args->charsubset); | |
2316 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2317 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 2318 /* This message is marked as UNICODE, so we have to |
2319 * convert it to utf-8 before handing it to the gaim core. | |
2320 * This conversion should *never* fail, if it does it | |
2321 * means that either the incoming ICBM is corrupted or | |
4662 | 2322 * there is something we don't understand about it. |
2323 * For the record, AIM Unicode is big-endian UCS-2 */ | |
2324 | |
8660 | 2325 gaim_debug_info("oscar", "Received UNICODE IM\n"); |
4121 | 2326 |
2327 if (!args->msg || !args->msglen) | |
2328 return 1; | |
4641 | 2329 |
3659 | 2330 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
2331 if (err) { | |
8660 | 2332 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2333 "Unicode IM conversion: %s\n", err->message); |
7475 | 2334 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 2335 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2336 } |
3722 | 2337 } else { |
3850 | 2338 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 2339 * unflagged messages, which are ASCII. That's OK because |
2340 * ASCII is a strict subset of ISO-8859-1; this should | |
2341 * help with compatibility with old, broken versions of | |
2342 * gaim (everything before 0.60) and other broken clients | |
2343 * that will happily send ISO-8859-1 without marking it as | |
2344 * such */ | |
4662 | 2345 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
8660 | 2346 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2347 "Received ISO-8859-1 IM\n"); |
4121 | 2348 |
2349 if (!args->msg || !args->msglen) | |
2350 return 1; | |
2351 | |
3659 | 2352 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
2353 if (err) { | |
8660 | 2354 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2355 "ISO-8859-1 IM conversion: %s\n", err->message); |
7475 | 2356 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 2357 g_error_free(err); |
3659 | 2358 } |
3642 | 2359 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2360 |
8493 | 2361 /* If the message came from an ICQ user then escape any HTML */ |
2362 if (isdigit(userinfo->sn[0])) { | |
8564 | 2363 gchar *tmp2; |
2364 gaim_markup_html_to_xhtml(tmp, &tmp2, NULL); | |
8493 | 2365 g_free(tmp); |
2366 tmp = tmp2; | |
2367 } | |
2368 | |
6982 | 2369 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2370 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2371 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2372 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2373 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2374 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2375 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
5575 | 2376 GaimConnection *gc = sess->aux_data; |
7283 | 2377 OscarData *od = gc->proto_data; |
5575 | 2378 const char *username = gaim_account_get_username(gaim_connection_get_account(gc)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2379 |
4121 | 2380 if (!args) |
2381 return 0; | |
4194 | 2382 |
8660 | 2383 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2384 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2385 userinfo->sn, args->status); |
2869 | 2386 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2387 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 2388 char *name; |
5234 | 2389 GHashTable *components; |
2390 | |
4121 | 2391 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
2392 return 1; | |
5234 | 2393 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
2394 g_free); | |
4121 | 2395 name = extract_name(args->info.chat.roominfo.name); |
5234 | 2396 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
2397 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
|
2398 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2399 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2400 userinfo->sn, |
6059 | 2401 args->msg, |
5234 | 2402 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2403 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2404 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2405 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 2406 /* BBB */ |
2407 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
2408 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2409 GaimXfer *xfer; |
5146 | 2410 struct aim_oft_info *oft_info; |
2411 | |
2412 if (!args->cookie || !args->port || !args->verifiedip || | |
2413 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 2414 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 2415 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2416 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2417 "information.\n", userinfo->sn); |
5146 | 2418 if (args->proxyip) |
8660 | 2419 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2420 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2421 "does not support this yet.\n"); |
4617 | 2422 return 1; |
4656 | 2423 } |
4617 | 2424 |
2425 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
2426 /* last char of the ft req is a star, they are sending us a | |
2427 * directory -- remove the star and trailing slash so we dont save | |
2428 * directories that look like 'dirname\*' -- arl */ | |
2429 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
2430 if (tmp && (tmp[1] == '*')) { | |
2431 tmp[0] = '\0'; | |
2432 } | |
8660 | 2433 gaim_debug_warning("oscar", |
8446 | 2434 "We're receiving a whole directory! What fun! " |
2435 "Especially since we don't support that!\n"); | |
4617 | 2436 } |
2437 | |
2438 /* Build the file transfer handle */ | |
2439 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 2440 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 2441 xfer->remote_port = args->port; |
4617 | 2442 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
2443 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 2444 |
2445 /* Create the oscar-specific data */ | |
5163 | 2446 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 2447 if (args->proxyip) |
5146 | 2448 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 2449 if (args->verifiedip) |
5146 | 2450 oft_info->verifiedip = g_strdup(args->verifiedip); |
2451 xfer->data = oft_info; | |
4617 | 2452 |
2453 /* Setup our I/O op functions */ | |
8446 | 2454 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 2455 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 2456 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
|
2457 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 2458 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 2459 |
2460 /* | |
2461 * XXX - Should do something with args->msg, args->encoding, and args->language | |
2462 * probably make it apply to all ch2 messages. | |
3752 | 2463 */ |
4617 | 2464 |
2465 /* Keep track of this transfer for later */ | |
2466 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2467 | |
2468 /* Now perform the request */ | |
2469 gaim_xfer_request(xfer); | |
2470 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
2471 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2472 GaimXfer *xfer; |
8660 | 2473 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2474 "AAA - File transfer canceled by remote user\n"); |
4617 | 2475 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
|
2476 gaim_xfer_cancel_remote(xfer); |
4617 | 2477 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
2478 /* | |
2479 * This gets sent by the receiver of a file | |
2480 * as they connect directly to us. If we don't | |
2481 * get this, then maybe a third party connected | |
2482 * to us, and we shouldn't send them anything. | |
2483 */ | |
2484 } else { | |
8660 | 2485 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2486 "unknown rendezvous status!\n"); |
3630 | 2487 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2488 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 2489 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2490 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2491 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2492 userinfo->sn, args->info.icon.icon, |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2493 args->info.icon.length); |
6871 | 2494 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2495 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2496 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2497 |
4212 | 2498 if (!args->verifiedip) { |
8660 | 2499 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2500 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 2501 return 1; |
4212 | 2502 } |
2503 | |
8660 | 2504 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2505 "%s received direct im request from %s (%s)\n", |
5575 | 2506 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2507 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2508 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2509 d->sn = g_strdup(userinfo->sn); |
8552 | 2510 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2511 memcpy(d->cookie, args->cookie, 8); |
5575 | 2512 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
|
2513 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2514 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2515 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2516 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2517 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2518 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2519 "risk."), 0, d, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2520 _("Connect"), G_CALLBACK(accept_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2521 _("Cancel"), G_CALLBACK(cancel_direct_im)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2522 } else { |
8660 | 2523 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2524 "Unknown reqclass %hu\n", args->reqclass); |
2246
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 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2527 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2528 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2529 |
3453 | 2530 /* |
4230 | 2531 * Authorization Functions |
2532 * Most of these are callbacks from dialogs. They're used by both | |
2533 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 2534 */ |
4269 | 2535 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2536 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 2537 GaimConnection *gc = data->gc; |
4244 | 2538 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2539 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 2540 OscarData *od = gc->proto_data; |
6695 | 2541 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
2542 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 2543 if (buddy && group) { |
8660 | 2544 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2545 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2546 buddy->name, group->name); |
4889 | 2547 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 2548 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
4889 | 2549 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
4244 | 2550 } |
4230 | 2551 } |
4337 | 2552 } |
2553 | |
2554 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2555 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
2556 NULL, _("Please authorize me!"), TRUE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2557 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 2558 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2559 data); |
4230 | 2560 } |
2561 | |
2562 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 2563 GaimConnection *gc = data->gc; |
4244 | 2564 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2565 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 2566 /* Remove from local list */ |
2567 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
2568 gaim_blist_remove_buddy(b); | |
4244 | 2569 } |
2570 | |
5836 | 2571 oscar_free_name_data(data); |
4230 | 2572 } |
2573 | |
5575 | 2574 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { |
4269 | 2575 struct name_data *data = g_new(struct name_data, 1); |
6695 | 2576 GaimBuddy *buddy; |
4269 | 2577 gchar *dialog_msg, *nombre; |
2578 | |
4687 | 2579 buddy = gaim_find_buddy(gc->account, name); |
2580 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
2581 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
4269 | 2582 else |
4830 | 2583 nombre = NULL; |
2584 | |
2585 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 | 2586 data->gc = gc; |
2587 data->name = g_strdup(name); | |
2588 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2589 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2590 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2591 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2592 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2593 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2594 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 2595 |
2596 g_free(dialog_msg); | |
2597 g_free(nombre); | |
2598 } | |
2599 | |
4230 | 2600 /* When other people ask you for authorization */ |
2601 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 2602 GaimConnection *gc = data->gc; |
4244 | 2603 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2604 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 2605 OscarData *od = gc->proto_data; |
4236 | 2606 #ifdef NOSSI |
6695 | 2607 GaimBuddy *buddy; |
4244 | 2608 gchar message; |
2609 message = 0; | |
4687 | 2610 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 2611 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
2612 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 2613 #else |
4889 | 2614 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 2615 #endif |
4244 | 2616 } |
2617 | |
5836 | 2618 oscar_free_name_data(data); |
3141 | 2619 } |
2620 | |
4230 | 2621 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2622 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 2623 GaimConnection *gc = data->gc; |
4244 | 2624 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2625 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 2626 OscarData *od = gc->proto_data; |
4230 | 2627 #ifdef NOSSI |
4617 | 2628 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 2629 #else |
4889 | 2630 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 2631 #endif |
4244 | 2632 } |
4337 | 2633 } |
2634 | |
2635 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2636 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
2637 NULL, _("No reason given."), TRUE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2638 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 2639 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2640 data); |
3141 | 2641 } |
2642 | |
7023 | 2643 /* When someone sends you buddies */ |
2644 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 2645 GaimConnection *gc = data->gc; |
4244 | 2646 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2647 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
2648 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 2649 } |
2650 | |
5836 | 2651 oscar_free_name_data(data); |
3453 | 2652 } |
2653 | |
4075 | 2654 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 | 2655 GaimConnection *gc = sess->aux_data; |
4076 | 2656 gchar **msg1, **msg2; |
2657 GError *err = NULL; | |
6051 | 2658 int i, numtoks; |
4076 | 2659 |
4121 | 2660 if (!args->type || !args->msg || !args->uin) |
2661 return 1; | |
4194 | 2662 |
8660 | 2663 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2664 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
4076 | 2665 |
2666 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 2667 msg1 = g_strsplit(args->msg, "\376", 0); |
6051 | 2668 for (numtoks=0; msg1[numtoks]; numtoks++); |
2669 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 2670 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
2671 gaim_str_strip_cr(msg1[i]); |
4076 | 2672 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); |
4800 | 2673 if (err) { |
8660 | 2674 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2675 "Error converting a string from ISO-8859-1 to " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2676 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 2677 g_error_free(err); |
2678 } | |
4076 | 2679 } |
2680 msg2[i] = NULL; | |
2681 | |
3952 | 2682 switch (args->type) { |
4173 | 2683 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 2684 if (i >= 1) { |
5556 | 2685 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 2686 gchar *tmp; |
2687 | |
2688 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 2689 tmp = gaim_escape_html(msg2[0]); |
8493 | 2690 |
4076 | 2691 if (t) { /* This is an offline message */ |
2692 /* I think this timestamp is in UTC, or something */ | |
8514 | 2693 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 2694 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 2695 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 2696 } |
2697 g_free(uin); | |
8493 | 2698 g_free(tmp); |
4075 | 2699 } |
3316 | 2700 } break; |
2701 | |
4173 | 2702 case 0x04: { /* Someone sent you a URL */ |
4076 | 2703 if (i >= 2) { |
7385 | 2704 if (msg2[1] != NULL) { |
2705 gchar *uin = g_strdup_printf("%u", args->uin); | |
2706 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
2707 msg2[1], | |
2708 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
2709 serv_got_im(gc, uin, message, 0, time(NULL)); | |
2710 g_free(uin); | |
2711 g_free(message); | |
2712 } | |
3453 | 2713 } |
2714 } break; | |
2715 | |
4173 | 2716 case 0x06: { /* Someone requested authorization */ |
4076 | 2717 if (i >= 6) { |
4230 | 2718 struct name_data *data = g_new(struct name_data, 1); |
5556 | 2719 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 | 2720 gaim_debug_info("oscar", |
5556 | 2721 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2722 args->uin); |
4076 | 2723 data->gc = gc; |
5556 | 2724 data->name = g_strdup_printf("%u", args->uin); |
4230 | 2725 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2726 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2727 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2728 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2729 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2730 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2731 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2732 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 2733 g_free(dialog_msg); |
2734 } | |
3141 | 2735 } break; |
2736 | |
4173 | 2737 case 0x07: { /* Someone has denied you authorization */ |
4076 | 2738 if (i >= 1) { |
7023 | 2739 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
|
2740 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2741 dialog_msg); |
4076 | 2742 g_free(dialog_msg); |
2743 } | |
3141 | 2744 } break; |
2745 | |
4173 | 2746 case 0x08: { /* Someone has granted you authorization */ |
7023 | 2747 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
|
2748 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2749 dialog_msg); |
3141 | 2750 g_free(dialog_msg); |
2751 } break; | |
2752 | |
4333 | 2753 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
2754 if (i >= 5) { | |
2755 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
|
2756 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 2757 g_free(dialog_msg); |
2758 } | |
2759 } break; | |
2760 | |
4173 | 2761 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 2762 if (i >= 6) { |
4194 | 2763 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
|
2764 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 2765 g_free(dialog_msg); |
2766 } | |
4075 | 2767 } break; |
2768 | |
4173 | 2769 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 2770 if (i >= 6) { |
4308 | 2771 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
|
2772 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 2773 g_free(dialog_msg); |
2774 } | |
4075 | 2775 } break; |
2776 | |
4173 | 2777 case 0x12: { |
3141 | 2778 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 2779 /* Someone added you to their buddy list? */ |
3141 | 2780 } break; |
2781 | |
7023 | 2782 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 2783 guint i, num; |
3453 | 2784 gchar **text; |
4173 | 2785 text = g_strsplit(args->msg, "\376", 0); |
3453 | 2786 if (text) { |
2787 num = 0; | |
2788 for (i=0; i<strlen(text[0]); i++) | |
2789 num = num*10 + text[0][i]-48; | |
2790 for (i=0; i<num; i++) { | |
4230 | 2791 struct name_data *data = g_new(struct name_data, 1); |
7023 | 2792 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 | 2793 data->gc = gc; |
4790 | 2794 data->name = g_strdup(text[i*2+1]); |
2795 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2796 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2797 gaim_request_action(gc, NULL, message, |
7023 | 2798 _("Do you want to add this buddy " |
2799 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2800 0, data, 2, |
7023 | 2801 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 2802 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 2803 g_free(message); |
2804 } | |
2805 g_strfreev(text); | |
2806 } | |
2807 } break; | |
2808 | |
7023 | 2809 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 2810 /* This is boring and silly. */ |
2811 } break; | |
2812 | |
3141 | 2813 default: { |
8660 | 2814 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2815 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2816 "(type 0x%02hhx).\n", args->type); |
3141 | 2817 } break; |
2818 } | |
2819 | |
4076 | 2820 g_strfreev(msg1); |
2821 g_strfreev(msg2); | |
2822 | |
3141 | 2823 return 1; |
2824 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2825 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2826 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 2827 fu16_t channel; |
2828 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2829 aim_userinfo_t *userinfo; |
2086 | 2830 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2831 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2832 va_start(ap, fr); |
4200 | 2833 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2834 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2835 |
3141 | 2836 switch (channel) { |
2837 case 1: { /* standard message */ | |
2838 struct aim_incomingim_ch1_args *args; | |
2839 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2840 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2841 } break; | |
2842 | |
2843 case 2: { /* rendevous */ | |
2844 struct aim_incomingim_ch2_args *args; | |
2845 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2846 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2847 } break; | |
2848 | |
2849 case 4: { /* ICQ */ | |
2850 struct aim_incomingim_ch4_args *args; | |
2851 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2852 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2853 } break; |
2854 | |
2855 default: { | |
8660 | 2856 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2857 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2858 "0x%04hx).", channel); |
3141 | 2859 } break; |
2086 | 2860 } |
2861 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2862 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2863 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2864 return ret; |
2086 | 2865 } |
2866 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2867 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 2868 char *buf; |
2086 | 2869 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2870 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2871 aim_userinfo_t *userinfo; |
2086 | 2872 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2873 va_start(ap, fr); |
4200 | 2874 chan = (fu16_t)va_arg(ap, unsigned int); |
2875 userinfo = va_arg(ap, aim_userinfo_t *); | |
2876 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
2877 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 2878 va_end(ap); |
2879 | |
2880 switch(reason) { | |
5420 | 2881 case 0: /* Invalid (0) */ |
2882 buf = g_strdup_printf( | |
2883 ngettext( | |
4276 | 2884 "You missed %hu message from %s because it was invalid.", |
2885 "You missed %hu messages from %s because they were invalid.", | |
2886 nummissed), | |
4282 | 2887 nummissed, |
2888 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2889 break; |
5420 | 2890 case 1: /* Message too large */ |
2891 buf = g_strdup_printf( | |
2892 ngettext( | |
4276 | 2893 "You missed %hu message from %s because it was too large.", |
2894 "You missed %hu messages from %s because they were too large.", | |
2895 nummissed), | |
4282 | 2896 nummissed, |
2897 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2898 break; |
5420 | 2899 case 2: /* Rate exceeded */ |
2900 buf = g_strdup_printf( | |
2901 ngettext( | |
4276 | 2902 "You missed %hu message from %s because the rate limit has been exceeded.", |
2903 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
2904 nummissed), | |
4282 | 2905 nummissed, |
2906 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2907 break; |
5420 | 2908 case 3: /* Evil Sender */ |
2909 buf = g_strdup_printf( | |
2910 ngettext( | |
4276 | 2911 "You missed %hu message from %s because he/she was too evil.", |
2912 "You missed %hu messages from %s because he/she was too evil.", | |
2913 nummissed), | |
4282 | 2914 nummissed, |
2915 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2916 break; |
5420 | 2917 case 4: /* Evil Receiver */ |
2918 buf = g_strdup_printf( | |
2919 ngettext( | |
4276 | 2920 "You missed %hu message from %s because you are too evil.", |
2921 "You missed %hu messages from %s because you are too evil.", | |
2922 nummissed), | |
4282 | 2923 nummissed, |
2924 userinfo->sn); | |
2086 | 2925 break; |
2926 default: | |
5420 | 2927 buf = g_strdup_printf( |
2928 ngettext( | |
4276 | 2929 "You missed %hu message from %s for an unknown reason.", |
2930 "You missed %hu messages from %s for an unknown reason.", | |
2931 nummissed), | |
4282 | 2932 nummissed, |
2933 userinfo->sn); | |
2086 | 2934 break; |
2935 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2936 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 2937 g_free(buf); |
2086 | 2938 |
2939 return 1; | |
2940 } | |
2941 | |
3212 | 2942 static char *gaim_icq_status(int state) { |
2943 /* Make a cute little string that shows the status of the dude or dudet */ | |
2944 if (state & AIM_ICQ_STATE_CHAT) | |
4342 | 2945 return g_strdup_printf(_("Free For Chat")); |
3212 | 2946 else if (state & AIM_ICQ_STATE_DND) |
4342 | 2947 return g_strdup_printf(_("Do Not Disturb")); |
3212 | 2948 else if (state & AIM_ICQ_STATE_OUT) |
4342 | 2949 return g_strdup_printf(_("Not Available")); |
3212 | 2950 else if (state & AIM_ICQ_STATE_BUSY) |
4342 | 2951 return g_strdup_printf(_("Occupied")); |
3212 | 2952 else if (state & AIM_ICQ_STATE_AWAY) |
4342 | 2953 return g_strdup_printf(_("Away")); |
3212 | 2954 else if (state & AIM_ICQ_STATE_WEBAWARE) |
4342 | 2955 return g_strdup_printf(_("Web Aware")); |
3212 | 2956 else if (state & AIM_ICQ_STATE_INVISIBLE) |
4342 | 2957 return g_strdup_printf(_("Invisible")); |
3212 | 2958 else |
4342 | 2959 return g_strdup_printf(_("Online")); |
3212 | 2960 } |
2961 | |
4194 | 2962 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 2963 GaimConnection *gc = sess->aux_data; |
7283 | 2964 OscarData *od = gc->proto_data; |
4617 | 2965 |
2966 /* BBB */ | |
3630 | 2967 switch (reason) { |
4151 | 2968 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2969 GaimXfer *xfer; |
8660 | 2970 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2971 "AAA - Other user declined file transfer\n"); |
4617 | 2972 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
|
2973 gaim_xfer_cancel_remote(xfer); |
4151 | 2974 } break; |
2975 | |
2976 default: { | |
8660 | 2977 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2978 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2979 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 2980 } |
3630 | 2981 |
2982 } | |
2983 | |
2984 return 0; | |
2985 } | |
2986 | |
4194 | 2987 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 2988 GaimConnection *gc = sess->aux_data; |
4151 | 2989 |
2990 switch(reason) { | |
2991 case 0x0003: { /* Reply from an ICQ status message request */ | |
2992 char *status_msg = gaim_icq_status(state); | |
2993 char *dialog_msg, **splitmsg; | |
2994 | |
2995 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2996 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2997 | |
7011 | 2998 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
7032 | 2999 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, dialog_msg, NULL, NULL); |
4151 | 3000 |
3001 g_free(status_msg); | |
3002 g_free(dialog_msg); | |
3003 g_strfreev(splitmsg); | |
3004 } break; | |
3005 | |
3006 default: { | |
8660 | 3007 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3008 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3009 "Type 0x%04hx\n", who, reason); |
4151 | 3010 } break; |
3011 } /* end of switch */ | |
3012 | |
3013 return 0; | |
3014 } | |
3015 | |
3212 | 3016 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3017 va_list ap; | |
3018 fu16_t chan, reason; | |
3019 char *who; | |
3020 | |
3021 va_start(ap, fr); | |
4200 | 3022 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3023 who = va_arg(ap, char *); |
4200 | 3024 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3025 |
3952 | 3026 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 3027 char *cookie = va_arg(ap, char *); |
4151 | 3028 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 3029 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 3030 fu32_t state = 0; |
4151 | 3031 char *msg = NULL; |
3032 if (reason == 0x0003) { | |
4200 | 3033 state = va_arg(ap, fu32_t); |
4151 | 3034 msg = va_arg(ap, char *); |
3035 } | |
3036 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
3037 } | |
3952 | 3038 |
3212 | 3039 va_end(ap); |
3040 | |
3041 return 1; | |
3042 } | |
3043 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3044 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3045 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3046 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3047 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3048 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3049 va_start(ap, fr); |
4199 | 3050 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3051 va_end(ap); |
3052 | |
8660 | 3053 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3054 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3055 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 3056 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3057 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 3058 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3059 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3060 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3061 |
2086 | 3062 return 1; |
3063 } | |
3064 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3065 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4617 | 3066 #if 0 |
5575 | 3067 GaimConnection *gc = sess->aux_data; |
7283 | 3068 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3069 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3070 #endif |
4617 | 3071 va_list ap; |
3072 fu16_t reason; | |
3073 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3074 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3075 va_start(ap, fr); |
4617 | 3076 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 3077 data = va_arg(ap, char *); |
2086 | 3078 va_end(ap); |
3079 | |
8660 | 3080 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3081 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 3082 |
3083 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3084 #if 0 |
4617 | 3085 /* If this was a file transfer request, data is a cookie */ |
3086 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
|
3087 gaim_xfer_cancel_remote(xfer); |
3630 | 3088 return 1; |
3089 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3090 #endif |
3630 | 3091 |
4617 | 3092 /* Data is assumed to be the destination sn */ |
3093 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3094 gaim_notify_error(sess->aux_data, NULL, buf, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3095 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
4617 | 3096 g_free(buf); |
2086 | 3097 |
3098 return 1; | |
3099 } | |
3100 | |
3595 | 3101 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3102 GaimConnection *gc = sess->aux_data; |
3595 | 3103 va_list ap; |
3104 fu16_t type1, type2; | |
3105 char *sn; | |
3106 | |
3107 va_start(ap, fr); | |
4199 | 3108 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3109 sn = va_arg(ap, char *); |
4199 | 3110 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3111 va_end(ap); |
3112 | |
3113 switch (type2) { | |
3114 case 0x0000: { /* Text has been cleared */ | |
3115 serv_got_typing_stopped(gc, sn); | |
3116 } break; | |
3117 | |
3118 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3119 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 3120 } break; |
3121 | |
3122 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3123 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 3124 } break; |
3125 | |
3126 default: { | |
8660 | 3127 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 | 3128 } break; |
3129 } | |
3130 | |
3131 return 1; | |
3132 } | |
3133 | |
7141 | 3134 /* |
3135 * We get this error when there was an error in the locate family. This | |
7259 | 3136 * happens when you request info of someone who is offline. |
7141 | 3137 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3138 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
7259 | 3139 gchar *buf; |
2086 | 3140 va_list ap; |
5420 | 3141 fu16_t reason; |
2086 | 3142 char *destn; |
3143 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3144 va_start(ap, fr); |
4199 | 3145 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3146 destn = va_arg(ap, char *); |
3147 va_end(ap); | |
3148 | |
7781 | 3149 if (destn == NULL) |
7793 | 3150 return 1; |
3151 | |
3152 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); | |
7781 | 3153 |
3154 gaim_notify_error(sess->aux_data, NULL, buf, | |
3155 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3156 g_free(buf); | |
2086 | 3157 |
3158 return 1; | |
3159 } | |
3160 | |
2920 | 3161 static char *caps_string(guint caps) |
3162 { | |
3163 static char buf[512], *tmp; | |
3164 int count = 0, i = 0; | |
3165 guint bit = 1; | |
4742 | 3166 |
3167 if (!caps) { | |
4744 | 3168 return NULL; |
6318 | 3169 } else while (bit <= AIM_CAPS_LAST) { |
2920 | 3170 if (bit & caps) { |
3171 switch (bit) { | |
6871 | 3172 case AIM_CAPS_BUDDYICON: |
2920 | 3173 tmp = _("Buddy Icon"); |
3174 break; | |
8092 | 3175 case AIM_CAPS_TALK: |
2920 | 3176 tmp = _("Voice"); |
3177 break; | |
6871 | 3178 case AIM_CAPS_DIRECTIM: |
7141 | 3179 tmp = _("AIM Direct IM"); |
2920 | 3180 break; |
6871 | 3181 case AIM_CAPS_CHAT: |
2920 | 3182 tmp = _("Chat"); |
3183 break; | |
6871 | 3184 case AIM_CAPS_GETFILE: |
2920 | 3185 tmp = _("Get File"); |
3186 break; | |
6871 | 3187 case AIM_CAPS_SENDFILE: |
2920 | 3188 tmp = _("Send File"); |
3189 break; | |
6871 | 3190 case AIM_CAPS_GAMES: |
3191 case AIM_CAPS_GAMES2: | |
2920 | 3192 tmp = _("Games"); |
3193 break; | |
8092 | 3194 case AIM_CAPS_ADDINS: |
4898 | 3195 tmp = _("Add-Ins"); |
2920 | 3196 break; |
6871 | 3197 case AIM_CAPS_SENDBUDDYLIST: |
2920 | 3198 tmp = _("Send Buddy List"); |
3199 break; | |
7141 | 3200 case AIM_CAPS_ICQ_DIRECT: |
3201 tmp = _("ICQ Direct Connect"); | |
2920 | 3202 break; |
6871 | 3203 case AIM_CAPS_APINFO: |
2920 | 3204 tmp = _("AP User"); |
3205 break; | |
6871 | 3206 case AIM_CAPS_ICQRTF: |
2920 | 3207 tmp = _("ICQ RTF"); |
3208 break; | |
6871 | 3209 case AIM_CAPS_EMPTY: |
2920 | 3210 tmp = _("Nihilist"); |
3211 break; | |
6871 | 3212 case AIM_CAPS_ICQSERVERRELAY: |
2920 | 3213 tmp = _("ICQ Server Relay"); |
3214 break; | |
6871 | 3215 case AIM_CAPS_ICQUTF8OLD: |
3216 tmp = _("Old ICQ UTF8"); | |
2920 | 3217 break; |
6871 | 3218 case AIM_CAPS_TRILLIANCRYPT: |
2920 | 3219 tmp = _("Trillian Encryption"); |
3220 break; | |
6871 | 3221 case AIM_CAPS_ICQUTF8: |
4742 | 3222 tmp = _("ICQ UTF8"); |
3223 break; | |
6318 | 3224 case AIM_CAPS_HIPTOP: |
3225 tmp = _("Hiptop"); | |
3226 break; | |
6871 | 3227 case AIM_CAPS_SECUREIM: |
7334 | 3228 tmp = _("Security Enabled"); |
6871 | 3229 break; |
7582 | 3230 case AIM_CAPS_VIDEO: |
3231 tmp = _("Video Chat"); | |
3232 break; | |
8092 | 3233 /* Not actually sure about this one... WinAIM doesn't show anything */ |
7945 | 3234 case AIM_CAPS_ICHATAV: |
3235 tmp = _("iChat AV"); | |
3236 break; | |
8092 | 3237 case AIM_CAPS_LIVEVIDEO: |
3238 tmp = _("Live Video"); | |
3239 break; | |
3240 case AIM_CAPS_CAMERA: | |
3241 tmp = _("Camera"); | |
3242 break; | |
2920 | 3243 default: |
3244 tmp = NULL; | |
3245 break; | |
3246 } | |
3247 if (tmp) | |
3248 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
3249 tmp); | |
3250 count++; | |
3251 } | |
3252 bit <<= 1; | |
3253 } | |
4744 | 3254 return buf; |
2920 | 3255 } |
3256 | |
7011 | 3257 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3258 GaimConnection *gc = sess->aux_data; |
7011 | 3259 GString *text; |
7162 | 3260 gchar *info_utf8 = NULL, *away_utf8 = NULL; |
3261 const char *final = NULL; | |
4791 | 3262 va_list ap; |
7011 | 3263 aim_userinfo_t *userinfo; |
2086 | 3264 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3265 va_start(ap, fr); |
7011 | 3266 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3267 va_end(ap); |
3268 | |
7011 | 3269 text = g_string_new(""); |
3270 g_string_append_printf(text, _("Username: <b>%s</b><br>\n"), userinfo->sn); | |
3271 g_string_append_printf(text, _("Warning Level: <b>%d%%</b><br>\n"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
3272 | |
3273 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
3274 g_string_append_printf(text, _("Online Since: <b>%s</b><br>\n"), | |
3275 asctime(localtime((time_t *)&userinfo->onlinesince))); | |
3276 | |
3277 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
3278 g_string_append_printf(text, _("Member Since: <b>%s</b><br>\n"), | |
3279 asctime(localtime((time_t *)&userinfo->membersince))); | |
3280 | |
3281 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
3282 gchar *itime = gaim_str_seconds_to_string(userinfo->idletime*60); |
7011 | 3283 g_string_append_printf(text, _("Idle: <b>%s</b>"), itime); |
4426 | 3284 g_free(itime); |
2993 | 3285 } else |
7011 | 3286 g_string_append_printf(text, _("Idle: <b>Active</b>")); |
3287 | |
3288 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 3289 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
3290 away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | |
3291 g_free(charset); | |
7011 | 3292 if (away_utf8 != NULL) { |
7129 | 3293 g_string_append_printf(text, "<hr>%s", away_utf8); |
7011 | 3294 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3295 } |
7011 | 3296 } |
3297 | |
3298 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8225 | 3299 gchar *charset = oscar_encoding_extract(userinfo->info_encoding); |
3300 info_utf8 = oscar_encoding_to_utf8(charset, userinfo->info, userinfo->info_len); | |
3301 g_free(charset); | |
7011 | 3302 if (info_utf8 != NULL) { |
7129 | 3303 g_string_append_printf(text, "<hr>%s", info_utf8); |
7011 | 3304 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3305 } |
7011 | 3306 } |
3307 | |
7164 | 3308 final = gaim_str_sub_away_formatters(text->str, gaim_account_get_username(gaim_connection_get_account(gc))); |
7011 | 3309 g_string_free(text, TRUE); |
7091 | 3310 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, final, NULL, NULL); |
4151 | 3311 |
2086 | 3312 return 1; |
3313 } | |
3314 | |
8341 | 3315 static gboolean gaim_reqinfo_timeout_cb(void *data) |
3316 { | |
3317 aim_session_t *sess = data; | |
3318 GaimConnection *gc = sess->aux_data; | |
3319 OscarData *od = (OscarData *)gc->proto_data; | |
3320 | |
3321 aim_locate_dorequest(data); | |
3322 od->getinfotimer = 0; | |
3323 | |
3324 return FALSE; | |
3325 } | |
3326 | |
3327 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
3328 { | |
3329 GaimConnection *gc = sess->aux_data; | |
3330 OscarData *od = (OscarData *)gc->proto_data; | |
3331 | |
3332 /* | |
3333 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
3334 * us from hitting the rate limit due to request away messages and info | |
3335 * too quickly. | |
3336 */ | |
3337 if (od->getinfotimer == 0) | |
3338 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
3339 | |
3340 return 1; | |
3341 } | |
3342 | |
3343 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
3344 { | |
2086 | 3345 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3346 fu16_t id; |
2086 | 3347 va_list ap; |
3348 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3349 va_start(ap, fr); |
4199 | 3350 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3351 msg = va_arg(ap, char *); |
3352 va_end(ap); | |
3353 | |
8660 | 3354 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3355 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
3356 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3357 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3358 _("Your AIM connection may be lost."), NULL); |
2086 | 3359 |
3360 return 1; | |
3361 } | |
3362 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3363 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3364 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3365 fu16_t type; |
5575 | 3366 GaimConnection *gc = sess->aux_data; |
7283 | 3367 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 3368 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3369 va_start(ap, fr); |
4199 | 3370 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3371 |
3372 switch(type) { | |
3373 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3374 fu8_t maxrooms; |
2086 | 3375 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3376 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3377 |
4199 | 3378 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 3379 exchangecount = va_arg(ap, int); |
3380 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
3381 | |
8660 | 3382 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3383 "chat info: Chat Rights:\n"); |
8660 | 3384 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3385 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 3386 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3387 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3388 for (i = 0; i < exchangecount; i++) |
8660 | 3389 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3390 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3391 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 3392 while (od->create_rooms) { |
3393 struct create_room *cr = od->create_rooms->data; | |
8660 | 3394 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3395 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3396 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3397 g_free(cr->name); |
4617 | 3398 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3399 g_free(cr); |
2086 | 3400 } |
3401 } | |
3402 break; | |
3403 case 0x0008: { | |
3404 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3405 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3406 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3407 fu32_t createtime; |
2086 | 3408 |
3409 fqcn = va_arg(ap, char *); | |
4200 | 3410 instance = (fu16_t)va_arg(ap, unsigned int); |
3411 exchange = (fu16_t)va_arg(ap, unsigned int); | |
3412 flags = (fu16_t)va_arg(ap, unsigned int); | |
3413 createtime = va_arg(ap, fu32_t); | |
3414 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3415 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
3416 createperms = (fu8_t)va_arg(ap, unsigned int); | |
3417 unknown = (fu16_t)va_arg(ap, unsigned int); | |
3418 name = va_arg(ap, char *); | |
3419 ck = va_arg(ap, char *); | |
4194 | 3420 |
8660 | 3421 gaim_debug_misc("oscar", |
5556 | 3422 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 3423 fqcn, |
3424 exchange, instance, flags, | |
3425 createtime, | |
3426 maxmsglen, maxoccupancy, createperms, unknown, | |
3427 name, ck); | |
4617 | 3428 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 3429 } |
3430 break; | |
3431 default: | |
8660 | 3432 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3433 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 3434 break; |
3435 } | |
4194 | 3436 |
3437 va_end(ap); | |
3438 | |
2086 | 3439 return 1; |
3440 } | |
3441 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3442 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3443 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3444 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3445 aim_userinfo_t *info; |
5575 | 3446 GaimConnection *g = sess->aux_data; |
2086 | 3447 |
3448 struct chat_connection *c = NULL; | |
3449 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3450 va_start(ap, fr); |
2086 | 3451 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3452 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3453 va_end(ap); |
3454 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3455 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3456 if (!c) |
3457 return 1; | |
3458 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3459 for (i = 0; i < count; i++) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3460 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3461 |
3462 return 1; | |
3463 } | |
3464 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3465 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3466 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3467 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3468 aim_userinfo_t *info; |
5575 | 3469 GaimConnection *g = sess->aux_data; |
2086 | 3470 |
3471 struct chat_connection *c = NULL; | |
3472 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3473 va_start(ap, fr); |
2086 | 3474 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3475 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3476 va_end(ap); |
3477 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3478 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3479 if (!c) |
3480 return 1; | |
3481 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3482 for (i = 0; i < count; i++) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3483 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3484 |
3485 return 1; | |
3486 } | |
3487 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3488 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
|
3489 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3490 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3491 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3492 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3493 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3494 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3495 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3496 fu32_t creationtime; |
5575 | 3497 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3498 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
|
3499 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3500 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3501 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3502 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3503 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3504 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3505 roomdesc = va_arg(ap, char *); |
4200 | 3506 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
3507 creationtime = va_arg(ap, fu32_t); | |
3508 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3509 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
3510 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
3511 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3512 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3513 |
8660 | 3514 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3515 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3516 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3517 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3518 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3519 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3520 |
2086 | 3521 return 1; |
3522 } | |
3523 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3524 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3525 GaimConnection *gc = sess->aux_data; |
8225 | 3526 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
3527 gchar *utf8; | |
2086 | 3528 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3529 aim_userinfo_t *info; |
8225 | 3530 int len; |
2086 | 3531 char *msg; |
8219 | 3532 char *charset; |
2086 | 3533 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3534 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3535 info = va_arg(ap, aim_userinfo_t *); |
8219 | 3536 len = va_arg(ap, int); |
4194 | 3537 msg = va_arg(ap, char *); |
8219 | 3538 charset = va_arg(ap, char *); |
4194 | 3539 va_end(ap); |
2086 | 3540 |
8225 | 3541 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
3542 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); | |
3543 g_free(utf8); | |
2086 | 3544 |
3545 return 1; | |
3546 } | |
3547 | |
3694 | 3548 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
3549 va_list ap; | |
5575 | 3550 GaimConnection *gc = sess->aux_data; |
3694 | 3551 struct aim_emailinfo *emailinfo; |
3725 | 3552 int havenewmail; |
7297 | 3553 char *alertitle, *alerturl; |
3694 | 3554 |
3555 va_start(ap, fr); | |
3556 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 3557 havenewmail = va_arg(ap, int); |
7301 | 3558 alertitle = va_arg(ap, char *); |
3559 alerturl = va_arg(ap, char *); | |
3694 | 3560 va_end(ap); |
3561 | |
5628 | 3562 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
5575 | 3563 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
5542 | 3564 if (emailinfo->unread && havenewmail) |
3565 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 3566 g_free(to); |
3694 | 3567 } |
7297 | 3568 |
7301 | 3569 if (alertitle) |
8660 | 3570 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 3571 |
3572 return 1; | |
3573 } | |
3574 | |
4804 | 3575 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3576 GaimConnection *gc = sess->aux_data; |
7283 | 3577 OscarData *od = gc->proto_data; |
4804 | 3578 char *sn; |
3579 | |
3580 sn = od->requesticon->data; | |
8660 | 3581 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3582 "removing %s from hash table\n", sn); |
4804 | 3583 od->requesticon = g_slist_remove(od->requesticon, sn); |
3584 free(sn); | |
3585 | |
3586 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3587 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3588 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 3589 |
3590 return 1; | |
3591 } | |
3592 | |
3593 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3594 GaimConnection *gc = sess->aux_data; |
7283 | 3595 OscarData *od = gc->proto_data; |
4804 | 3596 GSList *cur; |
3597 va_list ap; | |
3598 char *sn; | |
4853 | 3599 fu8_t *iconcsum, *icon; |
3600 fu16_t iconcsumlen, iconlen; | |
4804 | 3601 |
3602 va_start(ap, fr); | |
3603 sn = va_arg(ap, char *); | |
4853 | 3604 iconcsum = va_arg(ap, fu8_t *); |
3605 iconcsumlen = va_arg(ap, int); | |
4804 | 3606 icon = va_arg(ap, fu8_t *); |
3607 iconlen = va_arg(ap, int); | |
3608 va_end(ap); | |
3609 | |
4853 | 3610 if (iconlen > 0) { |
3611 char *b16; | |
6695 | 3612 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3613 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3614 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3615 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 3616 if (b16) { |
7693 | 3617 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
5129 | 3618 gaim_blist_save(); |
7162 | 3619 g_free(b16); |
5129 | 3620 } |
4853 | 3621 } |
4804 | 3622 |
3623 cur = od->requesticon; | |
3624 while (cur) { | |
3625 char *cursn = cur->data; | |
3626 if (!aim_sncmp(cursn, sn)) { | |
3627 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
3628 free(cursn); | |
3629 cur = od->requesticon; | |
3630 } else | |
3631 cur = cur->next; | |
3632 } | |
3633 | |
3634 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3635 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3636 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 3637 |
3638 return 1; | |
3639 } | |
3640 | |
3641 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 3642 GaimConnection *gc = data; |
7283 | 3643 OscarData *od = gc->proto_data; |
7011 | 3644 aim_userinfo_t *userinfo; |
4804 | 3645 aim_conn_t *conn; |
3646 | |
3647 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 3648 if (!conn) { |
3649 if (!od->iconconnecting) { | |
3650 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
3651 od->iconconnecting = TRUE; | |
3652 } | |
4804 | 3653 return FALSE; |
3654 } | |
3655 | |
5842 | 3656 if (od->set_icon) { |
6039 | 3657 struct stat st; |
3658 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
3659 if (iconfile == NULL) { | |
8363 | 3660 aim_ssi_delicon(od->sess); |
6039 | 3661 } else if (!stat(iconfile, &st)) { |
3662 char *buf = g_malloc(st.st_size); | |
3663 FILE *file = fopen(iconfile, "rb"); | |
3664 if (file) { | |
3665 fread(buf, 1, st.st_size, file); | |
3666 fclose(file); | |
8660 | 3667 gaim_debug_info("oscar", |
6039 | 3668 "Uploading icon to icon server\n"); |
6879 | 3669 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 3670 } else |
8660 | 3671 gaim_debug_error("oscar", |
6039 | 3672 "Can't open buddy icon file!\n"); |
3673 g_free(buf); | |
3674 } else { | |
8660 | 3675 gaim_debug_error("oscar", |
6039 | 3676 "Can't stat buddy icon file!\n"); |
5842 | 3677 } |
3678 od->set_icon = FALSE; | |
3679 } | |
3680 | |
3681 if (!od->requesticon) { | |
8660 | 3682 gaim_debug_misc("oscar", |
5842 | 3683 "no more icons to request\n"); |
3684 return FALSE; | |
3685 } | |
3686 | |
7045 | 3687 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 3688 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
3689 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 3690 return FALSE; |
3691 } else { | |
3692 char *sn = od->requesticon->data; | |
3693 od->requesticon = g_slist_remove(od->requesticon, sn); | |
3694 free(sn); | |
3695 } | |
3696 | |
3697 return TRUE; | |
3698 } | |
3699 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3700 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3701 * 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
|
3702 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3703 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3704 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3705 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3706 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3707 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3708 va_start(ap, fr); |
4199 | 3709 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3710 sn = va_arg(ap, char *); |
3711 va_end(ap); | |
3712 | |
8660 | 3713 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 3714 |
3715 return 1; | |
3716 } | |
3717 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3718 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
|
3719 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3720 "invalid", |
4194 | 3721 "change", |
3722 "warning", | |
3723 "limit", | |
3724 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3725 }; |
2086 | 3726 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3727 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3728 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3729 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3730 va_start(ap, fr); |
4200 | 3731 code = (fu16_t)va_arg(ap, unsigned int); |
3732 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
3733 windowsize = va_arg(ap, fu32_t); | |
3734 clear = va_arg(ap, fu32_t); | |
3735 alert = va_arg(ap, fu32_t); | |
3736 limit = va_arg(ap, fu32_t); | |
3737 disconnect = va_arg(ap, fu32_t); | |
3738 currentavg = va_arg(ap, fu32_t); | |
3739 maxavg = va_arg(ap, fu32_t); | |
2086 | 3740 va_end(ap); |
3741 | |
8660 | 3742 gaim_debug_misc("oscar", |
5556 | 3743 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
3744 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 3745 (code < 5) ? codes[code] : codes[0], |
3746 rateclass, | |
3747 currentavg, maxavg, | |
3748 alert, clear, | |
3749 limit, disconnect, | |
3750 windowsize); | |
3751 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3752 /* XXX fix these values */ |
2086 | 3753 if (code == AIM_RATE_CODE_CHANGE) { |
3754 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3755 aim_conn_setlatency(fr->conn, 0); |
2086 | 3756 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3757 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3758 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3759 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 3760 _("The last action you attempted could not be " |
3761 "performed because you are over the rate limit. " | |
3762 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3763 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3764 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3765 aim_conn_setlatency(fr->conn, 0); |
2086 | 3766 } |
3767 | |
3768 return 1; | |
3769 } | |
3770 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3771 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3772 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3773 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3774 aim_userinfo_t *userinfo; |
5575 | 3775 GaimConnection *gc = sess->aux_data; |
2086 | 3776 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3777 va_start(ap, fr); |
4199 | 3778 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3779 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3780 va_end(ap); |
3781 | |
7111 | 3782 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 3783 |
3784 return 1; | |
3785 } | |
3786 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3787 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3788 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3789 aim_userinfo_t *info; |
5575 | 3790 GaimConnection *gc = sess->aux_data; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3791 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3792 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3793 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3794 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3795 |
5628 | 3796 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 3797 |
7872 | 3798 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 3799 gc->login_time_official = info->onlinesince; |
7872 | 3800 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
3801 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3802 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3803 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3804 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3805 |
4649 | 3806 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3807 GaimConnection *gc = sess->aux_data; |
7283 | 3808 OscarData *od = gc->proto_data; |
4649 | 3809 va_list ap; |
3810 fu16_t code; | |
3811 char *msg; | |
3812 | |
3813 va_start(ap, fr); | |
3814 code = (fu16_t)va_arg(ap, int); | |
3815 msg = va_arg(ap, char *); | |
3816 va_end(ap); | |
3817 | |
8660 | 3818 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3819 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 3820 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 3821 if (code == 0x0001) { |
6113 | 3822 gc->wants_to_die = TRUE; |
5579 | 3823 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 3824 } else { |
5579 | 3825 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 3826 } |
4666 | 3827 od->killme = TRUE; |
4649 | 3828 } |
3829 | |
3830 return 1; | |
3831 } | |
3832 | |
2675 | 3833 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 3834 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3835 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3836 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 3837 |
3838 #ifndef NOSSI | |
8660 | 3839 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 3840 aim_ssi_reqrights(sess); |
6350 | 3841 aim_ssi_reqdata(sess); |
4230 | 3842 #endif |
3843 | |
7011 | 3844 aim_locate_reqrights(sess); |
7285 | 3845 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 3846 aim_im_reqparams(sess); |
7334 | 3847 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 3848 |
3849 #ifdef NOSSI | |
8660 | 3850 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 3851 aim_bos_reqrights(sess, fr->conn); |
4230 | 3852 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
3853 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3854 #endif | |
2086 | 3855 |
7283 | 3856 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
3857 | |
2086 | 3858 return 1; |
3859 } | |
3860 | |
2675 | 3861 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3862 GaimConnection *gc = sess->aux_data; |
7283 | 3863 OscarData *od = gc->proto_data; |
2647 | 3864 |
6905 | 3865 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
3866 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
3867 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
3868 | |
2672 | 3869 aim_clientready(sess, fr->conn); |
8660 | 3870 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3871 |
2647 | 3872 if (od->chpass) { |
8660 | 3873 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3874 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3875 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3876 od->oldp = NULL; |
2647 | 3877 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3878 od->newp = NULL; |
2647 | 3879 od->chpass = FALSE; |
3880 } | |
2979 | 3881 if (od->setnick) { |
8660 | 3882 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 3883 aim_admin_setnick(sess, fr->conn, od->newsn); |
3884 g_free(od->newsn); | |
3885 od->newsn = NULL; | |
3886 od->setnick = FALSE; | |
3887 } | |
2647 | 3888 if (od->conf) { |
8660 | 3889 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3890 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3891 od->conf = FALSE; |
3892 } | |
3893 if (od->reqemail) { | |
8660 | 3894 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3895 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3896 od->reqemail = FALSE; |
3897 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3898 if (od->setemail) { |
8660 | 3899 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3900 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3901 g_free(od->email); |
5497 | 3902 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3903 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3904 } |
2647 | 3905 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3906 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3907 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3908 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3909 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
|
3910 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3911 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3912 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3913 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3914 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3915 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3916 |
4194 | 3917 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 3918 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 3919 "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
|
3920 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3921 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3922 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3923 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3924 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3925 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3926 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3927 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3928 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3929 |
4617 | 3930 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3931 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3932 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3933 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3934 |
2993 | 3935 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3936 { | |
5575 | 3937 GaimConnection *gc = sess->aux_data; |
7283 | 3938 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 3939 va_list ap; |
3940 fu16_t maxsiglen; | |
2993 | 3941 |
3942 va_start(ap, fr); | |
4199 | 3943 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 3944 va_end(ap); |
3945 | |
8660 | 3946 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3947 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 3948 |
4617 | 3949 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3950 | |
3951 if (od->icq) | |
7334 | 3952 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 3953 else |
7334 | 3954 aim_locate_setcaps(od->sess, caps_aim); |
3955 oscar_set_info(gc, gc->account->user_info); | |
2993 | 3956 |
3957 return 1; | |
3958 } | |
3959 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3960 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
|
3961 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3962 fu16_t maxbuddies, maxwatchers; |
5575 | 3963 GaimConnection *gc = sess->aux_data; |
7283 | 3964 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3965 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3966 va_start(ap, fr); |
4199 | 3967 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
3968 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3969 va_end(ap); |
3970 | |
8660 | 3971 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3972 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 3973 |
4617 | 3974 od->rights.maxbuddies = (guint)maxbuddies; |
3975 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 3976 |
2086 | 3977 return 1; |
3978 } | |
3979 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3980 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3981 GaimConnection *gc = sess->aux_data; |
7283 | 3982 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 3983 va_list ap; |
3984 fu16_t maxpermits, maxdenies; | |
2086 | 3985 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3986 va_start(ap, fr); |
4199 | 3987 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
3988 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3989 va_end(ap); |
3990 | |
8660 | 3991 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3992 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 3993 |
4617 | 3994 od->rights.maxpermits = (guint)maxpermits; |
3995 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 3996 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
3997 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 3998 serv_finish_login(gc); |
3999 | |
8660 | 4000 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4001 |
2672 | 4002 aim_clientready(sess, fr->conn); |
5948 | 4003 aim_srv_setavailmsg(sess, NULL); |
7474 | 4004 aim_srv_setidle(sess, 0); |
4617 | 4005 |
4664 | 4006 if (od->icq) { |
4007 aim_icq_reqofflinemsgs(sess); | |
4008 aim_icq_hideip(sess); | |
4009 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4010 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4011 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4012 if (sess->authinfo->email) |
4013 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4014 |
4015 return 1; | |
4016 } | |
4017 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4018 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
|
4019 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4020 struct aim_icq_offlinemsg *msg; |
4075 | 4021 struct aim_incomingim_ch4_args args; |
4022 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4023 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4024 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4025 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4026 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4027 |
8660 | 4028 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4029 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4030 args.uin = msg->sender; |
4031 args.type = msg->type; | |
4173 | 4032 args.flags = msg->flags; |
4076 | 4033 args.msglen = msg->msglen; |
4075 | 4034 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4035 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4036 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4037 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4038 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4039 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4040 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4041 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
|
4042 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4043 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4044 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4045 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4046 |
7388 | 4047 #if 0 |
4048 /* | |
7465 | 4049 * Update, 2003-11-09: |
4050 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4051 * | |
7388 | 4052 * It may not be my place to do this, but... |
4053 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4054 * stupid, and should not exist for % switches (%x in our case) that request | |
4055 * a year in the preferred representation for the current locale. For that | |
4056 * reason I've chosen to not use this workaround (n., see kluge). | |
4057 * | |
4058 * I have a date. I want to show it to the user in the "preferred" way. | |
4059 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4060 * what the locale wanted. | |
4061 * | |
4062 * If I have a necessity for a full representation of the year in the current | |
4063 * locale, then I'll use a switch that returns a full representation of the | |
4064 * year. | |
4065 * | |
4066 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4067 * (because you're anal, or whatever), then change the f***ing locale. | |
4068 * | |
4069 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4070 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4071 * |
4072 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4073 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4074 */ |
4075 | |
4076 /* | |
4077 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4078 * "last 2 digits" warning. |
4079 */ | |
4080 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4081 const struct tm *tm) | |
4082 { | |
4083 return strftime(s, max, fmt, tm); | |
4084 } | |
7388 | 4085 #endif |
7386 | 4086 |
4624 | 4087 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
|
4088 { |
5575 | 4089 GaimConnection *gc = sess->aux_data; |
4819 | 4090 gchar *buf, *tmp, *utf8; |
4624 | 4091 gchar who[16]; |
6873 | 4092 GaimBuddy *buddy; |
4093 gchar *primary; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4094 va_list ap; |
4151 | 4095 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4096 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4097 va_start(ap, fr); |
4151 | 4098 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4099 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4100 |
4664 | 4101 if (!info->uin) |
4102 return 0; | |
4103 | |
5556 | 4104 g_snprintf(who, sizeof(who), "%u", info->uin); |
6623 | 4105 buf = g_strdup_printf("<b>%s:</b> %s", _("UIN"), who); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4106 if (info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
6623 | 4107 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 4108 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4109 if (info->first && info->first[0] && (utf8 = gaim_utf8_try_convert(info->first))) { |
6623 | 4110 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 4111 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4112 if (info->last && info->last[0] && (utf8 = gaim_utf8_try_convert(info->last))) { |
6623 | 4113 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 4114 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4115 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
6623 | 4116 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address"), ":</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4625 | 4117 } |
4118 if (info->numaddresses && info->email2) { | |
4119 int i; | |
4120 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4121 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
6623 | 4122 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address"), ":</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4643 | 4123 } |
4625 | 4124 } |
4624 | 4125 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4126 if (info->mobile && info->mobile[0] && (utf8 = gaim_utf8_try_convert(info->mobile))) { |
6623 | 4127 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4625 | 4128 } |
4129 if (info->gender) { | |
6623 | 4130 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender"), ":</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); |
4151 | 4131 } |
4624 | 4132 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 4133 char date[30]; |
4134 struct tm tm; | |
4135 tm.tm_mday = (int)info->birthday; | |
4136 tm.tm_mon = (int)info->birthmonth-1; | |
4137 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 4138 strftime(date, sizeof(date), "%x", &tm); |
6623 | 4139 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday"), ":</b> ", date, NULL); g_free(tmp); |
4151 | 4140 } |
4624 | 4141 if (info->age) { |
4142 char age[5]; | |
4143 snprintf(age, sizeof(age), "%hhd", info->age); | |
6623 | 4144 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age"), ":</b> ", age, NULL); g_free(tmp); |
4819 | 4145 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4146 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
6623 | 4147 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Personal Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4819 | 4148 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4149 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
6623 | 4150 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information"), ":</b><br>", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4151 } |
4152 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | |
4641 | 4153 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
6623 | 4154 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Home Address"), ":</b>", NULL); g_free(tmp); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4155 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_utf8_try_convert(info->homeaddr))) { |
6623 | 4156 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4157 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4158 if (info->homecity && info->homecity[0] && (utf8 = gaim_utf8_try_convert(info->homecity))) { |
6623 | 4159 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4160 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4161 if (info->homestate && info->homestate[0] && (utf8 = gaim_utf8_try_convert(info->homestate))) { |
6623 | 4162 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4163 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4164 if (info->homezip && info->homezip[0] && (utf8 = gaim_utf8_try_convert(info->homezip))) { |
6623 | 4165 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4166 } |
4167 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 4168 } |
4641 | 4169 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
6623 | 4170 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Address"), ":</b>", NULL); g_free(tmp); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4171 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_utf8_try_convert(info->workaddr))) { |
6623 | 4172 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4173 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4174 if (info->workcity && info->workcity[0] && (utf8 = gaim_utf8_try_convert(info->workcity))) { |
6623 | 4175 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4176 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4177 if (info->workstate && info->workstate[0] && (utf8 = gaim_utf8_try_convert(info->workstate))) { |
6623 | 4178 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4179 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4180 if (info->workzip && info->workzip[0] && (utf8 = gaim_utf8_try_convert(info->workzip))) { |
6623 | 4181 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4182 } |
4183 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4184 } | |
4641 | 4185 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
6623 | 4186 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Information"), ":</b>", NULL); g_free(tmp); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4187 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_utf8_try_convert(info->workcompany))) { |
6623 | 4188 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4189 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4190 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_utf8_try_convert(info->workdivision))) { |
6623 | 4191 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4192 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4193 if (info->workposition && info->workposition[0] && (utf8 = gaim_utf8_try_convert(info->workposition))) { |
6623 | 4194 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4195 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4196 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
6623 | 4197 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); |
4624 | 4198 } |
4199 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 4200 } |
4201 | |
6873 | 4202 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4203 primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); | |
4204 gaim_notify_formatted(gc, NULL, primary, NULL, buf, NULL, NULL); | |
4205 g_free(primary); | |
4151 | 4206 g_free(buf); |
4207 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4208 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4209 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4210 |
4759 | 4211 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
4212 { | |
5575 | 4213 GaimConnection *gc = sess->aux_data; |
4820 | 4214 gchar who[16], *utf8; |
6695 | 4215 GaimBuddy *b; |
4759 | 4216 va_list ap; |
4217 struct aim_icq_info *info; | |
4218 | |
4219 va_start(ap, fr); | |
4220 info = va_arg(ap, struct aim_icq_info *); | |
4221 va_end(ap); | |
4222 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4223 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 4224 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4225 serv_got_alias(gc, who, utf8); |
4759 | 4226 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 4227 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 4228 gaim_blist_save(); |
4229 } | |
4820 | 4230 g_free(utf8); |
4759 | 4231 } |
4232 | |
4233 return 1; | |
4234 } | |
4235 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4236 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
|
4237 { |
7032 | 4238 GaimConnection *gc = sess->aux_data; |
4239 gchar *text; | |
4240 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4241 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4242 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4243 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4244 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4245 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4246 url = va_arg(ap, char *); |
4199 | 4247 wid = (fu16_t) va_arg(ap, int); |
4248 hei = (fu16_t) va_arg(ap, int); | |
4249 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4250 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4251 |
7032 | 4252 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
4253 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
4254 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4255 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4256 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4257 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4258 |
7032 | 4259 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
4260 { | |
6873 | 4261 GaimConnection *gc = sess->aux_data; |
4262 gchar *secondary; | |
4263 GString *text; | |
4264 int i, num; | |
2086 | 4265 va_list ap; |
6873 | 4266 char *email, *SNs; |
2086 | 4267 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4268 va_start(ap, fr); |
6873 | 4269 email = va_arg(ap, char *); |
2086 | 4270 num = va_arg(ap, int); |
4271 SNs = va_arg(ap, char *); | |
4272 va_end(ap); | |
4273 | |
8152 | 4274 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 4275 text = g_string_new(""); |
2086 | 4276 for (i = 0; i < num; i++) |
6873 | 4277 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4278 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
4279 | |
4280 g_free(secondary); | |
4281 g_string_free(text, TRUE); | |
2086 | 4282 |
4283 return 1; | |
4284 } | |
4285 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4286 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4287 va_list ap; |
6873 | 4288 char *email; |
5420 | 4289 char *buf; |
2086 | 4290 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4291 va_start(ap, fr); |
6873 | 4292 email = va_arg(ap, char *); |
2086 | 4293 va_end(ap); |
4294 | |
6873 | 4295 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
|
4296 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4297 g_free(buf); |
2086 | 4298 |
4299 return 1; | |
4300 } | |
4301 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4302 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 4303 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4304 fu16_t status; |
2086 | 4305 va_list ap; |
4306 char msg[256]; | |
4307 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4308 va_start(ap, fr); |
4199 | 4309 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 4310 va_end(ap); |
4311 | |
8660 | 4312 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4313 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 4314 status ? "unknown" : "email sent"); |
4315 if (!status) { | |
5302 | 4316 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 4317 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4318 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 4319 } |
4320 | |
4321 return 1; | |
4322 } | |
4323 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4324 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4325 GaimConnection *gc = sess->aux_data; |
2086 | 4326 va_list ap; |
3912 | 4327 fu16_t perms, err; |
4328 char *url, *sn, *email; | |
4329 int change; | |
2086 | 4330 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4331 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4332 change = va_arg(ap, int); |
4199 | 4333 perms = (fu16_t) va_arg(ap, unsigned int); |
4334 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 4335 url = va_arg(ap, char *); |
4336 sn = va_arg(ap, char *); | |
4337 email = va_arg(ap, char *); | |
2086 | 4338 va_end(ap); |
4339 | |
8660 | 4340 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4341 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
3912 | 4342 change ? "change" : "request", perms, err, url, sn, email); |
4343 | |
4344 if (err && url) { | |
4345 char *dialog_msg; | |
4346 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
4347 switch (err) { | |
4348 case 0x0001: { | |
4349 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
4350 } break; | |
4351 case 0x0006: { | |
4352 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
4353 } break; | |
4354 case 0x000b: { | |
4355 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
4356 } break; | |
4357 case 0x001d: { | |
4358 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); | |
4359 } break; | |
4360 case 0x0021: { | |
4361 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); | |
4362 } break; | |
4363 case 0x0023: { | |
4364 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
4365 } break; | |
4366 default: { | |
4367 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
4368 } break; | |
4369 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4370 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 4371 g_free(dialog_top); |
4372 g_free(dialog_msg); | |
4373 return 1; | |
4374 } | |
4375 | |
4376 if (sn) { | |
4585 | 4377 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
|
4378 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4379 g_free(dialog_msg); |
4380 } | |
4381 | |
4382 if (email) { | |
5575 | 4383 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
4384 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4385 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4386 g_free(dialog_msg); |
2086 | 4387 } |
4388 | |
4389 return 1; | |
4390 } | |
4391 | |
5575 | 4392 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 4393 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4394 aim_flap_nop(od->sess, od->conn); |
2086 | 4395 } |
4396 | |
6059 | 4397 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 4398 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4399 struct direct_im *dim = find_direct_im(od, name); |
3595 | 4400 if (dim) |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4401 if (typing == GAIM_TYPING) |
4870 | 4402 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4403 else if (typing == GAIM_TYPED) |
4870 | 4404 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
4405 else | |
4406 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 4407 else { |
5300 | 4408 /* Don't send if this turkey is in our deny list */ |
4409 GSList *list; | |
4410 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
4411 if (!list) { | |
7261 | 4412 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 4413 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4414 if (typing == GAIM_TYPING) |
5300 | 4415 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4416 else if (typing == GAIM_TYPED) |
5300 | 4417 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
4418 else | |
4419 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
4420 } | |
3595 | 4421 } |
4422 } | |
2993 | 4423 return 0; |
4424 } | |
5575 | 4425 static void oscar_ask_direct_im(GaimConnection *gc, const char *name); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4426 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
|
4427 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4428 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 4429 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4430 struct direct_im *dim = find_direct_im(od, name); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4431 int ret = 0; |
3659 | 4432 GError *err = NULL; |
5575 | 4433 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
4434 char *tmpmsg = NULL; |
3458 | 4435 |
4838 | 4436 if (dim && dim->connected) { |
4437 /* If we're directly connected, send a direct IM */ | |
6982 | 4438 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4439 } else if (imflags & GAIM_CONV_IM_IMAGES) { |
3044 | 4440 /* Trying to send an IM image outside of a direct connection. */ |
4441 oscar_ask_direct_im(gc, name); | |
4838 | 4442 ret = -ENOTCONN; |
2086 | 4443 } else { |
4738 | 4444 struct buddyinfo *bi; |
3008 | 4445 struct aim_sendimext_args args; |
4446 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4447 gsize len; |
4269 | 4448 |
7261 | 4449 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 4450 if (!bi) { |
4451 bi = g_new0(struct buddyinfo, 1); | |
7261 | 4452 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 4453 } |
4454 | |
3008 | 4455 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 4456 if (od->icq) { |
4457 args.features = features_icq; | |
4458 args.featureslen = sizeof(features_icq); | |
3008 | 4459 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 4460 } else { |
4461 args.features = features_aim; | |
4462 args.featureslen = sizeof(features_aim); | |
4972 | 4463 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4464 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 4465 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 4466 } |
4269 | 4467 |
4738 | 4468 if (bi->ico_need) { |
8660 | 4469 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4470 "Sending buddy icon request with message\n"); |
3008 | 4471 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 4472 bi->ico_need = FALSE; |
3008 | 4473 } |
4269 | 4474 |
5575 | 4475 if (iconfile && !stat(iconfile, &st)) { |
8361 | 4476 FILE *file = fopen(iconfile, "rb"); |
3008 | 4477 if (file) { |
4478 char *buf = g_malloc(st.st_size); | |
4479 fread(buf, 1, st.st_size, file); | |
6039 | 4480 fclose(file); |
4269 | 4481 |
3008 | 4482 args.iconlen = st.st_size; |
4617 | 4483 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 4484 args.iconstamp = st.st_mtime; |
4485 | |
7406 | 4486 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 4487 bi->ico_informed = FALSE; |
7406 | 4488 bi->ico_sent = FALSE; |
4489 } | |
4738 | 4490 |
4491 if (!bi->ico_informed) { | |
8660 | 4492 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4493 "Claiming to have a buddy icon\n"); |
4738 | 4494 args.flags |= AIM_IMFLAGS_HASICON; |
4495 bi->ico_me_len = args.iconlen; | |
4496 bi->ico_me_csum = args.iconsum; | |
4497 bi->ico_me_time = args.iconstamp; | |
4498 bi->ico_informed = TRUE; | |
4499 } | |
4500 | |
3008 | 4501 g_free(buf); |
2086 | 4502 } |
4503 } | |
4269 | 4504 |
3008 | 4505 args.destsn = name; |
4269 | 4506 |
6310 | 4507 /* For ICQ send newlines as CR/LF, for AIM send newlines as <BR> */ |
4508 if (isdigit(name[0])) | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4509 tmpmsg = gaim_str_add_cr(message); |
6310 | 4510 else |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4511 tmpmsg = gaim_strdup_withhtml(message); |
6310 | 4512 len = strlen(tmpmsg); |
4513 | |
4514 args.flags |= oscar_encoding_check(tmpmsg); | |
3642 | 4515 if (args.flags & AIM_IMFLAGS_UNICODE) { |
8660 | 4516 gaim_debug_info("oscar", "Sending Unicode IM\n"); |
4662 | 4517 args.charset = 0x0002; |
4665 | 4518 args.charsubset = 0x0000; |
6310 | 4519 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3659 | 4520 if (err) { |
8660 | 4521 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4522 "Error converting a unicode message: %s\n", err->message); |
8660 | 4523 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4524 "This really shouldn't happen!\n"); |
3659 | 4525 /* We really shouldn't try to send the |
4526 * IM now, but I'm not sure what to do */ | |
4800 | 4527 g_error_free(err); |
3659 | 4528 } |
3850 | 4529 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 4530 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4531 "Sending ISO-8859-1 IM\n"); |
4662 | 4532 args.charset = 0x0003; |
4665 | 4533 args.charsubset = 0x0000; |
6310 | 4534 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3659 | 4535 if (err) { |
8660 | 4536 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4537 "conversion error: %s\n", err->message); |
8660 | 4538 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4539 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 4540 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
6310 | 4541 len = strlen(tmpmsg); |
4800 | 4542 g_error_free(err); |
6310 | 4543 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3659 | 4544 if (err) { |
8660 | 4545 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4546 "Error in unicode fallback: %s\n", err->message); |
4800 | 4547 g_error_free(err); |
3659 | 4548 } |
3642 | 4549 } |
4550 } else { | |
4662 | 4551 args.charset = 0x0000; |
4552 args.charsubset = 0x0000; | |
6310 | 4553 args.msg = tmpmsg; |
3642 | 4554 } |
4555 args.msglen = len; | |
4269 | 4556 |
4617 | 4557 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 4558 } |
4838 | 4559 |
6310 | 4560 g_free(tmpmsg); |
4561 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4562 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4563 return 1; |
6310 | 4564 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4565 return ret; |
2086 | 4566 } |
4567 | |
7011 | 4568 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 4569 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 4570 |
7173 | 4571 if (od->icq && isdigit(name[0])) |
4624 | 4572 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4573 else |
7235 | 4574 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 4575 } |
4576 | |
4577 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, | |
3466 | 4578 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 4579 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 4580 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 4581 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 4582 maiden, NULL, NULL, city, state, NULL, 0, web); |
4583 } | |
4584 | |
5575 | 4585 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 4586 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 4587 aim_srv_setidle(od->sess, time); |
2086 | 4588 } |
4589 | |
5954 | 4590 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 4591 OscarData *od = (OscarData *)gc->proto_data; |
5129 | 4592 fu32_t flags = 0; |
6019 | 4593 char *text_html = NULL; |
5129 | 4594 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4595 gsize msglen = 0; |
2993 | 4596 |
4617 | 4597 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4598 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4599 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4600 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4601 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4602 "again when you are fully connected.")); |
4617 | 4603 |
7334 | 4604 if (!text) { |
4605 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
4606 return; | |
4607 } | |
6019 | 4608 |
7334 | 4609 text_html = gaim_strdup_withhtml(text); |
4610 flags = oscar_encoding_check(text_html); | |
4611 if (flags & AIM_IMFLAGS_UNICODE) { | |
4612 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
4613 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
4614 g_free(msg); | |
4615 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
4616 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
4617 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
4618 g_free(msg); | |
4619 } else { | |
4620 msglen = strlen(text_html); | |
4621 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
4622 } | |
4623 | |
4624 if (msglen > od->rights.maxsiglen) { | |
4625 gchar *errstr; | |
4626 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
4627 "has been exceeded. Gaim has truncated it for you.", | |
4628 "The maximum profile length of %d bytes " | |
4629 "has been exceeded. Gaim has truncated it for you.", | |
4630 od->rights.maxsiglen), od->rights.maxsiglen); | |
4631 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
4632 g_free(errstr); | |
4633 } | |
4634 | |
4635 g_free(text_html); | |
2993 | 4636 |
4637 return; | |
2086 | 4638 } |
4639 | |
8257 | 4640 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 4641 { |
5129 | 4642 fu32_t flags = 0; |
6019 | 4643 gchar *text_html = NULL; |
5129 | 4644 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4645 gsize msglen = 0; |
2993 | 4646 |
8257 | 4647 if (!strcmp(state, _("Visible"))) { |
4648 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
4649 return; | |
4650 } else if (!strcmp(state, _("Invisible"))) { | |
4651 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
4652 return; | |
4653 } /* else... */ | |
4654 | |
8476 | 4655 if (!strcmp(state, _("Back"))) { |
4656 /* If this is our only online account then globally set Gaim not-away */ | |
4657 GList *gcs = gaim_connections_get_all(); | |
4658 if (gcs->next == NULL) | |
4659 do_im_back(NULL, NULL); | |
4660 } | |
4661 | |
8257 | 4662 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4663 | |
2993 | 4664 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4665 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4666 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4667 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4668 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4669 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4670 "fully connected.")); |
5129 | 4671 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4672 if (gc->away) { |
2993 | 4673 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4674 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4675 } |
2993 | 4676 |
5129 | 4677 if (!text) { |
7334 | 4678 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4679 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4680 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4681 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4682 text_html = gaim_strdup_withhtml(text); |
6019 | 4683 flags = oscar_encoding_check(text_html); |
5129 | 4684 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 4685 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 4686 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 4687 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 4688 g_free(msg); |
4689 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
4690 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 4691 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 4692 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 4693 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 4694 g_free(msg); |
6019 | 4695 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 4696 } else { |
6019 | 4697 msglen = strlen(text_html); |
7011 | 4698 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 4699 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 4700 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 4701 } |
4702 | |
4703 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 4704 gchar *errstr; |
4705 | |
6308 | 4706 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
4707 "has been exceeded. Gaim has truncated it for you.", | |
4708 "The maximum away message length of %d bytes " | |
4709 "has been exceeded. Gaim has truncated it for you.", | |
4710 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4711 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 4712 g_free(errstr); |
4713 } | |
6019 | 4714 |
4715 g_free(text_html); | |
8257 | 4716 |
2993 | 4717 return; |
4718 } | |
4719 | |
7283 | 4720 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 4721 { |
5575 | 4722 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4723 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4724 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4725 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4726 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4727 |
8265 | 4728 if (strcmp(state, _("Invisible"))) |
5575 | 4729 account->perm_deny = 4; |
8265 | 4730 else |
5575 | 4731 account->perm_deny = 3; |
8265 | 4732 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
4733 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 4734 |
4735 if (!strcmp(state, _("Online"))) | |
4901 | 4736 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 4737 else if (!strcmp(state, _("Away"))) { |
4901 | 4738 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4739 gc->away = g_strdup(""); |
4342 | 4740 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 4741 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4742 gc->away = g_strdup(""); |
4342 | 4743 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 4744 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4745 gc->away = g_strdup(""); |
4342 | 4746 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 4747 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4748 gc->away = g_strdup(""); |
4342 | 4749 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 4750 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4751 gc->away = g_strdup(""); |
4342 | 4752 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 4753 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4754 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4755 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 4756 if (message) { |
4901 | 4757 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4758 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4759 } else { |
4901 | 4760 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4761 } |
2086 | 4762 } |
2993 | 4763 |
4764 return; | |
4765 } | |
4766 | |
6059 | 4767 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 4768 { |
7283 | 4769 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 4770 |
4771 if (od->icq) | |
4772 oscar_set_away_icq(gc, od, state, message); | |
4773 else | |
8257 | 4774 oscar_set_away_aim(gc, od, state, message); |
2993 | 4775 |
4776 return; | |
2086 | 4777 } |
4778 | |
6059 | 4779 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
7283 | 4780 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4781 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 4782 } |
4783 | |
5575 | 4784 static void oscar_dir_search(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 4785 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
7283 | 4786 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4787 if (strlen(email)) |
6879 | 4788 aim_search_address(od->sess, od->conn, email); |
2086 | 4789 } |
4790 | |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
4791 static void oscar_add_buddy(GaimConnection *gc, const char *name, GaimGroup *g) { |
7283 | 4792 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 4793 GaimBuddy *b; |
4794 | |
4795 if (g == NULL) { | |
4796 /* If we were called from oscar_add_buddies... */ | |
4797 b = gaim_find_buddy(gaim_connection_get_account(gc), name); | |
4798 g = gaim_find_buddys_group(b); | |
4799 } else | |
4800 b = gaim_find_buddy_in_group(gaim_connection_get_account(gc), name, g); | |
8092 | 4801 |
4802 if (!aim_snvalid(name)) { | |
4803 gchar *buf; | |
8150 | 4804 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."), name); |
8092 | 4805 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4806 g_free(buf); | |
8150 | 4807 |
4808 /* Remove from local list */ | |
4809 gaim_blist_remove_buddy(b); | |
4810 | |
8092 | 4811 return; |
4812 } | |
4813 | |
4230 | 4814 #ifdef NOSSI |
8143 | 4815 aim_buddylist_addbuddy(od->sess, od->conn, name); |
4230 | 4816 #else |
4817 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
8150 | 4818 if (b && g) { |
8660 | 4819 gaim_debug_info("oscar", |
8150 | 4820 "ssi: adding buddy %s to group %s\n", name, g->name); |
4821 aim_ssi_addbuddy(od->sess, b->name, g->name, gaim_get_buddy_alias_only(b), NULL, NULL, 0); | |
4230 | 4822 } |
4823 } | |
4824 #endif | |
8150 | 4825 |
4759 | 4826 if (od->icq) |
4827 aim_icq_getalias(od->sess, name); | |
4230 | 4828 } |
4829 | |
5575 | 4830 static void oscar_add_buddies(GaimConnection *gc, GList *buddies) { |
7283 | 4831 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4832 #ifdef NOSSI |
4833 char buf[MSG_LEN]; | |
4834 int n=0; | |
4835 while (buddies) { | |
4836 if (n > MSG_LEN - 18) { | |
7285 | 4837 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 4838 n = 0; |
3092 | 4839 } |
8150 | 4840 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (const char *)buddies->data); |
4230 | 4841 buddies = buddies->next; |
4842 } | |
7285 | 4843 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 4844 #else |
4845 if (od->sess->ssi.received_data) { | |
4846 while (buddies) { | |
8092 | 4847 oscar_add_buddy(gc, buddies->data, NULL); |
4230 | 4848 buddies = buddies->next; |
4849 } | |
4850 } | |
4851 #endif | |
4852 } | |
4853 | |
6059 | 4854 static void oscar_remove_buddy(GaimConnection *gc, const char *name, const char *group) { |
7283 | 4855 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4856 #ifdef NOSSI |
8143 | 4857 aim_buddylist_removebuddy(od->sess, od->conn, name); |
4230 | 4858 #else |
4859 if (od->sess->ssi.received_data) { | |
8660 | 4860 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4861 "ssi: deleting buddy %s from group %s\n", name, group); |
4889 | 4862 aim_ssi_delbuddy(od->sess, name, group); |
4230 | 4863 } |
4864 #endif | |
4865 } | |
4866 | |
5575 | 4867 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { |
7283 | 4868 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4869 #ifdef NOSSI |
4870 GList *cur; | |
4871 for (cur=buddies; cur; cur=cur->next) | |
8143 | 4872 aim_buddylist_removebuddy(od->sess, od->conn, cur->data); |
4230 | 4873 #else |
4874 if (od->sess->ssi.received_data) { | |
3092 | 4875 while (buddies) { |
8150 | 4876 oscar_remove_buddy(gc, buddies->data, group); |
3092 | 4877 buddies = buddies->next; |
4878 } | |
4230 | 4879 } |
4880 #endif | |
4881 } | |
4882 | |
4883 #ifndef NOSSI | |
5575 | 4884 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 4885 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 4886 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 4887 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4888 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 4889 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 4890 } |
4891 } | |
4892 | |
5575 | 4893 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 4894 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 4895 if (od->sess->ssi.received_data) { |
4896 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
4897 if (gname) { | |
8660 | 4898 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4899 "ssi: changing the alias for buddy %s to %s\n", name, alias); |
4889 | 4900 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 4901 } |
4902 } | |
4903 } | |
4904 | |
8341 | 4905 static void oscar_rename_group(GaimConnection *gc, const char *old_group, const char *new_group, GList *members) { |
4906 OscarData *od = (OscarData *)gc->proto_data; | |
4230 | 4907 |
4908 if (od->sess->ssi.received_data) { | |
4909 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
8341 | 4910 oscar_remove_buddies(gc, members, old_group); |
4911 oscar_add_buddies(gc, members); | |
8660 | 4912 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4913 "ssi: moved all buddies from group %s to %s\n", old_group, new_group); |
4230 | 4914 } else { |
4889 | 4915 aim_ssi_rename_group(od->sess, old_group, new_group); |
8660 | 4916 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4917 "ssi: renamed group %s to %s\n", old_group, new_group); |
2995 | 4918 } |
4919 } | |
4920 } | |
4921 | |
5968 | 4922 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
4923 aim_session_t *sess = data; | |
6350 | 4924 aim_ssi_reqdata(sess); |
5968 | 4925 return FALSE; |
4926 } | |
4927 | |
4642 | 4928 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4929 GaimConnection *gc = sess->aux_data; |
7283 | 4930 OscarData *od = gc->proto_data; |
4642 | 4931 va_list ap; |
4932 fu16_t reason; | |
4933 | |
4934 va_start(ap, fr); | |
4935 reason = (fu16_t)va_arg(ap, unsigned int); | |
4936 va_end(ap); | |
4937 | |
8660 | 4938 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 4939 |
4940 if (reason == 0x0005) { | |
5892 | 4941 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 4942 _("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
|
4943 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 4944 } |
4945 | |
4946 /* Activate SSI */ | |
4947 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4948 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 4949 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 4950 aim_ssi_enable(od->sess); |
4951 | |
4952 return 1; | |
4953 } | |
4954 | |
2991 | 4955 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4956 GaimConnection *gc = sess->aux_data; |
7283 | 4957 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4958 int numtypes, i; |
4959 fu16_t *maxitems; | |
2991 | 4960 va_list ap; |
4961 | |
4962 va_start(ap, fr); | |
4230 | 4963 numtypes = va_arg(ap, int); |
4964 maxitems = va_arg(ap, fu16_t *); | |
2991 | 4965 va_end(ap); |
4966 | |
8660 | 4967 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4968 |
4230 | 4969 for (i=0; i<numtypes; i++) |
8660 | 4970 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4971 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4972 |
8660 | 4973 gaim_debug_misc(NULL, "\n"); |
4230 | 4974 |
4975 if (numtypes >= 0) | |
4976 od->rights.maxbuddies = maxitems[0]; | |
4977 if (numtypes >= 1) | |
4978 od->rights.maxgroups = maxitems[1]; | |
4979 if (numtypes >= 2) | |
4980 od->rights.maxpermits = maxitems[2]; | |
4981 if (numtypes >= 3) | |
4982 od->rights.maxdenies = maxitems[3]; | |
2991 | 4983 |
4984 return 1; | |
4985 } | |
4986 | |
4987 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4988 GaimConnection *gc = sess->aux_data; |
4989 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 4990 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 4991 GaimGroup *g; |
4992 GaimBuddy *b; | |
2995 | 4993 struct aim_ssi_item *curitem; |
2991 | 4994 int tmp; |
4230 | 4995 va_list ap; |
8219 | 4996 fu16_t fmtver, numitems; |
4997 struct aim_ssi_item *items; | |
4998 fu32_t timestamp; | |
4230 | 4999 |
5000 va_start(ap, fr); | |
5001 fmtver = (fu16_t)va_arg(ap, int); | |
5002 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5003 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5004 timestamp = va_arg(ap, fu32_t); |
8219 | 5005 va_end(ap); |
2991 | 5006 |
8660 | 5007 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5008 "ssi: syncing local list and server list\n"); |
2991 | 5009 |
8219 | 5010 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5011 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 | 5012 return 1; |
5013 } | |
5014 | |
2991 | 5015 /* Clean the buddy list */ |
4889 | 5016 aim_ssi_cleanlist(sess); |
2991 | 5017 |
8150 | 5018 { /* If not in server list then prune from local list */ |
5019 GaimBlistNode *gnode, *cnode, *bnode; | |
5020 GaimBuddyList *blist; | |
5021 GSList *cur; | |
5022 | |
5023 /* Buddies */ | |
5024 cur = NULL; | |
5025 if ((blist = gaim_get_blist()) != NULL) { | |
5026 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5027 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5028 continue; | |
5029 g = (GaimGroup *)gnode; | |
5030 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5031 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5032 continue; | |
5033 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5034 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5035 continue; | |
5036 b = (GaimBuddy *)bnode; | |
5037 if (b->account == gc->account) { | |
5038 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5039 /* If the buddy is an ICQ user then load his nickname */ | |
5040 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5041 char *alias; |
8150 | 5042 if (servernick) |
5043 serv_got_alias(gc, b->name, servernick); | |
5044 | |
5045 /* Store local alias on server */ | |
8214 | 5046 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5047 if (!alias && b->alias && strlen(b->alias)) |
5048 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5049 free(alias); | |
5050 } else { | |
8660 | 5051 gaim_debug_info("oscar", |
8150 | 5052 "ssi: removing buddy %s from local list\n", b->name); |
5053 /* We can't actually remove now because it will screw up our looping */ | |
5054 cur = g_slist_prepend(cur, b); | |
5055 } | |
5056 } | |
5057 } | |
5058 } | |
5059 } | |
5060 } | |
8175 | 5061 |
8150 | 5062 while (cur != NULL) { |
5063 b = cur->data; | |
5064 cur = g_slist_remove(cur, b); | |
5065 gaim_blist_remove_buddy(b); | |
5066 } | |
5067 | |
5068 /* Permit list */ | |
5069 if (gc->account->permit) { | |
5070 for (cur=gc->account->permit; cur; cur=cur->next) | |
5071 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { | |
8660 | 5072 gaim_debug_info("oscar", |
8150 | 5073 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5074 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5075 cur = gc->account->permit; | |
5076 } | |
5077 } | |
5078 | |
5079 /* Deny list */ | |
5080 if (gc->account->deny) { | |
5081 for (cur=gc->account->deny; cur; cur=cur->next) | |
5082 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { | |
8660 | 5083 gaim_debug_info("oscar", |
8150 | 5084 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
5085 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5086 cur = gc->account->deny; | |
5087 } | |
5088 } | |
5089 /* Presence settings (idle time visibility) */ | |
5090 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5091 if (!(tmp & 0x400)) | |
5092 aim_ssi_setpresence(sess, tmp | 0x400); | |
5093 } /* end pruning buddies from local list */ | |
5094 | |
2991 | 5095 /* Add from server list to local list */ |
4230 | 5096 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5097 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5098 switch (curitem->type) { |
4230 | 5099 case 0x0000: { /* Buddy */ |
4251 | 5100 if (curitem->name) { |
4292 | 5101 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5102 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 5103 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 5104 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 5105 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 5106 /* Should gname be freed here? -- elb */ |
4754 | 5107 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 5108 free(alias); |
8150 | 5109 if (b) { |
4292 | 5110 /* Get server stored alias */ |
4705 | 5111 if (alias_utf8) { |
8150 | 5112 g_free(b->alias); |
5113 b->alias = g_strdup(alias_utf8); | |
4705 | 5114 } |
4282 | 5115 } else { |
8150 | 5116 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 5117 |
4754 | 5118 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 5119 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 5120 gaim_blist_add_group(g, NULL); |
5121 } | |
5146 | 5122 |
8660 | 5123 gaim_debug_info("oscar", |
8150 | 5124 "ssi: adding b %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
5125 gaim_blist_add_buddy(b, NULL, g, NULL); | |
4251 | 5126 } |
8341 | 5127 if (!aim_sncmp(curitem->name, account->username)) { |
5128 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
5129 gaim_check_comment(od, comment); | |
5130 free(comment); | |
5131 } | |
7162 | 5132 g_free(gname_utf8); |
5133 g_free(alias_utf8); | |
2991 | 5134 } |
4230 | 5135 } break; |
5136 | |
5137 case 0x0001: { /* Group */ | |
4282 | 5138 /* Shouldn't add empty groups */ |
4230 | 5139 } break; |
5140 | |
5141 case 0x0002: { /* Permit buddy */ | |
2991 | 5142 if (curitem->name) { |
4230 | 5143 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 5144 GSList *list; |
5575 | 5145 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5146 if (!list) { |
8660 | 5147 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5148 "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
|
5149 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 5150 } |
5151 } | |
4230 | 5152 } break; |
5153 | |
5154 case 0x0003: { /* Deny buddy */ | |
2991 | 5155 if (curitem->name) { |
5156 GSList *list; | |
5575 | 5157 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5158 if (!list) { |
8660 | 5159 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5160 "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
|
5161 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 5162 } |
5163 } | |
4230 | 5164 } break; |
5165 | |
5166 case 0x0004: { /* Permit/deny setting */ | |
2991 | 5167 if (curitem->data) { |
5168 fu8_t permdeny; | |
5575 | 5169 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 5170 gaim_debug_info("oscar", |
5575 | 5171 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
5172 account->perm_deny = permdeny; | |
5173 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 5174 serv_set_away(gc, "Invisible", ""); |
5175 } | |
2991 | 5176 } |
5177 } | |
4230 | 5178 } break; |
5179 | |
5180 case 0x0005: { /* Presence setting */ | |
3109 | 5181 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 5182 } break; |
2991 | 5183 } /* End of switch on curitem->type */ |
5184 } /* End of for loop */ | |
4230 | 5185 |
4901 | 5186 /* Set our ICQ status */ |
8257 | 5187 if (!gc->away) { |
4901 | 5188 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
5189 } | |
5190 | |
4342 | 5191 /* Activate SSI */ |
5192 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5193 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5194 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5195 "ssi: activating server-stored buddy list\n"); |
4642 | 5196 aim_ssi_enable(sess); |
4342 | 5197 |
2991 | 5198 return 1; |
2086 | 5199 } |
4230 | 5200 |
5201 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5202 GaimConnection *gc = sess->aux_data; |
4230 | 5203 va_list ap; |
5204 struct aim_ssi_tmp *retval; | |
5205 | |
5206 va_start(ap, fr); | |
5207 retval = va_arg(ap, struct aim_ssi_tmp *); | |
5208 va_end(ap); | |
5209 | |
5210 while (retval) { | |
8660 | 5211 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5212 "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 | 5213 |
5214 if (retval->ack != 0xffff) | |
5215 switch (retval->ack) { | |
5216 case 0x0000: { /* added successfully */ | |
5217 } break; | |
5218 | |
4829 | 5219 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
5220 gchar *buf; | |
5221 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)"))); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5222 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 5223 g_free(buf); |
5224 } | |
5225 | |
7023 | 5226 case 0x000e: { /* buddy requires authorization */ |
4828 | 5227 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 5228 gaim_auth_sendrequest(gc, retval->name); |
4230 | 5229 } break; |
5230 | |
5231 default: { /* La la la */ | |
5197 | 5232 gchar *buf; |
8660 | 5233 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 5234 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)"))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5235 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 5236 g_free(buf); |
4230 | 5237 } break; |
5238 } | |
5239 | |
5240 retval = retval->next; | |
5241 } | |
5242 | |
5243 return 1; | |
5244 } | |
5245 | |
8227 | 5246 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
5247 GaimConnection *gc = sess->aux_data; | |
5248 char *gname, *gname_utf8, *alias, *alias_utf8; | |
5249 GaimBuddy *b; | |
5250 GaimGroup *g; | |
5251 va_list ap; | |
5252 fu16_t type; | |
5253 const char *name; | |
5254 | |
5255 va_start(ap, fr); | |
5256 type = (fu16_t)va_arg(ap, int); | |
5257 name = va_arg(ap, char *); | |
5258 va_end(ap); | |
5259 | |
5260 if ((type != 0x0000) || (name == NULL)) | |
5261 return 1; | |
5262 | |
5263 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
5264 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
5265 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
5266 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
5267 b = gaim_find_buddy(gc->account, name); | |
5268 free(alias); | |
5269 | |
5270 if (b) { | |
5271 /* Get server stored alias */ | |
5272 if (alias_utf8) { | |
5273 g_free(b->alias); | |
5274 b->alias = g_strdup(alias_utf8); | |
5275 } | |
5276 } else { | |
5277 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
5278 | |
5279 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
5280 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
5281 gaim_blist_add_group(g, NULL); | |
5282 } | |
5283 | |
8660 | 5284 gaim_debug_info("oscar", |
8227 | 5285 "ssi: adding b %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
5286 gaim_blist_add_buddy(b, NULL, g, NULL); | |
5287 } | |
5288 g_free(gname_utf8); | |
5289 g_free(alias_utf8); | |
5290 | |
5291 return 1; | |
5292 } | |
5293 | |
4230 | 5294 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5295 GaimConnection *gc = sess->aux_data; |
4230 | 5296 va_list ap; |
5297 char *sn, *msg; | |
4236 | 5298 gchar *dialog_msg, *nombre; |
4230 | 5299 struct name_data *data; |
6695 | 5300 GaimBuddy *buddy; |
4230 | 5301 |
5302 va_start(ap, fr); | |
5303 sn = va_arg(ap, char *); | |
5304 msg = va_arg(ap, char *); | |
5305 va_end(ap); | |
5306 | |
8660 | 5307 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5308 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 5309 |
4687 | 5310 buddy = gaim_find_buddy(gc->account, sn); |
5311 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5312 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5313 else |
5314 nombre = g_strdup(sn); | |
5315 | |
5316 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 | 5317 data = g_new(struct name_data, 1); |
5318 data->gc = gc; | |
5319 data->name = g_strdup(sn); | |
5320 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5321 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5322 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5323 0, data, |
7023 | 5324 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 5325 G_CALLBACK(oscar_free_name_data)); |
4236 | 5326 |
4230 | 5327 g_free(dialog_msg); |
4236 | 5328 g_free(nombre); |
4230 | 5329 |
5330 return 1; | |
5331 } | |
5332 | |
5333 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5334 GaimConnection *gc = sess->aux_data; |
4230 | 5335 va_list ap; |
5336 char *sn, *msg; | |
4236 | 5337 gchar *dialog_msg, *nombre; |
4230 | 5338 struct name_data *data; |
6695 | 5339 GaimBuddy *buddy; |
4230 | 5340 |
5341 va_start(ap, fr); | |
5342 sn = va_arg(ap, char *); | |
5343 msg = va_arg(ap, char *); | |
5344 va_end(ap); | |
5345 | |
8660 | 5346 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5347 "ssi: received authorization request from %s\n", sn); |
4230 | 5348 |
4687 | 5349 buddy = gaim_find_buddy(gc->account, sn); |
5350 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5351 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5352 else |
5353 nombre = g_strdup(sn); | |
5354 | |
4337 | 5355 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 | 5356 data = g_new(struct name_data, 1); |
5357 data->gc = gc; | |
5358 data->name = g_strdup(sn); | |
5359 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5360 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5361 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5362 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5363 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5364 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 5365 |
4230 | 5366 g_free(dialog_msg); |
4236 | 5367 g_free(nombre); |
4230 | 5368 |
5369 return 1; | |
5370 } | |
5371 | |
5372 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5373 GaimConnection *gc = sess->aux_data; |
4230 | 5374 va_list ap; |
5375 char *sn, *msg; | |
4236 | 5376 gchar *dialog_msg, *nombre; |
4230 | 5377 fu8_t reply; |
6695 | 5378 GaimBuddy *buddy; |
4230 | 5379 |
5380 va_start(ap, fr); | |
5381 sn = va_arg(ap, char *); | |
5382 reply = (fu8_t)va_arg(ap, int); | |
5383 msg = va_arg(ap, char *); | |
5384 va_end(ap); | |
5385 | |
8660 | 5386 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5387 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 5388 |
4687 | 5389 buddy = gaim_find_buddy(gc->account, sn); |
5390 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5391 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5392 else |
5393 nombre = g_strdup(sn); | |
5394 | |
4230 | 5395 if (reply) { |
5396 /* Granted */ | |
7023 | 5397 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
|
5398 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 5399 } else { |
5400 /* Denied */ | |
7023 | 5401 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
|
5402 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 5403 } |
5404 g_free(dialog_msg); | |
4236 | 5405 g_free(nombre); |
4230 | 5406 |
5407 return 1; | |
5408 } | |
5409 | |
5410 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5411 GaimConnection *gc = sess->aux_data; |
4230 | 5412 va_list ap; |
5413 char *sn; | |
6695 | 5414 GaimBuddy *buddy; |
4230 | 5415 |
5416 va_start(ap, fr); | |
5417 sn = va_arg(ap, char *); | |
5418 va_end(ap); | |
5419 | |
4687 | 5420 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 5421 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5422 "ssi: %s added you to their buddy list\n", sn); |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
5423 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 5424 |
5425 return 1; | |
5426 } | |
4269 | 5427 #endif |
2086 | 5428 |
5575 | 5429 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5430 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5431 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5432 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5433 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 5434 pce->label = _("_Group:"); |
5234 | 5435 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5436 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5437 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5438 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 5439 pce->label = _("_Exchange:"); |
5234 | 5440 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5441 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5442 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5443 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5444 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5445 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5446 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5447 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5448 |
8308 | 5449 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
5450 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5451 aim_conn_t *cur; |
5234 | 5452 char *name, *exchange; |
5453 | |
5454 name = g_hash_table_lookup(data, "room"); | |
5455 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5456 |
8660 | 5457 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5458 "Attempting to join chat room %s.\n", name); |
8308 | 5459 |
5460 if ((name == NULL) || (*name == '\0')) { | |
5461 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
5462 return; | |
5463 } | |
5464 | |
4617 | 5465 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 5466 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5467 "chatnav exists, creating room\n"); |
5234 | 5468 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 5469 } else { |
5470 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5471 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 5472 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5473 "chatnav does not exist, opening chatnav\n"); |
5234 | 5474 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5475 cr->name = g_strdup(name); |
4617 | 5476 od->create_rooms = g_slist_append(od->create_rooms, cr); |
5477 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 5478 } |
5479 } | |
5480 | |
8308 | 5481 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
5482 OscarData *od = (OscarData *)gc->proto_data; | |
5483 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 5484 |
5485 if (!ccon) | |
5486 return; | |
5487 | |
8225 | 5488 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 5489 ccon->exchange, ccon->name, 0x0); |
5490 } | |
5491 | |
8308 | 5492 static void oscar_chat_leave(GaimConnection *gc, int id) { |
5493 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
5494 GSList *bcs = gc->buddy_chats; | |
5679 | 5495 GaimConversation *b = NULL; |
2086 | 5496 struct chat_connection *c = NULL; |
5497 int count = 0; | |
5498 | |
5499 while (bcs) { | |
5500 count++; | |
5679 | 5501 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5502 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 5503 break; |
5504 bcs = bcs->next; | |
5505 b = NULL; | |
5506 } | |
5507 | |
5508 if (!b) | |
5509 return; | |
5510 | |
8660 | 5511 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5512 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 5513 |
8308 | 5514 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 5515 if (c != NULL) { |
4617 | 5516 if (od) |
5517 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 5518 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5519 gaim_input_remove(c->inpa); |
8308 | 5520 if (gc && od->sess) |
4617 | 5521 aim_conn_kill(od->sess, &c->conn); |
2086 | 5522 g_free(c->name); |
5523 g_free(c->show); | |
5524 g_free(c); | |
5525 } | |
5526 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 5527 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 5528 } |
5529 | |
8219 | 5530 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
5531 OscarData *od = (OscarData *)gc->proto_data; | |
5532 GError *err = NULL; | |
5533 GaimConversation *conv = NULL; | |
2086 | 5534 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5535 char *buf, *buf2; |
8219 | 5536 char *charset = NULL; |
5537 int encoding; | |
5538 int len; | |
5539 | |
5540 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5541 return -EINVAL; |
2086 | 5542 |
8219 | 5543 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5544 return -EINVAL; |
2086 | 5545 |
8219 | 5546 buf = gaim_strdup_withhtml(message); |
5547 len = strlen(buf); | |
5548 | |
5549 encoding = oscar_encoding_check(buf); | |
8233 | 5550 if (encoding & AIM_IMFLAGS_UNICODE) { |
8660 | 5551 gaim_debug_info("oscar", "Sending Unicode chat\n"); |
8219 | 5552 charset = "unicode-2-0"; |
5553 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
5554 if (err) { | |
8660 | 5555 gaim_debug_error("oscar", |
8359 | 5556 "Error converting to unicode-2-0: %s\n", err->message); |
5557 g_error_free(err); | |
5558 } | |
8219 | 5559 } else if (encoding & AIM_IMFLAGS_ISO_8859_1) { |
8660 | 5560 gaim_debug_info("oscar", "Sending ISO-8859-1 chat\n"); |
8219 | 5561 charset = "iso-8859-1"; |
5562 buf2 = g_convert(buf, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); | |
5563 if (err) { | |
8660 | 5564 gaim_debug_error("oscar", |
8359 | 5565 "Error converting to iso-8859-1: %s\n", err->message); |
8219 | 5566 g_error_free(err); |
8359 | 5567 err = NULL; |
5568 | |
8660 | 5569 gaim_debug_info("oscar", "Falling back to Unicode\n"); |
8359 | 5570 charset = "unicode-2-0"; |
5571 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
8219 | 5572 if (err) { |
8660 | 5573 gaim_debug_error("oscar", |
8359 | 5574 "Error converting to unicode-2-0: %s\n", |
5575 err->message); | |
8219 | 5576 g_error_free(err); |
5577 } | |
2086 | 5578 } |
8219 | 5579 } else { |
5580 charset = "us-ascii"; | |
5581 buf2 = g_strdup(buf); | |
5582 } | |
8359 | 5583 g_free(buf); |
5584 | |
5585 if ((len > c->maxlen) || (len > c->maxvis)) { | |
5586 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5587 return -E2BIG; |
8359 | 5588 } |
5589 | |
5590 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charset, "en"); | |
8219 | 5591 g_free(buf2); |
8359 | 5592 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5593 return 0; |
2086 | 5594 } |
5595 | |
6695 | 5596 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 5597 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5598 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 5599 return "icq"; |
5600 else | |
5601 return "aim"; | |
5602 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5603 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5604 if (b != NULL && isdigit(b->name[0])) |
4687 | 5605 return "icq"; |
5606 return "aim"; | |
5607 } | |
5608 | |
6695 | 5609 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 5610 { |
7334 | 5611 GaimAccount *account = NULL; |
5612 GaimConnection *gc = NULL; | |
5613 OscarData *od = NULL; | |
4687 | 5614 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
5615 int i = 0; | |
7334 | 5616 aim_userinfo_t *userinfo = NULL; |
5617 | |
5618 if (b != NULL) | |
5619 account = b->account; | |
5620 if (account != NULL) | |
5621 gc = account->gc; | |
5622 if (gc != NULL) | |
5623 od = gc->proto_data; | |
7945 | 5624 if (od != NULL) |
5625 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 5626 |
5131 | 5627 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
5628 char *gname; | |
7334 | 5629 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 5630 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
5631 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
5632 emblems[i++] = "notauthorized"; | |
5633 } else { | |
5634 emblems[i++] = "offline"; | |
5635 } | |
5636 } | |
4916 | 5637 |
4766 | 5638 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 5639 int uc = b->uc >> 16; |
4766 | 5640 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 5641 emblems[i++] = "invisible"; |
4766 | 5642 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 5643 emblems[i++] = "freeforchat"; |
4766 | 5644 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 5645 emblems[i++] = "dnd"; |
4766 | 5646 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 5647 emblems[i++] = "na"; |
4766 | 5648 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 5649 emblems[i++] = "occupied"; |
4766 | 5650 else if (uc & AIM_ICQ_STATE_AWAY) |
5651 emblems[i++] = "away"; | |
5652 } else { | |
5653 if (b->uc & UC_UNAVAILABLE) | |
5654 emblems[i++] = "away"; | |
5655 } | |
4687 | 5656 if (b->uc & UC_WIRELESS) |
5657 emblems[i++] = "wireless"; | |
5658 if (b->uc & UC_AOL) | |
5659 emblems[i++] = "aol"; | |
5660 if (b->uc & UC_ADMIN) | |
5661 emblems[i++] = "admin"; | |
5662 if (b->uc & UC_AB && i < 4) | |
5663 emblems[i++] = "activebuddy"; | |
4766 | 5664 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
5665 emblems[i++] = "unconfirmed"; */ | |
7334 | 5666 |
7945 | 5667 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
5668 emblems[i++] = "hiptop"; | |
5669 | |
5670 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 5671 emblems[i++] = "secure"; |
5672 | |
4687 | 5673 *se = emblems[0]; |
5674 *sw = emblems[1]; | |
5675 *nw = emblems[2]; | |
5676 *ne = emblems[3]; | |
5677 } | |
5678 | |
6695 | 5679 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 5680 GaimConnection *gc = b->account->gc; |
7283 | 5681 OscarData *od = gc->proto_data; |
7692 | 5682 GaimGroup *g = gaim_find_buddys_group(b); |
7261 | 5683 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
7045 | 5684 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8591 | 5685 GString *ret = g_string_new(""); |
5131 | 5686 |
5687 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
5688 if (isdigit(b->name[0])) { | |
7011 | 5689 char *status; |
5131 | 5690 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); |
8591 | 5691 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), status); |
5131 | 5692 g_free(status); |
5693 } | |
5694 | |
7011 | 5695 if ((bi != NULL) && (bi->ipaddr)) { |
7283 | 5696 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
7011 | 5697 (bi->ipaddr & 0xff000000) >> 24, |
5698 (bi->ipaddr & 0x00ff0000) >> 16, | |
5699 (bi->ipaddr & 0x0000ff00) >> 8, | |
5700 (bi->ipaddr & 0x000000ff)); | |
8591 | 5701 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("IP Address"), tstr); |
7162 | 5702 g_free(tstr); |
7011 | 5703 } |
5704 | |
5705 if ((userinfo != NULL) && (userinfo->capabilities)) { | |
5706 char *caps = caps_string(userinfo->capabilities); | |
8591 | 5707 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Capabilities"), caps); |
7011 | 5708 } |
5709 | |
7692 | 5710 if (g && g->name) { |
8591 | 5711 char *comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); |
7692 | 5712 if (comment != NULL) { |
8591 | 5713 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Buddy Comment"), comment); |
7692 | 5714 free(comment); |
5715 } | |
5716 } | |
5717 | |
7011 | 5718 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { |
5719 gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
8591 | 5720 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Available"), escaped); |
7011 | 5721 g_free(escaped); |
5722 } | |
5723 | |
5724 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 5725 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 5726 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 5727 g_free(charset); |
7011 | 5728 if (away_utf8 != NULL) { |
7091 | 5729 gchar *tmp1, *tmp2; |
8341 | 5730 const gchar *tmp3; |
5731 tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); | |
5732 g_free(away_utf8); | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7093
diff
changeset
|
5733 tmp2 = gaim_markup_strip_html(tmp1); |
7091 | 5734 g_free(tmp1); |
8571 | 5735 tmp1 = gaim_escape_html(tmp2); |
7091 | 5736 g_free(tmp2); |
8461 | 5737 tmp3 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
5738 g_free(tmp1); | |
8591 | 5739 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp3); |
5836 | 5740 } |
5131 | 5741 } |
5742 } else { | |
5743 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
8591 | 5744 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) |
5745 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), _("Not Authorized")); | |
5746 else | |
5747 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), _("Offline")); | |
5748 } | |
5749 | |
5750 return g_string_free(ret, FALSE);; | |
5131 | 5751 } |
5752 | |
6695 | 5753 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 5754 GaimConnection *gc = b->account->gc; |
7283 | 5755 OscarData *od = gc->proto_data; |
5167 | 5756 gchar *ret = NULL; |
5757 | |
5758 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
5759 if (isdigit(b->name[0])) | |
5760 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
7038 | 5761 else |
5762 ret = g_strdup(_("Away")); | |
5836 | 5763 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 5764 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 5765 if (bi->availmsg) |
5766 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 5767 } else { |
5167 | 5768 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
5769 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
5770 ret = g_strdup(_("Not Authorized")); | |
5771 else | |
5772 ret = g_strdup(_("Offline")); | |
5773 } | |
5774 | |
5775 return ret; | |
5776 } | |
5777 | |
5842 | 5778 |
5844 | 5779 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 5780 GaimConnection *gc = sess->aux_data; |
7283 | 5781 OscarData *od = gc->proto_data; |
5892 | 5782 va_list ap; |
5842 | 5783 fu16_t type; |
5892 | 5784 fu8_t flags = 0, length = 0; |
5785 char *md5 = NULL; | |
5786 | |
7334 | 5787 |
5842 | 5788 va_start(ap, fr); |
5789 type = va_arg(ap, int); | |
5892 | 5790 |
5791 switch(type) { | |
5792 case 0x0000: | |
5793 case 0x0001: { | |
5794 flags = va_arg(ap, int); | |
5795 length = va_arg(ap, int); | |
5796 md5 = va_arg(ap, char *); | |
5797 | |
5798 if (flags == 0x41) { | |
5799 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
5800 od->iconconnecting = TRUE; | |
5801 od->set_icon = TRUE; | |
5802 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
5803 } else { | |
6039 | 5804 struct stat st; |
5805 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
5806 if (iconfile == NULL) { | |
8363 | 5807 aim_ssi_delicon(od->sess); |
6039 | 5808 } else if (!stat(iconfile, &st)) { |
5809 char *buf = g_malloc(st.st_size); | |
5810 FILE *file = fopen(iconfile, "rb"); | |
5811 if (file) { | |
5812 fread(buf, 1, st.st_size, file); | |
5813 fclose(file); | |
8660 | 5814 gaim_debug_info("oscar", |
6039 | 5815 "Uploading icon to icon server\n"); |
6879 | 5816 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 5817 } else |
8660 | 5818 gaim_debug_error("oscar", |
6039 | 5819 "Can't open buddy icon file!\n"); |
5820 g_free(buf); | |
5821 } else { | |
8660 | 5822 gaim_debug_error("oscar", |
6039 | 5823 "Can't stat buddy icon file!\n"); |
5892 | 5824 } |
5825 } | |
8363 | 5826 } else if (flags == 0x81) { |
5827 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
5828 if (iconfile == NULL) | |
5829 aim_ssi_delicon(od->sess); | |
5830 else | |
5831 aim_ssi_seticon(od->sess, md5, length); | |
5832 } | |
5892 | 5833 } break; |
5834 | |
5835 case 0x0002: { /* We just set an "available" message? */ | |
5836 } break; | |
5837 } | |
5838 | |
5842 | 5839 va_end(ap); |
5844 | 5840 |
5841 return 0; | |
5842 | 5842 } |
5892 | 5843 |
3952 | 5844 /* |
4617 | 5845 * We have just established a socket with the other dude, so set up some handlers. |
3952 | 5846 */ |
4617 | 5847 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5848 GaimConnection *gc = sess->aux_data; |
7283 | 5849 OscarData *od = (OscarData *)gc->proto_data; |
5679 | 5850 GaimConversation *cnv; |
2086 | 5851 struct direct_im *dim; |
5852 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5853 char *sn; |
4617 | 5854 va_list ap; |
5855 aim_conn_t *newconn, *listenerconn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5856 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5857 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5858 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5859 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 5860 va_end(ap); |
5861 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5862 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5863 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5864 |
4617 | 5865 sn = g_strdup(aim_odc_getsn(newconn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5866 |
8660 | 5867 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5868 "DirectIM: initiate success to %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5869 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5870 |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
5871 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5872 gaim_input_remove(dim->watcher); |
2086 | 5873 dim->conn = newconn; |
4617 | 5874 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
3008 | 5875 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5876 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5877 g_free(sn); |
6982 | 5878 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
2086 | 5879 |
4617 | 5880 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
5881 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
6982 | 5882 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); |
4617 | 5883 |
2993 | 5884 return 1; |
5885 } | |
5886 | |
6982 | 5887 /* |
5888 * This is called when each chunk of an image is received. It can be used to | |
5889 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
5890 * nasty, you sicko. | |
5891 */ | |
5892 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
2993 | 5893 va_list ap; |
5894 char *sn; | |
5895 double percent; | |
5575 | 5896 GaimConnection *gc = sess->aux_data; |
7283 | 5897 OscarData *od = (OscarData *)gc->proto_data; |
5679 | 5898 GaimConversation *c; |
2993 | 5899 struct direct_im *dim; |
5900 | |
5901 va_start(ap, fr); | |
5902 sn = va_arg(ap, char *); | |
5903 percent = va_arg(ap, double); | |
5904 va_end(ap); | |
6873 | 5905 |
2994 | 5906 if (!(dim = find_direct_im(od, sn))) |
5907 return 1; | |
3059 | 5908 if (dim->watcher) { |
5909 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
5910 dim->watcher = 0; | |
5911 } | |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
5912 |
6982 | 5913 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); |
6873 | 5914 if (c != NULL) |
5915 gaim_conversation_update_progress(c, percent); | |
2993 | 5916 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
5917 oscar_callback, dim->conn); | |
2086 | 5918 |
5919 return 1; | |
5920 } | |
5921 | |
6982 | 5922 /* |
5923 * This is called after a direct IM has been received in its entirety. This | |
5924 * function is passed a long chunk of data which contains the IM with any | |
5925 * data chunks (images) appended to it. | |
5926 * | |
5927 * This function rips out all the data chunks and creates an imgstore for | |
5928 * each one. In order to do this, it first goes through the IM and takes | |
5929 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
5930 * with one compatable with the imgstore Gaim core code. For each one, we | |
5931 * then read in chunks of data from the end of the message and actually | |
5932 * create the img store using the given data. | |
5933 * | |
5934 * For somewhat easy reference, here's a sample message | |
5935 * (without the whitespace and asterisks): | |
5936 * | |
5937 * <HTML><BODY BGCOLOR="#ffffff"> | |
5938 * <FONT LANG="0"> | |
5939 * This is a really stupid picture:<BR> | |
5940 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
5941 * Yeah it is<BR> | |
5942 * Here is another one:<BR> | |
5943 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
5944 * </FONT> | |
5945 * </BODY></HTML> | |
5946 * <BINARY> | |
5947 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
5948 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
5949 * </BINARY> | |
5950 */ | |
4617 | 5951 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5952 GaimConnection *gc = sess->aux_data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5953 GaimConvImFlags imflags = 0; |
8233 | 5954 gchar *utf8; |
6982 | 5955 GString *newmsg = g_string_new(""); |
5956 GSList *images = NULL; | |
2086 | 5957 va_list ap; |
6982 | 5958 const char *sn, *msg, *msgend, *binary; |
5959 size_t len; | |
5960 int encoding, isawaymsg; | |
2086 | 5961 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5962 va_start(ap, fr); |
6982 | 5963 sn = va_arg(ap, const char *); |
5964 msg = va_arg(ap, const char *); | |
5965 len = va_arg(ap, size_t); | |
3952 | 5966 encoding = va_arg(ap, int); |
4870 | 5967 isawaymsg = va_arg(ap, int); |
2086 | 5968 va_end(ap); |
6982 | 5969 msgend = msg + len; |
2086 | 5970 |
8660 | 5971 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5972 "Got DirectIM message from %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5973 |
4870 | 5974 if (isawaymsg) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5975 imflags |= GAIM_CONV_IM_AUTO_RESP; |
4870 | 5976 |
6982 | 5977 /* message has a binary trailer */ |
5978 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
5979 GData *attribs; | |
5980 const char *tmp, *start, *end, *last = NULL; | |
5981 | |
5982 tmp = msg; | |
5983 | |
5984 /* for each valid image tag... */ | |
5985 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
5986 const char *id, *src, *datasize; | |
5987 const char *tag = NULL, *data = NULL; | |
5988 size_t size; | |
5989 int imgid = 0; | |
5990 | |
5991 /* update the location of the last img tag */ | |
5992 last = end; | |
5993 | |
5994 /* grab attributes */ | |
5995 id = g_datalist_get_data(&attribs, "id"); | |
5996 src = g_datalist_get_data(&attribs, "src"); | |
5997 datasize = g_datalist_get_data(&attribs, "datasize"); | |
5998 | |
5999 /* if we have id & datasize, build the data tag */ | |
6000 if (id && datasize) | |
6001 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
6002 | |
6003 /* if we have a tag, find the start of the data */ | |
6004 if (tag && (data = gaim_strcasestr(binary, tag))) | |
6005 data += strlen(tag); | |
6006 | |
6007 /* check the data is here and store it */ | |
6008 if (data + (size = atoi(datasize)) <= msgend) | |
6009 imgid = gaim_imgstore_add(data, size, src); | |
6010 | |
8233 | 6011 /* |
6012 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
6013 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
6014 */ | |
6982 | 6015 /* if we have a stored image... */ |
6016 if (imgid) { | |
6017 /* append the message up to the tag */ | |
8233 | 6018 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); |
6019 if (utf8 != NULL) { | |
6020 newmsg = g_string_append(newmsg, utf8); | |
6021 g_free(utf8); | |
6022 } | |
6982 | 6023 |
6024 /* write the new image tag */ | |
6025 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
6026 | |
6027 /* and record the image number */ | |
6028 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
6029 } else { | |
6030 /* otherwise, copy up to the end of the tag */ | |
8233 | 6031 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); |
6032 if (utf8 != NULL) { | |
6033 newmsg = g_string_append(newmsg, utf8); | |
6034 g_free(utf8); | |
6035 } | |
6982 | 6036 } |
6037 | |
6038 /* clear the attribute list */ | |
6039 g_datalist_clear(&attribs); | |
6040 | |
6041 /* continue from the end of the tag */ | |
6042 tmp = end + 1; | |
6043 } | |
6044 | |
6045 /* append any remaining message data (without the > :-) */ | |
6046 if (last++ && (last < binary)) | |
6047 newmsg = g_string_append_len(newmsg, last, binary - last); | |
6048 | |
6049 /* set the flag if we caught any images */ | |
6050 if (images) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6051 imflags |= GAIM_CONV_IM_IMAGES; |
6982 | 6052 } else { |
6053 g_string_append_len(newmsg, msg, len); | |
6054 } | |
6055 | |
4617 | 6056 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
6982 | 6057 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); |
6058 | |
6059 /* free up the message */ | |
6060 g_string_free(newmsg, TRUE); | |
6061 | |
6062 /* unref any images we allocated */ | |
6063 if (images) { | |
6064 GSList *tmp; | |
6065 int id; | |
6066 | |
6067 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
6068 id = GPOINTER_TO_INT(tmp->data); | |
6069 gaim_imgstore_unref(id); | |
6070 } | |
6071 | |
6072 g_slist_free(images); | |
6073 } | |
2086 | 6074 |
6075 return 1; | |
6076 } | |
6077 | |
4617 | 6078 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 6079 va_list ap; |
6080 char *sn; | |
2993 | 6081 int typing; |
5575 | 6082 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6083 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6084 va_start(ap, fr); |
2086 | 6085 sn = va_arg(ap, char *); |
2993 | 6086 typing = va_arg(ap, int); |
2086 | 6087 va_end(ap); |
6088 | |
4870 | 6089 if (typing == 0x0002) { |
2993 | 6090 /* I had to leave this. It's just too funny. It reminds me of my sister. */ |
8660 | 6091 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6092 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6093 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
4870 | 6094 } else if (typing == 0x0001) |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6095 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
4870 | 6096 else |
4342 | 6097 serv_got_typing_stopped(gc, sn); |
2086 | 6098 return 1; |
6099 } | |
6100 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6101 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { |
6982 | 6102 char *buf; |
6103 size_t len; | |
6104 int ret; | |
6105 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6106 if (imflags & GAIM_CONV_IM_IMAGES) { |
6982 | 6107 GString *msg = g_string_new(""); |
6108 GString *data = g_string_new("<BINARY>"); | |
6109 GData *attribs; | |
6110 const char *tmp, *start, *end, *last = NULL; | |
6111 int oscar_id = 0; | |
6112 | |
6113 tmp = message; | |
6114 | |
6115 /* for each valid IMG tag... */ | |
6116 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
6117 GaimStoredImage *image = NULL; | |
6118 const char *id; | |
6119 | |
6120 last = end; | |
6121 id = g_datalist_get_data(&attribs, "id"); | |
6122 | |
6123 /* ... if it refers to a valid gaim image ... */ | |
6124 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
6125 /* ... append the message from start to the tag ... */ | |
6126 msg = g_string_append_len(msg, tmp, start - tmp); | |
6127 oscar_id++; | |
6128 | |
6129 /* ... insert a new img tag with the oscar id ... */ | |
6130 if (image->filename) | |
6131 g_string_append_printf(msg, | |
6132 "<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", | |
7386 | 6133 image->filename, oscar_id, (int)image->size); |
6982 | 6134 else |
6135 g_string_append_printf(msg, | |
6136 "<IMG ID=\"%d\" DATASIZE=\"%d\">", | |
7386 | 6137 oscar_id, (int)image->size); |
6982 | 6138 |
6139 /* ... and append the data to the binary section ... */ | |
6140 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%d\">", | |
7386 | 6141 oscar_id, (int)image->size); |
6982 | 6142 data = g_string_append_len(data, image->data, image->size); |
6143 data = g_string_append(data, "</DATA>"); | |
6144 } else { | |
6145 /* ... otherwise, allow the possibly invalid img tag through. */ | |
6146 /* should we do something else? */ | |
6147 msg = g_string_append_len(msg, tmp, (end + 1) - tmp); | |
6148 } | |
6149 | |
6150 g_datalist_clear(&attribs); | |
6151 | |
6152 /* continue from the end of the tag */ | |
6153 tmp = end + 1; | |
6154 } | |
6155 | |
6156 /* append any remaining message data (without the > :-) */ | |
6157 if (last++ && *last) | |
6158 msg = g_string_append(msg, last); | |
6159 | |
6160 /* if we inserted any images in the binary section, append it */ | |
6161 if (oscar_id) { | |
6162 msg = g_string_append_len(msg, data->str, data->len); | |
6163 msg = g_string_append(msg, "</BINARY>"); | |
6164 } | |
6165 | |
6166 len = msg->len; | |
6167 buf = msg->str; | |
6168 g_string_free(msg, FALSE); | |
6169 g_string_free(data, TRUE); | |
6170 } else { | |
6171 len = strlen(message); | |
6172 buf = g_memdup(message, len+1); | |
6173 } | |
6174 | |
6175 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6176 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
6982 | 6177 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); |
6178 else | |
6179 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
6180 | |
6181 g_free(buf); | |
6182 | |
6183 return ret; | |
6184 } | |
6185 | |
2086 | 6186 struct ask_do_dir_im { |
6187 char *who; | |
5575 | 6188 GaimConnection *gc; |
2086 | 6189 }; |
6190 | |
3730 | 6191 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
5136 | 6192 g_free(data->who); |
2086 | 6193 g_free(data); |
6194 } | |
6195 | |
3730 | 6196 static void oscar_direct_im(struct ask_do_dir_im *data) { |
5575 | 6197 GaimConnection *gc = data->gc; |
7283 | 6198 OscarData *od; |
2086 | 6199 struct direct_im *dim; |
8240 | 6200 int listenfd; |
2086 | 6201 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
6202 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5136 | 6203 g_free(data->who); |
4244 | 6204 g_free(data); |
6205 return; | |
6206 } | |
6207 | |
7283 | 6208 od = (OscarData *)gc->proto_data; |
4244 | 6209 |
2086 | 6210 dim = find_direct_im(od, data->who); |
6211 if (dim) { | |
3008 | 6212 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
6213 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
6214 gaim_input_remove(dim->watcher); | |
6215 g_free(dim); | |
8660 | 6216 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6217 "Gave up on old direct IM, trying again\n"); |
3008 | 6218 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6219 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); |
5136 | 6220 g_free(data->who); |
4244 | 6221 g_free(data); |
3008 | 6222 return; |
6223 } | |
2086 | 6224 } |
6225 dim = g_new0(struct direct_im, 1); | |
6226 dim->gc = gc; | |
6227 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
6228 | |
8246 | 6229 listenfd = gaim_network_listen_range(5190, 5199); |
8240 | 6230 dim->conn = aim_odc_initiate(od->sess, data->who, listenfd, gaim_network_get_port_from_fd(listenfd)); |
2086 | 6231 if (dim->conn != NULL) { |
6232 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6233 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 6234 oscar_callback, dim->conn); |
4617 | 6235 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
6236 gaim_odc_initiate, 0); | |
2086 | 6237 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6238 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
2086 | 6239 g_free(dim); |
6240 } | |
4244 | 6241 |
5136 | 6242 g_free(data->who); |
4244 | 6243 g_free(data); |
2086 | 6244 } |
6245 | |
5575 | 6246 static void oscar_ask_direct_im(GaimConnection *gc, const char *who) { |
5420 | 6247 gchar *buf; |
2086 | 6248 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); |
5136 | 6249 data->who = g_strdup(who); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
6250 data->gc = gc; |
5420 | 6251 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), who); |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6252 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6253 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6254 _("Because this reveals your IP address, it " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6255 "may be considered a privacy risk. Do you " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6256 "wish to continue?"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6257 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6258 _("Connect"), G_CALLBACK(oscar_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6259 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
5420 | 6260 g_free(buf); |
2086 | 6261 } |
6262 | |
5575 | 6263 static void oscar_set_permit_deny(GaimConnection *gc) { |
6264 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6265 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6266 #ifdef NOSSI |
8143 | 6267 GSList *list; |
4230 | 6268 char buf[MAXMSGLEN]; |
6269 int at; | |
6270 | |
5575 | 6271 switch(account->perm_deny) { |
8175 | 6272 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6273 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6274 break; |
8175 | 6275 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6276 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6277 break; |
8175 | 6278 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6279 list = account->permit; |
4230 | 6280 at = 0; |
6281 while (list) { | |
6282 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6283 list = list->next; | |
6284 } | |
6285 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6286 break; | |
8175 | 6287 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6288 list = account->deny; |
4230 | 6289 at = 0; |
6290 while (list) { | |
6291 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6292 list = list->next; | |
6293 } | |
6294 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6295 break; | |
6296 default: | |
6297 break; | |
2086 | 6298 } |
4230 | 6299 #else |
8175 | 6300 if (od->sess->ssi.received_data) { |
6301 switch (account->perm_deny) { | |
6302 case GAIM_PRIVACY_ALLOW_ALL: | |
6303 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6304 break; | |
6305 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6306 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6307 break; | |
6308 case GAIM_PRIVACY_ALLOW_USERS: | |
6309 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6310 break; | |
6311 case GAIM_PRIVACY_DENY_ALL: | |
6312 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6313 break; | |
6314 case GAIM_PRIVACY_DENY_USERS: | |
6315 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6316 break; | |
6317 default: | |
6318 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6319 break; | |
6320 } | |
6321 } | |
4230 | 6322 #endif |
2086 | 6323 } |
6324 | |
5575 | 6325 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6326 #ifdef NOSSI |
8143 | 6327 if (gc->account->perm_deny == 3) |
4269 | 6328 oscar_set_permit_deny(gc); |
6329 #else | |
7283 | 6330 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6331 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6332 if (od->sess->ssi.received_data) |
4889 | 6333 aim_ssi_addpermit(od->sess, who); |
4230 | 6334 #endif |
2086 | 6335 } |
6336 | |
5575 | 6337 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6338 #ifdef NOSSI |
8143 | 6339 if (gc->account->perm_deny == 4) |
4269 | 6340 oscar_set_permit_deny(gc); |
6341 #else | |
7283 | 6342 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6343 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6344 if (od->sess->ssi.received_data) |
4889 | 6345 aim_ssi_adddeny(od->sess, who); |
4230 | 6346 #endif |
2086 | 6347 } |
6348 | |
5575 | 6349 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6350 #ifdef NOSSI |
8143 | 6351 if (gc->account->perm_deny == 3) |
4269 | 6352 oscar_set_permit_deny(gc); |
6353 #else | |
7283 | 6354 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6355 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6356 if (od->sess->ssi.received_data) |
4889 | 6357 aim_ssi_delpermit(od->sess, who); |
4230 | 6358 #endif |
2086 | 6359 } |
6360 | |
5575 | 6361 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6362 #ifdef NOSSI |
8143 | 6363 if (gc->account->perm_deny == 4) |
4269 | 6364 oscar_set_permit_deny(gc); |
6365 #else | |
7283 | 6366 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6367 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6368 if (od->sess->ssi.received_data) |
4889 | 6369 aim_ssi_deldeny(od->sess, who); |
4230 | 6370 #endif |
2086 | 6371 } |
6372 | |
5575 | 6373 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6374 { |
7283 | 6375 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6376 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6377 |
8257 | 6378 if (od->icq) { |
6379 m = g_list_append(m, _("Online")); | |
6380 m = g_list_append(m, _("Away")); | |
6381 m = g_list_append(m, _("Do Not Disturb")); | |
6382 m = g_list_append(m, _("Not Available")); | |
6383 m = g_list_append(m, _("Occupied")); | |
6384 m = g_list_append(m, _("Free For Chat")); | |
6385 m = g_list_append(m, _("Invisible")); | |
6386 } else { | |
6387 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6388 m = g_list_append(m, _("Back")); |
8257 | 6389 m = g_list_append(m, _("Visible")); |
6390 m = g_list_append(m, _("Invisible")); | |
6391 } | |
4333 | 6392 |
6393 return m; | |
6394 } | |
6395 | |
7172 | 6396 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6397 GaimConnection *gc = data->gc; |
6398 OscarData *od = gc->proto_data; | |
7172 | 6399 GaimBuddy *b; |
6400 GaimGroup *g; | |
6401 | |
6402 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6403 oscar_free_name_data(data); | |
6404 return; | |
6405 } | |
6406 | |
6407 if (!(g = gaim_find_buddys_group(b))) { | |
6408 oscar_free_name_data(data); | |
6409 return; | |
6410 } | |
6411 | |
6412 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6413 |
6414 if (!aim_sncmp(data->name, gc->account->username)) | |
6415 gaim_check_comment(od, text); | |
6416 | |
7172 | 6417 oscar_free_name_data(data); |
6418 } | |
6419 | |
6420 static void oscar_buddycb_edit_comment(GaimConnection *gc, const char *name) { | |
7283 | 6421 OscarData *od = gc->proto_data; |
7172 | 6422 struct name_data *data = g_new(struct name_data, 1); |
6423 GaimBuddy *b; | |
6424 GaimGroup *g; | |
6425 char *comment; | |
6426 gchar *comment_utf8; | |
6427 | |
6428 if (!(b = gaim_find_buddy(gaim_connection_get_account(gc), name))) | |
6429 return; | |
6430 if (!(g = gaim_find_buddys_group(b))) | |
6431 return; | |
6432 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, name); | |
6433 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; | |
6434 | |
6435 data->gc = gc; | |
6436 data->name = g_strdup(name); | |
6437 data->nick = NULL; | |
6438 | |
6439 gaim_request_input(gc, NULL, _("Buddy Comment:"), NULL, | |
6440 comment_utf8, TRUE, FALSE, | |
6441 _("OK"), G_CALLBACK(oscar_ssi_editcomment), | |
6442 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6443 data); | |
6444 | |
6445 free(comment); | |
6446 g_free(comment_utf8); | |
6447 } | |
6448 | |
5575 | 6449 static GList *oscar_buddy_menu(GaimConnection *gc, const char *who) { |
7283 | 6450 OscarData *od = gc->proto_data; |
4333 | 6451 GList *m = NULL; |
6452 struct proto_buddy_menu *pbm; | |
6453 | |
7172 | 6454 pbm = g_new0(struct proto_buddy_menu, 1); |
6455 pbm->label = _("Edit Buddy Comment"); | |
6456 pbm->callback = oscar_buddycb_edit_comment; | |
6457 pbm->gc = gc; | |
6458 m = g_list_append(m, pbm); | |
6459 | |
4333 | 6460 if (od->icq) { |
4624 | 6461 #if 0 |
4333 | 6462 pbm = g_new0(struct proto_buddy_menu, 1); |
6463 pbm->label = _("Get Status Msg"); | |
4969 | 6464 pbm->callback = oscar_get_icqstatusmsg; |
4333 | 6465 pbm->gc = gc; |
6466 m = g_list_append(m, pbm); | |
4624 | 6467 #endif |
4333 | 6468 } else { |
6695 | 6469 GaimBuddy *b = gaim_find_buddy(gc->account, who); |
7011 | 6470 aim_userinfo_t *userinfo; |
5975 | 6471 |
6472 if (b) | |
7045 | 6473 userinfo = aim_locate_finduserinfo(od->sess, b->name); |
7011 | 6474 |
6475 if (b && userinfo && aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), who) && GAIM_BUDDY_IS_ONLINE(b)) { | |
6476 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { | |
5917 | 6477 pbm = g_new0(struct proto_buddy_menu, 1); |
6478 pbm->label = _("Direct IM"); | |
6479 pbm->callback = oscar_ask_direct_im; | |
6480 pbm->gc = gc; | |
6481 m = g_list_append(m, pbm); | |
6482 } | |
7650 | 6483 |
6484 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { | |
6485 pbm = g_new0(struct proto_buddy_menu, 1); | |
6486 pbm->label = _("Send File"); | |
6487 pbm->callback = oscar_ask_sendfile; | |
6488 pbm->gc = gc; | |
6489 m = g_list_append(m, pbm); | |
6490 } | |
4826 | 6491 #if 0 |
7011 | 6492 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
5917 | 6493 pbm = g_new0(struct proto_buddy_menu, 1); |
6494 pbm->label = _("Get File"); | |
6495 pbm->callback = oscar_ask_getfile; | |
6496 pbm->gc = gc; | |
6497 m = g_list_append(m, pbm); | |
6498 } | |
4826 | 6499 #endif |
4333 | 6500 } |
5131 | 6501 } |
5197 | 6502 |
5131 | 6503 if (od->sess->ssi.received_data) { |
6504 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
6505 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
6506 pbm = g_new0(struct proto_buddy_menu, 1); | |
6873 | 6507 pbm->label = _("Re-request Authorization"); |
5131 | 6508 pbm->callback = gaim_auth_sendrequest; |
6509 pbm->gc = gc; | |
6510 m = g_list_append(m, pbm); | |
4333 | 6511 } |
4916 | 6512 } |
6513 | |
4333 | 6514 return m; |
6515 } | |
6516 | |
5575 | 6517 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6518 OscarData *od = gc->proto_data; |
5575 | 6519 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6520 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6521 od->setnick = TRUE; | |
6522 od->newsn = g_strdup(nick); | |
6523 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6524 } else { | |
6525 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6526 } | |
6527 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6528 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6529 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6530 } |
6531 } | |
6532 | |
5575 | 6533 static void oscar_show_format_screenname(GaimConnection *gc) |
4333 | 6534 { |
8152 | 6535 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6536 gaim_connection_get_display_name(gc), FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6537 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6538 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6539 gc); |
4333 | 6540 } |
6541 | |
5575 | 6542 static void oscar_confirm_account(GaimConnection *gc) |
4333 | 6543 { |
7283 | 6544 OscarData *od = gc->proto_data; |
4333 | 6545 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6546 | |
6547 if (conn) { | |
6548 aim_admin_reqconfirm(od->sess, conn); | |
6549 } else { | |
6550 od->conf = TRUE; | |
6551 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6552 } | |
6553 } | |
6554 | |
5575 | 6555 static void oscar_show_email(GaimConnection *gc) |
4333 | 6556 { |
7283 | 6557 OscarData *od = gc->proto_data; |
4333 | 6558 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6559 | |
6560 if (conn) { | |
6561 aim_admin_getinfo(od->sess, conn, 0x11); | |
6562 } else { | |
6563 od->reqemail = TRUE; | |
6564 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6565 } | |
6566 } | |
6567 | |
5575 | 6568 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6569 { |
7283 | 6570 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6571 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
|
6572 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6573 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6574 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6575 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6576 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6577 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6578 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6579 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6580 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6581 |
5575 | 6582 static void oscar_show_change_email(GaimConnection *gc) |
4333 | 6583 { |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6584 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6585 FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6586 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6587 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6588 gc); |
4333 | 6589 } |
6590 | |
5575 | 6591 static void oscar_show_awaitingauth(GaimConnection *gc) |
4333 | 6592 { |
7283 | 6593 OscarData *od = gc->proto_data; |
4333 | 6594 gchar *nombre, *text, *tmp; |
6695 | 6595 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6596 int num=0; |
6597 | |
6873 | 6598 text = g_strdup(""); |
4333 | 6599 |
4785 | 6600 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 6601 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 6602 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
6603 continue; | |
6695 | 6604 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
6605 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 6606 continue; |
6695 | 6607 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
6608 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
6609 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6610 continue; | |
6611 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
6612 if (gaim_get_buddy_alias_only(buddy)) | |
6613 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
6614 else | |
6615 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 6616 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 6617 g_free(text); |
6618 text = tmp; | |
6619 g_free(nombre); | |
6620 num++; | |
6621 } | |
4333 | 6622 } |
2979 | 6623 } |
4333 | 6624 } |
6625 | |
6626 if (!num) { | |
6627 g_free(text); | |
6873 | 6628 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
6629 } | |
6630 | |
6631 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
6632 "the following buddies"), _("You can re-request " | |
6633 "authorization from these buddies by " | |
6634 "right-clicking on them and selecting " | |
6635 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 6636 g_free(text); |
2979 | 6637 } |
6638 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6639 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6640 { |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6641 serv_dir_search(gc, "", "", "", "", "", "", "", email); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6642 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6643 |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6644 static void oscar_show_find_email(GaimConnection *gc) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6645 { |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6646 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6647 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6648 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6649 "searching for."), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6650 NULL, FALSE, FALSE, |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6651 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6652 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6653 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6654 |
7366 | 6655 #if 0 |
5917 | 6656 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 6657 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 6658 |
7334 | 6659 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 6660 aim_srv_setavailmsg(od->sess, text); |
6661 } | |
6662 | |
6663 static void oscar_show_setavailmsg(GaimConnection *gc) | |
6664 { | |
7313 | 6665 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
6666 _("I'm doing work and hoping for a distraction--IM me!"), | |
6667 TRUE, FALSE, | |
5917 | 6668 _("OK"), G_CALLBACK(oscar_setavailmsg), |
6669 _("Cancel"), NULL, | |
6670 gc); | |
6671 } | |
7366 | 6672 #endif |
5917 | 6673 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6674 static void oscar_show_set_info(GaimConnection *gc) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6675 { |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6676 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6677 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6678 |
8576 | 6679 static void oscar_show_set_info_icqurl(GaimConnection *gc) |
6680 { | |
6681 gaim_notify_uri(gc, "http://web.icq.com/whitepages/login/1,,,00.html"); | |
6682 } | |
6683 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6684 static void oscar_change_pass(GaimConnection *gc) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6685 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6686 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6687 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6688 |
5575 | 6689 static void oscar_show_chpassurl(GaimConnection *gc) |
4333 | 6690 { |
7283 | 6691 OscarData *od = gc->proto_data; |
5575 | 6692 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6400
diff
changeset
|
6693 gaim_notify_uri(gc, substituted); |
5517 | 6694 g_free(substituted); |
4333 | 6695 } |
6696 | |
7026 | 6697 static void oscar_show_imforwardingurl(GaimConnection *gc) |
6698 { | |
6699 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); | |
6700 } | |
6701 | |
5842 | 6702 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
6703 { | |
7283 | 6704 OscarData *od = gc->proto_data; |
5844 | 6705 aim_session_t *sess = od->sess; |
5842 | 6706 FILE *file; |
6707 struct stat st; | |
5844 | 6708 |
6039 | 6709 if (iconfile == NULL) { |
8363 | 6710 aim_ssi_delicon(od->sess); |
6039 | 6711 } else if (!stat(iconfile, &st)) { |
5842 | 6712 char *buf = g_malloc(st.st_size); |
6713 file = fopen(iconfile, "rb"); | |
6714 if (file) { | |
6052 | 6715 md5_state_t *state; |
6039 | 6716 char md5[16]; |
5842 | 6717 int len = fread(buf, 1, st.st_size, file); |
6039 | 6718 fclose(file); |
6052 | 6719 state = g_malloc(sizeof(md5_state_t)); |
5842 | 6720 md5_init(state); |
6721 md5_append(state, buf, len); | |
6722 md5_finish(state, md5); | |
6723 g_free(state); | |
6724 aim_ssi_seticon(sess, md5, 16); | |
6725 } else | |
8660 | 6726 gaim_debug_error("oscar", |
5842 | 6727 "Can't open buddy icon file!\n"); |
6728 g_free(buf); | |
6729 } else | |
8660 | 6730 gaim_debug_error("oscar", |
5842 | 6731 "Can't stat buddy icon file!\n"); |
6732 } | |
6733 | |
6734 | |
5575 | 6735 static GList *oscar_actions(GaimConnection *gc) |
2086 | 6736 { |
7283 | 6737 OscarData *od = gc->proto_data; |
4333 | 6738 struct proto_actions_menu *pam; |
6739 GList *m = NULL; | |
6740 | |
6741 pam = g_new0(struct proto_actions_menu, 1); | |
7853 | 6742 pam->label = _("Set User Info..."); |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6743 pam->callback = oscar_show_set_info; |
4333 | 6744 pam->gc = gc; |
6745 m = g_list_append(m, pam); | |
6746 | |
8576 | 6747 if (od->icq) { |
6748 pam = g_new0(struct proto_actions_menu, 1); | |
6749 pam->label = _("Set User Info (URL)..."); | |
6750 pam->callback = oscar_show_set_info_icqurl; | |
6751 pam->gc = gc; | |
6752 m = g_list_append(m, pam); | |
6753 } | |
6754 | |
7366 | 6755 #if 0 |
5917 | 6756 pam = g_new0(struct proto_actions_menu, 1); |
7853 | 6757 pam->label = _("Set Available Message..."); |
5917 | 6758 pam->callback = oscar_show_setavailmsg; |
6759 pam->gc = gc; | |
6760 m = g_list_append(m, pam); | |
7366 | 6761 #endif |
5917 | 6762 |
5238 | 6763 pam = g_new0(struct proto_actions_menu, 1); |
7853 | 6764 pam->label = _("Change Password..."); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6765 pam->callback = oscar_change_pass; |
5238 | 6766 pam->gc = gc; |
6767 m = g_list_append(m, pam); | |
4617 | 6768 |
6769 if (od->sess->authinfo->chpassurl) { | |
6770 pam = g_new0(struct proto_actions_menu, 1); | |
6771 pam->label = _("Change Password (URL)"); | |
6772 pam->callback = oscar_show_chpassurl; | |
6773 pam->gc = gc; | |
6774 m = g_list_append(m, pam); | |
6775 } | |
6776 | |
7026 | 6777 if (od->sess->authinfo->chpassurl) { |
6778 pam = g_new0(struct proto_actions_menu, 1); | |
6779 pam->label = _("Configure IM Forwarding (URL)"); | |
6780 pam->callback = oscar_show_imforwardingurl; | |
6781 pam->gc = gc; | |
6782 m = g_list_append(m, pam); | |
6783 } | |
6784 | |
5238 | 6785 if (!od->icq) { |
4617 | 6786 /* AIM actions */ |
6787 m = g_list_append(m, NULL); | |
4333 | 6788 |
5917 | 6789 pam = g_new0(struct proto_actions_menu, 1); |
8152 | 6790 pam->label = _("Format Screen Name..."); |
5844 | 6791 pam->callback = oscar_show_format_screenname; |
4333 | 6792 pam->gc = gc; |
6793 m = g_list_append(m, pam); | |
6794 | |
6795 pam = g_new0(struct proto_actions_menu, 1); | |
6796 pam->label = _("Confirm Account"); | |
6797 pam->callback = oscar_confirm_account; | |
6798 pam->gc = gc; | |
6799 m = g_list_append(m, pam); | |
6800 | |
6801 pam = g_new0(struct proto_actions_menu, 1); | |
7880 | 6802 pam->label = _("Display Currently Registered Address"); |
4333 | 6803 pam->callback = oscar_show_email; |
6804 pam->gc = gc; | |
6805 m = g_list_append(m, pam); | |
6806 | |
6807 pam = g_new0(struct proto_actions_menu, 1); | |
7880 | 6808 pam->label = _("Change Currently Registered Address..."); |
4333 | 6809 pam->callback = oscar_show_change_email; |
6810 pam->gc = gc; | |
6811 m = g_list_append(m, pam); | |
2086 | 6812 } |
4333 | 6813 |
6814 m = g_list_append(m, NULL); | |
6815 | |
6816 pam = g_new0(struct proto_actions_menu, 1); | |
6817 pam->label = _("Show Buddies Awaiting Authorization"); | |
6818 pam->callback = oscar_show_awaitingauth; | |
6819 pam->gc = gc; | |
6820 m = g_list_append(m, pam); | |
6821 | |
2086 | 6822 m = g_list_append(m, NULL); |
4333 | 6823 |
6824 pam = g_new0(struct proto_actions_menu, 1); | |
7853 | 6825 pam->label = _("Search for Buddy by Email..."); |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6826 pam->callback = oscar_show_find_email; |
4333 | 6827 pam->gc = gc; |
6828 m = g_list_append(m, pam); | |
6829 | |
8591 | 6830 #if 0 |
6831 pam = g_new0(struct proto_actions_menu, 1); | |
4333 | 6832 pam->label = _("Search for Buddy by Information"); |
6833 pam->callback = show_find_info; | |
6834 pam->gc = gc; | |
8591 | 6835 m = g_list_append(m, pam); |
6836 #endif | |
2086 | 6837 |
6838 return m; | |
6839 } | |
6840 | |
5575 | 6841 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 6842 { |
7283 | 6843 OscarData *od = gc->proto_data; |
4617 | 6844 |
6845 if (od->icq) { | |
6846 aim_icq_changepasswd(od->sess, new); | |
2086 | 6847 } else { |
4617 | 6848 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6849 if (conn) { | |
6850 aim_admin_changepasswd(od->sess, conn, new, old); | |
6851 } else { | |
6852 od->chpass = TRUE; | |
6853 od->oldp = g_strdup(old); | |
6854 od->newp = g_strdup(new); | |
6855 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6856 } | |
2086 | 6857 } |
6858 } | |
6859 | |
6059 | 6860 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6861 { |
7283 | 6862 OscarData *od = gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6863 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6864 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6865 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6866 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6867 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6868 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6869 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6870 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6871 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6872 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6873 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6874 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6875 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6876 OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6877 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6878 NULL, |
8170 | 6879 NULL, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6880 oscar_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6881 oscar_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6882 oscar_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6883 oscar_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6884 oscar_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6885 oscar_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6886 oscar_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6887 oscar_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6888 oscar_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6889 oscar_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6890 oscar_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6891 oscar_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6892 oscar_send_typing, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6893 oscar_get_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6894 oscar_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6895 oscar_set_dir, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6896 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6897 oscar_dir_search, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6898 oscar_set_idle, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6899 oscar_change_passwd, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6900 oscar_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6901 oscar_add_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6902 oscar_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6903 oscar_remove_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6904 oscar_add_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6905 oscar_add_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6906 oscar_rem_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6907 oscar_rem_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6908 oscar_set_permit_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6909 oscar_warn, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6910 oscar_join_chat, |
8562 | 6911 NULL, /* reject chat invite */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6912 oscar_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6913 oscar_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6914 NULL, |
8219 | 6915 oscar_send_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6916 oscar_keepalive, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6917 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6918 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6919 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6920 #ifndef NOSSI |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6921 oscar_alias_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6922 oscar_move_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6923 oscar_rename_group, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6924 #else |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6925 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6926 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6927 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6928 #endif |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6929 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6930 oscar_convo_closed, |
5842 | 6931 NULL, |
8586 | 6932 oscar_set_icon, |
8589 | 6933 NULL, |
6934 NULL, | |
6935 NULL, | |
6936 NULL, | |
6937 NULL, | |
6938 NULL, | |
6939 NULL, | |
6940 NULL | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6941 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6942 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6943 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6944 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6945 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6946 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6947 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6948 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6949 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6950 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6951 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6952 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6953 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6954 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6955 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6956 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6957 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6958 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6959 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
6960 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6961 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6962 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6963 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6964 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6965 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6966 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6967 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6968 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6969 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6970 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
6971 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6972 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6973 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6974 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
6975 option = gaim_account_option_string_new(_("Auth host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6976 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6977 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6978 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6979 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
6980 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6981 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
6982 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6983 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6984 my_protocol = plugin; |
2086 | 6985 } |
6986 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
6987 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |