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