Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 8590:de3d7eb3fc86
[gaim-migrate @ 9341]
Hunkahunkaburninlove
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 06 Apr 2004 01:19:51 +0000 |
parents | 72a0759a37a2 |
children | f96795b786d2 |
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') { | |
369 gaim_debug(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 { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
381 gaim_debug(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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
513 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
544 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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? */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
554 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
555 "oscar callback for closed connection (2).\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
556 gaim_debug(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) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
562 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
565 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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) { |
574 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "Waiting to be destroyed\n"); | |
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))) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
580 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
586 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
601 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
618 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
625 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
632 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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 { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
640 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); | |
656 gaim_debug(GAIM_DEBUG_INFO, "oscar", buf); | |
657 if (buf[strlen(buf)-1] != '\n') | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
658 gaim_debug(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 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
689 gaim_debug(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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
701 gaim_debug(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) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
731 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
817 gaim_debug(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 | |
925 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_end\n"); | |
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 | |
948 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_recv_init\n"); | |
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 | |
976 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_cancel_recv\n"); | |
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 | |
1005 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_send_init\n"); | |
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 } | |
1025 gaim_debug(GAIM_DEBUG_MISC, "oscar", | |
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 | |
1045 gaim_debug(GAIM_DEBUG_INFO, "oscar", "AAA - in oscar_xfer_cancel_send\n"); | |
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 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1130 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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 } | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1165 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1166 "Login Error Code 0x%04hx\n", info->errorcode); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1167 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1174 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
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) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1178 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Email: %s\n", info->email); |
2086 | 1179 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1180 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Email is NULL\n"); |
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 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1183 gaim_debug(GAIM_DEBUG_MISC, "oscar", "BOSIP: %s\n", info->bosip); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1184 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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'; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1310 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Sending hash: "); |
2086 | 1311 for (x = 0; x < 16; x++) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1312 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02hhx ", (unsigned char)m[x]); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1313 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1314 gaim_debug(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 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1365 gaim_debug(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) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1370 gaim_debug(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; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1395 gaim_debug(GAIM_DEBUG_MISC, "oscar", "len + offset is invalid, " |
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); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1538 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1545 gaim_debug(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); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1567 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
6905 | 1574 gaim_debug(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); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1629 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1636 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1658 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1665 gaim_debug(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 */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1695 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1699 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1710 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1721 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1732 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1745 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1766 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1775 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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))) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1782 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1793 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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))) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1803 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1814 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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? */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1823 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
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) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1970 gaim_debug(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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2024 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2062 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2101 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2145 gaim_debug(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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2177 gaim_debug(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; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2206 gaim_debug(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)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2277 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
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); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2297 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2305 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2309 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
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 |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2313 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2314 "Character set is %hu %hu\n", args->charset, args->charsubset); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2315 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 2316 /* This message is marked as UNICODE, so we have to |
2317 * convert it to utf-8 before handing it to the gaim core. | |
2318 * This conversion should *never* fail, if it does it | |
2319 * means that either the incoming ICBM is corrupted or | |
4662 | 2320 * there is something we don't understand about it. |
2321 * For the record, AIM Unicode is big-endian UCS-2 */ | |
2322 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2323 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Received UNICODE IM\n"); |
4121 | 2324 |
2325 if (!args->msg || !args->msglen) | |
2326 return 1; | |
4641 | 2327 |
3659 | 2328 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
2329 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2330 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2331 "Unicode IM conversion: %s\n", err->message); |
7475 | 2332 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 2333 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2334 } |
3722 | 2335 } else { |
3850 | 2336 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 2337 * unflagged messages, which are ASCII. That's OK because |
2338 * ASCII is a strict subset of ISO-8859-1; this should | |
2339 * help with compatibility with old, broken versions of | |
2340 * gaim (everything before 0.60) and other broken clients | |
2341 * that will happily send ISO-8859-1 without marking it as | |
2342 * such */ | |
4662 | 2343 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2344 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2345 "Received ISO-8859-1 IM\n"); |
4121 | 2346 |
2347 if (!args->msg || !args->msglen) | |
2348 return 1; | |
2349 | |
3659 | 2350 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
2351 if (err) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2352 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2353 "ISO-8859-1 IM conversion: %s\n", err->message); |
7475 | 2354 tmp = g_strdup(_("(There was an error receiving this message)")); |
4800 | 2355 g_error_free(err); |
3659 | 2356 } |
3642 | 2357 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2358 |
8493 | 2359 /* If the message came from an ICQ user then escape any HTML */ |
2360 if (isdigit(userinfo->sn[0])) { | |
8564 | 2361 gchar *tmp2; |
2362 gaim_markup_html_to_xhtml(tmp, &tmp2, NULL); | |
8493 | 2363 g_free(tmp); |
2364 tmp = tmp2; | |
2365 } | |
2366 | |
6982 | 2367 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2368 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2369 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2370 return 1; |
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 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2373 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
5575 | 2374 GaimConnection *gc = sess->aux_data; |
7283 | 2375 OscarData *od = gc->proto_data; |
5575 | 2376 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
|
2377 |
4121 | 2378 if (!args) |
2379 return 0; | |
4194 | 2380 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2381 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2382 "rendezvous with %s, status is %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2383 userinfo->sn, args->status); |
2869 | 2384 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2385 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 2386 char *name; |
5234 | 2387 GHashTable *components; |
2388 | |
4121 | 2389 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
2390 return 1; | |
5234 | 2391 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
2392 g_free); | |
4121 | 2393 name = extract_name(args->info.chat.roominfo.name); |
5234 | 2394 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
2395 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
|
2396 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2397 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2398 userinfo->sn, |
6059 | 2399 args->msg, |
5234 | 2400 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2401 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2402 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2403 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 2404 /* BBB */ |
2405 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
2406 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2407 GaimXfer *xfer; |
5146 | 2408 struct aim_oft_info *oft_info; |
2409 | |
2410 if (!args->cookie || !args->port || !args->verifiedip || | |
2411 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 2412 !args->info.sendfile.totfiles || !args->reqclass) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2413 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2414 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2415 "information.\n", userinfo->sn); |
5146 | 2416 if (args->proxyip) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2417 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2418 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2419 "does not support this yet.\n"); |
4617 | 2420 return 1; |
4656 | 2421 } |
4617 | 2422 |
2423 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
2424 /* last char of the ft req is a star, they are sending us a | |
2425 * directory -- remove the star and trailing slash so we dont save | |
2426 * directories that look like 'dirname\*' -- arl */ | |
2427 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
2428 if (tmp && (tmp[1] == '*')) { | |
2429 tmp[0] = '\0'; | |
2430 } | |
8446 | 2431 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
2432 "We're receiving a whole directory! What fun! " | |
2433 "Especially since we don't support that!\n"); | |
4617 | 2434 } |
2435 | |
2436 /* Build the file transfer handle */ | |
2437 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 2438 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 2439 xfer->remote_port = args->port; |
4617 | 2440 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
2441 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
5146 | 2442 |
2443 /* Create the oscar-specific data */ | |
5163 | 2444 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 2445 if (args->proxyip) |
5146 | 2446 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 2447 if (args->verifiedip) |
5146 | 2448 oft_info->verifiedip = g_strdup(args->verifiedip); |
2449 xfer->data = oft_info; | |
4617 | 2450 |
2451 /* Setup our I/O op functions */ | |
8446 | 2452 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 2453 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 2454 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
|
2455 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 2456 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 2457 |
2458 /* | |
2459 * XXX - Should do something with args->msg, args->encoding, and args->language | |
2460 * probably make it apply to all ch2 messages. | |
3752 | 2461 */ |
4617 | 2462 |
2463 /* Keep track of this transfer for later */ | |
2464 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2465 | |
2466 /* Now perform the request */ | |
2467 gaim_xfer_request(xfer); | |
2468 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
2469 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2470 GaimXfer *xfer; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2471 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2472 "AAA - File transfer canceled by remote user\n"); |
4617 | 2473 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
|
2474 gaim_xfer_cancel_remote(xfer); |
4617 | 2475 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
2476 /* | |
2477 * This gets sent by the receiver of a file | |
2478 * as they connect directly to us. If we don't | |
2479 * get this, then maybe a third party connected | |
2480 * to us, and we shouldn't send them anything. | |
2481 */ | |
2482 } else { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2483 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2484 "unknown rendezvous status!\n"); |
3630 | 2485 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2486 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 2487 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2488 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2489 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2490 userinfo->sn, args->info.icon.icon, |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
2491 args->info.icon.length); |
6871 | 2492 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2493 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2494 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2495 |
4212 | 2496 if (!args->verifiedip) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2497 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2498 "directim kill blocked (%s)\n", userinfo->sn); |
4650 | 2499 return 1; |
4212 | 2500 } |
2501 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2502 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2503 "%s received direct im request from %s (%s)\n", |
5575 | 2504 username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2505 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2506 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2507 d->sn = g_strdup(userinfo->sn); |
8552 | 2508 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
|
2509 memcpy(d->cookie, args->cookie, 8); |
5575 | 2510 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
|
2511 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2512 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2513 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2514 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2515 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2516 "revealed, this may be considered a privacy " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2517 "risk."), 0, d, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2518 _("Connect"), G_CALLBACK(accept_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2519 _("Cancel"), G_CALLBACK(cancel_direct_im)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2520 } else { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2521 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2522 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2523 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2524 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2525 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2526 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2527 |
3453 | 2528 /* |
4230 | 2529 * Authorization Functions |
2530 * Most of these are callbacks from dialogs. They're used by both | |
2531 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 2532 */ |
4269 | 2533 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2534 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 2535 GaimConnection *gc = data->gc; |
4244 | 2536 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2537 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 2538 OscarData *od = gc->proto_data; |
6695 | 2539 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
2540 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 2541 if (buddy && group) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2542 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2543 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2544 buddy->name, group->name); |
4889 | 2545 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 2546 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
4889 | 2547 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
4244 | 2548 } |
4230 | 2549 } |
4337 | 2550 } |
2551 | |
2552 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2553 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
2554 NULL, _("Please authorize me!"), TRUE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2555 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 2556 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2557 data); |
4230 | 2558 } |
2559 | |
2560 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 2561 GaimConnection *gc = data->gc; |
4244 | 2562 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2563 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 2564 /* Remove from local list */ |
2565 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
2566 gaim_blist_remove_buddy(b); | |
4244 | 2567 } |
2568 | |
5836 | 2569 oscar_free_name_data(data); |
4230 | 2570 } |
2571 | |
5575 | 2572 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { |
4269 | 2573 struct name_data *data = g_new(struct name_data, 1); |
6695 | 2574 GaimBuddy *buddy; |
4269 | 2575 gchar *dialog_msg, *nombre; |
2576 | |
4687 | 2577 buddy = gaim_find_buddy(gc->account, name); |
2578 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
2579 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
4269 | 2580 else |
4830 | 2581 nombre = NULL; |
2582 | |
2583 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 | 2584 data->gc = gc; |
2585 data->name = g_strdup(name); | |
2586 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2587 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2588 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2589 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2590 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2591 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2592 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 2593 |
2594 g_free(dialog_msg); | |
2595 g_free(nombre); | |
2596 } | |
2597 | |
4230 | 2598 /* When other people ask you for authorization */ |
2599 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 2600 GaimConnection *gc = data->gc; |
4244 | 2601 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2602 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 2603 OscarData *od = gc->proto_data; |
4236 | 2604 #ifdef NOSSI |
6695 | 2605 GaimBuddy *buddy; |
4244 | 2606 gchar message; |
2607 message = 0; | |
4687 | 2608 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 2609 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
|
2610 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 2611 #else |
4889 | 2612 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 2613 #endif |
4244 | 2614 } |
2615 | |
5836 | 2616 oscar_free_name_data(data); |
3141 | 2617 } |
2618 | |
4230 | 2619 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2620 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 2621 GaimConnection *gc = data->gc; |
4244 | 2622 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2623 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 2624 OscarData *od = gc->proto_data; |
4230 | 2625 #ifdef NOSSI |
4617 | 2626 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 2627 #else |
4889 | 2628 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 2629 #endif |
4244 | 2630 } |
4337 | 2631 } |
2632 | |
2633 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2634 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
2635 NULL, _("No reason given."), TRUE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2636 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 2637 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2638 data); |
3141 | 2639 } |
2640 | |
7023 | 2641 /* When someone sends you buddies */ |
2642 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 2643 GaimConnection *gc = data->gc; |
4244 | 2644 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2645 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
2646 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 2647 } |
2648 | |
5836 | 2649 oscar_free_name_data(data); |
3453 | 2650 } |
2651 | |
4075 | 2652 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 | 2653 GaimConnection *gc = sess->aux_data; |
4076 | 2654 gchar **msg1, **msg2; |
2655 GError *err = NULL; | |
6051 | 2656 int i, numtoks; |
4076 | 2657 |
4121 | 2658 if (!args->type || !args->msg || !args->uin) |
2659 return 1; | |
4194 | 2660 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2661 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2662 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
4076 | 2663 |
2664 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 2665 msg1 = g_strsplit(args->msg, "\376", 0); |
6051 | 2666 for (numtoks=0; msg1[numtoks]; numtoks++); |
2667 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 2668 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
2669 gaim_str_strip_cr(msg1[i]); |
4076 | 2670 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); |
4800 | 2671 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2672 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2673 "Error converting a string from ISO-8859-1 to " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2674 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 2675 g_error_free(err); |
2676 } | |
4076 | 2677 } |
2678 msg2[i] = NULL; | |
2679 | |
3952 | 2680 switch (args->type) { |
4173 | 2681 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 2682 if (i >= 1) { |
5556 | 2683 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 2684 gchar *tmp; |
2685 | |
2686 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 2687 tmp = gaim_escape_html(msg2[0]); |
8493 | 2688 |
4076 | 2689 if (t) { /* This is an offline message */ |
2690 /* I think this timestamp is in UTC, or something */ | |
8514 | 2691 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 2692 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 2693 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 2694 } |
2695 g_free(uin); | |
8493 | 2696 g_free(tmp); |
4075 | 2697 } |
3316 | 2698 } break; |
2699 | |
4173 | 2700 case 0x04: { /* Someone sent you a URL */ |
4076 | 2701 if (i >= 2) { |
7385 | 2702 if (msg2[1] != NULL) { |
2703 gchar *uin = g_strdup_printf("%u", args->uin); | |
2704 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
2705 msg2[1], | |
2706 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
2707 serv_got_im(gc, uin, message, 0, time(NULL)); | |
2708 g_free(uin); | |
2709 g_free(message); | |
2710 } | |
3453 | 2711 } |
2712 } break; | |
2713 | |
4173 | 2714 case 0x06: { /* Someone requested authorization */ |
4076 | 2715 if (i >= 6) { |
4230 | 2716 struct name_data *data = g_new(struct name_data, 1); |
5556 | 2717 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.")); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2718 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
5556 | 2719 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2720 args->uin); |
4076 | 2721 data->gc = gc; |
5556 | 2722 data->name = g_strdup_printf("%u", args->uin); |
4230 | 2723 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2724 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2725 gaim_request_action(gc, NULL, _("Authorization Request"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2726 dialog_msg, 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2727 _("Authorize"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2728 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2729 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2730 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 2731 g_free(dialog_msg); |
2732 } | |
3141 | 2733 } break; |
2734 | |
4173 | 2735 case 0x07: { /* Someone has denied you authorization */ |
4076 | 2736 if (i >= 1) { |
7023 | 2737 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
|
2738 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2739 dialog_msg); |
4076 | 2740 g_free(dialog_msg); |
2741 } | |
3141 | 2742 } break; |
2743 | |
4173 | 2744 case 0x08: { /* Someone has granted you authorization */ |
7023 | 2745 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
|
2746 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2747 dialog_msg); |
3141 | 2748 g_free(dialog_msg); |
2749 } break; | |
2750 | |
4333 | 2751 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
2752 if (i >= 5) { | |
2753 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
|
2754 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 2755 g_free(dialog_msg); |
2756 } | |
2757 } break; | |
2758 | |
4173 | 2759 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 2760 if (i >= 6) { |
4194 | 2761 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
|
2762 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 2763 g_free(dialog_msg); |
2764 } | |
4075 | 2765 } break; |
2766 | |
4173 | 2767 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 2768 if (i >= 6) { |
4308 | 2769 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
|
2770 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 2771 g_free(dialog_msg); |
2772 } | |
4075 | 2773 } break; |
2774 | |
4173 | 2775 case 0x12: { |
3141 | 2776 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 2777 /* Someone added you to their buddy list? */ |
3141 | 2778 } break; |
2779 | |
7023 | 2780 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 2781 guint i, num; |
3453 | 2782 gchar **text; |
4173 | 2783 text = g_strsplit(args->msg, "\376", 0); |
3453 | 2784 if (text) { |
2785 num = 0; | |
2786 for (i=0; i<strlen(text[0]); i++) | |
2787 num = num*10 + text[0][i]-48; | |
2788 for (i=0; i<num; i++) { | |
4230 | 2789 struct name_data *data = g_new(struct name_data, 1); |
7023 | 2790 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 | 2791 data->gc = gc; |
4790 | 2792 data->name = g_strdup(text[i*2+1]); |
2793 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2794 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2795 gaim_request_action(gc, NULL, message, |
7023 | 2796 _("Do you want to add this buddy " |
2797 "to your buddy list?"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
2798 0, data, 2, |
7023 | 2799 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 2800 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 2801 g_free(message); |
2802 } | |
2803 g_strfreev(text); | |
2804 } | |
2805 } break; | |
2806 | |
7023 | 2807 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 2808 /* This is boring and silly. */ |
2809 } break; | |
2810 | |
3141 | 2811 default: { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2812 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2813 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2814 "(type 0x%02hhx).\n", args->type); |
3141 | 2815 } break; |
2816 } | |
2817 | |
4076 | 2818 g_strfreev(msg1); |
2819 g_strfreev(msg2); | |
2820 | |
3141 | 2821 return 1; |
2822 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2823 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2824 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 2825 fu16_t channel; |
2826 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2827 aim_userinfo_t *userinfo; |
2086 | 2828 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2829 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2830 va_start(ap, fr); |
4200 | 2831 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2832 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2833 |
3141 | 2834 switch (channel) { |
2835 case 1: { /* standard message */ | |
2836 struct aim_incomingim_ch1_args *args; | |
2837 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2838 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2839 } break; | |
2840 | |
2841 case 2: { /* rendevous */ | |
2842 struct aim_incomingim_ch2_args *args; | |
2843 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2844 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2845 } break; | |
2846 | |
2847 case 4: { /* ICQ */ | |
2848 struct aim_incomingim_ch4_args *args; | |
2849 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2850 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2851 } break; |
2852 | |
2853 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2854 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2855 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2856 "0x%04hx).", channel); |
3141 | 2857 } break; |
2086 | 2858 } |
2859 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2860 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2861 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2862 return ret; |
2086 | 2863 } |
2864 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2865 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
5420 | 2866 char *buf; |
2086 | 2867 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2868 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2869 aim_userinfo_t *userinfo; |
2086 | 2870 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2871 va_start(ap, fr); |
4200 | 2872 chan = (fu16_t)va_arg(ap, unsigned int); |
2873 userinfo = va_arg(ap, aim_userinfo_t *); | |
2874 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
2875 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 2876 va_end(ap); |
2877 | |
2878 switch(reason) { | |
5420 | 2879 case 0: /* Invalid (0) */ |
2880 buf = g_strdup_printf( | |
2881 ngettext( | |
4276 | 2882 "You missed %hu message from %s because it was invalid.", |
2883 "You missed %hu messages from %s because they were invalid.", | |
2884 nummissed), | |
4282 | 2885 nummissed, |
2886 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2887 break; |
5420 | 2888 case 1: /* Message too large */ |
2889 buf = g_strdup_printf( | |
2890 ngettext( | |
4276 | 2891 "You missed %hu message from %s because it was too large.", |
2892 "You missed %hu messages from %s because they were too large.", | |
2893 nummissed), | |
4282 | 2894 nummissed, |
2895 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2896 break; |
5420 | 2897 case 2: /* Rate exceeded */ |
2898 buf = g_strdup_printf( | |
2899 ngettext( | |
4276 | 2900 "You missed %hu message from %s because the rate limit has been exceeded.", |
2901 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
2902 nummissed), | |
4282 | 2903 nummissed, |
2904 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2905 break; |
5420 | 2906 case 3: /* Evil Sender */ |
2907 buf = g_strdup_printf( | |
2908 ngettext( | |
4276 | 2909 "You missed %hu message from %s because he/she was too evil.", |
2910 "You missed %hu messages from %s because he/she was too evil.", | |
2911 nummissed), | |
4282 | 2912 nummissed, |
2913 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2914 break; |
5420 | 2915 case 4: /* Evil Receiver */ |
2916 buf = g_strdup_printf( | |
2917 ngettext( | |
4276 | 2918 "You missed %hu message from %s because you are too evil.", |
2919 "You missed %hu messages from %s because you are too evil.", | |
2920 nummissed), | |
4282 | 2921 nummissed, |
2922 userinfo->sn); | |
2086 | 2923 break; |
2924 default: | |
5420 | 2925 buf = g_strdup_printf( |
2926 ngettext( | |
4276 | 2927 "You missed %hu message from %s for an unknown reason.", |
2928 "You missed %hu messages from %s for an unknown reason.", | |
2929 nummissed), | |
4282 | 2930 nummissed, |
2931 userinfo->sn); | |
2086 | 2932 break; |
2933 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2934 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 2935 g_free(buf); |
2086 | 2936 |
2937 return 1; | |
2938 } | |
2939 | |
3212 | 2940 static char *gaim_icq_status(int state) { |
2941 /* Make a cute little string that shows the status of the dude or dudet */ | |
2942 if (state & AIM_ICQ_STATE_CHAT) | |
4342 | 2943 return g_strdup_printf(_("Free For Chat")); |
3212 | 2944 else if (state & AIM_ICQ_STATE_DND) |
4342 | 2945 return g_strdup_printf(_("Do Not Disturb")); |
3212 | 2946 else if (state & AIM_ICQ_STATE_OUT) |
4342 | 2947 return g_strdup_printf(_("Not Available")); |
3212 | 2948 else if (state & AIM_ICQ_STATE_BUSY) |
4342 | 2949 return g_strdup_printf(_("Occupied")); |
3212 | 2950 else if (state & AIM_ICQ_STATE_AWAY) |
4342 | 2951 return g_strdup_printf(_("Away")); |
3212 | 2952 else if (state & AIM_ICQ_STATE_WEBAWARE) |
4342 | 2953 return g_strdup_printf(_("Web Aware")); |
3212 | 2954 else if (state & AIM_ICQ_STATE_INVISIBLE) |
4342 | 2955 return g_strdup_printf(_("Invisible")); |
3212 | 2956 else |
4342 | 2957 return g_strdup_printf(_("Online")); |
3212 | 2958 } |
2959 | |
4194 | 2960 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 2961 GaimConnection *gc = sess->aux_data; |
7283 | 2962 OscarData *od = gc->proto_data; |
4617 | 2963 |
2964 /* BBB */ | |
3630 | 2965 switch (reason) { |
4151 | 2966 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2967 GaimXfer *xfer; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2968 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2969 "AAA - Other user declined file transfer\n"); |
4617 | 2970 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
|
2971 gaim_xfer_cancel_remote(xfer); |
4151 | 2972 } break; |
2973 | |
2974 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2975 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2976 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2977 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 2978 } |
3630 | 2979 |
2980 } | |
2981 | |
2982 return 0; | |
2983 } | |
2984 | |
4194 | 2985 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 2986 GaimConnection *gc = sess->aux_data; |
4151 | 2987 |
2988 switch(reason) { | |
2989 case 0x0003: { /* Reply from an ICQ status message request */ | |
2990 char *status_msg = gaim_icq_status(state); | |
2991 char *dialog_msg, **splitmsg; | |
2992 | |
2993 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2994 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2995 | |
7011 | 2996 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
7032 | 2997 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, dialog_msg, NULL, NULL); |
4151 | 2998 |
2999 g_free(status_msg); | |
3000 g_free(dialog_msg); | |
3001 g_strfreev(splitmsg); | |
3002 } break; | |
3003 | |
3004 default: { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3005 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3006 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3007 "Type 0x%04hx\n", who, reason); |
4151 | 3008 } break; |
3009 } /* end of switch */ | |
3010 | |
3011 return 0; | |
3012 } | |
3013 | |
3212 | 3014 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
3015 va_list ap; | |
3016 fu16_t chan, reason; | |
3017 char *who; | |
3018 | |
3019 va_start(ap, fr); | |
4200 | 3020 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3021 who = va_arg(ap, char *); |
4200 | 3022 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 3023 |
3952 | 3024 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 3025 char *cookie = va_arg(ap, char *); |
4151 | 3026 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 3027 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 3028 fu32_t state = 0; |
4151 | 3029 char *msg = NULL; |
3030 if (reason == 0x0003) { | |
4200 | 3031 state = va_arg(ap, fu32_t); |
4151 | 3032 msg = va_arg(ap, char *); |
3033 } | |
3034 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
3035 } | |
3952 | 3036 |
3212 | 3037 va_end(ap); |
3038 | |
3039 return 1; | |
3040 } | |
3041 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3042 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3043 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3044 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3045 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3046 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3047 va_start(ap, fr); |
4199 | 3048 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3049 va_end(ap); |
3050 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3051 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3052 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3053 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 3054 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3055 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 3056 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3057 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3058 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3059 |
2086 | 3060 return 1; |
3061 } | |
3062 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3063 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4617 | 3064 #if 0 |
5575 | 3065 GaimConnection *gc = sess->aux_data; |
7283 | 3066 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3067 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3068 #endif |
4617 | 3069 va_list ap; |
3070 fu16_t reason; | |
3071 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3072 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3073 va_start(ap, fr); |
4617 | 3074 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 3075 data = va_arg(ap, char *); |
2086 | 3076 va_end(ap); |
3077 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3078 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3079 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 3080 |
3081 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3082 #if 0 |
4617 | 3083 /* If this was a file transfer request, data is a cookie */ |
3084 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
|
3085 gaim_xfer_cancel_remote(xfer); |
3630 | 3086 return 1; |
3087 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3088 #endif |
3630 | 3089 |
4617 | 3090 /* Data is assumed to be the destination sn */ |
3091 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
|
3092 gaim_notify_error(sess->aux_data, NULL, buf, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3093 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
4617 | 3094 g_free(buf); |
2086 | 3095 |
3096 return 1; | |
3097 } | |
3098 | |
3595 | 3099 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3100 GaimConnection *gc = sess->aux_data; |
3595 | 3101 va_list ap; |
3102 fu16_t type1, type2; | |
3103 char *sn; | |
3104 | |
3105 va_start(ap, fr); | |
4199 | 3106 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3107 sn = va_arg(ap, char *); |
4199 | 3108 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 3109 va_end(ap); |
3110 | |
3111 switch (type2) { | |
3112 case 0x0000: { /* Text has been cleared */ | |
3113 serv_got_typing_stopped(gc, sn); | |
3114 } break; | |
3115 | |
3116 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3117 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 3118 } break; |
3119 | |
3120 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3121 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 3122 } break; |
3123 | |
3124 default: { | |
5435 | 3125 gaim_debug(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 | 3126 } break; |
3127 } | |
3128 | |
3129 return 1; | |
3130 } | |
3131 | |
7141 | 3132 /* |
3133 * We get this error when there was an error in the locate family. This | |
7259 | 3134 * happens when you request info of someone who is offline. |
7141 | 3135 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3136 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
7259 | 3137 gchar *buf; |
2086 | 3138 va_list ap; |
5420 | 3139 fu16_t reason; |
2086 | 3140 char *destn; |
3141 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3142 va_start(ap, fr); |
4199 | 3143 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3144 destn = va_arg(ap, char *); |
3145 va_end(ap); | |
3146 | |
7781 | 3147 if (destn == NULL) |
7793 | 3148 return 1; |
3149 | |
3150 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); | |
7781 | 3151 |
3152 gaim_notify_error(sess->aux_data, NULL, buf, | |
3153 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
3154 g_free(buf); | |
2086 | 3155 |
3156 return 1; | |
3157 } | |
3158 | |
6982 | 3159 #if 0 |
2086 | 3160 static char *images(int flags) { |
3161 static char buf[1024]; | |
3101 | 3162 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
2679 | 3163 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
2086 | 3164 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
3165 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
3101 | 3166 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
2086 | 3167 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
3079 | 3168 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
3169 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
2086 | 3170 return buf; |
3171 } | |
6982 | 3172 #endif |
3101 | 3173 |
2920 | 3174 static char *caps_string(guint caps) |
3175 { | |
3176 static char buf[512], *tmp; | |
3177 int count = 0, i = 0; | |
3178 guint bit = 1; | |
4742 | 3179 |
3180 if (!caps) { | |
4744 | 3181 return NULL; |
6318 | 3182 } else while (bit <= AIM_CAPS_LAST) { |
2920 | 3183 if (bit & caps) { |
3184 switch (bit) { | |
6871 | 3185 case AIM_CAPS_BUDDYICON: |
2920 | 3186 tmp = _("Buddy Icon"); |
3187 break; | |
8092 | 3188 case AIM_CAPS_TALK: |
2920 | 3189 tmp = _("Voice"); |
3190 break; | |
6871 | 3191 case AIM_CAPS_DIRECTIM: |
7141 | 3192 tmp = _("AIM Direct IM"); |
2920 | 3193 break; |
6871 | 3194 case AIM_CAPS_CHAT: |
2920 | 3195 tmp = _("Chat"); |
3196 break; | |
6871 | 3197 case AIM_CAPS_GETFILE: |
2920 | 3198 tmp = _("Get File"); |
3199 break; | |
6871 | 3200 case AIM_CAPS_SENDFILE: |
2920 | 3201 tmp = _("Send File"); |
3202 break; | |
6871 | 3203 case AIM_CAPS_GAMES: |
3204 case AIM_CAPS_GAMES2: | |
2920 | 3205 tmp = _("Games"); |
3206 break; | |
8092 | 3207 case AIM_CAPS_ADDINS: |
4898 | 3208 tmp = _("Add-Ins"); |
2920 | 3209 break; |
6871 | 3210 case AIM_CAPS_SENDBUDDYLIST: |
2920 | 3211 tmp = _("Send Buddy List"); |
3212 break; | |
7141 | 3213 case AIM_CAPS_ICQ_DIRECT: |
3214 tmp = _("ICQ Direct Connect"); | |
2920 | 3215 break; |
6871 | 3216 case AIM_CAPS_APINFO: |
2920 | 3217 tmp = _("AP User"); |
3218 break; | |
6871 | 3219 case AIM_CAPS_ICQRTF: |
2920 | 3220 tmp = _("ICQ RTF"); |
3221 break; | |
6871 | 3222 case AIM_CAPS_EMPTY: |
2920 | 3223 tmp = _("Nihilist"); |
3224 break; | |
6871 | 3225 case AIM_CAPS_ICQSERVERRELAY: |
2920 | 3226 tmp = _("ICQ Server Relay"); |
3227 break; | |
6871 | 3228 case AIM_CAPS_ICQUTF8OLD: |
3229 tmp = _("Old ICQ UTF8"); | |
2920 | 3230 break; |
6871 | 3231 case AIM_CAPS_TRILLIANCRYPT: |
2920 | 3232 tmp = _("Trillian Encryption"); |
3233 break; | |
6871 | 3234 case AIM_CAPS_ICQUTF8: |
4742 | 3235 tmp = _("ICQ UTF8"); |
3236 break; | |
6318 | 3237 case AIM_CAPS_HIPTOP: |
3238 tmp = _("Hiptop"); | |
3239 break; | |
6871 | 3240 case AIM_CAPS_SECUREIM: |
7334 | 3241 tmp = _("Security Enabled"); |
6871 | 3242 break; |
7582 | 3243 case AIM_CAPS_VIDEO: |
3244 tmp = _("Video Chat"); | |
3245 break; | |
8092 | 3246 /* Not actually sure about this one... WinAIM doesn't show anything */ |
7945 | 3247 case AIM_CAPS_ICHATAV: |
3248 tmp = _("iChat AV"); | |
3249 break; | |
8092 | 3250 case AIM_CAPS_LIVEVIDEO: |
3251 tmp = _("Live Video"); | |
3252 break; | |
3253 case AIM_CAPS_CAMERA: | |
3254 tmp = _("Camera"); | |
3255 break; | |
2920 | 3256 default: |
3257 tmp = NULL; | |
3258 break; | |
3259 } | |
3260 if (tmp) | |
3261 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
3262 tmp); | |
3263 count++; | |
3264 } | |
3265 bit <<= 1; | |
3266 } | |
4744 | 3267 return buf; |
2920 | 3268 } |
3269 | |
7011 | 3270 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3271 GaimConnection *gc = sess->aux_data; |
7011 | 3272 GString *text; |
7162 | 3273 gchar *info_utf8 = NULL, *away_utf8 = NULL; |
3274 const char *final = NULL; | |
4791 | 3275 va_list ap; |
7011 | 3276 aim_userinfo_t *userinfo; |
2086 | 3277 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3278 va_start(ap, fr); |
7011 | 3279 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3280 va_end(ap); |
3281 | |
7011 | 3282 text = g_string_new(""); |
3283 g_string_append_printf(text, _("Username: <b>%s</b><br>\n"), userinfo->sn); | |
3284 g_string_append_printf(text, _("Warning Level: <b>%d%%</b><br>\n"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
3285 | |
3286 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
3287 g_string_append_printf(text, _("Online Since: <b>%s</b><br>\n"), | |
3288 asctime(localtime((time_t *)&userinfo->onlinesince))); | |
3289 | |
3290 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
3291 g_string_append_printf(text, _("Member Since: <b>%s</b><br>\n"), | |
3292 asctime(localtime((time_t *)&userinfo->membersince))); | |
3293 | |
3294 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
3295 gchar *itime = gaim_str_seconds_to_string(userinfo->idletime*60); |
7011 | 3296 g_string_append_printf(text, _("Idle: <b>%s</b>"), itime); |
4426 | 3297 g_free(itime); |
2993 | 3298 } else |
7011 | 3299 g_string_append_printf(text, _("Idle: <b>Active</b>")); |
3300 | |
3301 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 3302 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
3303 away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | |
3304 g_free(charset); | |
7011 | 3305 if (away_utf8 != NULL) { |
7129 | 3306 g_string_append_printf(text, "<hr>%s", away_utf8); |
7011 | 3307 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3308 } |
7011 | 3309 } |
3310 | |
3311 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8225 | 3312 gchar *charset = oscar_encoding_extract(userinfo->info_encoding); |
3313 info_utf8 = oscar_encoding_to_utf8(charset, userinfo->info, userinfo->info_len); | |
3314 g_free(charset); | |
7011 | 3315 if (info_utf8 != NULL) { |
7129 | 3316 g_string_append_printf(text, "<hr>%s", info_utf8); |
7011 | 3317 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3318 } |
7011 | 3319 } |
3320 | |
7164 | 3321 final = gaim_str_sub_away_formatters(text->str, gaim_account_get_username(gaim_connection_get_account(gc))); |
7011 | 3322 g_string_free(text, TRUE); |
7091 | 3323 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, final, NULL, NULL); |
4151 | 3324 |
2086 | 3325 return 1; |
3326 } | |
3327 | |
8341 | 3328 static gboolean gaim_reqinfo_timeout_cb(void *data) |
3329 { | |
3330 aim_session_t *sess = data; | |
3331 GaimConnection *gc = sess->aux_data; | |
3332 OscarData *od = (OscarData *)gc->proto_data; | |
3333 | |
3334 aim_locate_dorequest(data); | |
3335 od->getinfotimer = 0; | |
3336 | |
3337 return FALSE; | |
3338 } | |
3339 | |
3340 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
3341 { | |
3342 GaimConnection *gc = sess->aux_data; | |
3343 OscarData *od = (OscarData *)gc->proto_data; | |
3344 | |
3345 /* | |
3346 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
3347 * us from hitting the rate limit due to request away messages and info | |
3348 * too quickly. | |
3349 */ | |
3350 if (od->getinfotimer == 0) | |
3351 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
3352 | |
3353 return 1; | |
3354 } | |
3355 | |
3356 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
3357 { | |
2086 | 3358 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3359 fu16_t id; |
2086 | 3360 va_list ap; |
3361 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3362 va_start(ap, fr); |
4199 | 3363 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3364 msg = va_arg(ap, char *); |
3365 va_end(ap); | |
3366 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3367 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3368 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
3369 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3370 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3371 _("Your AIM connection may be lost."), NULL); |
2086 | 3372 |
3373 return 1; | |
3374 } | |
3375 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3376 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3377 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3378 fu16_t type; |
5575 | 3379 GaimConnection *gc = sess->aux_data; |
7283 | 3380 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 3381 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3382 va_start(ap, fr); |
4199 | 3383 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3384 |
3385 switch(type) { | |
3386 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3387 fu8_t maxrooms; |
2086 | 3388 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3389 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3390 |
4199 | 3391 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 3392 exchangecount = va_arg(ap, int); |
3393 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
3394 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3395 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3396 "chat info: Chat Rights:\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3397 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3398 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3399 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3400 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3401 for (i = 0; i < exchangecount; i++) |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3402 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3403 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3404 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 3405 while (od->create_rooms) { |
3406 struct create_room *cr = od->create_rooms->data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3407 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3408 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3409 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3410 g_free(cr->name); |
4617 | 3411 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3412 g_free(cr); |
2086 | 3413 } |
3414 } | |
3415 break; | |
3416 case 0x0008: { | |
3417 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3418 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3419 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3420 fu32_t createtime; |
2086 | 3421 |
3422 fqcn = va_arg(ap, char *); | |
4200 | 3423 instance = (fu16_t)va_arg(ap, unsigned int); |
3424 exchange = (fu16_t)va_arg(ap, unsigned int); | |
3425 flags = (fu16_t)va_arg(ap, unsigned int); | |
3426 createtime = va_arg(ap, fu32_t); | |
3427 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3428 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
3429 createperms = (fu8_t)va_arg(ap, unsigned int); | |
3430 unknown = (fu16_t)va_arg(ap, unsigned int); | |
3431 name = va_arg(ap, char *); | |
3432 ck = va_arg(ap, char *); | |
4194 | 3433 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3434 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 3435 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 3436 fqcn, |
3437 exchange, instance, flags, | |
3438 createtime, | |
3439 maxmsglen, maxoccupancy, createperms, unknown, | |
3440 name, ck); | |
4617 | 3441 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 3442 } |
3443 break; | |
3444 default: | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3445 gaim_debug(GAIM_DEBUG_WARNING, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3446 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 3447 break; |
3448 } | |
4194 | 3449 |
3450 va_end(ap); | |
3451 | |
2086 | 3452 return 1; |
3453 } | |
3454 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3455 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3456 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3457 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3458 aim_userinfo_t *info; |
5575 | 3459 GaimConnection *g = sess->aux_data; |
2086 | 3460 |
3461 struct chat_connection *c = NULL; | |
3462 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3463 va_start(ap, fr); |
2086 | 3464 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3465 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3466 va_end(ap); |
3467 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3468 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3469 if (!c) |
3470 return 1; | |
3471 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3472 for (i = 0; i < count; i++) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3473 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3474 |
3475 return 1; | |
3476 } | |
3477 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3478 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3479 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3480 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3481 aim_userinfo_t *info; |
5575 | 3482 GaimConnection *g = sess->aux_data; |
2086 | 3483 |
3484 struct chat_connection *c = NULL; | |
3485 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3486 va_start(ap, fr); |
2086 | 3487 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3488 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3489 va_end(ap); |
3490 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3491 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3492 if (!c) |
3493 return 1; | |
3494 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3495 for (i = 0; i < count; i++) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3496 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3497 |
3498 return 1; | |
3499 } | |
3500 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3501 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
|
3502 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3503 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3504 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3505 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3506 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3507 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3508 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3509 fu32_t creationtime; |
5575 | 3510 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3511 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
|
3512 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3513 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3514 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3515 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3516 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3517 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3518 roomdesc = va_arg(ap, char *); |
4200 | 3519 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
3520 creationtime = va_arg(ap, fu32_t); | |
3521 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3522 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
3523 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
3524 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3525 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3526 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3527 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3528 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3529 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3530 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3531 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3532 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3533 |
2086 | 3534 return 1; |
3535 } | |
3536 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3537 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3538 GaimConnection *gc = sess->aux_data; |
8225 | 3539 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
3540 gchar *utf8; | |
2086 | 3541 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3542 aim_userinfo_t *info; |
8225 | 3543 int len; |
2086 | 3544 char *msg; |
8219 | 3545 char *charset; |
2086 | 3546 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3547 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3548 info = va_arg(ap, aim_userinfo_t *); |
8219 | 3549 len = va_arg(ap, int); |
4194 | 3550 msg = va_arg(ap, char *); |
8219 | 3551 charset = va_arg(ap, char *); |
4194 | 3552 va_end(ap); |
2086 | 3553 |
8225 | 3554 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
3555 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); | |
3556 g_free(utf8); | |
2086 | 3557 |
3558 return 1; | |
3559 } | |
3560 | |
3694 | 3561 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
3562 va_list ap; | |
5575 | 3563 GaimConnection *gc = sess->aux_data; |
3694 | 3564 struct aim_emailinfo *emailinfo; |
3725 | 3565 int havenewmail; |
7297 | 3566 char *alertitle, *alerturl; |
3694 | 3567 |
3568 va_start(ap, fr); | |
3569 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 3570 havenewmail = va_arg(ap, int); |
7301 | 3571 alertitle = va_arg(ap, char *); |
3572 alerturl = va_arg(ap, char *); | |
3694 | 3573 va_end(ap); |
3574 | |
5628 | 3575 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
5575 | 3576 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
5542 | 3577 if (emailinfo->unread && havenewmail) |
3578 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 3579 g_free(to); |
3694 | 3580 } |
7297 | 3581 |
7301 | 3582 if (alertitle) |
7313 | 3583 gaim_debug(GAIM_DEBUG_MISC, "oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 3584 |
3585 return 1; | |
3586 } | |
3587 | |
4804 | 3588 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3589 GaimConnection *gc = sess->aux_data; |
7283 | 3590 OscarData *od = gc->proto_data; |
4804 | 3591 char *sn; |
3592 | |
3593 sn = od->requesticon->data; | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3594 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3595 "removing %s from hash table\n", sn); |
4804 | 3596 od->requesticon = g_slist_remove(od->requesticon, sn); |
3597 free(sn); | |
3598 | |
3599 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3600 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3601 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 3602 |
3603 return 1; | |
3604 } | |
3605 | |
3606 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3607 GaimConnection *gc = sess->aux_data; |
7283 | 3608 OscarData *od = gc->proto_data; |
4804 | 3609 GSList *cur; |
3610 va_list ap; | |
3611 char *sn; | |
4853 | 3612 fu8_t *iconcsum, *icon; |
3613 fu16_t iconcsumlen, iconlen; | |
4804 | 3614 |
3615 va_start(ap, fr); | |
3616 sn = va_arg(ap, char *); | |
4853 | 3617 iconcsum = va_arg(ap, fu8_t *); |
3618 iconcsumlen = va_arg(ap, int); | |
4804 | 3619 icon = va_arg(ap, fu8_t *); |
3620 iconlen = va_arg(ap, int); | |
3621 va_end(ap); | |
3622 | |
4853 | 3623 if (iconlen > 0) { |
3624 char *b16; | |
6695 | 3625 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3626 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3627 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3628 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 3629 if (b16) { |
7693 | 3630 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
5129 | 3631 gaim_blist_save(); |
7162 | 3632 g_free(b16); |
5129 | 3633 } |
4853 | 3634 } |
4804 | 3635 |
3636 cur = od->requesticon; | |
3637 while (cur) { | |
3638 char *cursn = cur->data; | |
3639 if (!aim_sncmp(cursn, sn)) { | |
3640 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
3641 free(cursn); | |
3642 cur = od->requesticon; | |
3643 } else | |
3644 cur = cur->next; | |
3645 } | |
3646 | |
3647 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3648 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3649 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 3650 |
3651 return 1; | |
3652 } | |
3653 | |
3654 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 3655 GaimConnection *gc = data; |
7283 | 3656 OscarData *od = gc->proto_data; |
7011 | 3657 aim_userinfo_t *userinfo; |
4804 | 3658 aim_conn_t *conn; |
3659 | |
3660 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 3661 if (!conn) { |
3662 if (!od->iconconnecting) { | |
3663 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
3664 od->iconconnecting = TRUE; | |
3665 } | |
4804 | 3666 return FALSE; |
3667 } | |
3668 | |
5842 | 3669 if (od->set_icon) { |
6039 | 3670 struct stat st; |
3671 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
3672 if (iconfile == NULL) { | |
8363 | 3673 aim_ssi_delicon(od->sess); |
6039 | 3674 } else if (!stat(iconfile, &st)) { |
3675 char *buf = g_malloc(st.st_size); | |
3676 FILE *file = fopen(iconfile, "rb"); | |
3677 if (file) { | |
3678 fread(buf, 1, st.st_size, file); | |
3679 fclose(file); | |
3680 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
3681 "Uploading icon to icon server\n"); | |
6879 | 3682 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 3683 } else |
3684 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6039 | 3685 "Can't open buddy icon file!\n"); |
3686 g_free(buf); | |
3687 } else { | |
3688 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
3689 "Can't stat buddy icon file!\n"); | |
5842 | 3690 } |
3691 od->set_icon = FALSE; | |
3692 } | |
3693 | |
3694 if (!od->requesticon) { | |
3695 gaim_debug(GAIM_DEBUG_MISC, "oscar", | |
3696 "no more icons to request\n"); | |
3697 return FALSE; | |
3698 } | |
3699 | |
7045 | 3700 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 3701 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
3702 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 3703 return FALSE; |
3704 } else { | |
3705 char *sn = od->requesticon->data; | |
3706 od->requesticon = g_slist_remove(od->requesticon, sn); | |
3707 free(sn); | |
3708 } | |
3709 | |
3710 return TRUE; | |
3711 } | |
3712 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3713 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3714 * 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
|
3715 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3716 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3717 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3718 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3719 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3720 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3721 va_start(ap, fr); |
4199 | 3722 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3723 sn = va_arg(ap, char *); |
3724 va_end(ap); | |
3725 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3726 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sent message to %s.\n", sn); |
2086 | 3727 |
3728 return 1; | |
3729 } | |
3730 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3731 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
|
3732 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3733 "invalid", |
4194 | 3734 "change", |
3735 "warning", | |
3736 "limit", | |
3737 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3738 }; |
2086 | 3739 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3740 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3741 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3742 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3743 va_start(ap, fr); |
4200 | 3744 code = (fu16_t)va_arg(ap, unsigned int); |
3745 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
3746 windowsize = va_arg(ap, fu32_t); | |
3747 clear = va_arg(ap, fu32_t); | |
3748 alert = va_arg(ap, fu32_t); | |
3749 limit = va_arg(ap, fu32_t); | |
3750 disconnect = va_arg(ap, fu32_t); | |
3751 currentavg = va_arg(ap, fu32_t); | |
3752 maxavg = va_arg(ap, fu32_t); | |
2086 | 3753 va_end(ap); |
3754 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3755 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
5556 | 3756 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
3757 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 3758 (code < 5) ? codes[code] : codes[0], |
3759 rateclass, | |
3760 currentavg, maxavg, | |
3761 alert, clear, | |
3762 limit, disconnect, | |
3763 windowsize); | |
3764 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3765 /* XXX fix these values */ |
2086 | 3766 if (code == AIM_RATE_CODE_CHANGE) { |
3767 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3768 aim_conn_setlatency(fr->conn, 0); |
2086 | 3769 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3770 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3771 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3772 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 3773 _("The last action you attempted could not be " |
3774 "performed because you are over the rate limit. " | |
3775 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3776 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3777 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3778 aim_conn_setlatency(fr->conn, 0); |
2086 | 3779 } |
3780 | |
3781 return 1; | |
3782 } | |
3783 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3784 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3785 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3786 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3787 aim_userinfo_t *userinfo; |
5575 | 3788 GaimConnection *gc = sess->aux_data; |
2086 | 3789 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3790 va_start(ap, fr); |
4199 | 3791 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3792 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3793 va_end(ap); |
3794 | |
7111 | 3795 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
2086 | 3796 |
3797 return 1; | |
3798 } | |
3799 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3800 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
|
3801 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3802 aim_userinfo_t *info; |
5575 | 3803 GaimConnection *gc = sess->aux_data; |
2507
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 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3806 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3807 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3808 |
5628 | 3809 gc->evil = (info->warnlevel/10.0) + 0.5; |
4841 | 3810 |
7872 | 3811 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
4841 | 3812 gc->login_time_official = info->onlinesince; |
7872 | 3813 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
3814 gc->login_time_official = time(NULL) - info->sessionlen; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3815 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3816 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3817 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3818 |
4649 | 3819 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3820 GaimConnection *gc = sess->aux_data; |
7283 | 3821 OscarData *od = gc->proto_data; |
4649 | 3822 va_list ap; |
3823 fu16_t code; | |
3824 char *msg; | |
3825 | |
3826 va_start(ap, fr); | |
3827 code = (fu16_t)va_arg(ap, int); | |
3828 msg = va_arg(ap, char *); | |
3829 va_end(ap); | |
3830 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3831 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3832 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 3833 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 3834 if (code == 0x0001) { |
6113 | 3835 gc->wants_to_die = TRUE; |
5579 | 3836 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 3837 } else { |
5579 | 3838 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 3839 } |
4666 | 3840 od->killme = TRUE; |
4649 | 3841 } |
3842 | |
3843 return 1; | |
3844 } | |
3845 | |
2675 | 3846 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 3847 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3848 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3849 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 3850 |
3851 #ifndef NOSSI | |
7334 | 3852 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: requesting rights and list\n"); |
4889 | 3853 aim_ssi_reqrights(sess); |
6350 | 3854 aim_ssi_reqdata(sess); |
4230 | 3855 #endif |
3856 | |
7011 | 3857 aim_locate_reqrights(sess); |
7285 | 3858 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 3859 aim_im_reqparams(sess); |
7334 | 3860 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 3861 |
3862 #ifdef NOSSI | |
7334 | 3863 gaim_debug(GAIM_DEBUG_INFO, "oscar", "bos: requesting rights\n"); |
3864 aim_bos_reqrights(sess, fr->conn); | |
4230 | 3865 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
3866 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3867 #endif | |
2086 | 3868 |
7283 | 3869 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
3870 | |
2086 | 3871 return 1; |
3872 } | |
3873 | |
2675 | 3874 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3875 GaimConnection *gc = sess->aux_data; |
7283 | 3876 OscarData *od = gc->proto_data; |
2647 | 3877 |
6905 | 3878 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
3879 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
3880 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
3881 | |
2672 | 3882 aim_clientready(sess, fr->conn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3883 gaim_debug(GAIM_DEBUG_INFO, "oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3884 |
2647 | 3885 if (od->chpass) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3886 gaim_debug(GAIM_DEBUG_INFO, "oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3887 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3888 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3889 od->oldp = NULL; |
2647 | 3890 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3891 od->newp = NULL; |
2647 | 3892 od->chpass = FALSE; |
3893 } | |
2979 | 3894 if (od->setnick) { |
8152 | 3895 gaim_debug(GAIM_DEBUG_INFO, "oscar", "formatting screen name\n"); |
2979 | 3896 aim_admin_setnick(sess, fr->conn, od->newsn); |
3897 g_free(od->newsn); | |
3898 od->newsn = NULL; | |
3899 od->setnick = FALSE; | |
3900 } | |
2647 | 3901 if (od->conf) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3902 gaim_debug(GAIM_DEBUG_INFO, "oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3903 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3904 od->conf = FALSE; |
3905 } | |
3906 if (od->reqemail) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3907 gaim_debug(GAIM_DEBUG_INFO, "oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3908 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3909 od->reqemail = FALSE; |
3910 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3911 if (od->setemail) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3912 gaim_debug(GAIM_DEBUG_INFO, "oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3913 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3914 g_free(od->email); |
5497 | 3915 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3916 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3917 } |
2647 | 3918 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3919 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3920 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3921 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3922 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
|
3923 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3924 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3925 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3926 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3927 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3928 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3929 |
4194 | 3930 /* XXX - evidently this crashes on solaris. i have no clue why |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3931 gaim_debug(GAIM_DEBUG_MISC, "oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 3932 "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
|
3933 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3934 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3935 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3936 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3937 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3938 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3939 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3940 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3941 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3942 |
4617 | 3943 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3944 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3945 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3946 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3947 |
2993 | 3948 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3949 { | |
5575 | 3950 GaimConnection *gc = sess->aux_data; |
7283 | 3951 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 3952 va_list ap; |
3953 fu16_t maxsiglen; | |
2993 | 3954 |
3955 va_start(ap, fr); | |
4199 | 3956 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 3957 va_end(ap); |
3958 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3959 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3960 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 3961 |
4617 | 3962 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3963 | |
3964 if (od->icq) | |
7334 | 3965 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 3966 else |
7334 | 3967 aim_locate_setcaps(od->sess, caps_aim); |
3968 oscar_set_info(gc, gc->account->user_info); | |
2993 | 3969 |
3970 return 1; | |
3971 } | |
3972 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3973 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
|
3974 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3975 fu16_t maxbuddies, maxwatchers; |
5575 | 3976 GaimConnection *gc = sess->aux_data; |
7283 | 3977 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3978 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3979 va_start(ap, fr); |
4199 | 3980 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
3981 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3982 va_end(ap); |
3983 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3984 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3985 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 3986 |
4617 | 3987 od->rights.maxbuddies = (guint)maxbuddies; |
3988 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 3989 |
2086 | 3990 return 1; |
3991 } | |
3992 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3993 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3994 GaimConnection *gc = sess->aux_data; |
7283 | 3995 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 3996 va_list ap; |
3997 fu16_t maxpermits, maxdenies; | |
2086 | 3998 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3999 va_start(ap, fr); |
4199 | 4000 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4001 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4002 va_end(ap); |
4003 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4004 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4005 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4006 |
4617 | 4007 od->rights.maxpermits = (guint)maxpermits; |
4008 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4009 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4010 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4011 serv_finish_login(gc); |
4012 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4013 gaim_debug(GAIM_DEBUG_INFO, "oscar", "buddy list loaded\n"); |
2993 | 4014 |
2672 | 4015 aim_clientready(sess, fr->conn); |
5948 | 4016 aim_srv_setavailmsg(sess, NULL); |
7474 | 4017 aim_srv_setidle(sess, 0); |
4617 | 4018 |
4664 | 4019 if (od->icq) { |
4020 aim_icq_reqofflinemsgs(sess); | |
4021 aim_icq_hideip(sess); | |
4022 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4023 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4024 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4025 if (sess->authinfo->email) |
4026 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4027 |
4028 return 1; | |
4029 } | |
4030 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4031 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
|
4032 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4033 struct aim_icq_offlinemsg *msg; |
4075 | 4034 struct aim_incomingim_ch4_args args; |
4035 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4036 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4037 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4038 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4039 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4040 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4041 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4042 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4043 args.uin = msg->sender; |
4044 args.type = msg->type; | |
4173 | 4045 args.flags = msg->flags; |
4076 | 4046 args.msglen = msg->msglen; |
4075 | 4047 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4048 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4049 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4050 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4051 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4052 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4053 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4054 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
|
4055 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4056 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4057 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4058 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4059 |
7388 | 4060 #if 0 |
4061 /* | |
7465 | 4062 * Update, 2003-11-09: |
4063 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4064 * | |
7388 | 4065 * It may not be my place to do this, but... |
4066 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4067 * stupid, and should not exist for % switches (%x in our case) that request | |
4068 * a year in the preferred representation for the current locale. For that | |
4069 * reason I've chosen to not use this workaround (n., see kluge). | |
4070 * | |
4071 * I have a date. I want to show it to the user in the "preferred" way. | |
4072 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4073 * what the locale wanted. | |
4074 * | |
4075 * If I have a necessity for a full representation of the year in the current | |
4076 * locale, then I'll use a switch that returns a full representation of the | |
4077 * year. | |
4078 * | |
4079 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4080 * (because you're anal, or whatever), then change the f***ing locale. | |
4081 * | |
4082 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4083 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4084 * |
4085 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4086 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4087 */ |
4088 | |
4089 /* | |
4090 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4091 * "last 2 digits" warning. |
4092 */ | |
4093 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
4094 const struct tm *tm) | |
4095 { | |
4096 return strftime(s, max, fmt, tm); | |
4097 } | |
7388 | 4098 #endif |
7386 | 4099 |
4624 | 4100 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
|
4101 { |
5575 | 4102 GaimConnection *gc = sess->aux_data; |
4819 | 4103 gchar *buf, *tmp, *utf8; |
4624 | 4104 gchar who[16]; |
6873 | 4105 GaimBuddy *buddy; |
4106 gchar *primary; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4107 va_list ap; |
4151 | 4108 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4109 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4110 va_start(ap, fr); |
4151 | 4111 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4112 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4113 |
4664 | 4114 if (!info->uin) |
4115 return 0; | |
4116 | |
5556 | 4117 g_snprintf(who, sizeof(who), "%u", info->uin); |
6623 | 4118 buf = g_strdup_printf("<b>%s:</b> %s", _("UIN"), who); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4119 if (info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
6623 | 4120 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 4121 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4122 if (info->first && info->first[0] && (utf8 = gaim_utf8_try_convert(info->first))) { |
6623 | 4123 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 4124 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4125 if (info->last && info->last[0] && (utf8 = gaim_utf8_try_convert(info->last))) { |
6623 | 4126 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4819 | 4127 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4128 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
6623 | 4129 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 | 4130 } |
4131 if (info->numaddresses && info->email2) { | |
4132 int i; | |
4133 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4134 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
6623 | 4135 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 | 4136 } |
4625 | 4137 } |
4624 | 4138 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4139 if (info->mobile && info->mobile[0] && (utf8 = gaim_utf8_try_convert(info->mobile))) { |
6623 | 4140 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4625 | 4141 } |
4142 if (info->gender) { | |
6623 | 4143 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender"), ":</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); |
4151 | 4144 } |
4624 | 4145 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 4146 char date[30]; |
4147 struct tm tm; | |
4148 tm.tm_mday = (int)info->birthday; | |
4149 tm.tm_mon = (int)info->birthmonth-1; | |
4150 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 4151 strftime(date, sizeof(date), "%x", &tm); |
6623 | 4152 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday"), ":</b> ", date, NULL); g_free(tmp); |
4151 | 4153 } |
4624 | 4154 if (info->age) { |
4155 char age[5]; | |
4156 snprintf(age, sizeof(age), "%hhd", info->age); | |
6623 | 4157 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age"), ":</b> ", age, NULL); g_free(tmp); |
4819 | 4158 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4159 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
6623 | 4160 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 | 4161 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4162 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
6623 | 4163 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information"), ":</b><br>", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4164 } |
4165 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | |
4641 | 4166 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
6623 | 4167 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
|
4168 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_utf8_try_convert(info->homeaddr))) { |
6623 | 4169 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4170 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4171 if (info->homecity && info->homecity[0] && (utf8 = gaim_utf8_try_convert(info->homecity))) { |
6623 | 4172 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</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->homestate && info->homestate[0] && (utf8 = gaim_utf8_try_convert(info->homestate))) { |
6623 | 4175 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</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->homezip && info->homezip[0] && (utf8 = gaim_utf8_try_convert(info->homezip))) { |
6623 | 4178 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4179 } |
4180 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 4181 } |
4641 | 4182 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
6623 | 4183 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
|
4184 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_utf8_try_convert(info->workaddr))) { |
6623 | 4185 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4186 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4187 if (info->workcity && info->workcity[0] && (utf8 = gaim_utf8_try_convert(info->workcity))) { |
6623 | 4188 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</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->workstate && info->workstate[0] && (utf8 = gaim_utf8_try_convert(info->workstate))) { |
6623 | 4191 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</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->workzip && info->workzip[0] && (utf8 = gaim_utf8_try_convert(info->workzip))) { |
6623 | 4194 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4195 } |
4196 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4197 } | |
4641 | 4198 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
6623 | 4199 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
|
4200 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_utf8_try_convert(info->workcompany))) { |
6623 | 4201 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4202 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4203 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_utf8_try_convert(info->workdivision))) { |
6623 | 4204 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4205 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4206 if (info->workposition && info->workposition[0] && (utf8 = gaim_utf8_try_convert(info->workposition))) { |
6623 | 4207 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); |
4624 | 4208 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4209 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
6623 | 4210 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 | 4211 } |
4212 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 4213 } |
4214 | |
6873 | 4215 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4216 primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); | |
4217 gaim_notify_formatted(gc, NULL, primary, NULL, buf, NULL, NULL); | |
4218 g_free(primary); | |
4151 | 4219 g_free(buf); |
4220 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4221 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4222 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4223 |
4759 | 4224 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
4225 { | |
5575 | 4226 GaimConnection *gc = sess->aux_data; |
4820 | 4227 gchar who[16], *utf8; |
6695 | 4228 GaimBuddy *b; |
4759 | 4229 va_list ap; |
4230 struct aim_icq_info *info; | |
4231 | |
4232 va_start(ap, fr); | |
4233 info = va_arg(ap, struct aim_icq_info *); | |
4234 va_end(ap); | |
4235 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4236 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 4237 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 4238 serv_got_alias(gc, who, utf8); |
4759 | 4239 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 4240 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 4241 gaim_blist_save(); |
4242 } | |
4820 | 4243 g_free(utf8); |
4759 | 4244 } |
4245 | |
4246 return 1; | |
4247 } | |
4248 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4249 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
|
4250 { |
7032 | 4251 GaimConnection *gc = sess->aux_data; |
4252 gchar *text; | |
4253 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4254 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4255 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4256 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4257 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4258 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4259 url = va_arg(ap, char *); |
4199 | 4260 wid = (fu16_t) va_arg(ap, int); |
4261 hei = (fu16_t) va_arg(ap, int); | |
4262 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4263 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4264 |
7032 | 4265 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
4266 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
4267 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4268 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4269 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4270 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4271 |
7032 | 4272 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
4273 { | |
6873 | 4274 GaimConnection *gc = sess->aux_data; |
4275 gchar *secondary; | |
4276 GString *text; | |
4277 int i, num; | |
2086 | 4278 va_list ap; |
6873 | 4279 char *email, *SNs; |
2086 | 4280 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4281 va_start(ap, fr); |
6873 | 4282 email = va_arg(ap, char *); |
2086 | 4283 num = va_arg(ap, int); |
4284 SNs = va_arg(ap, char *); | |
4285 va_end(ap); | |
4286 | |
8152 | 4287 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 4288 text = g_string_new(""); |
2086 | 4289 for (i = 0; i < num; i++) |
6873 | 4290 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
4291 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
4292 | |
4293 g_free(secondary); | |
4294 g_string_free(text, TRUE); | |
2086 | 4295 |
4296 return 1; | |
4297 } | |
4298 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4299 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4300 va_list ap; |
6873 | 4301 char *email; |
5420 | 4302 char *buf; |
2086 | 4303 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4304 va_start(ap, fr); |
6873 | 4305 email = va_arg(ap, char *); |
2086 | 4306 va_end(ap); |
4307 | |
6873 | 4308 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
|
4309 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4310 g_free(buf); |
2086 | 4311 |
4312 return 1; | |
4313 } | |
4314 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4315 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 4316 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4317 fu16_t status; |
2086 | 4318 va_list ap; |
4319 char msg[256]; | |
4320 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4321 va_start(ap, fr); |
4199 | 4322 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 4323 va_end(ap); |
4324 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4325 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4326 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 4327 status ? "unknown" : "email sent"); |
4328 if (!status) { | |
5302 | 4329 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 4330 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4331 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 4332 } |
4333 | |
4334 return 1; | |
4335 } | |
4336 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4337 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4338 GaimConnection *gc = sess->aux_data; |
2086 | 4339 va_list ap; |
3912 | 4340 fu16_t perms, err; |
4341 char *url, *sn, *email; | |
4342 int change; | |
2086 | 4343 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4344 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4345 change = va_arg(ap, int); |
4199 | 4346 perms = (fu16_t) va_arg(ap, unsigned int); |
4347 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 4348 url = va_arg(ap, char *); |
4349 sn = va_arg(ap, char *); | |
4350 email = va_arg(ap, char *); | |
2086 | 4351 va_end(ap); |
4352 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4353 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4354 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
3912 | 4355 change ? "change" : "request", perms, err, url, sn, email); |
4356 | |
4357 if (err && url) { | |
4358 char *dialog_msg; | |
4359 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
4360 switch (err) { | |
4361 case 0x0001: { | |
4362 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
4363 } break; | |
4364 case 0x0006: { | |
4365 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
4366 } break; | |
4367 case 0x000b: { | |
4368 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
4369 } break; | |
4370 case 0x001d: { | |
4371 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); | |
4372 } break; | |
4373 case 0x0021: { | |
4374 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); | |
4375 } break; | |
4376 case 0x0023: { | |
4377 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
4378 } break; | |
4379 default: { | |
4380 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
4381 } break; | |
4382 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4383 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 4384 g_free(dialog_top); |
4385 g_free(dialog_msg); | |
4386 return 1; | |
4387 } | |
4388 | |
4389 if (sn) { | |
4585 | 4390 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
|
4391 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4392 g_free(dialog_msg); |
4393 } | |
4394 | |
4395 if (email) { | |
5575 | 4396 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
4397 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4398 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 4399 g_free(dialog_msg); |
2086 | 4400 } |
4401 | |
4402 return 1; | |
4403 } | |
4404 | |
5575 | 4405 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 4406 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4407 aim_flap_nop(od->sess, od->conn); |
2086 | 4408 } |
4409 | |
6059 | 4410 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 4411 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4412 struct direct_im *dim = find_direct_im(od, name); |
3595 | 4413 if (dim) |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4414 if (typing == GAIM_TYPING) |
4870 | 4415 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4416 else if (typing == GAIM_TYPED) |
4870 | 4417 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
4418 else | |
4419 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 4420 else { |
5300 | 4421 /* Don't send if this turkey is in our deny list */ |
4422 GSList *list; | |
4423 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
4424 if (!list) { | |
7261 | 4425 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 4426 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4427 if (typing == GAIM_TYPING) |
5300 | 4428 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4429 else if (typing == GAIM_TYPED) |
5300 | 4430 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
4431 else | |
4432 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
4433 } | |
3595 | 4434 } |
4435 } | |
2993 | 4436 return 0; |
4437 } | |
5575 | 4438 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
|
4439 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
|
4440 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4441 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 4442 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4443 struct direct_im *dim = find_direct_im(od, name); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4444 int ret = 0; |
3659 | 4445 GError *err = NULL; |
5575 | 4446 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
|
4447 char *tmpmsg = NULL; |
3458 | 4448 |
4838 | 4449 if (dim && dim->connected) { |
4450 /* If we're directly connected, send a direct IM */ | |
6982 | 4451 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
|
4452 } else if (imflags & GAIM_CONV_IM_IMAGES) { |
3044 | 4453 /* Trying to send an IM image outside of a direct connection. */ |
4454 oscar_ask_direct_im(gc, name); | |
4838 | 4455 ret = -ENOTCONN; |
2086 | 4456 } else { |
4738 | 4457 struct buddyinfo *bi; |
3008 | 4458 struct aim_sendimext_args args; |
4459 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4460 gsize len; |
4269 | 4461 |
7261 | 4462 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 4463 if (!bi) { |
4464 bi = g_new0(struct buddyinfo, 1); | |
7261 | 4465 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 4466 } |
4467 | |
3008 | 4468 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 4469 if (od->icq) { |
4470 args.features = features_icq; | |
4471 args.featureslen = sizeof(features_icq); | |
3008 | 4472 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 4473 } else { |
4474 args.features = features_aim; | |
4475 args.featureslen = sizeof(features_aim); | |
4972 | 4476 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4477 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 4478 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 4479 } |
4269 | 4480 |
4738 | 4481 if (bi->ico_need) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4482 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4483 "Sending buddy icon request with message\n"); |
3008 | 4484 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 4485 bi->ico_need = FALSE; |
3008 | 4486 } |
4269 | 4487 |
5575 | 4488 if (iconfile && !stat(iconfile, &st)) { |
8361 | 4489 FILE *file = fopen(iconfile, "rb"); |
3008 | 4490 if (file) { |
4491 char *buf = g_malloc(st.st_size); | |
4492 fread(buf, 1, st.st_size, file); | |
6039 | 4493 fclose(file); |
4269 | 4494 |
3008 | 4495 args.iconlen = st.st_size; |
4617 | 4496 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 4497 args.iconstamp = st.st_mtime; |
4498 | |
7406 | 4499 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 4500 bi->ico_informed = FALSE; |
7406 | 4501 bi->ico_sent = FALSE; |
4502 } | |
4738 | 4503 |
4504 if (!bi->ico_informed) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4505 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4506 "Claiming to have a buddy icon\n"); |
4738 | 4507 args.flags |= AIM_IMFLAGS_HASICON; |
4508 bi->ico_me_len = args.iconlen; | |
4509 bi->ico_me_csum = args.iconsum; | |
4510 bi->ico_me_time = args.iconstamp; | |
4511 bi->ico_informed = TRUE; | |
4512 } | |
4513 | |
3008 | 4514 g_free(buf); |
2086 | 4515 } |
4516 } | |
4269 | 4517 |
3008 | 4518 args.destsn = name; |
4269 | 4519 |
6310 | 4520 /* For ICQ send newlines as CR/LF, for AIM send newlines as <BR> */ |
4521 if (isdigit(name[0])) | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4522 tmpmsg = gaim_str_add_cr(message); |
6310 | 4523 else |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4524 tmpmsg = gaim_strdup_withhtml(message); |
6310 | 4525 len = strlen(tmpmsg); |
4526 | |
4527 args.flags |= oscar_encoding_check(tmpmsg); | |
3642 | 4528 if (args.flags & AIM_IMFLAGS_UNICODE) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4529 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode IM\n"); |
4662 | 4530 args.charset = 0x0002; |
4665 | 4531 args.charsubset = 0x0000; |
6310 | 4532 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3659 | 4533 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4534 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4535 "Error converting a unicode message: %s\n", err->message); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4536 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4537 "This really shouldn't happen!\n"); |
3659 | 4538 /* We really shouldn't try to send the |
4539 * IM now, but I'm not sure what to do */ | |
4800 | 4540 g_error_free(err); |
3659 | 4541 } |
3850 | 4542 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4543 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4544 "Sending ISO-8859-1 IM\n"); |
4662 | 4545 args.charset = 0x0003; |
4665 | 4546 args.charsubset = 0x0000; |
6310 | 4547 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3659 | 4548 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4549 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4550 "conversion error: %s\n", err->message); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4551 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4552 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
3642 | 4553 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
6310 | 4554 len = strlen(tmpmsg); |
4800 | 4555 g_error_free(err); |
6310 | 4556 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3659 | 4557 if (err) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4558 gaim_debug(GAIM_DEBUG_ERROR, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4559 "Error in unicode fallback: %s\n", err->message); |
4800 | 4560 g_error_free(err); |
3659 | 4561 } |
3642 | 4562 } |
4563 } else { | |
4662 | 4564 args.charset = 0x0000; |
4565 args.charsubset = 0x0000; | |
6310 | 4566 args.msg = tmpmsg; |
3642 | 4567 } |
4568 args.msglen = len; | |
4269 | 4569 |
4617 | 4570 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 4571 } |
4838 | 4572 |
6310 | 4573 g_free(tmpmsg); |
4574 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4575 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4576 return 1; |
6310 | 4577 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4578 return ret; |
2086 | 4579 } |
4580 | |
7011 | 4581 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 4582 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 4583 |
7173 | 4584 if (od->icq && isdigit(name[0])) |
4624 | 4585 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4586 else |
7235 | 4587 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 4588 } |
4589 | |
4590 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, | |
3466 | 4591 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 4592 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 4593 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 4594 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 4595 maiden, NULL, NULL, city, state, NULL, 0, web); |
4596 } | |
4597 | |
5575 | 4598 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 4599 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 4600 aim_srv_setidle(od->sess, time); |
2086 | 4601 } |
4602 | |
5954 | 4603 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 4604 OscarData *od = (OscarData *)gc->proto_data; |
5129 | 4605 fu32_t flags = 0; |
6019 | 4606 char *text_html = NULL; |
5129 | 4607 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4608 gsize msglen = 0; |
2993 | 4609 |
4617 | 4610 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4611 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4612 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4613 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4614 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4615 "again when you are fully connected.")); |
4617 | 4616 |
7334 | 4617 if (!text) { |
4618 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
4619 return; | |
4620 } | |
6019 | 4621 |
7334 | 4622 text_html = gaim_strdup_withhtml(text); |
4623 flags = oscar_encoding_check(text_html); | |
4624 if (flags & AIM_IMFLAGS_UNICODE) { | |
4625 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
4626 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
4627 g_free(msg); | |
4628 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
4629 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
4630 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
4631 g_free(msg); | |
4632 } else { | |
4633 msglen = strlen(text_html); | |
4634 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
4635 } | |
4636 | |
4637 if (msglen > od->rights.maxsiglen) { | |
4638 gchar *errstr; | |
4639 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
4640 "has been exceeded. Gaim has truncated it for you.", | |
4641 "The maximum profile length of %d bytes " | |
4642 "has been exceeded. Gaim has truncated it for you.", | |
4643 od->rights.maxsiglen), od->rights.maxsiglen); | |
4644 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
4645 g_free(errstr); | |
4646 } | |
4647 | |
4648 g_free(text_html); | |
2993 | 4649 |
4650 return; | |
2086 | 4651 } |
4652 | |
8257 | 4653 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
2993 | 4654 { |
5129 | 4655 fu32_t flags = 0; |
6019 | 4656 gchar *text_html = NULL; |
5129 | 4657 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
4658 gsize msglen = 0; |
2993 | 4659 |
8257 | 4660 if (!strcmp(state, _("Visible"))) { |
4661 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
4662 return; | |
4663 } else if (!strcmp(state, _("Invisible"))) { | |
4664 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
4665 return; | |
4666 } /* else... */ | |
4667 | |
8476 | 4668 if (!strcmp(state, _("Back"))) { |
4669 /* If this is our only online account then globally set Gaim not-away */ | |
4670 GList *gcs = gaim_connections_get_all(); | |
4671 if (gcs->next == NULL) | |
4672 do_im_back(NULL, NULL); | |
4673 } | |
4674 | |
8257 | 4675 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4676 | |
2993 | 4677 if (od->rights.maxawaymsglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4678 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4679 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4680 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4681 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4682 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4683 "fully connected.")); |
5129 | 4684 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4685 if (gc->away) { |
2993 | 4686 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4687 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4688 } |
2993 | 4689 |
5129 | 4690 if (!text) { |
7334 | 4691 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4692 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4693 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4694 |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4695 text_html = gaim_strdup_withhtml(text); |
6019 | 4696 flags = oscar_encoding_check(text_html); |
5129 | 4697 if (flags & AIM_IMFLAGS_UNICODE) { |
6019 | 4698 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 4699 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 4700 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 4701 g_free(msg); |
4702 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
4703 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
6019 | 4704 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 4705 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 4706 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 4707 g_free(msg); |
6019 | 4708 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 4709 } else { |
6019 | 4710 msglen = strlen(text_html); |
7011 | 4711 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 4712 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
6019 | 4713 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
5129 | 4714 } |
4715 | |
4716 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 4717 gchar *errstr; |
4718 | |
6308 | 4719 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
4720 "has been exceeded. Gaim has truncated it for you.", | |
4721 "The maximum away message length of %d bytes " | |
4722 "has been exceeded. Gaim has truncated it for you.", | |
4723 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4724 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 4725 g_free(errstr); |
4726 } | |
6019 | 4727 |
4728 g_free(text_html); | |
8257 | 4729 |
2993 | 4730 return; |
4731 } | |
4732 | |
7283 | 4733 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
2993 | 4734 { |
5575 | 4735 GaimAccount *account = gaim_connection_get_account(gc); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4736 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4737 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4738 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4739 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4740 |
8265 | 4741 if (strcmp(state, _("Invisible"))) |
5575 | 4742 account->perm_deny = 4; |
8265 | 4743 else |
5575 | 4744 account->perm_deny = 3; |
8265 | 4745 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
4746 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 4747 |
4748 if (!strcmp(state, _("Online"))) | |
4901 | 4749 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 4750 else if (!strcmp(state, _("Away"))) { |
4901 | 4751 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4752 gc->away = g_strdup(""); |
4342 | 4753 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 4754 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
|
4755 gc->away = g_strdup(""); |
4342 | 4756 } else if (!strcmp(state, _("Not Available"))) { |
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(""); |
4342 | 4759 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 4760 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
|
4761 gc->away = g_strdup(""); |
4342 | 4762 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 4763 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4764 gc->away = g_strdup(""); |
4342 | 4765 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 4766 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4767 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4768 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 4769 if (message) { |
4901 | 4770 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
|
4771 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4772 } else { |
4901 | 4773 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4774 } |
2086 | 4775 } |
2993 | 4776 |
4777 return; | |
4778 } | |
4779 | |
6059 | 4780 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
2993 | 4781 { |
7283 | 4782 OscarData *od = (OscarData *)gc->proto_data; |
2993 | 4783 |
4784 if (od->icq) | |
4785 oscar_set_away_icq(gc, od, state, message); | |
4786 else | |
8257 | 4787 oscar_set_away_aim(gc, od, state, message); |
2993 | 4788 |
4789 return; | |
2086 | 4790 } |
4791 | |
6059 | 4792 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
7283 | 4793 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 4794 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 4795 } |
4796 | |
5575 | 4797 static void oscar_dir_search(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 4798 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
7283 | 4799 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4800 if (strlen(email)) |
6879 | 4801 aim_search_address(od->sess, od->conn, email); |
2086 | 4802 } |
4803 | |
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
4804 static void oscar_add_buddy(GaimConnection *gc, const char *name, GaimGroup *g) { |
7283 | 4805 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 4806 GaimBuddy *b; |
4807 | |
4808 if (g == NULL) { | |
4809 /* If we were called from oscar_add_buddies... */ | |
4810 b = gaim_find_buddy(gaim_connection_get_account(gc), name); | |
4811 g = gaim_find_buddys_group(b); | |
4812 } else | |
4813 b = gaim_find_buddy_in_group(gaim_connection_get_account(gc), name, g); | |
8092 | 4814 |
4815 if (!aim_snvalid(name)) { | |
4816 gchar *buf; | |
8150 | 4817 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 | 4818 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4819 g_free(buf); | |
8150 | 4820 |
4821 /* Remove from local list */ | |
4822 gaim_blist_remove_buddy(b); | |
4823 | |
8092 | 4824 return; |
4825 } | |
4826 | |
4230 | 4827 #ifdef NOSSI |
8143 | 4828 aim_buddylist_addbuddy(od->sess, od->conn, name); |
4230 | 4829 #else |
4830 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
8150 | 4831 if (b && g) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4832 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
8150 | 4833 "ssi: adding buddy %s to group %s\n", name, g->name); |
4834 aim_ssi_addbuddy(od->sess, b->name, g->name, gaim_get_buddy_alias_only(b), NULL, NULL, 0); | |
4230 | 4835 } |
4836 } | |
4837 #endif | |
8150 | 4838 |
4759 | 4839 if (od->icq) |
4840 aim_icq_getalias(od->sess, name); | |
4230 | 4841 } |
4842 | |
5575 | 4843 static void oscar_add_buddies(GaimConnection *gc, GList *buddies) { |
7283 | 4844 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4845 #ifdef NOSSI |
4846 char buf[MSG_LEN]; | |
4847 int n=0; | |
4848 while (buddies) { | |
4849 if (n > MSG_LEN - 18) { | |
7285 | 4850 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 4851 n = 0; |
3092 | 4852 } |
8150 | 4853 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (const char *)buddies->data); |
4230 | 4854 buddies = buddies->next; |
4855 } | |
7285 | 4856 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 4857 #else |
4858 if (od->sess->ssi.received_data) { | |
4859 while (buddies) { | |
8092 | 4860 oscar_add_buddy(gc, buddies->data, NULL); |
4230 | 4861 buddies = buddies->next; |
4862 } | |
4863 } | |
4864 #endif | |
4865 } | |
4866 | |
6059 | 4867 static void oscar_remove_buddy(GaimConnection *gc, const char *name, const char *group) { |
7283 | 4868 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4869 #ifdef NOSSI |
8143 | 4870 aim_buddylist_removebuddy(od->sess, od->conn, name); |
4230 | 4871 #else |
4872 if (od->sess->ssi.received_data) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4873 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4874 "ssi: deleting buddy %s from group %s\n", name, group); |
4889 | 4875 aim_ssi_delbuddy(od->sess, name, group); |
4230 | 4876 } |
4877 #endif | |
4878 } | |
4879 | |
5575 | 4880 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { |
7283 | 4881 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4882 #ifdef NOSSI |
4883 GList *cur; | |
4884 for (cur=buddies; cur; cur=cur->next) | |
8143 | 4885 aim_buddylist_removebuddy(od->sess, od->conn, cur->data); |
4230 | 4886 #else |
4887 if (od->sess->ssi.received_data) { | |
3092 | 4888 while (buddies) { |
8150 | 4889 oscar_remove_buddy(gc, buddies->data, group); |
3092 | 4890 buddies = buddies->next; |
4891 } | |
4230 | 4892 } |
4893 #endif | |
4894 } | |
4895 | |
4896 #ifndef NOSSI | |
5575 | 4897 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 4898 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 4899 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4900 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4901 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 4902 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 4903 } |
4904 } | |
4905 | |
5575 | 4906 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 4907 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 4908 if (od->sess->ssi.received_data) { |
4909 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
4910 if (gname) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4911 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4912 "ssi: changing the alias for buddy %s to %s\n", name, alias); |
4889 | 4913 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 4914 } |
4915 } | |
4916 } | |
4917 | |
8341 | 4918 static void oscar_rename_group(GaimConnection *gc, const char *old_group, const char *new_group, GList *members) { |
4919 OscarData *od = (OscarData *)gc->proto_data; | |
4230 | 4920 |
4921 if (od->sess->ssi.received_data) { | |
4922 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
8341 | 4923 oscar_remove_buddies(gc, members, old_group); |
4924 oscar_add_buddies(gc, members); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4925 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4926 "ssi: moved all buddies from group %s to %s\n", old_group, new_group); |
4230 | 4927 } else { |
4889 | 4928 aim_ssi_rename_group(od->sess, old_group, new_group); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4929 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4930 "ssi: renamed group %s to %s\n", old_group, new_group); |
2995 | 4931 } |
4932 } | |
4933 } | |
4934 | |
5968 | 4935 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
4936 aim_session_t *sess = data; | |
6350 | 4937 aim_ssi_reqdata(sess); |
5968 | 4938 return FALSE; |
4939 } | |
4940 | |
4642 | 4941 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4942 GaimConnection *gc = sess->aux_data; |
7283 | 4943 OscarData *od = gc->proto_data; |
4642 | 4944 va_list ap; |
4945 fu16_t reason; | |
4946 | |
4947 va_start(ap, fr); | |
4948 reason = (fu16_t)va_arg(ap, unsigned int); | |
4949 va_end(ap); | |
4950 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4951 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 4952 |
4953 if (reason == 0x0005) { | |
5892 | 4954 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 4955 _("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
|
4956 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 4957 } |
4958 | |
4959 /* Activate SSI */ | |
4960 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4961 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
5968 | 4962 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 4963 aim_ssi_enable(od->sess); |
4964 | |
4965 return 1; | |
4966 } | |
4967 | |
2991 | 4968 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4969 GaimConnection *gc = sess->aux_data; |
7283 | 4970 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 4971 int numtypes, i; |
4972 fu16_t *maxitems; | |
2991 | 4973 va_list ap; |
4974 | |
4975 va_start(ap, fr); | |
4230 | 4976 numtypes = va_arg(ap, int); |
4977 maxitems = va_arg(ap, fu16_t *); | |
2991 | 4978 va_end(ap); |
4979 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4980 gaim_debug(GAIM_DEBUG_MISC, "oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4981 |
4230 | 4982 for (i=0; i<numtypes; i++) |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4983 gaim_debug(GAIM_DEBUG_MISC, NULL, " max type 0x%04x=%hd,", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4984 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4985 |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
4986 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n"); |
4230 | 4987 |
4988 if (numtypes >= 0) | |
4989 od->rights.maxbuddies = maxitems[0]; | |
4990 if (numtypes >= 1) | |
4991 od->rights.maxgroups = maxitems[1]; | |
4992 if (numtypes >= 2) | |
4993 od->rights.maxpermits = maxitems[2]; | |
4994 if (numtypes >= 3) | |
4995 od->rights.maxdenies = maxitems[3]; | |
2991 | 4996 |
4997 return 1; | |
4998 } | |
4999 | |
5000 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5001 GaimConnection *gc = sess->aux_data; |
5002 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 5003 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5004 GaimGroup *g; |
5005 GaimBuddy *b; | |
2995 | 5006 struct aim_ssi_item *curitem; |
2991 | 5007 int tmp; |
4230 | 5008 va_list ap; |
8219 | 5009 fu16_t fmtver, numitems; |
5010 struct aim_ssi_item *items; | |
5011 fu32_t timestamp; | |
4230 | 5012 |
5013 va_start(ap, fr); | |
5014 fmtver = (fu16_t)va_arg(ap, int); | |
5015 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5016 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5017 timestamp = va_arg(ap, fu32_t); |
8219 | 5018 va_end(ap); |
2991 | 5019 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5020 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5021 "ssi: syncing local list and server list\n"); |
2991 | 5022 |
8219 | 5023 if ((timestamp == 0) || (numitems == 0)) { |
8430 | 5024 gaim_debug(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 | 5025 return 1; |
5026 } | |
5027 | |
2991 | 5028 /* Clean the buddy list */ |
4889 | 5029 aim_ssi_cleanlist(sess); |
2991 | 5030 |
8150 | 5031 { /* If not in server list then prune from local list */ |
5032 GaimBlistNode *gnode, *cnode, *bnode; | |
5033 GaimBuddyList *blist; | |
5034 GSList *cur; | |
5035 | |
5036 /* Buddies */ | |
5037 cur = NULL; | |
5038 if ((blist = gaim_get_blist()) != NULL) { | |
5039 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5040 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5041 continue; | |
5042 g = (GaimGroup *)gnode; | |
5043 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5044 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5045 continue; | |
5046 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5047 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5048 continue; | |
5049 b = (GaimBuddy *)bnode; | |
5050 if (b->account == gc->account) { | |
5051 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5052 /* If the buddy is an ICQ user then load his nickname */ | |
5053 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5054 char *alias; |
8150 | 5055 if (servernick) |
5056 serv_got_alias(gc, b->name, servernick); | |
5057 | |
5058 /* Store local alias on server */ | |
8214 | 5059 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5060 if (!alias && b->alias && strlen(b->alias)) |
5061 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5062 free(alias); | |
5063 } else { | |
5064 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
5065 "ssi: removing buddy %s from local list\n", b->name); | |
5066 /* We can't actually remove now because it will screw up our looping */ | |
5067 cur = g_slist_prepend(cur, b); | |
5068 } | |
5069 } | |
5070 } | |
5071 } | |
5072 } | |
5073 } | |
8175 | 5074 |
8150 | 5075 while (cur != NULL) { |
5076 b = cur->data; | |
5077 cur = g_slist_remove(cur, b); | |
5078 gaim_blist_remove_buddy(b); | |
5079 } | |
5080 | |
5081 /* Permit list */ | |
5082 if (gc->account->permit) { | |
5083 for (cur=gc->account->permit; cur; cur=cur->next) | |
5084 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { | |
5085 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
5086 "ssi: removing permit %s from local list\n", (const char *)cur->data); | |
5087 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5088 cur = gc->account->permit; | |
5089 } | |
5090 } | |
5091 | |
5092 /* Deny list */ | |
5093 if (gc->account->deny) { | |
5094 for (cur=gc->account->deny; cur; cur=cur->next) | |
5095 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { | |
5096 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
5097 "ssi: removing deny %s from local list\n", (const char *)cur->data); | |
5098 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
5099 cur = gc->account->deny; | |
5100 } | |
5101 } | |
5102 /* Presence settings (idle time visibility) */ | |
5103 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
5104 if (!(tmp & 0x400)) | |
5105 aim_ssi_setpresence(sess, tmp | 0x400); | |
5106 } /* end pruning buddies from local list */ | |
5107 | |
2991 | 5108 /* Add from server list to local list */ |
4230 | 5109 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 5110 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 5111 switch (curitem->type) { |
4230 | 5112 case 0x0000: { /* Buddy */ |
4251 | 5113 if (curitem->name) { |
4292 | 5114 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 5115 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 5116 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 5117 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 5118 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 5119 /* Should gname be freed here? -- elb */ |
4754 | 5120 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 5121 free(alias); |
8150 | 5122 if (b) { |
4292 | 5123 /* Get server stored alias */ |
4705 | 5124 if (alias_utf8) { |
8150 | 5125 g_free(b->alias); |
5126 b->alias = g_strdup(alias_utf8); | |
4705 | 5127 } |
4282 | 5128 } else { |
8150 | 5129 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 5130 |
4754 | 5131 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 5132 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 5133 gaim_blist_add_group(g, NULL); |
5134 } | |
5146 | 5135 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5136 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
8150 | 5137 "ssi: adding b %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
5138 gaim_blist_add_buddy(b, NULL, g, NULL); | |
4251 | 5139 } |
8341 | 5140 if (!aim_sncmp(curitem->name, account->username)) { |
5141 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
5142 gaim_check_comment(od, comment); | |
5143 free(comment); | |
5144 } | |
7162 | 5145 g_free(gname_utf8); |
5146 g_free(alias_utf8); | |
2991 | 5147 } |
4230 | 5148 } break; |
5149 | |
5150 case 0x0001: { /* Group */ | |
4282 | 5151 /* Shouldn't add empty groups */ |
4230 | 5152 } break; |
5153 | |
5154 case 0x0002: { /* Permit buddy */ | |
2991 | 5155 if (curitem->name) { |
4230 | 5156 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 5157 GSList *list; |
5575 | 5158 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5159 if (!list) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5160 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5161 "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
|
5162 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 5163 } |
5164 } | |
4230 | 5165 } break; |
5166 | |
5167 case 0x0003: { /* Deny buddy */ | |
2991 | 5168 if (curitem->name) { |
5169 GSList *list; | |
5575 | 5170 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 5171 if (!list) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5172 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5173 "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
|
5174 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 5175 } |
5176 } | |
4230 | 5177 } break; |
5178 | |
5179 case 0x0004: { /* Permit/deny setting */ | |
2991 | 5180 if (curitem->data) { |
5181 fu8_t permdeny; | |
5575 | 5182 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5183 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
5575 | 5184 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
5185 account->perm_deny = permdeny; | |
5186 if (od->icq && account->perm_deny == 0x03) { | |
4342 | 5187 serv_set_away(gc, "Invisible", ""); |
5188 } | |
2991 | 5189 } |
5190 } | |
4230 | 5191 } break; |
5192 | |
5193 case 0x0005: { /* Presence setting */ | |
3109 | 5194 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 5195 } break; |
2991 | 5196 } /* End of switch on curitem->type */ |
5197 } /* End of for loop */ | |
4230 | 5198 |
4901 | 5199 /* Set our ICQ status */ |
8257 | 5200 if (!gc->away) { |
4901 | 5201 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
5202 } | |
5203 | |
4342 | 5204 /* Activate SSI */ |
5205 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5206 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5207 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5208 "ssi: activating server-stored buddy list\n"); |
4642 | 5209 aim_ssi_enable(sess); |
4342 | 5210 |
2991 | 5211 return 1; |
2086 | 5212 } |
4230 | 5213 |
5214 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5215 GaimConnection *gc = sess->aux_data; |
4230 | 5216 va_list ap; |
5217 struct aim_ssi_tmp *retval; | |
5218 | |
5219 va_start(ap, fr); | |
5220 retval = va_arg(ap, struct aim_ssi_tmp *); | |
5221 va_end(ap); | |
5222 | |
5223 while (retval) { | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5224 gaim_debug(GAIM_DEBUG_MISC, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5225 "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 | 5226 |
5227 if (retval->ack != 0xffff) | |
5228 switch (retval->ack) { | |
5229 case 0x0000: { /* added successfully */ | |
5230 } break; | |
5231 | |
4829 | 5232 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
5233 gchar *buf; | |
5234 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
|
5235 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 5236 g_free(buf); |
5237 } | |
5238 | |
7023 | 5239 case 0x000e: { /* buddy requires authorization */ |
4828 | 5240 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 5241 gaim_auth_sendrequest(gc, retval->name); |
4230 | 5242 } break; |
5243 | |
5244 default: { /* La la la */ | |
5197 | 5245 gchar *buf; |
5402 | 5246 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5247 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
|
5248 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 5249 g_free(buf); |
4230 | 5250 } break; |
5251 } | |
5252 | |
5253 retval = retval->next; | |
5254 } | |
5255 | |
5256 return 1; | |
5257 } | |
5258 | |
8227 | 5259 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
5260 GaimConnection *gc = sess->aux_data; | |
5261 char *gname, *gname_utf8, *alias, *alias_utf8; | |
5262 GaimBuddy *b; | |
5263 GaimGroup *g; | |
5264 va_list ap; | |
5265 fu16_t type; | |
5266 const char *name; | |
5267 | |
5268 va_start(ap, fr); | |
5269 type = (fu16_t)va_arg(ap, int); | |
5270 name = va_arg(ap, char *); | |
5271 va_end(ap); | |
5272 | |
5273 if ((type != 0x0000) || (name == NULL)) | |
5274 return 1; | |
5275 | |
5276 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
5277 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
5278 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
5279 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
5280 b = gaim_find_buddy(gc->account, name); | |
5281 free(alias); | |
5282 | |
5283 if (b) { | |
5284 /* Get server stored alias */ | |
5285 if (alias_utf8) { | |
5286 g_free(b->alias); | |
5287 b->alias = g_strdup(alias_utf8); | |
5288 } | |
5289 } else { | |
5290 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
5291 | |
5292 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
5293 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
5294 gaim_blist_add_group(g, NULL); | |
5295 } | |
5296 | |
5297 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
5298 "ssi: adding b %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); | |
5299 gaim_blist_add_buddy(b, NULL, g, NULL); | |
5300 } | |
5301 g_free(gname_utf8); | |
5302 g_free(alias_utf8); | |
5303 | |
5304 return 1; | |
5305 } | |
5306 | |
4230 | 5307 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5308 GaimConnection *gc = sess->aux_data; |
4230 | 5309 va_list ap; |
5310 char *sn, *msg; | |
4236 | 5311 gchar *dialog_msg, *nombre; |
4230 | 5312 struct name_data *data; |
6695 | 5313 GaimBuddy *buddy; |
4230 | 5314 |
5315 va_start(ap, fr); | |
5316 sn = va_arg(ap, char *); | |
5317 msg = va_arg(ap, char *); | |
5318 va_end(ap); | |
5319 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5320 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5321 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 5322 |
4687 | 5323 buddy = gaim_find_buddy(gc->account, sn); |
5324 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5325 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5326 else |
5327 nombre = g_strdup(sn); | |
5328 | |
5329 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 | 5330 data = g_new(struct name_data, 1); |
5331 data->gc = gc; | |
5332 data->name = g_strdup(sn); | |
5333 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5334 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5335 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5336 0, data, |
7023 | 5337 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 5338 G_CALLBACK(oscar_free_name_data)); |
4236 | 5339 |
4230 | 5340 g_free(dialog_msg); |
4236 | 5341 g_free(nombre); |
4230 | 5342 |
5343 return 1; | |
5344 } | |
5345 | |
5346 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5347 GaimConnection *gc = sess->aux_data; |
4230 | 5348 va_list ap; |
5349 char *sn, *msg; | |
4236 | 5350 gchar *dialog_msg, *nombre; |
4230 | 5351 struct name_data *data; |
6695 | 5352 GaimBuddy *buddy; |
4230 | 5353 |
5354 va_start(ap, fr); | |
5355 sn = va_arg(ap, char *); | |
5356 msg = va_arg(ap, char *); | |
5357 va_end(ap); | |
5358 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5359 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5360 "ssi: received authorization request from %s\n", sn); |
4230 | 5361 |
4687 | 5362 buddy = gaim_find_buddy(gc->account, sn); |
5363 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5364 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5365 else |
5366 nombre = g_strdup(sn); | |
5367 | |
4337 | 5368 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 | 5369 data = g_new(struct name_data, 1); |
5370 data->gc = gc; | |
5371 data->name = g_strdup(sn); | |
5372 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5373 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5374 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5375 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5376 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
5377 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 5378 |
4230 | 5379 g_free(dialog_msg); |
4236 | 5380 g_free(nombre); |
4230 | 5381 |
5382 return 1; | |
5383 } | |
5384 | |
5385 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5386 GaimConnection *gc = sess->aux_data; |
4230 | 5387 va_list ap; |
5388 char *sn, *msg; | |
4236 | 5389 gchar *dialog_msg, *nombre; |
4230 | 5390 fu8_t reply; |
6695 | 5391 GaimBuddy *buddy; |
4230 | 5392 |
5393 va_start(ap, fr); | |
5394 sn = va_arg(ap, char *); | |
5395 reply = (fu8_t)va_arg(ap, int); | |
5396 msg = va_arg(ap, char *); | |
5397 va_end(ap); | |
5398 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5399 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5400 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 5401 |
4687 | 5402 buddy = gaim_find_buddy(gc->account, sn); |
5403 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
5404 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 5405 else |
5406 nombre = g_strdup(sn); | |
5407 | |
4230 | 5408 if (reply) { |
5409 /* Granted */ | |
7023 | 5410 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
|
5411 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 5412 } else { |
5413 /* Denied */ | |
7023 | 5414 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
|
5415 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 5416 } |
5417 g_free(dialog_msg); | |
4236 | 5418 g_free(nombre); |
4230 | 5419 |
5420 return 1; | |
5421 } | |
5422 | |
5423 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5424 GaimConnection *gc = sess->aux_data; |
4230 | 5425 va_list ap; |
5426 char *sn; | |
6695 | 5427 GaimBuddy *buddy; |
4230 | 5428 |
5429 va_start(ap, fr); | |
5430 sn = va_arg(ap, char *); | |
5431 va_end(ap); | |
5432 | |
4687 | 5433 buddy = gaim_find_buddy(gc->account, sn); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5434 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5435 "ssi: %s added you to their buddy list\n", sn); |
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
5436 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 5437 |
5438 return 1; | |
5439 } | |
4269 | 5440 #endif |
2086 | 5441 |
5575 | 5442 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5443 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5444 struct proto_chat_entry *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 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 5447 pce->label = _("_Group:"); |
5234 | 5448 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5449 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5450 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5451 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 5452 pce->label = _("_Exchange:"); |
5234 | 5453 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5454 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5455 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5456 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5457 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5458 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5459 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5460 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5461 |
8308 | 5462 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
5463 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5464 aim_conn_t *cur; |
5234 | 5465 char *name, *exchange; |
5466 | |
5467 name = g_hash_table_lookup(data, "room"); | |
5468 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5469 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5470 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5471 "Attempting to join chat room %s.\n", name); |
8308 | 5472 |
5473 if ((name == NULL) || (*name == '\0')) { | |
5474 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
5475 return; | |
5476 } | |
5477 | |
4617 | 5478 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5479 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5480 "chatnav exists, creating room\n"); |
5234 | 5481 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 5482 } else { |
5483 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5484 struct create_room *cr = g_new0(struct create_room, 1); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5485 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5486 "chatnav does not exist, opening chatnav\n"); |
5234 | 5487 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5488 cr->name = g_strdup(name); |
4617 | 5489 od->create_rooms = g_slist_append(od->create_rooms, cr); |
5490 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 5491 } |
5492 } | |
5493 | |
8308 | 5494 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
5495 OscarData *od = (OscarData *)gc->proto_data; | |
5496 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 5497 |
5498 if (!ccon) | |
5499 return; | |
5500 | |
8225 | 5501 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 5502 ccon->exchange, ccon->name, 0x0); |
5503 } | |
5504 | |
8308 | 5505 static void oscar_chat_leave(GaimConnection *gc, int id) { |
5506 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
5507 GSList *bcs = gc->buddy_chats; | |
5679 | 5508 GaimConversation *b = NULL; |
2086 | 5509 struct chat_connection *c = NULL; |
5510 int count = 0; | |
5511 | |
5512 while (bcs) { | |
5513 count++; | |
5679 | 5514 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5515 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 5516 break; |
5517 bcs = bcs->next; | |
5518 b = NULL; | |
5519 } | |
5520 | |
5521 if (!b) | |
5522 return; | |
5523 | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5524 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5525 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 5526 |
8308 | 5527 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 5528 if (c != NULL) { |
4617 | 5529 if (od) |
5530 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 5531 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5532 gaim_input_remove(c->inpa); |
8308 | 5533 if (gc && od->sess) |
4617 | 5534 aim_conn_kill(od->sess, &c->conn); |
2086 | 5535 g_free(c->name); |
5536 g_free(c->show); | |
5537 g_free(c); | |
5538 } | |
5539 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 5540 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 5541 } |
5542 | |
8219 | 5543 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
5544 OscarData *od = (OscarData *)gc->proto_data; | |
5545 GError *err = NULL; | |
5546 GaimConversation *conv = NULL; | |
2086 | 5547 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5548 char *buf, *buf2; |
8219 | 5549 char *charset = NULL; |
5550 int encoding; | |
5551 int len; | |
5552 | |
5553 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5554 return -EINVAL; |
2086 | 5555 |
8219 | 5556 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5557 return -EINVAL; |
2086 | 5558 |
8219 | 5559 buf = gaim_strdup_withhtml(message); |
5560 len = strlen(buf); | |
5561 | |
5562 encoding = oscar_encoding_check(buf); | |
8233 | 5563 if (encoding & AIM_IMFLAGS_UNICODE) { |
8359 | 5564 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending Unicode chat\n"); |
8219 | 5565 charset = "unicode-2-0"; |
5566 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
5567 if (err) { | |
5568 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
8359 | 5569 "Error converting to unicode-2-0: %s\n", err->message); |
5570 g_error_free(err); | |
5571 } | |
8219 | 5572 } else if (encoding & AIM_IMFLAGS_ISO_8859_1) { |
8359 | 5573 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Sending ISO-8859-1 chat\n"); |
8219 | 5574 charset = "iso-8859-1"; |
5575 buf2 = g_convert(buf, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); | |
5576 if (err) { | |
5577 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
8359 | 5578 "Error converting to iso-8859-1: %s\n", err->message); |
8219 | 5579 g_error_free(err); |
8359 | 5580 err = NULL; |
5581 | |
5582 gaim_debug(GAIM_DEBUG_INFO, "oscar", "Falling back to Unicode\n"); | |
5583 charset = "unicode-2-0"; | |
5584 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
8219 | 5585 if (err) { |
5586 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
8359 | 5587 "Error converting to unicode-2-0: %s\n", |
5588 err->message); | |
8219 | 5589 g_error_free(err); |
5590 } | |
2086 | 5591 } |
8219 | 5592 } else { |
5593 charset = "us-ascii"; | |
5594 buf2 = g_strdup(buf); | |
5595 } | |
8359 | 5596 g_free(buf); |
5597 | |
5598 if ((len > c->maxlen) || (len > c->maxvis)) { | |
5599 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5600 return -E2BIG; |
8359 | 5601 } |
5602 | |
5603 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charset, "en"); | |
8219 | 5604 g_free(buf2); |
8359 | 5605 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5606 return 0; |
2086 | 5607 } |
5608 | |
6695 | 5609 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 5610 if (!b || (b && b->name && b->name[0] == '+')) { |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5611 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
4687 | 5612 return "icq"; |
5613 else | |
5614 return "aim"; | |
5615 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5616 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
5617 if (b != NULL && isdigit(b->name[0])) |
4687 | 5618 return "icq"; |
5619 return "aim"; | |
5620 } | |
5621 | |
6695 | 5622 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 5623 { |
7334 | 5624 GaimAccount *account = NULL; |
5625 GaimConnection *gc = NULL; | |
5626 OscarData *od = NULL; | |
4687 | 5627 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
5628 int i = 0; | |
7334 | 5629 aim_userinfo_t *userinfo = NULL; |
5630 | |
5631 if (b != NULL) | |
5632 account = b->account; | |
5633 if (account != NULL) | |
5634 gc = account->gc; | |
5635 if (gc != NULL) | |
5636 od = gc->proto_data; | |
7945 | 5637 if (od != NULL) |
5638 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 5639 |
5131 | 5640 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
5641 char *gname; | |
7334 | 5642 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 5643 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
5644 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
5645 emblems[i++] = "notauthorized"; | |
5646 } else { | |
5647 emblems[i++] = "offline"; | |
5648 } | |
5649 } | |
4916 | 5650 |
4766 | 5651 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4960 | 5652 int uc = b->uc >> 16; |
4766 | 5653 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 5654 emblems[i++] = "invisible"; |
4766 | 5655 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 5656 emblems[i++] = "freeforchat"; |
4766 | 5657 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 5658 emblems[i++] = "dnd"; |
4766 | 5659 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 5660 emblems[i++] = "na"; |
4766 | 5661 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 5662 emblems[i++] = "occupied"; |
4766 | 5663 else if (uc & AIM_ICQ_STATE_AWAY) |
5664 emblems[i++] = "away"; | |
5665 } else { | |
5666 if (b->uc & UC_UNAVAILABLE) | |
5667 emblems[i++] = "away"; | |
5668 } | |
4687 | 5669 if (b->uc & UC_WIRELESS) |
5670 emblems[i++] = "wireless"; | |
5671 if (b->uc & UC_AOL) | |
5672 emblems[i++] = "aol"; | |
5673 if (b->uc & UC_ADMIN) | |
5674 emblems[i++] = "admin"; | |
5675 if (b->uc & UC_AB && i < 4) | |
5676 emblems[i++] = "activebuddy"; | |
4766 | 5677 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
5678 emblems[i++] = "unconfirmed"; */ | |
7334 | 5679 |
7945 | 5680 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
5681 emblems[i++] = "hiptop"; | |
5682 | |
5683 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 5684 emblems[i++] = "secure"; |
5685 | |
4687 | 5686 *se = emblems[0]; |
5687 *sw = emblems[1]; | |
5688 *nw = emblems[2]; | |
5689 *ne = emblems[3]; | |
5690 } | |
5691 | |
6695 | 5692 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 5693 GaimConnection *gc = b->account->gc; |
7283 | 5694 OscarData *od = gc->proto_data; |
7692 | 5695 GaimGroup *g = gaim_find_buddys_group(b); |
7261 | 5696 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
7045 | 5697 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
7011 | 5698 gchar *tmp = NULL, *ret = g_strdup(""); |
5131 | 5699 |
5700 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
5701 if (isdigit(b->name[0])) { | |
7011 | 5702 char *status; |
5131 | 5703 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); |
7011 | 5704 tmp = ret; |
5705 ret = g_strconcat(tmp, _("<b>Status:</b> "), status, "\n", NULL); | |
5131 | 5706 g_free(tmp); |
5707 g_free(status); | |
5708 } | |
5709 | |
7011 | 5710 if ((bi != NULL) && (bi->ipaddr)) { |
7283 | 5711 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
7011 | 5712 (bi->ipaddr & 0xff000000) >> 24, |
5713 (bi->ipaddr & 0x00ff0000) >> 16, | |
5714 (bi->ipaddr & 0x0000ff00) >> 8, | |
5715 (bi->ipaddr & 0x000000ff)); | |
5716 tmp = ret; | |
5717 ret = g_strconcat(tmp, _("<b>IP Address:</b> "), tstr, "\n", NULL); | |
7162 | 5718 g_free(tmp); |
5719 g_free(tstr); | |
7011 | 5720 } |
5721 | |
5722 if ((userinfo != NULL) && (userinfo->capabilities)) { | |
5723 char *caps = caps_string(userinfo->capabilities); | |
5724 tmp = ret; | |
5725 ret = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL); | |
7162 | 5726 g_free(tmp); |
7011 | 5727 } |
5728 | |
7692 | 5729 if (g && g->name) { |
5730 char *comment = NULL; | |
5731 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
5732 if (comment != NULL) { | |
5733 tmp = ret; | |
5734 ret = g_strconcat(tmp, _("<b>Buddy Comment:</b> "), comment, "\n", NULL); | |
5735 free(tmp); | |
5736 free(comment); | |
5737 } | |
5738 } | |
5739 | |
7011 | 5740 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { |
5741 gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5742 tmp = ret; | |
5743 ret = g_strconcat(tmp, _("<b>Available:</b> "), escaped, "\n", NULL); | |
7162 | 5744 g_free(tmp); |
7011 | 5745 g_free(escaped); |
5746 } | |
5747 | |
5748 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 5749 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 5750 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 5751 g_free(charset); |
7011 | 5752 if (away_utf8 != NULL) { |
7091 | 5753 gchar *tmp1, *tmp2; |
8341 | 5754 const gchar *tmp3; |
5755 tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); | |
5756 g_free(away_utf8); | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7093
diff
changeset
|
5757 tmp2 = gaim_markup_strip_html(tmp1); |
7091 | 5758 g_free(tmp1); |
8571 | 5759 tmp1 = gaim_escape_html(tmp2); |
7091 | 5760 g_free(tmp2); |
8461 | 5761 tmp3 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
5762 g_free(tmp1); | |
7011 | 5763 tmp = ret; |
7162 | 5764 ret = g_strconcat(tmp, _("<b>Away Message:</b> "), tmp3, "\n", NULL); |
5765 g_free(tmp); | |
5836 | 5766 } |
5131 | 5767 } |
5768 } else { | |
5769 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
5770 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) { | |
7011 | 5771 tmp = ret; |
5772 ret = g_strconcat(tmp, _("<b>Status:</b> Not Authorized"), "\n", NULL); | |
5131 | 5773 g_free(tmp); |
5774 } else { | |
7011 | 5775 tmp = ret; |
5776 ret = g_strconcat(tmp, _("<b>Status:</b> Offline"), "\n", NULL); | |
5131 | 5777 g_free(tmp); |
5778 } | |
5779 } | |
5780 | |
5781 /* remove the trailing newline character */ | |
8266 | 5782 if (ret && (strlen(ret) > 0)) |
7011 | 5783 ret[strlen(ret)-1] = '\0'; |
5784 return ret; | |
5131 | 5785 } |
5786 | |
6695 | 5787 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 5788 GaimConnection *gc = b->account->gc; |
7283 | 5789 OscarData *od = gc->proto_data; |
5167 | 5790 gchar *ret = NULL; |
5791 | |
5792 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
5793 if (isdigit(b->name[0])) | |
5794 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
7038 | 5795 else |
5796 ret = g_strdup(_("Away")); | |
5836 | 5797 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 5798 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 5799 if (bi->availmsg) |
5800 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 5801 } else { |
5167 | 5802 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
5803 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
5804 ret = g_strdup(_("Not Authorized")); | |
5805 else | |
5806 ret = g_strdup(_("Offline")); | |
5807 } | |
5808 | |
5809 return ret; | |
5810 } | |
5811 | |
5842 | 5812 |
5844 | 5813 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 5814 GaimConnection *gc = sess->aux_data; |
7283 | 5815 OscarData *od = gc->proto_data; |
5892 | 5816 va_list ap; |
5842 | 5817 fu16_t type; |
5892 | 5818 fu8_t flags = 0, length = 0; |
5819 char *md5 = NULL; | |
5820 | |
7334 | 5821 |
5842 | 5822 va_start(ap, fr); |
5823 type = va_arg(ap, int); | |
5892 | 5824 |
5825 switch(type) { | |
5826 case 0x0000: | |
5827 case 0x0001: { | |
5828 flags = va_arg(ap, int); | |
5829 length = va_arg(ap, int); | |
5830 md5 = va_arg(ap, char *); | |
5831 | |
5832 if (flags == 0x41) { | |
5833 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
5834 od->iconconnecting = TRUE; | |
5835 od->set_icon = TRUE; | |
5836 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
5837 } else { | |
6039 | 5838 struct stat st; |
5839 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
5840 if (iconfile == NULL) { | |
8363 | 5841 aim_ssi_delicon(od->sess); |
6039 | 5842 } else if (!stat(iconfile, &st)) { |
5843 char *buf = g_malloc(st.st_size); | |
5844 FILE *file = fopen(iconfile, "rb"); | |
5845 if (file) { | |
5846 fread(buf, 1, st.st_size, file); | |
5847 fclose(file); | |
5848 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
5849 "Uploading icon to icon server\n"); | |
6879 | 5850 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 5851 } else |
5852 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6039 | 5853 "Can't open buddy icon file!\n"); |
5854 g_free(buf); | |
5855 } else { | |
5856 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
5857 "Can't stat buddy icon file!\n"); | |
5892 | 5858 } |
5859 } | |
8363 | 5860 } else if (flags == 0x81) { |
5861 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
5862 if (iconfile == NULL) | |
5863 aim_ssi_delicon(od->sess); | |
5864 else | |
5865 aim_ssi_seticon(od->sess, md5, length); | |
5866 } | |
5892 | 5867 } break; |
5868 | |
5869 case 0x0002: { /* We just set an "available" message? */ | |
5870 } break; | |
5871 } | |
5872 | |
5842 | 5873 va_end(ap); |
5844 | 5874 |
5875 return 0; | |
5842 | 5876 } |
5892 | 5877 |
3952 | 5878 /* |
4617 | 5879 * We have just established a socket with the other dude, so set up some handlers. |
3952 | 5880 */ |
4617 | 5881 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5882 GaimConnection *gc = sess->aux_data; |
7283 | 5883 OscarData *od = (OscarData *)gc->proto_data; |
5679 | 5884 GaimConversation *cnv; |
2086 | 5885 struct direct_im *dim; |
5886 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5887 char *sn; |
4617 | 5888 va_list ap; |
5889 aim_conn_t *newconn, *listenerconn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5890 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5891 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5892 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5893 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 5894 va_end(ap); |
5895 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5896 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5897 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5898 |
4617 | 5899 sn = g_strdup(aim_odc_getsn(newconn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5900 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5901 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5902 "DirectIM: initiate success to %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5903 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5904 |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
5905 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
|
5906 gaim_input_remove(dim->watcher); |
2086 | 5907 dim->conn = newconn; |
4617 | 5908 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
3008 | 5909 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5910 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5911 g_free(sn); |
6982 | 5912 gaim_conversation_write(cnv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
2086 | 5913 |
4617 | 5914 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
5915 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
6982 | 5916 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); |
4617 | 5917 |
2993 | 5918 return 1; |
5919 } | |
5920 | |
6982 | 5921 /* |
5922 * This is called when each chunk of an image is received. It can be used to | |
5923 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
5924 * nasty, you sicko. | |
5925 */ | |
5926 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
2993 | 5927 va_list ap; |
5928 char *sn; | |
5929 double percent; | |
5575 | 5930 GaimConnection *gc = sess->aux_data; |
7283 | 5931 OscarData *od = (OscarData *)gc->proto_data; |
5679 | 5932 GaimConversation *c; |
2993 | 5933 struct direct_im *dim; |
5934 | |
5935 va_start(ap, fr); | |
5936 sn = va_arg(ap, char *); | |
5937 percent = va_arg(ap, double); | |
5938 va_end(ap); | |
6873 | 5939 |
2994 | 5940 if (!(dim = find_direct_im(od, sn))) |
5941 return 1; | |
3059 | 5942 if (dim->watcher) { |
5943 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
5944 dim->watcher = 0; | |
5945 } | |
6640
314111e7b601
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
5946 |
6982 | 5947 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); |
6873 | 5948 if (c != NULL) |
5949 gaim_conversation_update_progress(c, percent); | |
2993 | 5950 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
5951 oscar_callback, dim->conn); | |
2086 | 5952 |
5953 return 1; | |
5954 } | |
5955 | |
6982 | 5956 /* |
5957 * This is called after a direct IM has been received in its entirety. This | |
5958 * function is passed a long chunk of data which contains the IM with any | |
5959 * data chunks (images) appended to it. | |
5960 * | |
5961 * This function rips out all the data chunks and creates an imgstore for | |
5962 * each one. In order to do this, it first goes through the IM and takes | |
5963 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
5964 * with one compatable with the imgstore Gaim core code. For each one, we | |
5965 * then read in chunks of data from the end of the message and actually | |
5966 * create the img store using the given data. | |
5967 * | |
5968 * For somewhat easy reference, here's a sample message | |
5969 * (without the whitespace and asterisks): | |
5970 * | |
5971 * <HTML><BODY BGCOLOR="#ffffff"> | |
5972 * <FONT LANG="0"> | |
5973 * This is a really stupid picture:<BR> | |
5974 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
5975 * Yeah it is<BR> | |
5976 * Here is another one:<BR> | |
5977 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
5978 * </FONT> | |
5979 * </BODY></HTML> | |
5980 * <BINARY> | |
5981 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
5982 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
5983 * </BINARY> | |
5984 */ | |
4617 | 5985 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5986 GaimConnection *gc = sess->aux_data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5987 GaimConvImFlags imflags = 0; |
8233 | 5988 gchar *utf8; |
6982 | 5989 GString *newmsg = g_string_new(""); |
5990 GSList *images = NULL; | |
2086 | 5991 va_list ap; |
6982 | 5992 const char *sn, *msg, *msgend, *binary; |
5993 size_t len; | |
5994 int encoding, isawaymsg; | |
2086 | 5995 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5996 va_start(ap, fr); |
6982 | 5997 sn = va_arg(ap, const char *); |
5998 msg = va_arg(ap, const char *); | |
5999 len = va_arg(ap, size_t); | |
3952 | 6000 encoding = va_arg(ap, int); |
4870 | 6001 isawaymsg = va_arg(ap, int); |
2086 | 6002 va_end(ap); |
6982 | 6003 msgend = msg + len; |
2086 | 6004 |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6005 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6006 "Got DirectIM message from %s\n", sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6007 |
4870 | 6008 if (isawaymsg) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6009 imflags |= GAIM_CONV_IM_AUTO_RESP; |
4870 | 6010 |
6982 | 6011 /* message has a binary trailer */ |
6012 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
6013 GData *attribs; | |
6014 const char *tmp, *start, *end, *last = NULL; | |
6015 | |
6016 tmp = msg; | |
6017 | |
6018 /* for each valid image tag... */ | |
6019 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
6020 const char *id, *src, *datasize; | |
6021 const char *tag = NULL, *data = NULL; | |
6022 size_t size; | |
6023 int imgid = 0; | |
6024 | |
6025 /* update the location of the last img tag */ | |
6026 last = end; | |
6027 | |
6028 /* grab attributes */ | |
6029 id = g_datalist_get_data(&attribs, "id"); | |
6030 src = g_datalist_get_data(&attribs, "src"); | |
6031 datasize = g_datalist_get_data(&attribs, "datasize"); | |
6032 | |
6033 /* if we have id & datasize, build the data tag */ | |
6034 if (id && datasize) | |
6035 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
6036 | |
6037 /* if we have a tag, find the start of the data */ | |
6038 if (tag && (data = gaim_strcasestr(binary, tag))) | |
6039 data += strlen(tag); | |
6040 | |
6041 /* check the data is here and store it */ | |
6042 if (data + (size = atoi(datasize)) <= msgend) | |
6043 imgid = gaim_imgstore_add(data, size, src); | |
6044 | |
8233 | 6045 /* |
6046 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
6047 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
6048 */ | |
6982 | 6049 /* if we have a stored image... */ |
6050 if (imgid) { | |
6051 /* append the message up to the tag */ | |
8233 | 6052 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); |
6053 if (utf8 != NULL) { | |
6054 newmsg = g_string_append(newmsg, utf8); | |
6055 g_free(utf8); | |
6056 } | |
6982 | 6057 |
6058 /* write the new image tag */ | |
6059 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
6060 | |
6061 /* and record the image number */ | |
6062 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
6063 } else { | |
6064 /* otherwise, copy up to the end of the tag */ | |
8233 | 6065 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); |
6066 if (utf8 != NULL) { | |
6067 newmsg = g_string_append(newmsg, utf8); | |
6068 g_free(utf8); | |
6069 } | |
6982 | 6070 } |
6071 | |
6072 /* clear the attribute list */ | |
6073 g_datalist_clear(&attribs); | |
6074 | |
6075 /* continue from the end of the tag */ | |
6076 tmp = end + 1; | |
6077 } | |
6078 | |
6079 /* append any remaining message data (without the > :-) */ | |
6080 if (last++ && (last < binary)) | |
6081 newmsg = g_string_append_len(newmsg, last, binary - last); | |
6082 | |
6083 /* set the flag if we caught any images */ | |
6084 if (images) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6085 imflags |= GAIM_CONV_IM_IMAGES; |
6982 | 6086 } else { |
6087 g_string_append_len(newmsg, msg, len); | |
6088 } | |
6089 | |
4617 | 6090 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
6982 | 6091 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); |
6092 | |
6093 /* free up the message */ | |
6094 g_string_free(newmsg, TRUE); | |
6095 | |
6096 /* unref any images we allocated */ | |
6097 if (images) { | |
6098 GSList *tmp; | |
6099 int id; | |
6100 | |
6101 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
6102 id = GPOINTER_TO_INT(tmp->data); | |
6103 gaim_imgstore_unref(id); | |
6104 } | |
6105 | |
6106 g_slist_free(images); | |
6107 } | |
2086 | 6108 |
6109 return 1; | |
6110 } | |
6111 | |
4617 | 6112 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 6113 va_list ap; |
6114 char *sn; | |
2993 | 6115 int typing; |
5575 | 6116 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6117 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6118 va_start(ap, fr); |
2086 | 6119 sn = va_arg(ap, char *); |
2993 | 6120 typing = va_arg(ap, int); |
2086 | 6121 va_end(ap); |
6122 | |
4870 | 6123 if (typing == 0x0002) { |
2993 | 6124 /* I had to leave this. It's just too funny. It reminds me of my sister. */ |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6125 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6126 "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
|
6127 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
4870 | 6128 } else if (typing == 0x0001) |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6129 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
4870 | 6130 else |
4342 | 6131 serv_got_typing_stopped(gc, sn); |
2086 | 6132 return 1; |
6133 } | |
6134 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6135 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { |
6982 | 6136 char *buf; |
6137 size_t len; | |
6138 int ret; | |
6139 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6140 if (imflags & GAIM_CONV_IM_IMAGES) { |
6982 | 6141 GString *msg = g_string_new(""); |
6142 GString *data = g_string_new("<BINARY>"); | |
6143 GData *attribs; | |
6144 const char *tmp, *start, *end, *last = NULL; | |
6145 int oscar_id = 0; | |
6146 | |
6147 tmp = message; | |
6148 | |
6149 /* for each valid IMG tag... */ | |
6150 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
6151 GaimStoredImage *image = NULL; | |
6152 const char *id; | |
6153 | |
6154 last = end; | |
6155 id = g_datalist_get_data(&attribs, "id"); | |
6156 | |
6157 /* ... if it refers to a valid gaim image ... */ | |
6158 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
6159 /* ... append the message from start to the tag ... */ | |
6160 msg = g_string_append_len(msg, tmp, start - tmp); | |
6161 oscar_id++; | |
6162 | |
6163 /* ... insert a new img tag with the oscar id ... */ | |
6164 if (image->filename) | |
6165 g_string_append_printf(msg, | |
6166 "<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", | |
7386 | 6167 image->filename, oscar_id, (int)image->size); |
6982 | 6168 else |
6169 g_string_append_printf(msg, | |
6170 "<IMG ID=\"%d\" DATASIZE=\"%d\">", | |
7386 | 6171 oscar_id, (int)image->size); |
6982 | 6172 |
6173 /* ... and append the data to the binary section ... */ | |
6174 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%d\">", | |
7386 | 6175 oscar_id, (int)image->size); |
6982 | 6176 data = g_string_append_len(data, image->data, image->size); |
6177 data = g_string_append(data, "</DATA>"); | |
6178 } else { | |
6179 /* ... otherwise, allow the possibly invalid img tag through. */ | |
6180 /* should we do something else? */ | |
6181 msg = g_string_append_len(msg, tmp, (end + 1) - tmp); | |
6182 } | |
6183 | |
6184 g_datalist_clear(&attribs); | |
6185 | |
6186 /* continue from the end of the tag */ | |
6187 tmp = end + 1; | |
6188 } | |
6189 | |
6190 /* append any remaining message data (without the > :-) */ | |
6191 if (last++ && *last) | |
6192 msg = g_string_append(msg, last); | |
6193 | |
6194 /* if we inserted any images in the binary section, append it */ | |
6195 if (oscar_id) { | |
6196 msg = g_string_append_len(msg, data->str, data->len); | |
6197 msg = g_string_append(msg, "</BINARY>"); | |
6198 } | |
6199 | |
6200 len = msg->len; | |
6201 buf = msg->str; | |
6202 g_string_free(msg, FALSE); | |
6203 g_string_free(data, TRUE); | |
6204 } else { | |
6205 len = strlen(message); | |
6206 buf = g_memdup(message, len+1); | |
6207 } | |
6208 | |
6209 /* 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
|
6210 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
6982 | 6211 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); |
6212 else | |
6213 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
6214 | |
6215 g_free(buf); | |
6216 | |
6217 return ret; | |
6218 } | |
6219 | |
2086 | 6220 struct ask_do_dir_im { |
6221 char *who; | |
5575 | 6222 GaimConnection *gc; |
2086 | 6223 }; |
6224 | |
3730 | 6225 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
5136 | 6226 g_free(data->who); |
2086 | 6227 g_free(data); |
6228 } | |
6229 | |
3730 | 6230 static void oscar_direct_im(struct ask_do_dir_im *data) { |
5575 | 6231 GaimConnection *gc = data->gc; |
7283 | 6232 OscarData *od; |
2086 | 6233 struct direct_im *dim; |
8240 | 6234 int listenfd; |
2086 | 6235 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
6236 if (!g_list_find(gaim_connections_get_all(), gc)) { |
5136 | 6237 g_free(data->who); |
4244 | 6238 g_free(data); |
6239 return; | |
6240 } | |
6241 | |
7283 | 6242 od = (OscarData *)gc->proto_data; |
4244 | 6243 |
2086 | 6244 dim = find_direct_im(od, data->who); |
6245 if (dim) { | |
3008 | 6246 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
6247 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
6248 gaim_input_remove(dim->watcher); | |
6249 g_free(dim); | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6250 gaim_debug(GAIM_DEBUG_INFO, "oscar", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6251 "Gave up on old direct IM, trying again\n"); |
3008 | 6252 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6253 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); |
5136 | 6254 g_free(data->who); |
4244 | 6255 g_free(data); |
3008 | 6256 return; |
6257 } | |
2086 | 6258 } |
6259 dim = g_new0(struct direct_im, 1); | |
6260 dim->gc = gc; | |
6261 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
6262 | |
8246 | 6263 listenfd = gaim_network_listen_range(5190, 5199); |
8240 | 6264 dim->conn = aim_odc_initiate(od->sess, data->who, listenfd, gaim_network_get_port_from_fd(listenfd)); |
2086 | 6265 if (dim->conn != NULL) { |
6266 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6267 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 6268 oscar_callback, dim->conn); |
4617 | 6269 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
6270 gaim_odc_initiate, 0); | |
2086 | 6271 } else { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6272 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
2086 | 6273 g_free(dim); |
6274 } | |
4244 | 6275 |
5136 | 6276 g_free(data->who); |
4244 | 6277 g_free(data); |
2086 | 6278 } |
6279 | |
5575 | 6280 static void oscar_ask_direct_im(GaimConnection *gc, const char *who) { |
5420 | 6281 gchar *buf; |
2086 | 6282 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); |
5136 | 6283 data->who = g_strdup(who); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
6284 data->gc = gc; |
5420 | 6285 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
|
6286 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6287 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6288 _("Because this reveals your IP address, it " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6289 "may be considered a privacy risk. Do you " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6290 "wish to continue?"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6291 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6292 _("Connect"), G_CALLBACK(oscar_direct_im), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6293 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
5420 | 6294 g_free(buf); |
2086 | 6295 } |
6296 | |
5575 | 6297 static void oscar_set_permit_deny(GaimConnection *gc) { |
6298 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6299 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6300 #ifdef NOSSI |
8143 | 6301 GSList *list; |
4230 | 6302 char buf[MAXMSGLEN]; |
6303 int at; | |
6304 | |
5575 | 6305 switch(account->perm_deny) { |
8175 | 6306 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6307 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6308 break; |
8175 | 6309 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6310 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6311 break; |
8175 | 6312 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6313 list = account->permit; |
4230 | 6314 at = 0; |
6315 while (list) { | |
6316 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6317 list = list->next; | |
6318 } | |
6319 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6320 break; | |
8175 | 6321 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6322 list = account->deny; |
4230 | 6323 at = 0; |
6324 while (list) { | |
6325 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6326 list = list->next; | |
6327 } | |
6328 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6329 break; | |
6330 default: | |
6331 break; | |
2086 | 6332 } |
4230 | 6333 #else |
8175 | 6334 if (od->sess->ssi.received_data) { |
6335 switch (account->perm_deny) { | |
6336 case GAIM_PRIVACY_ALLOW_ALL: | |
6337 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6338 break; | |
6339 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6340 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6341 break; | |
6342 case GAIM_PRIVACY_ALLOW_USERS: | |
6343 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6344 break; | |
6345 case GAIM_PRIVACY_DENY_ALL: | |
6346 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6347 break; | |
6348 case GAIM_PRIVACY_DENY_USERS: | |
6349 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6350 break; | |
6351 default: | |
6352 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6353 break; | |
6354 } | |
6355 } | |
4230 | 6356 #endif |
2086 | 6357 } |
6358 | |
5575 | 6359 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6360 #ifdef NOSSI |
8143 | 6361 if (gc->account->perm_deny == 3) |
4269 | 6362 oscar_set_permit_deny(gc); |
6363 #else | |
7283 | 6364 OscarData *od = (OscarData *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6365 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to add a permit\n"); |
4230 | 6366 if (od->sess->ssi.received_data) |
4889 | 6367 aim_ssi_addpermit(od->sess, who); |
4230 | 6368 #endif |
2086 | 6369 } |
6370 | |
5575 | 6371 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6372 #ifdef NOSSI |
8143 | 6373 if (gc->account->perm_deny == 4) |
4269 | 6374 oscar_set_permit_deny(gc); |
6375 #else | |
7283 | 6376 OscarData *od = (OscarData *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6377 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to add a deny\n"); |
4230 | 6378 if (od->sess->ssi.received_data) |
4889 | 6379 aim_ssi_adddeny(od->sess, who); |
4230 | 6380 #endif |
2086 | 6381 } |
6382 | |
5575 | 6383 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6384 #ifdef NOSSI |
8143 | 6385 if (gc->account->perm_deny == 3) |
4269 | 6386 oscar_set_permit_deny(gc); |
6387 #else | |
7283 | 6388 OscarData *od = (OscarData *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6389 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to delete a permit\n"); |
4230 | 6390 if (od->sess->ssi.received_data) |
4889 | 6391 aim_ssi_delpermit(od->sess, who); |
4230 | 6392 #endif |
2086 | 6393 } |
6394 | |
5575 | 6395 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6396 #ifdef NOSSI |
8143 | 6397 if (gc->account->perm_deny == 4) |
4269 | 6398 oscar_set_permit_deny(gc); |
6399 #else | |
7283 | 6400 OscarData *od = (OscarData *)gc->proto_data; |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6401 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: About to delete a deny\n"); |
4230 | 6402 if (od->sess->ssi.received_data) |
4889 | 6403 aim_ssi_deldeny(od->sess, who); |
4230 | 6404 #endif |
2086 | 6405 } |
6406 | |
5575 | 6407 static GList *oscar_away_states(GaimConnection *gc) |
2086 | 6408 { |
7283 | 6409 OscarData *od = gc->proto_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6410 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6411 |
8257 | 6412 if (od->icq) { |
6413 m = g_list_append(m, _("Online")); | |
6414 m = g_list_append(m, _("Away")); | |
6415 m = g_list_append(m, _("Do Not Disturb")); | |
6416 m = g_list_append(m, _("Not Available")); | |
6417 m = g_list_append(m, _("Occupied")); | |
6418 m = g_list_append(m, _("Free For Chat")); | |
6419 m = g_list_append(m, _("Invisible")); | |
6420 } else { | |
6421 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
8476 | 6422 m = g_list_append(m, _("Back")); |
8257 | 6423 m = g_list_append(m, _("Visible")); |
6424 m = g_list_append(m, _("Invisible")); | |
6425 } | |
4333 | 6426 |
6427 return m; | |
6428 } | |
6429 | |
7172 | 6430 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6431 GaimConnection *gc = data->gc; |
6432 OscarData *od = gc->proto_data; | |
7172 | 6433 GaimBuddy *b; |
6434 GaimGroup *g; | |
6435 | |
6436 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6437 oscar_free_name_data(data); | |
6438 return; | |
6439 } | |
6440 | |
6441 if (!(g = gaim_find_buddys_group(b))) { | |
6442 oscar_free_name_data(data); | |
6443 return; | |
6444 } | |
6445 | |
6446 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6447 |
6448 if (!aim_sncmp(data->name, gc->account->username)) | |
6449 gaim_check_comment(od, text); | |
6450 | |
7172 | 6451 oscar_free_name_data(data); |
6452 } | |
6453 | |
6454 static void oscar_buddycb_edit_comment(GaimConnection *gc, const char *name) { | |
7283 | 6455 OscarData *od = gc->proto_data; |
7172 | 6456 struct name_data *data = g_new(struct name_data, 1); |
6457 GaimBuddy *b; | |
6458 GaimGroup *g; | |
6459 char *comment; | |
6460 gchar *comment_utf8; | |
6461 | |
6462 if (!(b = gaim_find_buddy(gaim_connection_get_account(gc), name))) | |
6463 return; | |
6464 if (!(g = gaim_find_buddys_group(b))) | |
6465 return; | |
6466 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, name); | |
6467 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; | |
6468 | |
6469 data->gc = gc; | |
6470 data->name = g_strdup(name); | |
6471 data->nick = NULL; | |
6472 | |
6473 gaim_request_input(gc, NULL, _("Buddy Comment:"), NULL, | |
6474 comment_utf8, TRUE, FALSE, | |
6475 _("OK"), G_CALLBACK(oscar_ssi_editcomment), | |
6476 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6477 data); | |
6478 | |
6479 free(comment); | |
6480 g_free(comment_utf8); | |
6481 } | |
6482 | |
5575 | 6483 static GList *oscar_buddy_menu(GaimConnection *gc, const char *who) { |
7283 | 6484 OscarData *od = gc->proto_data; |
4333 | 6485 GList *m = NULL; |
6486 struct proto_buddy_menu *pbm; | |
6487 | |
7172 | 6488 pbm = g_new0(struct proto_buddy_menu, 1); |
6489 pbm->label = _("Edit Buddy Comment"); | |
6490 pbm->callback = oscar_buddycb_edit_comment; | |
6491 pbm->gc = gc; | |
6492 m = g_list_append(m, pbm); | |
6493 | |
4333 | 6494 if (od->icq) { |
4624 | 6495 #if 0 |
4333 | 6496 pbm = g_new0(struct proto_buddy_menu, 1); |
6497 pbm->label = _("Get Status Msg"); | |
4969 | 6498 pbm->callback = oscar_get_icqstatusmsg; |
4333 | 6499 pbm->gc = gc; |
6500 m = g_list_append(m, pbm); | |
4624 | 6501 #endif |
4333 | 6502 } else { |
6695 | 6503 GaimBuddy *b = gaim_find_buddy(gc->account, who); |
7011 | 6504 aim_userinfo_t *userinfo; |
5975 | 6505 |
6506 if (b) | |
7045 | 6507 userinfo = aim_locate_finduserinfo(od->sess, b->name); |
7011 | 6508 |
6509 if (b && userinfo && aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), who) && GAIM_BUDDY_IS_ONLINE(b)) { | |
6510 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { | |
5917 | 6511 pbm = g_new0(struct proto_buddy_menu, 1); |
6512 pbm->label = _("Direct IM"); | |
6513 pbm->callback = oscar_ask_direct_im; | |
6514 pbm->gc = gc; | |
6515 m = g_list_append(m, pbm); | |
6516 } | |
7650 | 6517 |
6518 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { | |
6519 pbm = g_new0(struct proto_buddy_menu, 1); | |
6520 pbm->label = _("Send File"); | |
6521 pbm->callback = oscar_ask_sendfile; | |
6522 pbm->gc = gc; | |
6523 m = g_list_append(m, pbm); | |
6524 } | |
4826 | 6525 #if 0 |
7011 | 6526 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
5917 | 6527 pbm = g_new0(struct proto_buddy_menu, 1); |
6528 pbm->label = _("Get File"); | |
6529 pbm->callback = oscar_ask_getfile; | |
6530 pbm->gc = gc; | |
6531 m = g_list_append(m, pbm); | |
6532 } | |
4826 | 6533 #endif |
4333 | 6534 } |
5131 | 6535 } |
5197 | 6536 |
5131 | 6537 if (od->sess->ssi.received_data) { |
6538 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
6539 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
6540 pbm = g_new0(struct proto_buddy_menu, 1); | |
6873 | 6541 pbm->label = _("Re-request Authorization"); |
5131 | 6542 pbm->callback = gaim_auth_sendrequest; |
6543 pbm->gc = gc; | |
6544 m = g_list_append(m, pbm); | |
4333 | 6545 } |
4916 | 6546 } |
6547 | |
4333 | 6548 return m; |
6549 } | |
6550 | |
5575 | 6551 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 6552 OscarData *od = gc->proto_data; |
5575 | 6553 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 6554 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
6555 od->setnick = TRUE; | |
6556 od->newsn = g_strdup(nick); | |
6557 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6558 } else { | |
6559 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
6560 } | |
6561 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6562 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 6563 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 6564 } |
6565 } | |
6566 | |
5575 | 6567 static void oscar_show_format_screenname(GaimConnection *gc) |
4333 | 6568 { |
8152 | 6569 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6570 gaim_connection_get_display_name(gc), FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6571 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6572 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6573 gc); |
4333 | 6574 } |
6575 | |
5575 | 6576 static void oscar_confirm_account(GaimConnection *gc) |
4333 | 6577 { |
7283 | 6578 OscarData *od = gc->proto_data; |
4333 | 6579 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6580 | |
6581 if (conn) { | |
6582 aim_admin_reqconfirm(od->sess, conn); | |
6583 } else { | |
6584 od->conf = TRUE; | |
6585 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6586 } | |
6587 } | |
6588 | |
5575 | 6589 static void oscar_show_email(GaimConnection *gc) |
4333 | 6590 { |
7283 | 6591 OscarData *od = gc->proto_data; |
4333 | 6592 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6593 | |
6594 if (conn) { | |
6595 aim_admin_getinfo(od->sess, conn, 0x11); | |
6596 } else { | |
6597 od->reqemail = TRUE; | |
6598 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6599 } | |
6600 } | |
6601 | |
5575 | 6602 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6603 { |
7283 | 6604 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6605 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
|
6606 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6607 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6608 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6609 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6610 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6611 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6612 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6613 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6614 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6615 |
5575 | 6616 static void oscar_show_change_email(GaimConnection *gc) |
4333 | 6617 { |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6618 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6619 FALSE, FALSE, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6620 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6621 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6622 gc); |
4333 | 6623 } |
6624 | |
5575 | 6625 static void oscar_show_awaitingauth(GaimConnection *gc) |
4333 | 6626 { |
7283 | 6627 OscarData *od = gc->proto_data; |
4333 | 6628 gchar *nombre, *text, *tmp; |
6695 | 6629 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 6630 int num=0; |
6631 | |
6873 | 6632 text = g_strdup(""); |
4333 | 6633 |
4785 | 6634 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 6635 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 6636 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
6637 continue; | |
6695 | 6638 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
6639 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 6640 continue; |
6695 | 6641 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
6642 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
6643 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6644 continue; | |
6645 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
6646 if (gaim_get_buddy_alias_only(buddy)) | |
6647 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
6648 else | |
6649 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 6650 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 6651 g_free(text); |
6652 text = tmp; | |
6653 g_free(nombre); | |
6654 num++; | |
6655 } | |
4333 | 6656 } |
2979 | 6657 } |
4333 | 6658 } |
6659 | |
6660 if (!num) { | |
6661 g_free(text); | |
6873 | 6662 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
6663 } | |
6664 | |
6665 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
6666 "the following buddies"), _("You can re-request " | |
6667 "authorization from these buddies by " | |
6668 "right-clicking on them and selecting " | |
6669 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 6670 g_free(text); |
2979 | 6671 } |
6672 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6673 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6674 { |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6675 serv_dir_search(gc, "", "", "", "", "", "", "", email); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6676 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6677 |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6678 static void oscar_show_find_email(GaimConnection *gc) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6679 { |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6680 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6681 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6682 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6683 "searching for."), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6684 NULL, FALSE, FALSE, |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6685 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6686 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6687 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6688 |
7366 | 6689 #if 0 |
5917 | 6690 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
7283 | 6691 OscarData *od = (OscarData *)gc->proto_data; |
5917 | 6692 |
7334 | 6693 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
5917 | 6694 aim_srv_setavailmsg(od->sess, text); |
6695 } | |
6696 | |
6697 static void oscar_show_setavailmsg(GaimConnection *gc) | |
6698 { | |
7313 | 6699 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
6700 _("I'm doing work and hoping for a distraction--IM me!"), | |
6701 TRUE, FALSE, | |
5917 | 6702 _("OK"), G_CALLBACK(oscar_setavailmsg), |
6703 _("Cancel"), NULL, | |
6704 gc); | |
6705 } | |
7366 | 6706 #endif |
5917 | 6707 |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6708 static void oscar_show_set_info(GaimConnection *gc) |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6709 { |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6710 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6711 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6712 |
8576 | 6713 static void oscar_show_set_info_icqurl(GaimConnection *gc) |
6714 { | |
6715 gaim_notify_uri(gc, "http://web.icq.com/whitepages/login/1,,,00.html"); | |
6716 } | |
6717 | |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6718 static void oscar_change_pass(GaimConnection *gc) |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6719 { |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6720 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6721 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6722 |
5575 | 6723 static void oscar_show_chpassurl(GaimConnection *gc) |
4333 | 6724 { |
7283 | 6725 OscarData *od = gc->proto_data; |
5575 | 6726 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
|
6727 gaim_notify_uri(gc, substituted); |
5517 | 6728 g_free(substituted); |
4333 | 6729 } |
6730 | |
7026 | 6731 static void oscar_show_imforwardingurl(GaimConnection *gc) |
6732 { | |
6733 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); | |
6734 } | |
6735 | |
5842 | 6736 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
6737 { | |
7283 | 6738 OscarData *od = gc->proto_data; |
5844 | 6739 aim_session_t *sess = od->sess; |
5842 | 6740 FILE *file; |
6741 struct stat st; | |
5844 | 6742 |
6039 | 6743 if (iconfile == NULL) { |
8363 | 6744 aim_ssi_delicon(od->sess); |
6039 | 6745 } else if (!stat(iconfile, &st)) { |
5842 | 6746 char *buf = g_malloc(st.st_size); |
6747 file = fopen(iconfile, "rb"); | |
6748 if (file) { | |
6052 | 6749 md5_state_t *state; |
6039 | 6750 char md5[16]; |
5842 | 6751 int len = fread(buf, 1, st.st_size, file); |
6039 | 6752 fclose(file); |
6052 | 6753 state = g_malloc(sizeof(md5_state_t)); |
5842 | 6754 md5_init(state); |
6755 md5_append(state, buf, len); | |
6756 md5_finish(state, md5); | |
6757 g_free(state); | |
6758 aim_ssi_seticon(sess, md5, 16); | |
6759 } else | |
6760 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6761 "Can't open buddy icon file!\n"); | |
6762 g_free(buf); | |
6763 } else | |
6764 gaim_debug(GAIM_DEBUG_ERROR, "oscar", | |
6765 "Can't stat buddy icon file!\n"); | |
6766 } | |
6767 | |
6768 | |
5575 | 6769 static GList *oscar_actions(GaimConnection *gc) |
2086 | 6770 { |
7283 | 6771 OscarData *od = gc->proto_data; |
4333 | 6772 struct proto_actions_menu *pam; |
6773 GList *m = NULL; | |
6774 | |
6775 pam = g_new0(struct proto_actions_menu, 1); | |
7853 | 6776 pam->label = _("Set User Info..."); |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6777 pam->callback = oscar_show_set_info; |
4333 | 6778 pam->gc = gc; |
6779 m = g_list_append(m, pam); | |
6780 | |
8576 | 6781 if (od->icq) { |
6782 pam = g_new0(struct proto_actions_menu, 1); | |
6783 pam->label = _("Set User Info (URL)..."); | |
6784 pam->callback = oscar_show_set_info_icqurl; | |
6785 pam->gc = gc; | |
6786 m = g_list_append(m, pam); | |
6787 } | |
6788 | |
7366 | 6789 #if 0 |
5917 | 6790 pam = g_new0(struct proto_actions_menu, 1); |
7853 | 6791 pam->label = _("Set Available Message..."); |
5917 | 6792 pam->callback = oscar_show_setavailmsg; |
6793 pam->gc = gc; | |
6794 m = g_list_append(m, pam); | |
7366 | 6795 #endif |
5917 | 6796 |
5238 | 6797 pam = g_new0(struct proto_actions_menu, 1); |
7853 | 6798 pam->label = _("Change Password..."); |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6799 pam->callback = oscar_change_pass; |
5238 | 6800 pam->gc = gc; |
6801 m = g_list_append(m, pam); | |
4617 | 6802 |
6803 if (od->sess->authinfo->chpassurl) { | |
6804 pam = g_new0(struct proto_actions_menu, 1); | |
6805 pam->label = _("Change Password (URL)"); | |
6806 pam->callback = oscar_show_chpassurl; | |
6807 pam->gc = gc; | |
6808 m = g_list_append(m, pam); | |
6809 } | |
6810 | |
7026 | 6811 if (od->sess->authinfo->chpassurl) { |
6812 pam = g_new0(struct proto_actions_menu, 1); | |
6813 pam->label = _("Configure IM Forwarding (URL)"); | |
6814 pam->callback = oscar_show_imforwardingurl; | |
6815 pam->gc = gc; | |
6816 m = g_list_append(m, pam); | |
6817 } | |
6818 | |
5238 | 6819 if (!od->icq) { |
4617 | 6820 /* AIM actions */ |
6821 m = g_list_append(m, NULL); | |
4333 | 6822 |
5917 | 6823 pam = g_new0(struct proto_actions_menu, 1); |
8152 | 6824 pam->label = _("Format Screen Name..."); |
5844 | 6825 pam->callback = oscar_show_format_screenname; |
4333 | 6826 pam->gc = gc; |
6827 m = g_list_append(m, pam); | |
6828 | |
6829 pam = g_new0(struct proto_actions_menu, 1); | |
6830 pam->label = _("Confirm Account"); | |
6831 pam->callback = oscar_confirm_account; | |
6832 pam->gc = gc; | |
6833 m = g_list_append(m, pam); | |
6834 | |
6835 pam = g_new0(struct proto_actions_menu, 1); | |
7880 | 6836 pam->label = _("Display Currently Registered Address"); |
4333 | 6837 pam->callback = oscar_show_email; |
6838 pam->gc = gc; | |
6839 m = g_list_append(m, pam); | |
6840 | |
6841 pam = g_new0(struct proto_actions_menu, 1); | |
7880 | 6842 pam->label = _("Change Currently Registered Address..."); |
4333 | 6843 pam->callback = oscar_show_change_email; |
6844 pam->gc = gc; | |
6845 m = g_list_append(m, pam); | |
2086 | 6846 } |
4333 | 6847 |
6848 m = g_list_append(m, NULL); | |
6849 | |
6850 pam = g_new0(struct proto_actions_menu, 1); | |
6851 pam->label = _("Show Buddies Awaiting Authorization"); | |
6852 pam->callback = oscar_show_awaitingauth; | |
6853 pam->gc = gc; | |
6854 m = g_list_append(m, pam); | |
6855 | |
2086 | 6856 m = g_list_append(m, NULL); |
4333 | 6857 |
6858 pam = g_new0(struct proto_actions_menu, 1); | |
7853 | 6859 pam->label = _("Search for Buddy by Email..."); |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6860 pam->callback = oscar_show_find_email; |
4333 | 6861 pam->gc = gc; |
6862 m = g_list_append(m, pam); | |
6863 | |
4336 | 6864 /* pam = g_new0(struct proto_actions_menu, 1); |
4333 | 6865 pam->label = _("Search for Buddy by Information"); |
6866 pam->callback = show_find_info; | |
6867 pam->gc = gc; | |
4336 | 6868 m = g_list_append(m, pam); */ |
2086 | 6869 |
6870 return m; | |
6871 } | |
6872 | |
5575 | 6873 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 6874 { |
7283 | 6875 OscarData *od = gc->proto_data; |
4617 | 6876 |
6877 if (od->icq) { | |
6878 aim_icq_changepasswd(od->sess, new); | |
2086 | 6879 } else { |
4617 | 6880 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
6881 if (conn) { | |
6882 aim_admin_changepasswd(od->sess, conn, new, old); | |
6883 } else { | |
6884 od->chpass = TRUE; | |
6885 od->oldp = g_strdup(old); | |
6886 od->newp = g_strdup(new); | |
6887 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
6888 } | |
2086 | 6889 } |
6890 } | |
6891 | |
6059 | 6892 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6893 { |
7283 | 6894 OscarData *od = gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6895 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6896 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6897 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6898 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6899 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6900 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6901 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6902 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6903 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6904 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6905 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6906 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6907 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6908 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
|
6909 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6910 NULL, |
8170 | 6911 NULL, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6912 oscar_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6913 oscar_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6914 oscar_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6915 oscar_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6916 oscar_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6917 oscar_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6918 oscar_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6919 oscar_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6920 oscar_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6921 oscar_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6922 oscar_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6923 oscar_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6924 oscar_send_typing, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6925 oscar_get_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6926 oscar_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6927 oscar_set_dir, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6928 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6929 oscar_dir_search, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6930 oscar_set_idle, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6931 oscar_change_passwd, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6932 oscar_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6933 oscar_add_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6934 oscar_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6935 oscar_remove_buddies, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6936 oscar_add_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6937 oscar_add_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6938 oscar_rem_permit, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6939 oscar_rem_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6940 oscar_set_permit_deny, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6941 oscar_warn, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6942 oscar_join_chat, |
8562 | 6943 NULL, /* reject chat invite */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6944 oscar_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6945 oscar_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6946 NULL, |
8219 | 6947 oscar_send_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6948 oscar_keepalive, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6949 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6950 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6951 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6952 #ifndef NOSSI |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6953 oscar_alias_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6954 oscar_move_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6955 oscar_rename_group, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6956 #else |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6957 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6958 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6959 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6960 #endif |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6961 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6962 oscar_convo_closed, |
5842 | 6963 NULL, |
8586 | 6964 oscar_set_icon, |
8589 | 6965 NULL, |
6966 NULL, | |
6967 NULL, | |
6968 NULL, | |
6969 NULL, | |
6970 NULL, | |
6971 NULL, | |
6972 NULL | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6973 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6974 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6975 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6976 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6977 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6978 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6979 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6980 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6981 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6982 GAIM_PRIORITY_DEFAULT, /**< priority */ |
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 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6985 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6986 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6987 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6988 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6989 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6990 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6991 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
6992 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6993 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6994 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6995 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6996 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6997 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6998 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
6999 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7000 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7001 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7002 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7003 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7004 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7005 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7006 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7007 option = gaim_account_option_string_new(_("Auth host"), "server", |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7008 "login.oscar.aol.com"); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7009 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7010 option); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7011 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7012 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7013 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7014 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7015 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7016 my_protocol = plugin; |
2086 | 7017 } |
7018 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7019 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |