Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 10487:659edfcac14e
[gaim-migrate @ 11777]
Removed protocol preferences.
MSN will display closed conversation messages but not timeouts.
Jabber will not display your OS.
I left the preferences for OSCAR, but removed them from the UI. OSCAR is
complicated because it stores prefs on the server. I'll let Mark figure
out a smarter way to handle that.
As with all slashed prefs, feel free to voice objections.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 08 Jan 2005 20:30:41 +0000 |
parents | 58ab47ed31bf |
children | aba3000cc50a |
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 | |
10485 | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 20 * GNU General Public License for more details. |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
31 #include "buddyicon.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
32 #include "conversation.h" |
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
33 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "ft.h" |
6982 | 36 #include "imgstore.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
37 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
38 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
39 #include "privacy.h" |
2086 | 40 #include "prpl.h" |
4889 | 41 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
42 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
43 #include "util.h" |
9943 | 44 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 |
2086 | 46 #include "aim.h" |
5842 | 47 #include "md5.h" |
2086 | 48 |
9976 | 49 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
50 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
51 #define OSCAR_STATUS_ID_ONLINE "online" | |
9991 | 52 #define OSCAR_STATUS_ID_AVAILABLE "available" |
9976 | 53 #define OSCAR_STATUS_ID_AWAY "away" |
54 #define OSCAR_STATUS_ID_DND "dnd" | |
55 #define OSCAR_STATUS_ID_NA "na" | |
56 #define OSCAR_STATUS_ID_OCCUPIED "occupied" | |
57 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
58 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
9975 | 59 |
2086 | 60 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
61 | |
7283 | 62 #define OSCAR_CONNECT_STEPS 6 |
9830 | 63 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 64 |
10329 | 65 #define FAIM_DEBUG_LEVEL 0 |
66 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
67 static GaimPlugin *my_protocol = NULL; |
4249 | 68 |
7376 | 69 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
70 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 71 |
4665 | 72 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
73 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 74 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 75 |
7283 | 76 typedef struct _OscarData OscarData; |
77 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
78 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
79 aim_conn_t *conn; |
2086 | 80 |
81 guint cnpa; | |
82 guint paspa; | |
3694 | 83 guint emlpa; |
4804 | 84 guint icopa; |
2086 | 85 |
4823 | 86 gboolean iconconnecting; |
5842 | 87 gboolean set_icon; |
4823 | 88 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
89 GSList *create_rooms; |
2086 | 90 |
91 gboolean conf; | |
92 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
93 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
94 char *email; |
2979 | 95 gboolean setnick; |
96 char *newsn; | |
2086 | 97 gboolean chpass; |
98 char *oldp; | |
99 char *newp; | |
9971 | 100 |
2086 | 101 GSList *oscar_chats; |
102 GSList *direct_ims; | |
3630 | 103 GSList *file_transfers; |
4738 | 104 GHashTable *buddyinfo; |
4804 | 105 GSList *requesticon; |
2086 | 106 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
107 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
108 gboolean icq; |
4804 | 109 guint icontimer; |
5968 | 110 guint getblisttimer; |
8341 | 111 guint getinfotimer; |
2993 | 112 |
113 struct { | |
4230 | 114 guint maxwatchers; /* max users who can watch you */ |
2993 | 115 guint maxbuddies; /* max users you can watch */ |
4230 | 116 guint maxgroups; /* max groups in server list */ |
2993 | 117 guint maxpermits; /* max users on permit list */ |
118 guint maxdenies; /* max users on deny list */ | |
119 guint maxsiglen; /* max size (bytes) of profile */ | |
120 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
121 } rights; | |
2086 | 122 }; |
123 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
124 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
125 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
126 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
127 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
128 |
2086 | 129 struct chat_connection { |
130 char *name; | |
131 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
132 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
133 fu16_t instance; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
134 aim_conn_t *conn; |
2086 | 135 int inpa; |
136 int id; | |
5575 | 137 GaimConnection *gc; /* i hate this. */ |
8733 | 138 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
139 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
140 int maxvis; |
2086 | 141 }; |
142 | |
8971 | 143 struct oscar_direct_im { |
5575 | 144 GaimConnection *gc; |
2086 | 145 char name[80]; |
146 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
147 aim_conn_t *conn; |
3008 | 148 gboolean connected; |
8978 | 149 gboolean gpc_pend; |
150 gboolean killme; | |
8984 | 151 gboolean donttryagain; |
2086 | 152 }; |
153 | |
154 struct ask_direct { | |
5575 | 155 GaimConnection *gc; |
2086 | 156 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
157 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
158 fu8_t cookie[8]; |
8984 | 159 gboolean donttryagain; |
2086 | 160 }; |
161 | |
7011 | 162 /* |
163 * Various PRPL-specific buddy info that we want to keep track of | |
164 * Some other info is maintained by locate.c, and I'd like to move | |
165 * the rest of this to libfaim, mostly im.c | |
166 */ | |
4738 | 167 struct buddyinfo { |
168 gboolean typingnot; | |
6292 | 169 gchar *availmsg; |
6857 | 170 fu32_t ipaddr; |
5836 | 171 |
172 unsigned long ico_me_len; | |
173 unsigned long ico_me_csum; | |
174 time_t ico_me_time; | |
175 gboolean ico_informed; | |
4738 | 176 |
177 unsigned long ico_len; | |
178 unsigned long ico_csum; | |
179 time_t ico_time; | |
180 gboolean ico_need; | |
7406 | 181 gboolean ico_sent; |
2086 | 182 }; |
183 | |
4230 | 184 struct name_data { |
5575 | 185 GaimConnection *gc; |
4230 | 186 gchar *name; |
3453 | 187 gchar *nick; |
3141 | 188 }; |
189 | |
5129 | 190 static char *msgerrreason[] = { |
191 N_("Invalid error"), | |
192 N_("Invalid SNAC"), | |
193 N_("Rate to host"), | |
194 N_("Rate to client"), | |
195 N_("Not logged in"), | |
196 N_("Service unavailable"), | |
197 N_("Service not defined"), | |
198 N_("Obsolete SNAC"), | |
199 N_("Not supported by host"), | |
200 N_("Not supported by client"), | |
201 N_("Refused by client"), | |
202 N_("Reply too big"), | |
203 N_("Responses lost"), | |
204 N_("Request denied"), | |
205 N_("Busted SNAC payload"), | |
206 N_("Insufficient rights"), | |
207 N_("In local permit/deny"), | |
208 N_("Too evil (sender)"), | |
209 N_("Too evil (receiver)"), | |
210 N_("User temporarily unavailable"), | |
211 N_("No match"), | |
212 N_("List overflow"), | |
213 N_("Request ambiguous"), | |
214 N_("Queue full"), | |
215 N_("Not while on AOL") | |
216 }; | |
217 static int msgerrreasonlen = 25; | |
218 | |
219 /* All the libfaim->gaim callback functions */ | |
220 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
221 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
10464 | 222 static int gaim_parse_auth_securid_request(aim_session_t *, aim_frame_t *, ...); |
5129 | 223 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
224 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
225 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
226 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
227 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
228 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 231 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 232 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 233 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
234 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
235 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
236 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
237 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
238 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 239 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
240 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
241 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 242 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 243 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
244 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
245 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
246 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
247 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
249 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
250 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
251 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
252 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
253 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
254 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
255 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
258 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
259 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
260 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
261 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
262 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
270 #ifndef NOSSI | |
271 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 275 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 276 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
277 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
278 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
280 #endif | |
281 | |
282 /* for DirectIM/image transfer */ | |
283 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
284 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 286 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 287 |
288 /* for file transfer */ | |
289 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
290 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
291 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
292 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
293 | |
294 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 295 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 296 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 297 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 298 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
299 | |
5836 | 300 static void oscar_free_name_data(struct name_data *data) { |
4230 | 301 g_free(data->name); |
302 g_free(data->nick); | |
303 g_free(data); | |
304 } | |
305 | |
5836 | 306 static void oscar_free_buddyinfo(void *data) { |
307 struct buddyinfo *bi = data; | |
6292 | 308 g_free(bi->availmsg); |
5836 | 309 g_free(bi); |
310 } | |
311 | |
9807 | 312 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 313 { |
314 int i = 0; | |
9826 | 315 int charset = AIM_CHARSET_ASCII; |
5129 | 316 |
317 /* Determine how we can send this message. Per the warnings elsewhere | |
318 * in this file, these little checks determine the simplest encoding | |
319 * we can use for a given message send using it. */ | |
320 while (utf8[i]) { | |
321 if ((unsigned char)utf8[i] > 0x7f) { | |
322 /* not ASCII! */ | |
9826 | 323 charset = AIM_CHARSET_CUSTOM; |
5129 | 324 break; |
325 } | |
326 i++; | |
327 } | |
328 while (utf8[i]) { | |
329 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
330 * followed by 0xc0-0xc3 in the second */ | |
331 if ((unsigned char)utf8[i] < 0x80) { | |
332 i++; | |
333 continue; | |
334 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
335 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
336 i += 2; | |
337 continue; | |
338 } | |
9826 | 339 charset = AIM_CHARSET_UNICODE; |
5129 | 340 break; |
341 } | |
342 | |
9807 | 343 return charset; |
5129 | 344 } |
345 | |
8225 | 346 /* |
347 * Take a string of the form charset="bleh" where bleh is | |
348 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
349 * return a newly allocated string containing bleh. | |
350 */ | |
351 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 352 { |
8225 | 353 gchar *ret = NULL; |
354 char *begin, *end; | |
355 | |
9933 | 356 g_return_val_if_fail(encoding != NULL, NULL); |
357 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
358 /* Make sure encoding begins with charset= */ |
8225 | 359 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
360 return NULL; | |
361 | |
362 begin = strchr(encoding, '"'); | |
363 end = strrchr(encoding, '"'); | |
364 | |
365 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
366 return NULL; | |
367 | |
368 ret = g_strndup(begin+1, (end-1) - begin); | |
369 | |
370 return ret; | |
371 } | |
372 | |
9830 | 373 static gchar * |
374 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 375 { |
376 gchar *utf8 = NULL; | |
9595 | 377 |
378 if ((encoding == NULL) || encoding[0] == '\0') { | |
379 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
10396 | 380 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
10376 | 381 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
10396 | 382 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
10375 | 383 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
10396 | 384 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
9595 | 385 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
10396 | 386 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
9595 | 387 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
10096 | 388 "attempting to convert to UTF-8 anyway\n", encoding); |
9595 | 389 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
390 } | |
391 | |
392 /* | |
393 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
394 * we have been unable to convert the text to utf-8 from the encoding | |
395 * that was specified. So we check if the text is valid utf-8 then | |
396 * just copy it. | |
397 */ | |
398 if (utf8 == NULL) { | |
9638 | 399 if (textlen != 0 && *text != '\0' |
400 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 401 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 402 else |
9481 | 403 utf8 = g_strndup(text, textlen); |
5129 | 404 } |
405 | |
406 return utf8; | |
407 } | |
408 | |
9830 | 409 static gchar * |
9908 | 410 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 411 { |
412 gchar *ret = NULL; | |
413 GError *err = NULL; | |
414 | |
9908 | 415 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
416 return NULL; | |
417 | |
418 if (strcasecmp("UTF-8", charsetstr)) { | |
419 if (fallback) | |
420 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
421 else | |
422 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
423 if (err != NULL) { | |
424 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
425 charsetstr, err->message); | |
426 g_error_free(err); | |
427 } | |
428 } else { | |
429 if (g_utf8_validate(data, datalen, NULL)) | |
430 ret = g_strndup(data, datalen); | |
431 else | |
432 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
433 } | |
434 | |
435 return ret; | |
436 } | |
437 | |
438 /* | |
439 * We try decoding using two different character sets. The charset | |
440 * specified in the IM determines the order in which we attempt to | |
441 * decode. We do this because there are lots of broken ICQ clients | |
442 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
443 * able to deal with that crap, then people complain like banshees. | |
444 * charsetstr1 is always set to what the correct encoding should be. | |
445 */ | |
446 static gchar * | |
447 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
448 { | |
449 gchar *ret = NULL; | |
450 const gchar *charsetstr1, *charsetstr2; | |
451 | |
452 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 453 |
454 if ((datalen == 0) || (data == NULL)) | |
455 return NULL; | |
456 | |
9908 | 457 if (charset == AIM_CHARSET_UNICODE) { |
458 charsetstr1 = "UCS-2BE"; | |
459 charsetstr2 = "UTF-8"; | |
460 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 461 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 462 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 463 else |
9908 | 464 charsetstr1 = "ISO-8859-1"; |
465 charsetstr2 = "UTF-8"; | |
466 } else if (charset == AIM_CHARSET_ASCII) { | |
467 /* Should just be "ASCII" */ | |
9914 | 468 charsetstr1 = "ASCII"; |
9908 | 469 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
470 } else if (charset == 0x000d) { | |
9830 | 471 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 472 charsetstr1 = "ISO-8859-1"; |
473 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
474 } else { | |
9830 | 475 /* Unknown, hope for valid UTF-8... */ |
9908 | 476 charsetstr1 = "UTF-8"; |
477 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
478 } | |
479 | |
480 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
481 if (ret == NULL) | |
482 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
483 if (ret == NULL) | |
484 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 485 |
486 return ret; | |
487 } | |
488 | |
489 static void | |
490 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 491 gchar **msg, int *msglen_int, |
9830 | 492 fu16_t *charset, fu16_t *charsubset) |
493 { | |
494 OscarData *od = gc->proto_data; | |
495 GaimAccount *account = gaim_connection_get_account(gc); | |
496 GError *err = NULL; | |
497 aim_userinfo_t *userinfo = NULL; | |
498 const gchar *charsetstr; | |
10039 | 499 gsize msglen; |
9830 | 500 |
501 /* Attempt to send as ASCII */ | |
10098 | 502 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
10097 | 503 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
10098 | 504 *charset = AIM_CHARSET_ASCII; |
9830 | 505 *charsubset = 0x0000; |
10039 | 506 *msglen_int = msglen; |
9830 | 507 return; |
508 } | |
509 | |
510 /* | |
9908 | 511 * If we're sending to an ICQ user, and they are advertising the |
512 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 513 */ |
9975 | 514 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 515 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
516 | |
517 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
10039 | 518 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
9830 | 519 if (*msg != NULL) { |
520 *charset = AIM_CHARSET_UNICODE; | |
521 *charsubset = 0x0000; | |
10039 | 522 *msglen_int = msglen; |
9830 | 523 return; |
524 } | |
525 } | |
526 | |
527 /* | |
528 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
529 * ICQ then attempt to send as the user specified character encoding. | |
530 */ | |
531 charsetstr = "ISO-8859-1"; | |
9975 | 532 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 533 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
534 | |
10097 | 535 /* |
536 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
537 * can be converted to "charsetstr" | |
538 */ | |
10039 | 539 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 540 if (*msg != NULL) { |
541 *charset = AIM_CHARSET_CUSTOM; | |
542 *charsubset = 0x0000; | |
10039 | 543 *msglen_int = msglen; |
9830 | 544 return; |
545 } | |
546 | |
547 /* | |
548 * Nothing else worked, so send as UCS-2BE. | |
549 */ | |
10039 | 550 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 551 if (*msg != NULL) { |
552 *charset = AIM_CHARSET_UNICODE; | |
553 *charsubset = 0x0000; | |
10039 | 554 *msglen_int = msglen; |
9830 | 555 return; |
556 } | |
557 | |
9908 | 558 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 559 g_error_free(err); |
560 | |
561 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
562 *msg = g_strdup(from); | |
10039 | 563 *msglen_int = strlen(*msg); |
9830 | 564 *charset = AIM_CHARSET_ASCII; |
565 *charsubset = 0x0000; | |
566 return; | |
567 } | |
568 | |
9407 | 569 gchar *oscar_caps_to_string(guint caps) |
8701 | 570 { |
9407 | 571 GString *str; |
572 gchar *tmp; | |
8701 | 573 guint bit = 1; |
574 | |
9407 | 575 str = g_string_new(""); |
576 | |
8701 | 577 if (!caps) { |
578 return NULL; | |
579 } else while (bit <= AIM_CAPS_LAST) { | |
580 if (bit & caps) { | |
581 switch (bit) { | |
582 case AIM_CAPS_BUDDYICON: | |
583 tmp = _("Buddy Icon"); | |
584 break; | |
585 case AIM_CAPS_TALK: | |
586 tmp = _("Voice"); | |
587 break; | |
588 case AIM_CAPS_DIRECTIM: | |
589 tmp = _("AIM Direct IM"); | |
590 break; | |
591 case AIM_CAPS_CHAT: | |
592 tmp = _("Chat"); | |
593 break; | |
594 case AIM_CAPS_GETFILE: | |
595 tmp = _("Get File"); | |
596 break; | |
597 case AIM_CAPS_SENDFILE: | |
598 tmp = _("Send File"); | |
599 break; | |
600 case AIM_CAPS_GAMES: | |
601 case AIM_CAPS_GAMES2: | |
602 tmp = _("Games"); | |
603 break; | |
604 case AIM_CAPS_ADDINS: | |
605 tmp = _("Add-Ins"); | |
606 break; | |
607 case AIM_CAPS_SENDBUDDYLIST: | |
608 tmp = _("Send Buddy List"); | |
609 break; | |
610 case AIM_CAPS_ICQ_DIRECT: | |
611 tmp = _("ICQ Direct Connect"); | |
612 break; | |
613 case AIM_CAPS_APINFO: | |
614 tmp = _("AP User"); | |
615 break; | |
616 case AIM_CAPS_ICQRTF: | |
617 tmp = _("ICQ RTF"); | |
618 break; | |
619 case AIM_CAPS_EMPTY: | |
620 tmp = _("Nihilist"); | |
621 break; | |
622 case AIM_CAPS_ICQSERVERRELAY: | |
623 tmp = _("ICQ Server Relay"); | |
624 break; | |
625 case AIM_CAPS_ICQUTF8OLD: | |
626 tmp = _("Old ICQ UTF8"); | |
627 break; | |
628 case AIM_CAPS_TRILLIANCRYPT: | |
629 tmp = _("Trillian Encryption"); | |
630 break; | |
631 case AIM_CAPS_ICQUTF8: | |
632 tmp = _("ICQ UTF8"); | |
633 break; | |
634 case AIM_CAPS_HIPTOP: | |
635 tmp = _("Hiptop"); | |
636 break; | |
637 case AIM_CAPS_SECUREIM: | |
638 tmp = _("Security Enabled"); | |
639 break; | |
640 case AIM_CAPS_VIDEO: | |
641 tmp = _("Video Chat"); | |
642 break; | |
643 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
644 case AIM_CAPS_ICHATAV: | |
645 tmp = _("iChat AV"); | |
646 break; | |
647 case AIM_CAPS_LIVEVIDEO: | |
648 tmp = _("Live Video"); | |
649 break; | |
650 case AIM_CAPS_CAMERA: | |
651 tmp = _("Camera"); | |
652 break; | |
653 default: | |
654 tmp = NULL; | |
655 break; | |
656 } | |
657 if (tmp) | |
9532 | 658 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 659 } |
660 bit <<= 1; | |
661 } | |
9407 | 662 |
663 return g_string_free(str, FALSE); | |
8701 | 664 } |
665 | |
666 static char *oscar_icqstatus(int state) { | |
667 /* Make a cute little string that shows the status of the dude or dudet */ | |
668 if (state & AIM_ICQ_STATE_CHAT) | |
669 return g_strdup_printf(_("Free For Chat")); | |
670 else if (state & AIM_ICQ_STATE_DND) | |
671 return g_strdup_printf(_("Do Not Disturb")); | |
672 else if (state & AIM_ICQ_STATE_OUT) | |
673 return g_strdup_printf(_("Not Available")); | |
674 else if (state & AIM_ICQ_STATE_BUSY) | |
675 return g_strdup_printf(_("Occupied")); | |
676 else if (state & AIM_ICQ_STATE_AWAY) | |
677 return g_strdup_printf(_("Away")); | |
678 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
679 return g_strdup_printf(_("Web Aware")); | |
680 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
681 return g_strdup_printf(_("Invisible")); | |
682 else | |
683 return g_strdup_printf(_("Online")); | |
684 } | |
685 | |
9973 | 686 static void |
687 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 688 { |
689 gchar *utf8; | |
690 | |
691 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 692 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 693 g_free(utf8); |
694 } | |
695 } | |
696 | |
9973 | 697 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 698 { |
10042 | 699 OscarData *od; |
700 GaimAccount *account; | |
701 GaimPresence *presence; | |
702 GaimPresence *buddy_presence; | |
8701 | 703 GaimGroup *g = NULL; |
704 struct buddyinfo *bi = NULL; | |
705 char *tmp; | |
706 | |
10042 | 707 od = gc->proto_data; |
708 account = gaim_connection_get_account(gc); | |
709 presence = gaim_account_get_presence(account); | |
710 buddy_presence = gaim_buddy_get_presence(b); | |
711 | |
712 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
8701 | 713 return; |
714 | |
715 if (userinfo == NULL) | |
716 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
717 | |
718 if (b == NULL) | |
10042 | 719 b = gaim_find_buddy(account, userinfo->sn); |
8701 | 720 |
721 if (b != NULL) | |
722 g = gaim_find_buddys_group(b); | |
723 | |
724 if (userinfo != NULL) | |
725 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
726 | |
8733 | 727 if (b != NULL) { |
10042 | 728 if (gaim_presence_is_online(buddy_presence)) { |
9975 | 729 if (aim_sn_is_icq(b->name)) { |
8733 | 730 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
731 oscar_string_append(str, newline, _("Status"), tmp); | |
732 g_free(tmp); | |
733 } | |
734 } else { | |
9625 | 735 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 736 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
737 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
738 else | |
739 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 740 } |
8733 | 741 } |
8701 | 742 |
743 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 744 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 745 (bi->ipaddr & 0xff000000) >> 24, |
746 (bi->ipaddr & 0x00ff0000) >> 16, | |
747 (bi->ipaddr & 0x0000ff00) >> 8, | |
748 (bi->ipaddr & 0x000000ff)); | |
749 oscar_string_append(str, newline, _("IP Address"), tmp); | |
750 g_free(tmp); | |
751 } | |
752 | |
753 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
754 tmp = oscar_caps_to_string(userinfo->capabilities); | |
755 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 756 g_free(tmp); |
8701 | 757 } |
758 | |
759 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
760 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
761 if (tmp != NULL) { | |
9625 | 762 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 763 g_free(tmp); |
9625 | 764 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
765 g_free(tmp2); | |
8701 | 766 } |
767 } | |
768 | |
10042 | 769 if ((bi != NULL) && (bi->availmsg != NULL) && gaim_presence_is_available(presence)) { |
8701 | 770 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
771 oscar_string_append(str, newline, _("Available"), tmp); | |
772 g_free(tmp); | |
773 } | |
774 } | |
775 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
776 static char *extract_name(const char *name) { |
4121 | 777 char *tmp, *x; |
2086 | 778 int i, j; |
4120 | 779 |
780 if (!name) | |
4121 | 781 return NULL; |
10042 | 782 |
4120 | 783 x = strchr(name, '-'); |
4121 | 784 |
2086 | 785 if (!x) return NULL; |
786 x = strchr(++x, '-'); | |
787 if (!x) return NULL; | |
788 tmp = g_strdup(++x); | |
789 | |
790 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
791 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
792 if (x[i] != '%') { |
2086 | 793 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
794 continue; |
2086 | 795 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
796 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
797 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
798 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 799 } |
800 | |
801 tmp[j] = 0; | |
802 return tmp; | |
803 } | |
804 | |
10458 | 805 static struct chat_connection * |
806 find_oscar_chat(GaimConnection *gc, int id) | |
807 { | |
808 OscarData *od = (OscarData *)gc->proto_data; | |
809 GSList *cur; | |
810 struct chat_connection *cc; | |
811 | |
812 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
813 { | |
814 cc = (struct chat_connection *)cur->data; | |
815 if (cc->id == id) | |
816 return cc; | |
817 } | |
818 | |
819 return NULL; | |
820 } | |
821 | |
822 static struct chat_connection * | |
823 find_oscar_chat_by_conn(GaimConnection *gc, aim_conn_t *conn) | |
824 { | |
825 OscarData *od = (OscarData *)gc->proto_data; | |
826 GSList *cur; | |
827 struct chat_connection *cc; | |
828 | |
829 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
830 { | |
831 cc = (struct chat_connection *)cur->data; | |
832 if (cc->conn == conn) | |
833 return cc; | |
834 } | |
835 | |
836 return NULL; | |
837 } | |
838 | |
839 static struct chat_connection * | |
840 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
841 { | |
842 OscarData *od = (OscarData *)gc->proto_data; | |
843 GSList *cur; | |
844 struct chat_connection *cc; | |
845 | |
846 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
847 { | |
848 cc = (struct chat_connection *)cur->data; | |
849 if (cc->conv == conv) | |
850 return cc; | |
851 } | |
852 | |
853 return NULL; | |
854 } | |
855 | |
856 static void | |
857 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
858 { | |
859 OscarData *od = (OscarData *)gc->proto_data; | |
860 | |
861 /* Notify the conversation window that we've left the chat */ | |
862 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
863 | |
864 /* Destroy the chat_connection */ | |
865 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
866 if (cc->inpa > 0) | |
867 gaim_input_remove(cc->inpa); | |
868 aim_conn_kill(od->sess, &cc->conn); | |
869 g_free(cc->name); | |
870 g_free(cc->show); | |
871 g_free(cc); | |
8219 | 872 } |
873 | |
8971 | 874 /***************************************************************************** |
875 * Begin scary direct im stuff | |
876 *****************************************************************************/ | |
877 | |
878 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
879 GSList *d = od->direct_ims; | |
880 struct oscar_direct_im *m = NULL; | |
881 | |
882 while (d) { | |
883 m = (struct oscar_direct_im *)d->data; | |
884 if (!aim_sncmp(who, m->name)) | |
885 return m; | |
886 d = d->next; | |
887 } | |
888 | |
889 return NULL; | |
890 } | |
891 | |
892 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
893 { | |
894 gaim_debug_info("oscar", | |
895 "destroying Direct IM for %s.\n", dim->name); | |
896 | |
897 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 898 if (dim->gpc_pend) { |
899 dim->killme = TRUE; | |
900 return; | |
901 } | |
8971 | 902 if (dim->watcher) |
903 gaim_input_remove(dim->watcher); | |
904 if (dim->conn) { | |
10271 | 905 aim_conn_close(dim->conn); |
8971 | 906 aim_conn_kill(od->sess, &dim->conn); |
907 } | |
908 g_free(dim); | |
909 } | |
910 | |
911 /* the only difference between this and destroy is this writes a conv message */ | |
912 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
913 { | |
914 GaimConversation *conv; | |
915 char buf[256]; | |
916 | |
917 gaim_debug_info("oscar", | |
918 "%s disconnected Direct IM.\n", dim->name); | |
919 | |
920 if (dim->connected) | |
921 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 922 else |
8971 | 923 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
924 | |
10246 | 925 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, dim->name, |
926 gaim_connection_get_account(dim->gc)); | |
8971 | 927 if (conv) { |
928 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 929 gaim_conversation_update_progress(conv, 0); |
8971 | 930 } else { |
931 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
932 } | |
933 | |
934 oscar_direct_im_destroy(od, dim); | |
935 | |
936 return; | |
937 } | |
938 | |
939 /* oops i made two of these. this one just calls the other one. */ | |
940 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
941 { | |
942 GaimConnection *gc = sess->aux_data; | |
943 OscarData *od = (OscarData *)gc->proto_data; | |
944 struct oscar_direct_im *dim; | |
945 char *sn; | |
946 | |
947 sn = g_strdup(aim_odc_getsn(conn)); | |
948 dim = oscar_direct_im_find(od, sn); | |
949 oscar_direct_im_disconnect(od, dim); | |
950 g_free(sn); | |
951 } | |
952 | |
953 static void destroy_direct_im_request(struct ask_direct *d) { | |
954 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
955 | |
956 g_free(d->sn); | |
957 g_free(d); | |
958 } | |
959 | |
960 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
961 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
962 struct oscar_direct_im *dim = data; | |
963 GaimConnection *gc = dim->gc; | |
964 OscarData *od = gc->proto_data; | |
965 GaimConversation *conv; | |
966 char buf[256]; | |
967 struct sockaddr name; | |
968 socklen_t name_len = 1; | |
969 | |
970 g_return_if_fail(gc != NULL); | |
971 | |
8978 | 972 dim->gpc_pend = FALSE; |
973 if (dim->killme) { | |
974 oscar_direct_im_destroy(od, dim); | |
975 return; | |
976 } | |
977 | |
8971 | 978 if (!g_list_find(gaim_connections_get_all(), gc)) { |
979 oscar_direct_im_destroy(od, dim); | |
980 return; | |
981 } | |
982 | |
983 if (source < 0) { | |
8984 | 984 if (dim->donttryagain) { |
985 oscar_direct_im_disconnect(od, dim); | |
986 return; | |
987 } else { | |
988 fu8_t cookie[8]; | |
989 char *who = g_strdup(dim->name); | |
990 const char *tmp = aim_odc_getcookie(dim->conn); | |
991 | |
992 memcpy(cookie, tmp, 8); | |
993 oscar_direct_im_destroy(od, dim); | |
994 oscar_direct_im_initiate(gc, who, cookie); | |
995 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
996 g_free(who); | |
997 return; | |
998 } | |
8971 | 999 } |
1000 | |
1001 dim->conn->fd = source; | |
1002 aim_conn_completeconnect(od->sess, dim->conn); | |
1003 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
1004 | |
1005 /* This is the best way to see if we're connected or not */ | |
8983 | 1006 /* Is this really needed? */ |
8971 | 1007 if (getpeername(source, &name, &name_len) == 0) { |
1008 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1009 dim->connected = TRUE; | |
1010 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 1011 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
1012 } else { | |
8984 | 1013 if (dim->donttryagain) { |
1014 oscar_direct_im_disconnect(od, dim); | |
1015 return; | |
1016 } else { | |
1017 fu8_t cookie[8]; | |
1018 char *who = g_strdup(dim->name); | |
1019 const char *tmp = aim_odc_getcookie(dim->conn); | |
1020 | |
1021 memcpy(cookie, tmp, 8); | |
1022 oscar_direct_im_destroy(od, dim); | |
1023 oscar_direct_im_initiate(gc, who, cookie); | |
1024 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1025 g_free(who); | |
1026 return; | |
1027 } | |
8983 | 1028 } |
1029 | |
1030 | |
8971 | 1031 } |
1032 | |
1033 static void accept_direct_im_request(struct ask_direct *d) { | |
1034 GaimConnection *gc = d->gc; | |
1035 OscarData *od; | |
1036 struct oscar_direct_im *dim; | |
1037 char *host; int port = 5190; | |
1038 int i, rc; | |
8982 | 1039 char *tmp; |
1040 GaimConversation *conv; | |
8971 | 1041 |
1042 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1043 destroy_direct_im_request(d); | |
1044 return; | |
1045 } | |
1046 | |
1047 od = (OscarData *)gc->proto_data; | |
1048 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1049 | |
1050 dim = oscar_direct_im_find(od, d->sn); | |
1051 if (dim && dim->connected) { | |
1052 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1053 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1054 return; | |
1055 } | |
1056 dim = g_new0(struct oscar_direct_im, 1); | |
1057 dim->gc = d->gc; | |
8984 | 1058 dim->donttryagain = d->donttryagain; |
8971 | 1059 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1060 | |
1061 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1062 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1063 if (!dim->conn) { | |
1064 oscar_direct_im_disconnect(od, dim); | |
1065 destroy_direct_im_request(d); | |
1066 return; | |
1067 } | |
1068 | |
1069 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1070 gaim_odc_incoming, 0); | |
1071 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1072 gaim_odc_typing, 0); | |
1073 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1074 gaim_odc_update_ui, 0); | |
1075 | |
1076 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1077 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1078 if (d->ip[i] == ':') { | |
1079 port = atoi(&(d->ip[i+1])); | |
1080 break; | |
1081 } | |
1082 } | |
1083 host = g_strndup(d->ip, i); | |
1084 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1085 dim->gpc_pend = TRUE; |
8971 | 1086 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1087 |
1088 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1089 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1090 port); | |
1091 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1092 g_free(tmp); | |
8983 | 1093 |
8971 | 1094 g_free(host); |
1095 if (rc < 0) { | |
8978 | 1096 dim->gpc_pend = FALSE; |
8971 | 1097 oscar_direct_im_disconnect(od, dim); |
1098 destroy_direct_im_request(d); | |
1099 return; | |
1100 } | |
1101 | |
1102 destroy_direct_im_request(d); | |
1103 | |
1104 return; | |
1105 } | |
1106 | |
1107 /* | |
1108 * We have just established a socket with the other dude, so set up some handlers. | |
1109 */ | |
1110 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1111 GaimConnection *gc = sess->aux_data; |
7283 | 1112 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1113 GaimConversation *conv; |
8971 | 1114 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1115 char buf[256]; |
8971 | 1116 char *sn; |
1117 va_list ap; | |
1118 aim_conn_t *newconn, *listenerconn; | |
1119 | |
1120 va_start(ap, fr); | |
1121 newconn = va_arg(ap, aim_conn_t *); | |
1122 listenerconn = va_arg(ap, aim_conn_t *); | |
1123 va_end(ap); | |
1124 | |
10271 | 1125 aim_conn_close(listenerconn); |
8971 | 1126 aim_conn_kill(sess, &listenerconn); |
1127 | |
1128 sn = g_strdup(aim_odc_getsn(newconn)); | |
1129 | |
1130 gaim_debug_info("oscar", | |
1131 "DirectIM: initiate success to %s\n", sn); | |
1132 dim = oscar_direct_im_find(od, sn); | |
1133 | |
1134 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1135 gaim_input_remove(dim->watcher); | |
1136 dim->conn = newconn; | |
1137 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1138 dim->connected = TRUE; | |
1139 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1140 g_free(sn); | |
1141 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1142 | |
1143 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1144 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1145 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1146 | |
1147 return 1; | |
1148 } | |
1149 | |
1150 /* | |
1151 * This is called when each chunk of an image is received. It can be used to | |
1152 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1153 * nasty, you sicko. | |
1154 */ | |
1155 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1156 va_list ap; | |
1157 char *sn; | |
1158 double percent; | |
1159 GaimConnection *gc = sess->aux_data; | |
1160 OscarData *od = (OscarData *)gc->proto_data; | |
1161 GaimConversation *c; | |
1162 struct oscar_direct_im *dim; | |
1163 | |
1164 va_start(ap, fr); | |
1165 sn = va_arg(ap, char *); | |
1166 percent = va_arg(ap, double); | |
1167 va_end(ap); | |
1168 | |
1169 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1170 return 1; | |
1171 if (dim->watcher) { | |
1172 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1173 /* The callback will callback? I don't get how that would happen here. */ | |
1174 dim->watcher = 0; | |
1175 } | |
1176 | |
10246 | 1177 c = gaim_find_conversation_with_account(GAIM_CONV_IM, sn, |
1178 gaim_connection_get_account(gc)); | |
8971 | 1179 if (c != NULL) |
1180 gaim_conversation_update_progress(c, percent); | |
1181 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1182 oscar_callback, dim->conn); | |
1183 | |
1184 return 1; | |
1185 } | |
1186 | |
1187 /* | |
1188 * This is called after a direct IM has been received in its entirety. This | |
1189 * function is passed a long chunk of data which contains the IM with any | |
1190 * data chunks (images) appended to it. | |
1191 * | |
1192 * This function rips out all the data chunks and creates an imgstore for | |
1193 * each one. In order to do this, it first goes through the IM and takes | |
1194 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1195 * with one compatible with the imgstore Gaim core code. For each one, we | |
1196 * then read in chunks of data from the end of the message and actually | |
1197 * create the img store using the given data. | |
1198 * | |
1199 * For somewhat easy reference, here's a sample message | |
1200 * (without the whitespace and asterisks): | |
1201 * | |
1202 * <HTML><BODY BGCOLOR="#ffffff"> | |
1203 * <FONT LANG="0"> | |
1204 * This is a really stupid picture:<BR> | |
1205 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1206 * Yeah it is<BR> | |
1207 * Here is another one:<BR> | |
1208 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1209 * </FONT> | |
1210 * </BODY></HTML> | |
1211 * <BINARY> | |
1212 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1213 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1214 * </BINARY> | |
1215 */ | |
1216 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1217 GaimConnection *gc = sess->aux_data; | |
1218 GaimConvImFlags imflags = 0; | |
1219 gchar *utf8; | |
1220 GString *newmsg = g_string_new(""); | |
1221 GSList *images = NULL; | |
1222 va_list ap; | |
1223 const char *sn, *msg, *msgend, *binary; | |
1224 size_t len; | |
1225 int encoding, isawaymsg; | |
1226 | |
1227 va_start(ap, fr); | |
1228 sn = va_arg(ap, const char *); | |
1229 msg = va_arg(ap, const char *); | |
1230 len = va_arg(ap, size_t); | |
1231 encoding = va_arg(ap, int); | |
1232 isawaymsg = va_arg(ap, int); | |
1233 va_end(ap); | |
1234 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1235 |
8660 | 1236 gaim_debug_info("oscar", |
8971 | 1237 "Got DirectIM message from %s\n", sn); |
1238 | |
1239 if (isawaymsg) | |
1240 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1241 | |
1242 /* message has a binary trailer */ | |
1243 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1244 GData *attribs; | |
1245 const char *tmp, *start, *end, *last = NULL; | |
1246 | |
1247 tmp = msg; | |
1248 | |
1249 /* for each valid image tag... */ | |
1250 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1251 const char *id, *src, *datasize; | |
1252 const char *tag = NULL, *data = NULL; | |
1253 size_t size; | |
1254 int imgid = 0; | |
1255 | |
1256 /* update the location of the last img tag */ | |
1257 last = end; | |
1258 | |
1259 /* grab attributes */ | |
1260 id = g_datalist_get_data(&attribs, "id"); | |
1261 src = g_datalist_get_data(&attribs, "src"); | |
1262 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1263 | |
1264 /* if we have id & datasize, build the data tag */ | |
1265 if (id && datasize) | |
1266 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1267 | |
1268 /* if we have a tag, find the start of the data */ | |
1269 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1270 data += strlen(tag); | |
1271 | |
1272 /* check the data is here and store it */ | |
1273 if (data + (size = atoi(datasize)) <= msgend) | |
1274 imgid = gaim_imgstore_add(data, size, src); | |
1275 | |
1276 /* | |
1277 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1278 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1279 */ | |
1280 /* if we have a stored image... */ | |
1281 if (imgid) { | |
1282 /* append the message up to the tag */ | |
1283 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1284 if (utf8 != NULL) { | |
1285 newmsg = g_string_append(newmsg, utf8); | |
1286 g_free(utf8); | |
1287 } | |
1288 | |
1289 /* write the new image tag */ | |
1290 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1291 | |
1292 /* and record the image number */ | |
1293 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1294 } else { | |
1295 /* otherwise, copy up to the end of the tag */ | |
1296 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1297 if (utf8 != NULL) { | |
1298 newmsg = g_string_append(newmsg, utf8); | |
1299 g_free(utf8); | |
1300 } | |
1301 } | |
1302 | |
1303 /* clear the attribute list */ | |
1304 g_datalist_clear(&attribs); | |
1305 | |
1306 /* continue from the end of the tag */ | |
1307 tmp = end + 1; | |
1308 } | |
1309 | |
1310 /* append any remaining message data (without the > :-) */ | |
1311 if (last++ && (last < binary)) | |
1312 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1313 | |
1314 /* set the flag if we caught any images */ | |
1315 if (images) | |
1316 imflags |= GAIM_CONV_IM_IMAGES; | |
1317 } else { | |
1318 g_string_append_len(newmsg, msg, len); | |
1319 } | |
1320 | |
10318 | 1321 /* Convert to UTF8 */ |
1322 /* (This hasn't been tested very much) */ | |
1323 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
1324 if (utf8 != NULL) { | |
1325 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
1326 g_free(utf8); | |
1327 } | |
1328 | |
1329 /* free the message */ | |
8971 | 1330 g_string_free(newmsg, TRUE); |
1331 | |
1332 /* unref any images we allocated */ | |
1333 if (images) { | |
1334 GSList *tmp; | |
1335 int id; | |
1336 | |
1337 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1338 id = GPOINTER_TO_INT(tmp->data); | |
1339 gaim_imgstore_unref(id); | |
1340 } | |
1341 | |
1342 g_slist_free(images); | |
1343 } | |
1344 | |
1345 return 1; | |
1346 } | |
1347 | |
1348 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1349 va_list ap; | |
1350 char *sn; | |
1351 int typing; | |
1352 GaimConnection *gc = sess->aux_data; | |
1353 | |
1354 va_start(ap, fr); | |
1355 sn = va_arg(ap, char *); | |
1356 typing = va_arg(ap, int); | |
1357 va_end(ap); | |
1358 | |
1359 if (typing == 0x0002) { | |
1360 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1361 gaim_debug_info("oscar", | |
1362 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1363 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1364 } else if (typing == 0x0001) | |
1365 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1366 else | |
1367 serv_got_typing_stopped(gc, sn); | |
1368 return 1; | |
1369 } | |
1370 | |
1371 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1372 char *buf; | |
1373 size_t len; | |
1374 int ret; | |
1375 GString *msg = g_string_new("<HTML><BODY>"); | |
1376 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1377 GData *attribs; | |
1378 const char *start, *end, *last; | |
1379 int oscar_id = 0; | |
1380 | |
1381 last = message; | |
1382 | |
1383 /* for each valid IMG tag... */ | |
1384 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1385 GaimStoredImage *image = NULL; | |
1386 const char *id; | |
1387 | |
1388 if (start - last) { | |
1389 g_string_append_len(msg, last, start - last); | |
1390 } | |
1391 | |
1392 id = g_datalist_get_data(&attribs, "id"); | |
1393 | |
1394 /* ... if it refers to a valid gaim image ... */ | |
1395 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1396 /* ... append the message from start to the tag ... */ | |
9126 | 1397 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1398 const char *filename = gaim_imgstore_get_filename(image); |
1399 gpointer imgdata = gaim_imgstore_get_data(image); | |
1400 | |
1401 oscar_id++; | |
1402 | |
1403 /* ... insert a new img tag with the oscar id ... */ | |
1404 if (filename) | |
1405 g_string_append_printf(msg, | |
9126 | 1406 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1407 filename, oscar_id, size); |
1408 else | |
1409 g_string_append_printf(msg, | |
9126 | 1410 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1411 oscar_id, size); |
1412 | |
1413 /* ... and append the data to the binary section ... */ | |
9126 | 1414 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1415 oscar_id, size); |
1416 data = g_string_append_len(data, imgdata, size); | |
1417 data = g_string_append(data, "</DATA>"); | |
1418 } | |
1419 /* If the tag is invalid, skip it, thus no else here */ | |
1420 | |
1421 g_datalist_clear(&attribs); | |
1422 | |
1423 /* continue from the end of the tag */ | |
1424 last = end + 1; | |
1425 } | |
1426 | |
1427 /* append any remaining message data (without the > :-) */ | |
1428 if (last && *last) | |
1429 msg = g_string_append(msg, last); | |
1430 | |
1431 /* if we inserted any images in the binary section, append it */ | |
1432 if (oscar_id) { | |
1433 msg = g_string_append_len(msg, data->str, data->len); | |
1434 msg = g_string_append(msg, "</BINARY>"); | |
1435 } | |
1436 | |
1437 len = msg->len; | |
1438 buf = msg->str; | |
1439 g_string_free(msg, FALSE); | |
1440 g_string_free(data, TRUE); | |
1441 | |
1442 | |
1443 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1444 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1445 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1446 else | |
1447 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1448 | |
1449 g_free(buf); | |
1450 | |
1451 return ret; | |
1452 } | |
1453 | |
1454 struct ask_do_dir_im { | |
1455 char *who; | |
1456 GaimConnection *gc; | |
1457 }; | |
1458 | |
1459 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1460 g_free(data->who); | |
1461 g_free(data); | |
1462 } | |
1463 | |
8983 | 1464 /* this function is used to initiate a direct im session with someone. |
1465 * we start listening on a port and send a request. they either connect | |
1466 * or send some kind of reply. If they can't connect, they ask us to | |
1467 * connect to them, and so we do that. | |
1468 * | |
1469 * this function will also get called if the other side initiate's a direct | |
1470 * im and we try to connect and fail. in that case cookie will not be null. | |
1471 * | |
1472 * note that cookie is an 8 byte string that isn't NULL terminated | |
1473 */ | |
1474 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1475 OscarData *od; |
1476 struct oscar_direct_im *dim; | |
1477 int listenfd; | |
8982 | 1478 const char *ip; |
8971 | 1479 |
1480 od = (OscarData *)gc->proto_data; | |
1481 | |
8983 | 1482 dim = oscar_direct_im_find(od, who); |
8971 | 1483 if (dim) { |
1484 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1485 oscar_direct_im_disconnect(od, dim); | |
1486 gaim_debug_info("oscar", | |
1487 "Gave up on old direct IM, trying again\n"); | |
1488 } else { | |
1489 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1490 return; |
8971 | 1491 } |
1492 } | |
1493 dim = g_new0(struct oscar_direct_im, 1); | |
1494 dim->gc = gc; | |
8983 | 1495 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1496 |
1497 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1498 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1499 if (listenfd >= 0) |
1500 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1501 if (dim->conn != NULL) { |
8982 | 1502 char *tmp; |
1503 GaimConversation *conv; | |
1504 | |
8971 | 1505 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1506 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1507 oscar_callback, dim->conn); | |
1508 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1509 gaim_odc_initiate, 0); | |
8982 | 1510 |
8983 | 1511 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1512 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1513 gaim_network_get_port_from_fd(listenfd)); |
1514 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1515 g_free(tmp); | |
8971 | 1516 } else { |
1517 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1518 oscar_direct_im_destroy(od, dim); | |
1519 } | |
8983 | 1520 } |
1521 | |
1522 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1523 GaimConnection *gc = data->gc; | |
1524 | |
1525 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1526 g_free(data->who); | |
1527 g_free(data); | |
1528 return; | |
1529 } | |
1530 | |
1531 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1532 g_free(data->who); |
1533 g_free(data); | |
1534 } | |
1535 | |
1536 /* this is the right click menu cb thingy */ | |
9030 | 1537 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1538 | |
1539 GaimBuddy *buddy; | |
1540 GaimConnection *gc; | |
8971 | 1541 gchar *buf; |
9030 | 1542 struct ask_do_dir_im *data; |
1543 | |
1544 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1545 | |
1546 buddy = (GaimBuddy *) node; | |
1547 gc = gaim_account_get_connection(buddy->account); | |
1548 | |
1549 data = g_new0(struct ask_do_dir_im, 1); | |
1550 data->who = g_strdup(buddy->name); | |
8971 | 1551 data->gc = gc; |
9030 | 1552 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1553 buddy->name); | |
8971 | 1554 |
1555 gaim_request_action(gc, NULL, buf, | |
9030 | 1556 _("Because this reveals your IP address, it " |
1557 "may be considered a privacy risk. Do you " | |
1558 "wish to continue?"), | |
1559 0, data, 2, | |
1560 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1561 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1562 g_free(buf); |
1563 } | |
1564 | |
1565 /***************************************************************************** | |
1566 * End scary direct im stuff | |
1567 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1568 |
4617 | 1569 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1570 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1571 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1572 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1573 OscarData *od; |
2086 | 1574 |
1575 if (!gc) { | |
8660 | 1576 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1577 "oscar callback for closed connection (1).\n"); |
2086 | 1578 return; |
1579 } | |
10458 | 1580 |
7283 | 1581 od = (OscarData *)gc->proto_data; |
2086 | 1582 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1583 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1584 /* oh boy. this is probably bad. i guess the only thing we |
1585 * can really do is return? */ | |
8660 | 1586 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1587 "oscar callback for closed connection (2).\n"); |
8660 | 1588 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1589 return; |
1590 } | |
1591 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1592 if (condition & GAIM_INPUT_READ) { |
4617 | 1593 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1594 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1595 "got information on rendezvous listener\n"); |
4617 | 1596 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1597 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1598 "connection error (rendezvous listener)\n"); |
4617 | 1599 aim_conn_kill(od->sess, &conn); |
8446 | 1600 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1601 } |
1602 } else { | |
4617 | 1603 if (aim_get_command(od->sess, conn) >= 0) { |
1604 aim_rxdispatch(od->sess); | |
6029 | 1605 if (od->killme) { |
8660 | 1606 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1607 return; |
1608 } | |
2086 | 1609 } else { |
1610 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
10444 | 1611 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) |
1612 { | |
1613 gaim_debug_error("oscar", "Major connection error. i.e. " | |
1614 "invalid data was received on the oscar TCP stream\n"); | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1615 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1616 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
10458 | 1617 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); |
1618 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
5420 | 1619 char *buf; |
10458 | 1620 |
1621 gaim_debug_info("oscar", "Lost connection " | |
1622 "to chat room %s\n", cc->name); | |
1623 | |
1624 buf = g_strdup_printf(_("You have lost your connection " | |
1625 "to chat room %s."), cc->name); | |
1626 if (conv != NULL) | |
9627 | 1627 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); |
1628 else | |
1629 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1630 g_free(buf); |
10458 | 1631 |
1632 oscar_chat_kill(gc, cc); | |
1633 | |
2086 | 1634 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1635 if (od->cnpa > 0) |
1636 gaim_input_remove(od->cnpa); | |
1637 od->cnpa = 0; | |
8660 | 1638 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1639 "removing chatnav input watcher\n"); |
4617 | 1640 while (od->create_rooms) { |
1641 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1642 g_free(cr->name); |
4617 | 1643 od->create_rooms = |
1644 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1645 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1646 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1647 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1648 NULL); |
2086 | 1649 } |
4617 | 1650 aim_conn_kill(od->sess, &conn); |
2086 | 1651 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1652 if (od->paspa > 0) |
1653 gaim_input_remove(od->paspa); | |
1654 od->paspa = 0; | |
8660 | 1655 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1656 "removing authconn input watcher\n"); |
4617 | 1657 aim_conn_kill(od->sess, &conn); |
3694 | 1658 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1659 if (od->emlpa > 0) |
1660 gaim_input_remove(od->emlpa); | |
1661 od->emlpa = 0; | |
8660 | 1662 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1663 "removing email input watcher\n"); |
4617 | 1664 aim_conn_kill(od->sess, &conn); |
4804 | 1665 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1666 if (od->icopa > 0) | |
1667 gaim_input_remove(od->icopa); | |
1668 od->icopa = 0; | |
8660 | 1669 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1670 "removing icon input watcher\n"); |
4804 | 1671 aim_conn_kill(od->sess, &conn); |
2086 | 1672 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1673 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1674 gaim_odc_disconnect(od->sess, conn); |
1675 aim_conn_kill(od->sess, &conn); | |
2086 | 1676 } else { |
8660 | 1677 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1678 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1679 conn->type); |
4617 | 1680 aim_conn_kill(od->sess, &conn); |
2086 | 1681 } |
1682 } | |
1683 } | |
1684 } | |
1685 } | |
1686 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1687 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1688 GaimConnection *gc = sess->aux_data; |
7285 | 1689 gchar *s = g_strdup_vprintf(format, va); |
1690 gchar *buf; | |
1691 | |
1692 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1693 gaim_debug_info("oscar", buf); |
7285 | 1694 if (buf[strlen(buf)-1] != '\n') |
8660 | 1695 gaim_debug_info(NULL, "\n"); |
7285 | 1696 g_free(buf); |
2086 | 1697 g_free(s); |
1698 } | |
1699 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1700 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1701 { |
5575 | 1702 GaimConnection *gc = data; |
7283 | 1703 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1704 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1705 aim_conn_t *conn; |
2086 | 1706 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1707 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1708 close(source); |
1709 return; | |
1710 } | |
1711 | |
4617 | 1712 od = gc->proto_data; |
1713 sess = od->sess; | |
2086 | 1714 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1715 conn->fd = source; |
2086 | 1716 |
1717 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1718 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1719 return; |
1720 } | |
1721 | |
1722 aim_conn_completeconnect(sess, conn); | |
4617 | 1723 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1724 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1725 | |
8660 | 1726 gaim_debug_info("oscar", |
7282 | 1727 "Screen name sent, waiting for response\n"); |
7283 | 1728 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1729 ck[1] = 0x65; |
2086 | 1730 } |
1731 | |
10444 | 1732 static void |
1733 oscar_login(GaimAccount *account, GaimStatus *status) | |
1734 { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1735 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1736 aim_conn_t *conn; |
5575 | 1737 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1738 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
10400 | 1739 GaimStatusType *status_type; |
1740 GaimStatusPrimitive primitive; | |
1741 | |
1742 status_type = gaim_status_get_type(status); | |
1743 primitive = gaim_status_type_get_primitive(status_type); | |
2086 | 1744 |
8660 | 1745 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
10444 | 1746 |
10400 | 1747 if (primitive == GAIM_STATUS_OFFLINE) |
1748 return; | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1749 |
8437 | 1750 if (!aim_snvalid(gaim_account_get_username(account))) { |
1751 gchar *buf; | |
8590 | 1752 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 | 1753 gaim_connection_error(gc, buf); |
1754 g_free(buf); | |
1755 } | |
1756 | |
9975 | 1757 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1758 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1759 } else { |
6622 | 1760 gc->flags |= GAIM_CONNECTION_HTML; |
1761 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1762 } |
5836 | 1763 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1764 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1765 sess = g_new0(aim_session_t, 1); |
10329 | 1766 aim_session_init(sess, TRUE, FAIM_DEBUG_LEVEL); |
2086 | 1767 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1768 /* |
1769 * We need an immediate queue because we don't use a while-loop | |
1770 * to see if things need to be sent. | |
1771 */ | |
2086 | 1772 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1773 od->sess = sess; |
2086 | 1774 sess->aux_data = gc; |
1775 | |
9935 | 1776 /* Connect to core Gaim signals */ |
10087 | 1777 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1778 |
2086 | 1779 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1780 if (conn == NULL) { | |
10444 | 1781 gaim_debug_error("oscar", "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1782 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1783 return; |
1784 } | |
1785 | |
4649 | 1786 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
10464 | 1787 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
2086 | 1788 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
10464 | 1789 aim_conn_addhandler(sess, conn, AIM_CB_FAM_ATH, AIM_CB_ATH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
2086 | 1790 |
1791 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1792 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1793 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1794 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1795 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1796 return; |
1797 } | |
7282 | 1798 |
7283 | 1799 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1800 ck[0] = 0x5a; |
5575 | 1801 } |
1802 | |
1803 static void oscar_close(GaimConnection *gc) { | |
7283 | 1804 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1805 |
1806 while (od->oscar_chats) { | |
1807 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1808 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1809 gaim_input_remove(n->inpa); |
2086 | 1810 g_free(n->name); |
1811 g_free(n->show); | |
4617 | 1812 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1813 g_free(n); |
1814 } | |
4617 | 1815 while (od->direct_ims) { |
8971 | 1816 struct oscar_direct_im *n = od->direct_ims->data; |
1817 oscar_direct_im_destroy(od, n); | |
2086 | 1818 } |
4617 | 1819 /* BBB */ |
1820 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1821 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1822 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1823 gaim_xfer_cancel_local(xfer); |
3630 | 1824 } |
4804 | 1825 while (od->requesticon) { |
1826 char *sn = od->requesticon->data; | |
1827 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1828 free(sn); | |
1829 } | |
4738 | 1830 g_hash_table_destroy(od->buddyinfo); |
4617 | 1831 while (od->create_rooms) { |
1832 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1833 g_free(cr->name); |
4617 | 1834 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1835 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1836 } |
4617 | 1837 if (od->email) |
1838 g_free(od->email); | |
1839 if (od->newp) | |
1840 g_free(od->newp); | |
1841 if (od->oldp) | |
1842 g_free(od->oldp); | |
2086 | 1843 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1844 gaim_input_remove(gc->inpa); |
4617 | 1845 if (od->cnpa > 0) |
1846 gaim_input_remove(od->cnpa); | |
1847 if (od->paspa > 0) | |
1848 gaim_input_remove(od->paspa); | |
1849 if (od->emlpa > 0) | |
1850 gaim_input_remove(od->emlpa); | |
4804 | 1851 if (od->icopa > 0) |
1852 gaim_input_remove(od->icopa); | |
6907 | 1853 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1854 gaim_timeout_remove(od->icontimer); |
8341 | 1855 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1856 gaim_timeout_remove(od->getblisttimer); |
8341 | 1857 if (od->getinfotimer > 0) |
1858 gaim_timeout_remove(od->getinfotimer); | |
10087 | 1859 gaim_prefs_disconnect_by_handle(gc); |
9971 | 1860 |
4617 | 1861 aim_session_kill(od->sess); |
1862 g_free(od->sess); | |
1863 od->sess = NULL; | |
2086 | 1864 g_free(gc->proto_data); |
1865 gc->proto_data = NULL; | |
8660 | 1866 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1867 } |
1868 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1869 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1870 GaimConnection *gc = data; |
7283 | 1871 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1872 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1873 aim_conn_t *bosconn; |
2086 | 1874 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1875 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1876 close(source); |
1877 return; | |
1878 } | |
1879 | |
4617 | 1880 od = gc->proto_data; |
1881 sess = od->sess; | |
1882 bosconn = od->conn; | |
4366 | 1883 bosconn->fd = source; |
2086 | 1884 |
1885 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1886 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1887 return; |
1888 } | |
1889 | |
1890 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1891 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1892 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1893 gaim_connection_update_progress(gc, |
7283 | 1894 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1895 ck[4] = 0x61; |
2086 | 1896 } |
1897 | |
4617 | 1898 /* BBB */ |
4656 | 1899 /* |
1900 * This little area in oscar.c is the nexus of file transfer code, | |
1901 * so I wrote a little explanation of what happens. I am such a | |
1902 * ninja. | |
1903 * | |
1904 * The series of events for a file send is: | |
1905 * -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
|
1906 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1907 * listening socket, then asks the remote user to connect to us (and |
1908 * gives them the file name, port, IP, etc.) | |
1909 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1910 * in oscar_sendfile_estblsh) | |
1911 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1912 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1913 * connection. | |
1914 * -We get drunk because file transfer kicks ass. | |
1915 * | |
1916 * The series of events for a file receive is: | |
1917 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1918 * -Gaim user selects file to name and location to save file to and | |
1919 * oscar_xfer_init is called | |
1920 * -It connects to the remote user using the IP they gave us earlier | |
1921 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1922 * them an AIM_CB_OFT_ACK. | |
1923 * -They begin to send us lots of raw data. | |
1924 * -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
|
1925 * the connection. |
4656 | 1926 */ |
1927 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1928 | |
8446 | 1929 /* |
1930 * Miscellaneous xfer functions | |
1931 */ | |
1932 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1933 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1934 GaimXfer *xfer; |
5146 | 1935 struct aim_oft_info *oft_info; |
4656 | 1936 |
1937 while (fts) { | |
1938 xfer = fts->data; | |
5146 | 1939 oft_info = xfer->data; |
1940 | |
8446 | 1941 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1942 return xfer; |
1943 | |
1944 fts = g_slist_next(fts); | |
1945 } | |
1946 | |
1947 return NULL; | |
1948 } | |
1949 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1950 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1951 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1952 GaimXfer *xfer; |
5146 | 1953 struct aim_oft_info *oft_info; |
4656 | 1954 |
1955 while (fts) { | |
1956 xfer = fts->data; | |
5146 | 1957 oft_info = xfer->data; |
1958 | |
1959 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1960 return xfer; |
1961 | |
1962 fts = g_slist_next(fts); | |
1963 } | |
1964 | |
1965 return NULL; | |
1966 } | |
1967 | |
8446 | 1968 static void oscar_xfer_end(GaimXfer *xfer) |
1969 { | |
1970 struct aim_oft_info *oft_info = xfer->data; | |
1971 GaimConnection *gc = oft_info->sess->aux_data; | |
1972 OscarData *od = gc->proto_data; | |
1973 | |
8660 | 1974 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1975 |
1976 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1977 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1978 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1979 } | |
1980 | |
1981 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1982 aim_oft_destroyinfo(oft_info); | |
1983 xfer->data = NULL; | |
1984 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1985 } | |
1986 | |
1987 /* | |
1988 * xfer functions used when receiving files | |
1989 */ | |
1990 | |
1991 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1992 { | |
1993 struct aim_oft_info *oft_info = xfer->data; | |
1994 GaimConnection *gc = oft_info->sess->aux_data; | |
1995 OscarData *od = gc->proto_data; | |
1996 | |
8660 | 1997 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1998 |
1999 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
2000 if (oft_info->conn) { | |
2001 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
2002 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
2003 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
2004 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
2005 if (xfer->fd == -1) { | |
2006 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
2007 _("Unable to establish file descriptor.")); | |
2008 gaim_xfer_cancel_local(xfer); | |
2009 } | |
2010 } else { | |
2011 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
2012 _("Unable to create new connection.")); | |
2013 gaim_xfer_cancel_local(xfer); | |
2014 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
2015 } | |
2016 | |
2017 } | |
2018 | |
2019 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
2020 { | |
10405 | 2021 struct aim_oft_info *oft_info; |
2022 GaimConnection *gc; | |
2023 OscarData *od; | |
2024 | |
2025 g_return_if_fail(xfer != NULL); | |
2026 g_return_if_fail(xfer->data != NULL); | |
2027 | |
2028 oft_info = xfer->data; | |
2029 gc = oft_info->sess->aux_data; | |
2030 od = gc->proto_data; | |
8446 | 2031 |
8660 | 2032 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 2033 |
9771 | 2034 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2035 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2036 |
2037 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2038 aim_oft_destroyinfo(oft_info); | |
2039 xfer->data = NULL; | |
2040 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2041 } | |
2042 | |
2043 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
2044 { | |
2045 struct aim_oft_info *oft_info = xfer->data; | |
2046 | |
2047 /* Update our rolling checksum. Like Walmart, yo. */ | |
2048 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2049 } | |
2050 | |
2051 /* | |
2052 * xfer functions used when sending files | |
2053 */ | |
2054 | |
2055 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2056 { | |
2057 struct aim_oft_info *oft_info = xfer->data; | |
2058 GaimConnection *gc = oft_info->sess->aux_data; | |
2059 OscarData *od = gc->proto_data; | |
2060 int listenfd; | |
2061 | |
8660 | 2062 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2063 |
2064 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2065 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2066 oft_info->fh.name[63] = '\0'; | |
2067 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2068 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2069 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2070 | |
2071 /* Create a listening socket and an associated libfaim conn */ | |
2072 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2073 gaim_xfer_cancel_local(xfer); | |
2074 return; | |
2075 } | |
2076 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2077 oft_info->port = xfer->local_port; | |
2078 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2079 gaim_xfer_cancel_local(xfer); | |
2080 return; | |
2081 } | |
8660 | 2082 gaim_debug_misc("oscar", |
8446 | 2083 "port is %hu, ip is %s\n", |
2084 xfer->local_port, oft_info->clientip); | |
2085 if (oft_info->conn) { | |
2086 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2087 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2088 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2089 } else { | |
2090 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2091 _("Unable to establish listener socket.")); | |
2092 gaim_xfer_cancel_local(xfer); | |
2093 } | |
2094 } | |
2095 | |
2096 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2097 { | |
2098 struct aim_oft_info *oft_info = xfer->data; | |
2099 GaimConnection *gc = oft_info->sess->aux_data; | |
2100 OscarData *od = gc->proto_data; | |
2101 | |
8660 | 2102 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2103 |
9771 | 2104 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2105 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2106 |
2107 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2108 aim_oft_destroyinfo(oft_info); | |
2109 xfer->data = NULL; | |
2110 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2111 } | |
2112 | |
2113 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2114 { | |
2115 struct aim_oft_info *oft_info = xfer->data; | |
2116 | |
2117 /* I'm not sure I like how we do this. --marv | |
2118 * I do. AIM file transfers aren't really meant to be thought | |
2119 * of as a transferring just a single file. The rendezvous | |
2120 * establishes a connection between two computers, and then | |
2121 * those computers can use the same connection for transferring | |
2122 * multiple files. So we don't want the Gaim core up and closing | |
2123 * the socket all willy-nilly. We want to do that in the oscar | |
2124 * prpl, whenever one side or the other says they're finished | |
2125 * using the connection. There might be a better way to intercept | |
2126 * the socket from the core, however... --KingAnt | |
2127 */ | |
2128 | |
2129 /* | |
2130 * If we're done sending, intercept the socket from the core ft code | |
2131 * and wait for the other guy to send the "done" OFT packet. | |
2132 */ | |
2133 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2134 gaim_input_remove(xfer->watcher); | |
2135 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2136 xfer->fd = 0; | |
2137 gaim_xfer_set_completed(xfer, TRUE); | |
2138 } | |
2139 } | |
2140 | |
9466 | 2141 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2142 gboolean can_receive = FALSE; | |
2143 OscarData *od = gc->proto_data; | |
2144 | |
2145 if (!od->icq) { | |
2146 aim_userinfo_t *userinfo; | |
2147 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2148 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2149 can_receive = TRUE; | |
2150 } | |
2151 | |
2152 return can_receive; | |
2153 } | |
2154 | |
2155 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2156 |
2157 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2158 GaimXfer *xfer; |
5146 | 2159 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2160 const char *ip; |
3752 | 2161 |
9030 | 2162 od = (OscarData *)gc->proto_data; |
2163 | |
4617 | 2164 /* You want to send a file to someone else, you're so generous */ |
2165 | |
2166 /* Build the file transfer handle */ | |
9466 | 2167 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2168 |
5146 | 2169 /* Create the oscar-specific data */ |
8838 | 2170 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2171 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2172 xfer->data = oft_info; |
2173 | |
4617 | 2174 /* Setup our I/O op functions */ |
8446 | 2175 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2176 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2177 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2178 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2179 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2180 |
2181 /* Keep track of this transfer for later */ | |
2182 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2183 | |
2184 /* Now perform the request */ | |
9466 | 2185 if (file) |
2186 gaim_xfer_request_accepted(xfer, file); | |
2187 else | |
2188 gaim_xfer_request(xfer); | |
3630 | 2189 } |
2190 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2191 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2192 GaimConnection *gc = sess->aux_data; |
7283 | 2193 OscarData *od = gc->proto_data; |
6029 | 2194 GaimAccount *account = gc->account; |
2195 aim_conn_t *bosconn; | |
2196 char *host; int port; | |
2197 int i, rc; | |
2086 | 2198 va_list ap; |
2704 | 2199 struct aim_authresp_info *info; |
6029 | 2200 |
5575 | 2201 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2202 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2203 va_start(ap, fr); |
2704 | 2204 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2205 va_end(ap); |
2206 | |
8660 | 2207 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2208 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2209 |
4293 | 2210 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2211 char buf[256]; |
2704 | 2212 switch (info->errorcode) { |
2086 | 2213 case 0x05: |
2214 /* Incorrect nick/password */ | |
6498 | 2215 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2216 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2217 break; |
2218 case 0x11: | |
2219 /* Suspended account */ | |
6498 | 2220 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2221 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2222 break; |
3498 | 2223 case 0x14: |
2224 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2225 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2226 break; |
2086 | 2227 case 0x18: |
2228 /* connecting too frequently */ | |
6498 | 2229 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2230 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 | 2231 break; |
2232 case 0x1c: | |
2233 /* client too old */ | |
6498 | 2234 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2235 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
|
2236 gaim_connection_error(gc, buf); |
2086 | 2237 break; |
2238 default: | |
6623 | 2239 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2240 break; |
2241 } | |
8660 | 2242 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2243 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2244 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2245 "Error URL: %s\n", info->errorurl); |
2086 | 2246 od->killme = TRUE; |
2247 return 1; | |
2248 } | |
2249 | |
2250 | |
9992 | 2251 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2252 |
2704 | 2253 if (info->email) { |
8660 | 2254 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2255 } else { |
8660 | 2256 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2257 } |
10042 | 2258 |
8660 | 2259 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2260 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2261 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2262 aim_conn_kill(sess, &fr->conn); |
2086 | 2263 |
2264 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2265 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2266 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2267 od->killme = TRUE; |
2268 return 0; | |
2269 } | |
2270 | |
4649 | 2271 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2272 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2273 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2274 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2275 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2276 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2277 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2278 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2279 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2280 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2281 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2282 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2283 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2284 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2285 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2286 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2287 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2288 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2289 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2290 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2291 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2292 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2293 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
|
2294 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2295 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2296 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2297 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2298 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2299 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2300 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
|
2301 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
|
2302 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
|
2303 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2304 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2305 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2306 #ifndef NOSSI |
4642 | 2307 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2308 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2309 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2310 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2311 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2312 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2313 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2314 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2315 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2316 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2317 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2318 |
7283 | 2319 od->conn = bosconn; |
2704 | 2320 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2321 if (info->bosip[i] == ':') { | |
2322 port = atoi(&(info->bosip[i+1])); | |
2086 | 2323 break; |
2324 } | |
2325 } | |
2704 | 2326 host = g_strndup(info->bosip, i); |
2086 | 2327 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2328 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2329 g_free(host); |
4366 | 2330 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2331 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2332 od->killme = TRUE; |
2333 return 0; | |
2334 } | |
4293 | 2335 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2336 gaim_input_remove(gc->inpa); |
2704 | 2337 |
7283 | 2338 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2339 ck[3] = 0x64; |
7282 | 2340 |
2086 | 2341 return 1; |
2342 } | |
2343 | |
10464 | 2344 static void |
2345 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
2346 { | |
2347 GaimConnection *gc = user_data; | |
2348 OscarData *od = gc->proto_data; | |
2349 aim_session_t *sess = od->sess; | |
2350 | |
2351 aim_auth_securid_send(sess, msg); | |
2352 } | |
2353 | |
2354 static void | |
2355 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
2356 { | |
2357 GaimConnection *gc = user_data; | |
2358 OscarData *od = gc->proto_data; | |
2359 | |
2360 /* Disconnect */ | |
2361 gc->wants_to_die = TRUE; | |
2362 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
2363 od->killme = TRUE; | |
2364 } | |
2365 | |
2366 static int | |
2367 gaim_parse_auth_securid_request(aim_session_t *sess, aim_frame_t *fr, ...) | |
2368 { | |
2369 GaimConnection *gc = sess->aux_data; | |
2370 GaimAccount *account = gaim_connection_get_account(gc); | |
2371 gchar *primary; | |
2372 | |
2373 gaim_debug_info("oscar", "Got SecurID request\n"); | |
2374 | |
2375 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
2376 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
2377 _("Enter the 6 digit number from the digital display."), | |
2378 FALSE, FALSE, NULL, | |
2379 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
2380 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
2381 gc); | |
2382 g_free(primary); | |
2383 | |
2384 return 1; | |
2385 } | |
2386 | |
7285 | 2387 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2388 struct pieceofcrap { |
5575 | 2389 GaimConnection *gc; |
2086 | 2390 unsigned long offset; |
2391 unsigned long len; | |
2392 char *modname; | |
2393 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2394 aim_conn_t *conn; |
2086 | 2395 unsigned int inpa; |
2396 }; | |
2397 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2398 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2399 { |
2400 struct pieceofcrap *pos = data; | |
7283 | 2401 OscarData *od = pos->gc->proto_data; |
2086 | 2402 char in = '\0'; |
2403 int x = 0; | |
2404 unsigned char m[17]; | |
2405 | |
2406 while (read(pos->fd, &in, 1) == 1) { | |
2407 if (in == '\n') | |
2408 x++; | |
2409 else if (in != '\r') | |
2410 x = 0; | |
2411 if (x == 2) | |
2412 break; | |
2413 in = '\0'; | |
2414 } | |
2415 if (in != '\n') { | |
4056 | 2416 char buf[256]; |
2417 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
|
2418 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2419 gaim_notify_warning(pos->gc, NULL, |
7422 | 2420 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2421 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2422 gaim_input_remove(pos->inpa); |
2086 | 2423 close(pos->fd); |
2424 g_free(pos); | |
2425 return; | |
2426 } | |
2427 read(pos->fd, m, 16); | |
2428 m[16] = '\0'; | |
8660 | 2429 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2430 for (x = 0; x < 16; x++) |
8660 | 2431 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2432 | |
2433 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2434 gaim_input_remove(pos->inpa); |
2086 | 2435 close(pos->fd); |
2436 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2437 g_free(pos); | |
2438 } | |
2439 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2440 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2441 struct pieceofcrap *pos = data; |
5420 | 2442 gchar *buf; |
2086 | 2443 |
4366 | 2444 pos->fd = source; |
2445 | |
2086 | 2446 if (source < 0) { |
5420 | 2447 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
|
2448 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2449 gaim_notify_warning(pos->gc, NULL, |
7422 | 2450 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2451 buf); |
5420 | 2452 g_free(buf); |
2086 | 2453 if (pos->modname) |
2454 g_free(pos->modname); | |
2455 g_free(pos); | |
2456 return; | |
2457 } | |
2458 | |
5420 | 2459 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2460 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2461 write(pos->fd, buf, strlen(buf)); | |
5420 | 2462 g_free(buf); |
2086 | 2463 if (pos->modname) |
2464 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2465 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2466 return; |
2467 } | |
2468 | |
2469 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2470 #define AIM_MAX_FILE_SIZE 98304 | |
2471 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2472 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2473 va_list ap; |
2474 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2475 fu32_t offset, len; |
2086 | 2476 char *modname; |
2477 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2478 va_start(ap, fr); |
4200 | 2479 offset = va_arg(ap, fu32_t); |
2480 len = va_arg(ap, fu32_t); | |
2086 | 2481 modname = va_arg(ap, char *); |
2482 va_end(ap); | |
2483 | |
8660 | 2484 gaim_debug_misc("oscar", |
5556 | 2485 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2486 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2487 |
2086 | 2488 if (len == 0) { |
8660 | 2489 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2490 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2491 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2492 return 1; | |
2493 } | |
9625 | 2494 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2495 #if 0 | |
2086 | 2496 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2497 char *buf; | |
2498 int i = 8; | |
2499 if (modname) | |
2500 i += strlen(modname); | |
2501 buf = g_malloc(i); | |
2502 i = 0; | |
2503 if (modname) { | |
2504 memcpy(buf, modname, strlen(modname)); | |
2505 i += strlen(modname); | |
2506 } | |
2507 buf[i++] = offset & 0xff; | |
2508 buf[i++] = (offset >> 8) & 0xff; | |
2509 buf[i++] = (offset >> 16) & 0xff; | |
2510 buf[i++] = (offset >> 24) & 0xff; | |
2511 buf[i++] = len & 0xff; | |
2512 buf[i++] = (len >> 8) & 0xff; | |
2513 buf[i++] = (len >> 16) & 0xff; | |
2514 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2515 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2516 "hashing request\n"); |
2086 | 2517 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2518 g_free(buf); | |
2519 return 1; | |
2520 } | |
9625 | 2521 #endif |
2086 | 2522 |
2523 pos = g_new0(struct pieceofcrap, 1); | |
2524 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2525 pos->conn = fr->conn; |
2086 | 2526 |
2527 pos->offset = offset; | |
2528 pos->len = len; | |
2529 pos->modname = modname ? g_strdup(modname) : NULL; | |
2530 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2531 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2532 char buf[256]; |
2086 | 2533 if (pos->modname) |
2534 g_free(pos->modname); | |
2535 g_free(pos); | |
4056 | 2536 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
|
2537 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2538 gaim_notify_warning(pos->gc, NULL, |
7422 | 2539 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2540 buf); |
2086 | 2541 } |
2542 | |
2543 return 1; | |
2544 } | |
2545 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2546 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2547 GaimConnection *gc = sess->aux_data; |
7283 | 2548 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2549 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2550 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2551 #if 0 |
2552 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2553 #endif | |
7011 | 2554 va_list ap; |
2555 char *key; | |
2086 | 2556 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2557 va_start(ap, fr); |
2086 | 2558 key = va_arg(ap, char *); |
2559 va_end(ap); | |
2560 | |
4617 | 2561 if (od->icq) { |
3458 | 2562 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2563 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2564 gaim_account_get_password(account), &info, key); |
3458 | 2565 } else { |
2566 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2567 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2568 gaim_account_get_password(account), &info, key); |
3458 | 2569 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2570 |
7283 | 2571 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2572 ck[2] = 0x6c; |
7282 | 2573 |
2086 | 2574 return 1; |
2575 } | |
2576 | |
2675 | 2577 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2578 GaimConnection *gc = sess->aux_data; |
2647 | 2579 struct chat_connection *chatcon; |
2580 static int id = 1; | |
2581 | |
6905 | 2582 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
|
2583 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
|
2584 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
|
2585 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
|
2586 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2587 |
2672 | 2588 aim_clientready(sess, fr->conn); |
2675 | 2589 |
2647 | 2590 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2591 chatcon->id = id; | |
8733 | 2592 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2593 |
2594 return 1; | |
2595 } | |
2596 | |
2675 | 2597 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2598 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2599 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2600 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2601 |
2602 aim_clientready(sess, fr->conn); | |
2603 | |
2604 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2605 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2606 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2607 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2608 |
3694 | 2609 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2610 | |
2611 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2612 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2613 | |
7282 | 2614 aim_email_sendcookies(sess); |
2615 aim_email_activate(sess); | |
3694 | 2616 aim_clientready(sess, fr->conn); |
2617 | |
2618 return 1; | |
2619 } | |
2620 | |
4804 | 2621 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2622 GaimConnection *gc = sess->aux_data; |
7283 | 2623 OscarData *od = gc->proto_data; |
4804 | 2624 |
2625 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2626 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2627 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2628 | |
2629 aim_clientready(sess, fr->conn); | |
2630 | |
4823 | 2631 od->iconconnecting = FALSE; |
2632 | |
4804 | 2633 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2634 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2635 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2636 |
2637 return 1; | |
2638 } | |
2639 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2640 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2641 GaimConnection *gc = data; |
7283 | 2642 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2643 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2644 aim_conn_t *tstconn; |
2086 | 2645 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2646 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2647 close(source); |
2648 return; | |
2649 } | |
2650 | |
4617 | 2651 od = gc->proto_data; |
2652 sess = od->sess; | |
2086 | 2653 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2654 tstconn->fd = source; |
2086 | 2655 |
2656 if (source < 0) { | |
2657 aim_conn_kill(sess, &tstconn); | |
8660 | 2658 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2659 "unable to connect to chatnav server\n"); |
2086 | 2660 return; |
2661 } | |
2662 | |
2663 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2664 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2665 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2666 } |
2667 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2668 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2669 { |
5575 | 2670 GaimConnection *gc = data; |
7283 | 2671 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2672 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2673 aim_conn_t *tstconn; |
2086 | 2674 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2675 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2676 close(source); |
2677 return; | |
2678 } | |
2679 | |
4617 | 2680 od = gc->proto_data; |
2681 sess = od->sess; | |
2086 | 2682 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2683 tstconn->fd = source; |
2086 | 2684 |
2685 if (source < 0) { | |
2686 aim_conn_kill(sess, &tstconn); | |
8660 | 2687 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2688 "unable to connect to authorizer\n"); |
2086 | 2689 return; |
2690 } | |
2691 | |
2692 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2693 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2694 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2695 } |
2696 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2697 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2698 { |
2699 struct chat_connection *ccon = data; | |
5575 | 2700 GaimConnection *gc = ccon->gc; |
7283 | 2701 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2702 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2703 aim_conn_t *tstconn; |
2086 | 2704 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2705 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2706 close(source); |
2707 g_free(ccon->show); | |
2708 g_free(ccon->name); | |
2709 g_free(ccon); | |
2710 return; | |
2711 } | |
2712 | |
4617 | 2713 od = gc->proto_data; |
2714 sess = od->sess; | |
2086 | 2715 tstconn = ccon->conn; |
4366 | 2716 tstconn->fd = source; |
2086 | 2717 |
2718 if (source < 0) { | |
2719 aim_conn_kill(sess, &tstconn); | |
2720 g_free(ccon->show); | |
2721 g_free(ccon->name); | |
2722 g_free(ccon); | |
2723 return; | |
2724 } | |
2725 | |
2726 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2727 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2728 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2729 } |
2730 | |
3694 | 2731 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2732 GaimConnection *gc = data; |
7283 | 2733 OscarData *od; |
3694 | 2734 aim_session_t *sess; |
2735 aim_conn_t *tstconn; | |
2736 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2737 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2738 close(source); |
2739 return; | |
2740 } | |
2741 | |
4617 | 2742 od = gc->proto_data; |
2743 sess = od->sess; | |
3694 | 2744 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2745 tstconn->fd = source; |
3694 | 2746 |
2747 if (source < 0) { | |
2748 aim_conn_kill(sess, &tstconn); | |
8660 | 2749 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2750 "unable to connect to email server\n"); |
3694 | 2751 return; |
2752 } | |
2753 | |
2754 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2755 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2756 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2757 "email: connected\n"); |
3694 | 2758 } |
2759 | |
4804 | 2760 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2761 GaimConnection *gc = data; |
7283 | 2762 OscarData *od; |
4804 | 2763 aim_session_t *sess; |
2764 aim_conn_t *tstconn; | |
2765 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2766 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2767 close(source); |
2768 return; | |
2769 } | |
2770 | |
2771 od = gc->proto_data; | |
2772 sess = od->sess; | |
2773 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2774 tstconn->fd = source; | |
2775 | |
2776 if (source < 0) { | |
2777 aim_conn_kill(sess, &tstconn); | |
8660 | 2778 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2779 "unable to connect to icon server\n"); |
4804 | 2780 return; |
2781 } | |
2782 | |
2783 aim_conn_completeconnect(sess, tstconn); | |
2784 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2785 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2786 } |
2787 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2788 /* 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
|
2789 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2790 GaimConnection *gc = sess->aux_data; |
2791 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2792 aim_conn_t *tstconn; |
4452 | 2793 int i; |
2086 | 2794 char *host; |
2795 int port; | |
4821 | 2796 va_list ap; |
2797 struct aim_redirect_data *redir; | |
2086 | 2798 |
5575 | 2799 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2800 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2801 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2802 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2803 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2804 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2805 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2806 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2807 port = atoi(&(redir->ip[i+1])); |
2086 | 2808 break; |
2809 } | |
2810 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2811 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2812 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2813 switch(redir->group) { |
2086 | 2814 case 0x7: /* Authorizer */ |
8660 | 2815 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2816 "Reconnecting with authorizor...\n"); |
2086 | 2817 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2818 if (tstconn == NULL) { | |
8660 | 2819 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2820 "unable to reconnect with authorizer\n"); |
2086 | 2821 g_free(host); |
2822 return 1; | |
2823 } | |
4649 | 2824 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2825 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2826 |
2827 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2828 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2829 aim_conn_kill(sess, &tstconn); |
8660 | 2830 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2831 "unable to reconnect with authorizer\n"); |
2086 | 2832 g_free(host); |
2833 return 1; | |
2834 } | |
4293 | 2835 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2836 break; |
2837 | |
2086 | 2838 case 0xd: /* ChatNav */ |
2839 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2840 if (tstconn == NULL) { | |
8660 | 2841 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2842 "unable to connect to chatnav server\n"); |
2086 | 2843 g_free(host); |
2844 return 1; | |
2845 } | |
4649 | 2846 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2847 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2848 |
2849 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2850 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2851 aim_conn_kill(sess, &tstconn); |
8660 | 2852 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2853 "unable to connect to chatnav server\n"); |
2086 | 2854 g_free(host); |
2855 return 1; | |
2856 } | |
4293 | 2857 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2858 break; |
2859 | |
2860 case 0xe: { /* Chat */ | |
2086 | 2861 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2862 |
2086 | 2863 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2864 if (tstconn == NULL) { | |
8660 | 2865 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2866 "unable to connect to chat server\n"); |
2086 | 2867 g_free(host); |
2868 return 1; | |
2869 } | |
2870 | |
4649 | 2871 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2872 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2873 | |
2086 | 2874 ccon = g_new0(struct chat_connection, 1); |
2875 ccon->conn = tstconn; | |
2876 ccon->gc = gc; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2877 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2878 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2879 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2880 ccon->show = extract_name(redir->chat.room); |
4634 | 2881 |
2086 | 2882 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2883 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2884 aim_conn_kill(sess, &tstconn); |
8660 | 2885 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2886 "unable to connect to chat server\n"); |
2086 | 2887 g_free(host); |
2888 g_free(ccon->show); | |
2889 g_free(ccon->name); | |
2890 g_free(ccon); | |
2891 return 1; | |
2892 } | |
4293 | 2893 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2894 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2895 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2896 ccon->name, ccon->exchange); |
4194 | 2897 } break; |
3694 | 2898 |
4804 | 2899 case 0x0010: { /* icon */ |
2900 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2901 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2902 "unable to connect to icon server\n"); |
4804 | 2903 g_free(host); |
2904 return 1; | |
2905 } | |
2906 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2907 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2908 | |
2909 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2910 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2911 aim_conn_kill(sess, &tstconn); |
8660 | 2912 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2913 "unable to connect to icon server\n"); |
4804 | 2914 g_free(host); |
2915 return 1; | |
2916 } | |
2917 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2918 } break; | |
2919 | |
3694 | 2920 case 0x0018: { /* email */ |
2921 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2922 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2923 "unable to connect to email server\n"); |
3694 | 2924 g_free(host); |
2925 return 1; | |
2926 } | |
4649 | 2927 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2928 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2929 | |
2930 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2931 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2932 aim_conn_kill(sess, &tstconn); |
8660 | 2933 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2934 "unable to connect to email server\n"); |
3694 | 2935 g_free(host); |
2936 return 1; | |
2937 } | |
4293 | 2938 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2939 } break; |
2940 | |
2086 | 2941 default: /* huh? */ |
8660 | 2942 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2943 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2944 redir->group); |
2086 | 2945 break; |
2946 } | |
2947 | |
2948 g_free(host); | |
2949 return 1; | |
2950 } | |
2951 | |
10042 | 2952 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) |
2953 { | |
2954 GaimConnection *gc; | |
2955 GaimAccount *account; | |
2956 OscarData *od; | |
4738 | 2957 struct buddyinfo *bi; |
2993 | 2958 time_t time_idle = 0, signon = 0; |
2959 int type = 0; | |
2960 int caps = 0; | |
2086 | 2961 va_list ap; |
4738 | 2962 aim_userinfo_t *info; |
10042 | 2963 gboolean buddy_is_away = FALSE; |
2964 | |
2965 gc = sess->aux_data; | |
2966 account = gaim_connection_get_account(gc); | |
2967 od = gc->proto_data; | |
4194 | 2968 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2969 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2970 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2971 va_end(ap); |
2972 | |
10130 | 2973 g_return_val_if_fail(info != NULL, 1); |
2974 g_return_val_if_fail(info->sn != NULL, 1); | |
2975 | |
2993 | 2976 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2977 caps = info->capabilities; | |
3267 | 2978 |
4766 | 2979 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2980 if (info->flags & AIM_FLAG_AWAY) | |
10042 | 2981 buddy_is_away = TRUE; |
2982 } | |
2983 | |
2993 | 2984 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2985 type = (info->icqinfo.status << 16); |
3013 | 2986 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2987 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
10042 | 2988 buddy_is_away = TRUE; |
3013 | 2989 } |
2993 | 2990 } |
2991 | |
7141 | 2992 if (caps & AIM_CAPS_ICQ_DIRECT) |
2993 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2994 |
2995 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2996 time(&time_idle); |
2997 time_idle -= info->idletime*60; | |
9295 | 2998 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2999 } |
3000 | |
5836 | 3001 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3002 signon = info->onlinesince; | |
3003 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 3004 signon = time(NULL) - info->sessionlen; |
2086 | 3005 |
9982 | 3006 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) |
5575 | 3007 gaim_connection_set_display_name(gc, info->sn); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
3008 |
9982 | 3009 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 3010 if (!bi) { |
3011 bi = g_new0(struct buddyinfo, 1); | |
9982 | 3012 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 3013 } |
4739 | 3014 bi->typingnot = FALSE; |
3015 bi->ico_informed = FALSE; | |
6857 | 3016 bi->ipaddr = info->icqinfo.ipaddr; |
3017 | |
3018 /* Available message stuff */ | |
6292 | 3019 free(bi->availmsg); |
7011 | 3020 if (info->avail != NULL) |
8225 | 3021 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 3022 else |
6292 | 3023 bi->availmsg = NULL; |
4732 | 3024 |
4804 | 3025 /* Server stored icon stuff */ |
4853 | 3026 if (info->iconcsumlen) { |
7125 | 3027 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 3028 char *b16 = NULL, *filepath = NULL; |
7093 | 3029 GaimBuddy *b = NULL; |
4853 | 3030 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3031 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 3032 b = gaim_find_buddy(account, info->sn); |
7093 | 3033 /* |
3034 * If for some reason the checksum is valid, but cached file is not.. | |
3035 * we want to know. | |
3036 */ | |
7693 | 3037 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 3038 if (filename != NULL) { |
3039 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 3040 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
3041 "icon_checksum"); | |
9801 | 3042 else { |
3043 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
3044 filename, NULL); | |
3045 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
3046 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
3047 "icon_checksum"); | |
3048 g_free(filepath); | |
3049 } | |
7093 | 3050 } else |
3051 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3052 |
4853 | 3053 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
3054 GSList *cur = od->requesticon; | |
3055 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
3056 cur = cur->next; | |
3057 if (!cur) { | |
9982 | 3058 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 3059 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3060 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3061 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 3062 } |
3063 } | |
6053 | 3064 g_free(b16); |
4853 | 3065 } |
3066 | |
10042 | 3067 /* XXX - Represent other ICQ statuses */ |
3068 if (buddy_is_away == TRUE) | |
3069 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AWAY, NULL); | |
3070 else | |
3071 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_AVAILABLE, NULL); | |
9982 | 3072 gaim_prpl_got_user_login_time(account, info->sn, signon); |
3073 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); | |
3074 | |
3075 if (time_idle > 0) | |
3076 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 3077 else |
3078 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 3079 |
3080 return 1; | |
3081 } | |
3082 | |
8341 | 3083 static void gaim_check_comment(OscarData *od, const char *str) { |
3084 if ((str == NULL) || strcmp(str, ck)) | |
3085 aim_locate_setcaps(od->sess, caps_aim); | |
3086 else | |
3087 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
3088 } | |
3089 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3090 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3091 GaimConnection *gc = sess->aux_data; |
7283 | 3092 OscarData *od = gc->proto_data; |
9982 | 3093 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3094 va_list ap; |
4739 | 3095 aim_userinfo_t *info; |
2086 | 3096 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3097 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3098 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3099 va_end(ap); |
3100 | |
9982 | 3101 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3102 |
7261 | 3103 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3104 |
2086 | 3105 return 1; |
3106 } | |
3107 | |
4617 | 3108 /* BBB */ |
3952 | 3109 /* |
4617 | 3110 * This is called after a remote AIM user has connected to us. We |
3111 * want to do some voodoo with the socket file descriptors, add a | |
3112 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3113 */ |
4656 | 3114 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3115 GaimConnection *gc = sess->aux_data; |
7283 | 3116 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3117 GaimXfer *xfer; |
5146 | 3118 struct aim_oft_info *oft_info; |
3630 | 3119 va_list ap; |
3120 aim_conn_t *conn, *listenerconn; | |
4656 | 3121 |
8660 | 3122 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3123 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3124 va_start(ap, fr); |
3125 conn = va_arg(ap, aim_conn_t *); | |
3126 listenerconn = va_arg(ap, aim_conn_t *); | |
3127 va_end(ap); | |
3128 | |
4617 | 3129 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3130 return 1; | |
3131 | |
5146 | 3132 if (!(oft_info = xfer->data)) |
4617 | 3133 return 1; |
3134 | |
3630 | 3135 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3136 gaim_input_remove(xfer->watcher); |
3630 | 3137 aim_conn_kill(sess, &listenerconn); |
3138 | |
5146 | 3139 oft_info->conn = conn; |
3140 xfer->fd = oft_info->conn->fd; | |
3141 | |
3142 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3143 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3144 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3145 |
3146 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3147 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3148 |
3149 return 0; | |
3150 } | |
3151 | |
3952 | 3152 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3153 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3154 * user in order to transfer a file. |
3952 | 3155 */ |
4617 | 3156 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
|
3157 GaimXfer *xfer; |
5146 | 3158 struct aim_oft_info *oft_info; |
4656 | 3159 |
8660 | 3160 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3161 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3162 if (!(xfer = data)) |
3163 return; | |
5146 | 3164 if (!(oft_info = xfer->data)) |
3630 | 3165 return; |
8446 | 3166 if (source < 0) { |
3167 gaim_xfer_cancel_remote(xfer); | |
4617 | 3168 return; |
8446 | 3169 } |
4617 | 3170 |
3171 xfer->fd = source; | |
5146 | 3172 oft_info->conn->fd = source; |
3173 | |
3174 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3175 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3176 |
3177 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3178 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3179 |
3180 return; | |
3630 | 3181 } |
3182 | |
3952 | 3183 /* |
4617 | 3184 * This is called when a buddy sends us some file info. This happens when they |
3185 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3186 * You should send them the exact same info except use the real cookie. We also |
4617 | 3187 * get like totally ready to like, receive the file, kay? |
3952 | 3188 */ |
4617 | 3189 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3190 GaimConnection *gc = sess->aux_data; |
7283 | 3191 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3192 GaimXfer *xfer; |
5146 | 3193 struct aim_oft_info *oft_info; |
4617 | 3194 va_list ap; |
3195 aim_conn_t *conn; | |
3196 fu8_t *cookie; | |
3197 struct aim_fileheader_t *fh; | |
4656 | 3198 |
8660 | 3199 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3200 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3201 va_start(ap, fr); |
3202 conn = va_arg(ap, aim_conn_t *); | |
3203 cookie = va_arg(ap, fu8_t *); | |
3204 fh = va_arg(ap, struct aim_fileheader_t *); | |
3205 va_end(ap); | |
3206 | |
3207 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3208 return 1; | |
3209 | |
5146 | 3210 if (!(oft_info = xfer->data)) |
4617 | 3211 return 1; |
3212 | |
3213 /* We want to stop listening with a normal thingy */ | |
3214 gaim_input_remove(xfer->watcher); | |
3215 xfer->watcher = 0; | |
3216 | |
5146 | 3217 /* They sent us some information about the file they're sending */ |
3218 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3219 | |
3220 /* Fill in the cookie */ | |
3221 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3222 | |
4617 | 3223 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3224 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3225 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3226 | |
3227 return 0; | |
3630 | 3228 } |
3229 | |
3952 | 3230 /* |
4657 | 3231 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3232 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3233 */ |
4617 | 3234 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3235 GaimConnection *gc = sess->aux_data; |
7283 | 3236 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3237 GaimXfer *xfer; |
4617 | 3238 va_list ap; |
3239 aim_conn_t *conn; | |
3240 fu8_t *cookie; | |
3241 struct aim_fileheader_t *fh; | |
4656 | 3242 |
8660 | 3243 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3244 va_start(ap, fr); |
3245 conn = va_arg(ap, aim_conn_t *); | |
3246 cookie = va_arg(ap, fu8_t *); | |
3247 fh = va_arg(ap, struct aim_fileheader_t *); | |
3248 va_end(ap); | |
3249 | |
3250 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3251 return 1; | |
3252 | |
4656 | 3253 /* We want to stop listening with a normal thingy */ |
3254 gaim_input_remove(xfer->watcher); | |
3255 xfer->watcher = 0; | |
3256 | |
4617 | 3257 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3258 | |
3259 return 0; | |
3630 | 3260 } |
4617 | 3261 |
3262 /* | |
3263 * We just sent a file to someone. They said they got it and everything, | |
3264 * so we can close our direct connection and what not. | |
3265 */ | |
3266 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3267 GaimConnection *gc = sess->aux_data; |
7283 | 3268 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3269 GaimXfer *xfer; |
4617 | 3270 va_list ap; |
3271 aim_conn_t *conn; | |
3272 fu8_t *cookie; | |
3273 struct aim_fileheader_t *fh; | |
4656 | 3274 |
8660 | 3275 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3276 va_start(ap, fr); |
3277 conn = va_arg(ap, aim_conn_t *); | |
3278 cookie = va_arg(ap, fu8_t *); | |
3279 fh = va_arg(ap, struct aim_fileheader_t *); | |
3280 va_end(ap); | |
3281 | |
3282 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3283 return 1; | |
3284 | |
4656 | 3285 xfer->fd = conn->fd; |
4617 | 3286 gaim_xfer_end(xfer); |
3287 | |
3288 return 0; | |
3289 } | |
3630 | 3290 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3291 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3292 GaimConnection *gc = sess->aux_data; |
7283 | 3293 OscarData *od = gc->proto_data; |
8708 | 3294 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3295 GaimConvImFlags flags = 0; |
4738 | 3296 struct buddyinfo *bi; |
5575 | 3297 const char *iconfile; |
9806 | 3298 GString *message; |
3299 gchar *tmp; | |
3300 aim_mpmsg_section_t *curpart; | |
3301 | |
10472 | 3302 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
9806 | 3303 userinfo->sn, args->mpmsg.numparts); |
4738 | 3304 |
8708 | 3305 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3306 if (!bi) { |
3307 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3308 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3309 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3310 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3311 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3312 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3313 |
4738 | 3314 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3315 bi->typingnot = TRUE; | |
3316 else | |
3317 bi->typingnot = FALSE; | |
3318 | |
4380 | 3319 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3320 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3321 "%s has an icon\n", userinfo->sn); |
4738 | 3322 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3323 bi->ico_need = TRUE; | |
3324 bi->ico_len = args->iconlen; | |
3325 bi->ico_csum = args->iconsum; | |
3326 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3327 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3328 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3329 |
10458 | 3330 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3331 (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
|
3332 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3333 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3334 |
5575 | 3335 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3336 char *buf = g_malloc(st.st_size); |
5575 | 3337 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3338 if (file) { |
9532 | 3339 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3340 int len = fread(buf, 1, st.st_size, file); |
8660 | 3341 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3342 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3343 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3344 userinfo->sn, len, st.st_size); |
4617 | 3345 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3346 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3347 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3348 } else |
8660 | 3349 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3350 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3351 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3352 } else |
8660 | 3353 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3354 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3355 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3356 |
9806 | 3357 message = g_string_new(""); |
3358 curpart = args->mpmsg.parts; | |
3359 while (curpart != NULL) { | |
9908 | 3360 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3361 curpart->data, curpart->datalen); |
3362 if (tmp != NULL) { | |
3363 g_string_append(message, tmp); | |
3364 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3365 } |
9806 | 3366 |
3367 curpart = curpart->next; | |
3368 } | |
3369 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3370 |
8666 | 3371 /* |
8995 | 3372 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3373 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3374 * so any HTML we receive is intended to be displayed |
3375 * | |
3376 * Note: There *may* be some clients which send messages as HTML formatted - | |
3377 * they need to be special-cased somehow. | |
8666 | 3378 */ |
9982 | 3379 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3380 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3381 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3382 g_free(tmp); |
3383 tmp = tmp2; | |
3384 } | |
3385 | |
6982 | 3386 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3387 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3388 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3389 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3390 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3391 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3392 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3393 GaimConnection *gc; |
9933 | 3394 GaimAccount *account; |
9070 | 3395 OscarData *od; |
9933 | 3396 const char *username = NULL; |
3397 char *message = NULL; | |
9070 | 3398 |
3399 g_return_val_if_fail(sess != NULL, 0); | |
3400 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3401 | |
3402 gc = sess->aux_data; | |
9933 | 3403 account = gaim_connection_get_account(gc); |
9070 | 3404 od = gc->proto_data; |
9933 | 3405 username = gaim_account_get_username(account); |
3406 | |
3407 if (args == NULL) | |
4121 | 3408 return 0; |
4194 | 3409 |
9933 | 3410 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3411 userinfo->sn, args->status); | |
3412 | |
3413 if (args->msg != NULL) | |
3414 { | |
3415 if (args->encoding != NULL) | |
3416 { | |
3417 char *encoding = NULL; | |
3418 encoding = oscar_encoding_extract(args->encoding); | |
3419 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3420 g_free(encoding); | |
3421 } else { | |
3422 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3423 message = g_strdup(args->msg); | |
3424 } | |
3425 } | |
2869 | 3426 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3427 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3428 char *name; |
5234 | 3429 GHashTable *components; |
3430 | |
9933 | 3431 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3432 g_free(message); | |
4121 | 3433 return 1; |
9933 | 3434 } |
5234 | 3435 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3436 g_free); | |
4121 | 3437 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3438 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3439 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
|
3440 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3441 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3442 userinfo->sn, |
9933 | 3443 message, |
5234 | 3444 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3445 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3446 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3447 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3448 /* BBB */ |
3449 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3450 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3451 GaimXfer *xfer; |
5146 | 3452 struct aim_oft_info *oft_info; |
3453 | |
3454 if (!args->cookie || !args->port || !args->verifiedip || | |
3455 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3456 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3457 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3458 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3459 "information.\n", userinfo->sn); |
5146 | 3460 if (args->proxyip) |
8660 | 3461 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3462 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3463 "does not support this yet.\n"); |
9933 | 3464 g_free(message); |
4617 | 3465 return 1; |
4656 | 3466 } |
4617 | 3467 |
3468 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3469 /* 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
|
3470 * directory -- remove the star and trailing slash so we don't save |
4617 | 3471 * directories that look like 'dirname\*' -- arl */ |
3472 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3473 if (tmp && (tmp[1] == '*')) { | |
3474 tmp[0] = '\0'; | |
3475 } | |
8660 | 3476 gaim_debug_warning("oscar", |
8446 | 3477 "We're receiving a whole directory! What fun! " |
3478 "Especially since we don't support that!\n"); | |
4617 | 3479 } |
3480 | |
3481 /* Build the file transfer handle */ | |
3482 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3483 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3484 xfer->remote_port = args->port; |
4617 | 3485 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3486 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3487 gaim_xfer_set_message(xfer, message); |
5146 | 3488 |
3489 /* Create the oscar-specific data */ | |
5163 | 3490 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3491 if (args->proxyip) |
5146 | 3492 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3493 if (args->verifiedip) |
5146 | 3494 oft_info->verifiedip = g_strdup(args->verifiedip); |
3495 xfer->data = oft_info; | |
4617 | 3496 |
3497 /* Setup our I/O op functions */ | |
8446 | 3498 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3499 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3500 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
|
3501 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3502 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3503 |
3504 /* Keep track of this transfer for later */ | |
3505 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3506 | |
3507 /* Now perform the request */ | |
3508 gaim_xfer_request(xfer); | |
3509 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3510 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3511 GaimXfer *xfer; |
8660 | 3512 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3513 "AAA - File transfer canceled by remote user\n"); |
4617 | 3514 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
|
3515 gaim_xfer_cancel_remote(xfer); |
4617 | 3516 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3517 /* | |
3518 * This gets sent by the receiver of a file | |
3519 * as they connect directly to us. If we don't | |
3520 * get this, then maybe a third party connected | |
3521 * to us, and we shouldn't send them anything. | |
3522 */ | |
3523 } else { | |
8660 | 3524 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3525 "unknown rendezvous status!\n"); |
3630 | 3526 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3527 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3528 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3529 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3530 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3531 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3532 args->info.icon.length); |
6871 | 3533 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3534 /* Consider moving all this into a helper func in the direct im block way up there */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3535 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3536 struct oscar_direct_im *dim = oscar_direct_im_find(od, userinfo->sn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3537 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3538 |
4212 | 3539 if (!args->verifiedip) { |
8983 | 3540 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3541 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3542 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3543 g_free(message); |
4650 | 3544 return 1; |
4212 | 3545 } |
3546 | |
8660 | 3547 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3548 "%s received direct im request from %s (%s)\n", |
8983 | 3549 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3550 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3551 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3552 d->sn = g_strdup(userinfo->sn); |
8983 | 3553 /* Let's use the clientip here, because I think that's what AIM does. |
3554 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3555 * and then ask them to connect to us. */ | |
3556 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3557 memcpy(d->cookie, args->cookie, 8); |
9070 | 3558 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3559 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3560 | |
8971 | 3561 oscar_direct_im_destroy(od, dim); |
8984 | 3562 d->donttryagain = TRUE; |
8971 | 3563 accept_direct_im_request(d); |
3564 } else { | |
8983 | 3565 if (dim && !dim->connected) |
8971 | 3566 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3567 "already connected to that buddy!"); | |
5575 | 3568 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
|
3569 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3570 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3571 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3572 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3573 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3574 "revealed, this may be considered a privacy " |
9972 | 3575 "risk."), |
3576 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3577 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3578 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3579 /* FIXME: we should actually send a packet on cancel */ | |
3580 } | |
8708 | 3581 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3582 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
|
3583 } else { |
8660 | 3584 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3585 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3586 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3587 |
9933 | 3588 g_free(message); |
3589 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3590 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3591 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3592 |
3453 | 3593 /* |
4230 | 3594 * Authorization Functions |
3595 * Most of these are callbacks from dialogs. They're used by both | |
3596 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3597 */ |
4269 | 3598 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3599 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3600 GaimConnection *gc = data->gc; |
4244 | 3601 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3602 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3603 OscarData *od = gc->proto_data; |
6695 | 3604 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3605 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3606 if (buddy && group) { |
8660 | 3607 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3608 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3609 buddy->name, group->name); |
4889 | 3610 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3611 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3612 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3613 } |
4230 | 3614 } |
4337 | 3615 } |
3616 | |
3617 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3618 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3619 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3620 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3621 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3622 data); |
4230 | 3623 } |
3624 | |
3625 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3626 GaimConnection *gc = data->gc; |
4244 | 3627 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3628 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3629 /* Remove from local list */ |
3630 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3631 gaim_blist_remove_buddy(b); | |
4244 | 3632 } |
3633 | |
5836 | 3634 oscar_free_name_data(data); |
4230 | 3635 } |
3636 | |
9030 | 3637 |
3638 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3639 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3640 GaimBuddy *buddy; |
4269 | 3641 gchar *dialog_msg, *nombre; |
3642 | |
4687 | 3643 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3644 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3645 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3646 else |
4830 | 3647 nombre = NULL; |
3648 | |
3649 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 | 3650 data->gc = gc; |
3651 data->name = g_strdup(name); | |
3652 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3653 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3654 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3655 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3656 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3657 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3658 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3659 |
3660 g_free(dialog_msg); | |
3661 g_free(nombre); | |
3662 } | |
3663 | |
9030 | 3664 |
3665 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3666 GaimBuddy *buddy; | |
3667 GaimConnection *gc; | |
3668 | |
3669 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3670 | |
3671 buddy = (GaimBuddy *) node; | |
3672 gc = gaim_account_get_connection(buddy->account); | |
3673 gaim_auth_sendrequest(gc, buddy->name); | |
3674 } | |
3675 | |
4230 | 3676 /* When other people ask you for authorization */ |
3677 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3678 GaimConnection *gc = data->gc; |
4244 | 3679 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3680 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3681 OscarData *od = gc->proto_data; |
4236 | 3682 #ifdef NOSSI |
6695 | 3683 GaimBuddy *buddy; |
4244 | 3684 gchar message; |
3685 message = 0; | |
4687 | 3686 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3687 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3688 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3689 #else |
4889 | 3690 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3691 #endif |
4244 | 3692 } |
3693 | |
5836 | 3694 oscar_free_name_data(data); |
3141 | 3695 } |
3696 | |
4230 | 3697 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3698 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3699 GaimConnection *gc = data->gc; |
4244 | 3700 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3701 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3702 OscarData *od = gc->proto_data; |
4230 | 3703 #ifdef NOSSI |
4617 | 3704 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3705 #else |
4889 | 3706 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3707 #endif |
4244 | 3708 } |
4337 | 3709 } |
3710 | |
3711 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3712 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3713 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3714 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3715 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3716 data); |
3141 | 3717 } |
3718 | |
7023 | 3719 /* When someone sends you buddies */ |
3720 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3721 GaimConnection *gc = data->gc; |
4244 | 3722 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3723 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3724 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3725 } |
3726 | |
5836 | 3727 oscar_free_name_data(data); |
3453 | 3728 } |
3729 | |
4075 | 3730 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 | 3731 GaimConnection *gc = sess->aux_data; |
9908 | 3732 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3733 gchar **msg1, **msg2; |
6051 | 3734 int i, numtoks; |
4076 | 3735 |
4121 | 3736 if (!args->type || !args->msg || !args->uin) |
3737 return 1; | |
4194 | 3738 |
8660 | 3739 gaim_debug_info("oscar", |
9908 | 3740 "Received a channel 4 message of type 0x%02hhx.\n", |
3741 args->type); | |
4076 | 3742 |
9919 | 3743 /* |
3744 * Split up the message at the delimeter character, then convert each | |
3745 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3746 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3747 * character in whatever encoding the message was sent in. Type 1 | |
3748 * messages are always made up of only one part, so we can easily account | |
3749 * for this suck-ass part of the protocol by splitting the string into at | |
3750 * most 1 baby string. | |
3751 */ | |
3752 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3753 for (numtoks=0; msg1[numtoks]; numtoks++); |
3754 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3755 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3756 gaim_str_strip_cr(msg1[i]); |
9908 | 3757 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3758 } |
3759 msg2[i] = NULL; | |
3760 | |
3952 | 3761 switch (args->type) { |
4173 | 3762 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3763 if (i >= 1) { |
5556 | 3764 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3765 gchar *tmp; |
3766 | |
3767 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3768 tmp = gaim_escape_html(msg2[0]); |
8493 | 3769 |
4076 | 3770 if (t) { /* This is an offline message */ |
9680 | 3771 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3772 #ifdef HAVE_TM_GMTOFF |
9724 | 3773 time_t now; |
3774 struct tm *tm; | |
3775 now = time(NULL); | |
3776 tm = localtime(&now); | |
3777 t += tm->tm_gmtoff; | |
9698 | 3778 #else |
3779 # ifdef HAVE_TIMEZONE | |
9680 | 3780 tzset(); |
3781 t -= timezone; | |
9698 | 3782 # endif |
3783 #endif | |
8514 | 3784 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3785 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3786 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3787 } |
3788 g_free(uin); | |
8493 | 3789 g_free(tmp); |
4075 | 3790 } |
3316 | 3791 } break; |
3792 | |
4173 | 3793 case 0x04: { /* Someone sent you a URL */ |
4076 | 3794 if (i >= 2) { |
7385 | 3795 if (msg2[1] != NULL) { |
3796 gchar *uin = g_strdup_printf("%u", args->uin); | |
3797 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3798 msg2[1], | |
3799 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3800 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3801 g_free(uin); | |
3802 g_free(message); | |
3803 } | |
3453 | 3804 } |
3805 } break; | |
3806 | |
4173 | 3807 case 0x06: { /* Someone requested authorization */ |
4076 | 3808 if (i >= 6) { |
4230 | 3809 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3810 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 | 3811 gaim_debug_info("oscar", |
5556 | 3812 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3813 args->uin); |
4076 | 3814 data->gc = gc; |
5556 | 3815 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3816 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3817 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3818 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3819 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3820 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3821 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3822 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3823 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3824 g_free(dialog_msg); |
3825 } | |
3141 | 3826 } break; |
3827 | |
4173 | 3828 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3829 if (i >= 1) { |
7023 | 3830 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
|
3831 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3832 dialog_msg); |
4076 | 3833 g_free(dialog_msg); |
3834 } | |
3141 | 3835 } break; |
3836 | |
4173 | 3837 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3838 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
|
3839 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3840 dialog_msg); |
3141 | 3841 g_free(dialog_msg); |
3842 } break; | |
3843 | |
4333 | 3844 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3845 if (i >= 5) { | |
3846 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
|
3847 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3848 g_free(dialog_msg); |
3849 } | |
3850 } break; | |
3851 | |
4173 | 3852 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3853 if (i >= 6) { |
4194 | 3854 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
|
3855 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3856 g_free(dialog_msg); |
3857 } | |
4075 | 3858 } break; |
3859 | |
4173 | 3860 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3861 if (i >= 6) { |
4308 | 3862 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
|
3863 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3864 g_free(dialog_msg); |
3865 } | |
4075 | 3866 } break; |
3867 | |
4173 | 3868 case 0x12: { |
3141 | 3869 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3870 /* Someone added you to their buddy list? */ |
3141 | 3871 } break; |
3872 | |
7023 | 3873 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3874 guint i, num; |
3453 | 3875 gchar **text; |
4173 | 3876 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3877 if (text) { |
3878 num = 0; | |
3879 for (i=0; i<strlen(text[0]); i++) | |
3880 num = num*10 + text[0][i]-48; | |
3881 for (i=0; i<num; i++) { | |
4230 | 3882 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3883 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 | 3884 data->gc = gc; |
4790 | 3885 data->name = g_strdup(text[i*2+1]); |
3886 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3887 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3888 gaim_request_action(gc, NULL, message, |
7023 | 3889 _("Do you want to add this buddy " |
3890 "to your buddy list?"), | |
9972 | 3891 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3892 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3893 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3894 g_free(message); |
3895 } | |
3896 g_strfreev(text); | |
3897 } | |
3898 } break; | |
3899 | |
7023 | 3900 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3901 /* This is boring and silly. */ |
3902 } break; | |
3903 | |
3141 | 3904 default: { |
8660 | 3905 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3906 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3907 "(type 0x%02hhx).\n", args->type); |
3141 | 3908 } break; |
3909 } | |
3910 | |
4076 | 3911 g_strfreev(msg1); |
3912 g_strfreev(msg2); | |
3913 | |
3141 | 3914 return 1; |
3915 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3916 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3917 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3918 fu16_t channel; |
3919 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3920 aim_userinfo_t *userinfo; |
2086 | 3921 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3922 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3923 va_start(ap, fr); |
4200 | 3924 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3925 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3926 |
3141 | 3927 switch (channel) { |
3928 case 1: { /* standard message */ | |
3929 struct aim_incomingim_ch1_args *args; | |
3930 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3931 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3932 } break; | |
3933 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3934 case 2: { /* rendezvous */ |
3141 | 3935 struct aim_incomingim_ch2_args *args; |
3936 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3937 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3938 } break; | |
3939 | |
3940 case 4: { /* ICQ */ | |
3941 struct aim_incomingim_ch4_args *args; | |
3942 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3943 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3944 } break; |
3945 | |
3946 default: { | |
8660 | 3947 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3948 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3949 "0x%04hx).", channel); |
3141 | 3950 } break; |
2086 | 3951 } |
3952 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3953 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3954 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3955 return ret; |
2086 | 3956 } |
3957 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3958 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3959 GaimConnection *gc = sess->aux_data; |
3960 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3961 char *buf; |
2086 | 3962 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3963 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3964 aim_userinfo_t *userinfo; |
2086 | 3965 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3966 va_start(ap, fr); |
4200 | 3967 chan = (fu16_t)va_arg(ap, unsigned int); |
3968 userinfo = va_arg(ap, aim_userinfo_t *); | |
3969 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3970 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3971 va_end(ap); |
3972 | |
3973 switch(reason) { | |
5420 | 3974 case 0: /* Invalid (0) */ |
3975 buf = g_strdup_printf( | |
3976 ngettext( | |
4276 | 3977 "You missed %hu message from %s because it was invalid.", |
3978 "You missed %hu messages from %s because they were invalid.", | |
3979 nummissed), | |
4282 | 3980 nummissed, |
3981 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3982 break; |
5420 | 3983 case 1: /* Message too large */ |
3984 buf = g_strdup_printf( | |
3985 ngettext( | |
4276 | 3986 "You missed %hu message from %s because it was too large.", |
3987 "You missed %hu messages from %s because they were too large.", | |
3988 nummissed), | |
4282 | 3989 nummissed, |
3990 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3991 break; |
5420 | 3992 case 2: /* Rate exceeded */ |
3993 buf = g_strdup_printf( | |
3994 ngettext( | |
4276 | 3995 "You missed %hu message from %s because the rate limit has been exceeded.", |
3996 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3997 nummissed), | |
4282 | 3998 nummissed, |
3999 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4000 break; |
5420 | 4001 case 3: /* Evil Sender */ |
4002 buf = g_strdup_printf( | |
4003 ngettext( | |
4276 | 4004 "You missed %hu message from %s because he/she was too evil.", |
4005 "You missed %hu messages from %s because he/she was too evil.", | |
4006 nummissed), | |
4282 | 4007 nummissed, |
4008 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4009 break; |
5420 | 4010 case 4: /* Evil Receiver */ |
4011 buf = g_strdup_printf( | |
4012 ngettext( | |
4276 | 4013 "You missed %hu message from %s because you are too evil.", |
4014 "You missed %hu messages from %s because you are too evil.", | |
4015 nummissed), | |
4282 | 4016 nummissed, |
4017 userinfo->sn); | |
2086 | 4018 break; |
4019 default: | |
5420 | 4020 buf = g_strdup_printf( |
4021 ngettext( | |
4276 | 4022 "You missed %hu message from %s for an unknown reason.", |
4023 "You missed %hu messages from %s for an unknown reason.", | |
4024 nummissed), | |
4282 | 4025 nummissed, |
4026 userinfo->sn); | |
2086 | 4027 break; |
4028 } | |
8733 | 4029 |
9627 | 4030 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 4031 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 4032 g_free(buf); |
2086 | 4033 |
4034 return 1; | |
4035 } | |
4036 | |
4194 | 4037 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 4038 GaimConnection *gc = sess->aux_data; |
7283 | 4039 OscarData *od = gc->proto_data; |
4617 | 4040 |
4041 /* BBB */ | |
3630 | 4042 switch (reason) { |
4151 | 4043 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4044 GaimXfer *xfer; |
8971 | 4045 struct oscar_direct_im *dim; |
4046 | |
8660 | 4047 gaim_debug_info("oscar", |
9070 | 4048 "AAA - Other user declined some sort of direct " |
8971 | 4049 "connect attempt (automaticly?)\n"); |
4617 | 4050 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
|
4051 gaim_xfer_cancel_remote(xfer); |
8971 | 4052 else if ((dim = oscar_direct_im_find(od, who))) { |
4053 /* AAA should use find by cookie or something here */ | |
4054 oscar_direct_im_disconnect(od, dim); | |
4055 } | |
4151 | 4056 } break; |
4057 | |
4058 default: { | |
8660 | 4059 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4060 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4061 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 4062 } |
3630 | 4063 |
4064 } | |
4065 | |
4066 return 0; | |
4067 } | |
4068 | |
4194 | 4069 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 4070 GaimConnection *gc = sess->aux_data; |
4151 | 4071 |
4072 switch(reason) { | |
4073 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 4074 char *title, *statusmsg, **splitmsg, *dialogmsg; |
4075 | |
4076 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 4077 |
4078 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 4079 statusmsg = oscar_icqstatus(state); |
4151 | 4080 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 4081 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
4082 g_free(statusmsg); | |
4151 | 4083 g_strfreev(splitmsg); |
9244 | 4084 |
9797 | 4085 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 4086 |
4087 g_free(title); | |
4088 g_free(dialogmsg); | |
4151 | 4089 } break; |
4090 | |
4091 default: { | |
8660 | 4092 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4093 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4094 "Type 0x%04hx\n", who, reason); |
4151 | 4095 } break; |
4096 } /* end of switch */ | |
4097 | |
4098 return 0; | |
4099 } | |
4100 | |
3212 | 4101 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4102 va_list ap; | |
4103 fu16_t chan, reason; | |
4104 char *who; | |
4105 | |
4106 va_start(ap, fr); | |
4200 | 4107 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4108 who = va_arg(ap, char *); |
4200 | 4109 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4110 |
3952 | 4111 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4112 char *cookie = va_arg(ap, char *); |
4151 | 4113 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4114 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4115 fu32_t state = 0; |
4151 | 4116 char *msg = NULL; |
4117 if (reason == 0x0003) { | |
4200 | 4118 state = va_arg(ap, fu32_t); |
4151 | 4119 msg = va_arg(ap, char *); |
4120 } | |
4121 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4122 } | |
3952 | 4123 |
3212 | 4124 va_end(ap); |
4125 | |
4126 return 1; | |
4127 } | |
4128 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4129 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4130 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4131 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4132 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4133 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4134 va_start(ap, fr); |
4199 | 4135 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4136 va_end(ap); |
4137 | |
8660 | 4138 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4139 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4140 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4141 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4142 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4143 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4144 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4145 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4146 |
2086 | 4147 return 1; |
4148 } | |
4149 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4150 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4151 GaimConnection *gc = sess->aux_data; |
4617 | 4152 #if 0 |
7283 | 4153 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4154 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4155 #endif |
4617 | 4156 va_list ap; |
4157 fu16_t reason; | |
4158 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4159 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4160 va_start(ap, fr); |
4617 | 4161 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4162 data = va_arg(ap, char *); |
2086 | 4163 va_end(ap); |
4164 | |
8660 | 4165 gaim_debug_error("oscar", |
10130 | 4166 "Message error with data %s and reason %hu\n", |
4167 (data != NULL ? data : ""), reason); | |
4617 | 4168 |
4169 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4170 #if 0 |
4617 | 4171 /* If this was a file transfer request, data is a cookie */ |
4172 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
|
4173 gaim_xfer_cancel_remote(xfer); |
3630 | 4174 return 1; |
4175 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4176 #endif |
3630 | 4177 |
4617 | 4178 /* Data is assumed to be the destination sn */ |
9826 | 4179 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4180 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4181 g_free(buf); | |
4182 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4183 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4184 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4185 } | |
4186 g_free(buf); | |
4187 | |
2086 | 4188 return 1; |
4189 } | |
4190 | |
3595 | 4191 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4192 GaimConnection *gc = sess->aux_data; |
3595 | 4193 va_list ap; |
4194 fu16_t type1, type2; | |
4195 char *sn; | |
4196 | |
4197 va_start(ap, fr); | |
4199 | 4198 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4199 sn = va_arg(ap, char *); |
4199 | 4200 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4201 va_end(ap); |
4202 | |
4203 switch (type2) { | |
4204 case 0x0000: { /* Text has been cleared */ | |
4205 serv_got_typing_stopped(gc, sn); | |
4206 } break; | |
4207 | |
4208 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4209 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4210 } break; |
4211 | |
4212 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4213 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4214 } break; |
4215 | |
4216 default: { | |
8660 | 4217 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 | 4218 } break; |
4219 } | |
4220 | |
4221 return 1; | |
4222 } | |
4223 | |
7141 | 4224 /* |
4225 * We get this error when there was an error in the locate family. This | |
7259 | 4226 * happens when you request info of someone who is offline. |
7141 | 4227 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4228 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4229 gchar *buf; |
2086 | 4230 va_list ap; |
5420 | 4231 fu16_t reason; |
2086 | 4232 char *destn; |
4233 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4234 va_start(ap, fr); |
4199 | 4235 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4236 destn = va_arg(ap, char *); |
4237 va_end(ap); | |
4238 | |
7781 | 4239 if (destn == NULL) |
7793 | 4240 return 1; |
9627 | 4241 |
9826 | 4242 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4243 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4244 g_free(buf); | |
9627 | 4245 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4246 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4247 } | |
4248 g_free(buf); | |
2086 | 4249 |
4250 return 1; | |
4251 } | |
4252 | |
7011 | 4253 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4254 GaimConnection *gc = sess->aux_data; |
8700 | 4255 GaimAccount *account = gaim_connection_get_account(gc); |
4256 GString *str; | |
9244 | 4257 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4258 va_list ap; |
7011 | 4259 aim_userinfo_t *userinfo; |
2086 | 4260 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4261 va_start(ap, fr); |
7011 | 4262 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4263 va_end(ap); |
4264 | |
8700 | 4265 str = g_string_new(""); |
4266 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4267 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4268 |
10116 | 4269 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4270 time_t t = userinfo->onlinesince; | |
4271 oscar_string_append(str, "\n<br>", _("Online Since"), ctime(&t)); | |
4272 } | |
4273 | |
4274 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4275 time_t t = userinfo->membersince; | |
4276 oscar_string_append(str, "\n<br>", _("Member Since"), ctime(&t)); | |
4277 } | |
7011 | 4278 |
4279 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4280 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4281 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4282 g_free(tmp); |
4283 } | |
4284 | |
8701 | 4285 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4286 |
4287 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4288 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4289 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4290 g_free(tmp); | |
7011 | 4291 if (away_utf8 != NULL) { |
8700 | 4292 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4293 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4294 } |
7011 | 4295 } |
4296 | |
4297 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4298 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4299 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4300 g_free(tmp); | |
7011 | 4301 if (info_utf8 != NULL) { |
8700 | 4302 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4303 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4304 } |
7011 | 4305 } |
4306 | |
8701 | 4307 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4308 g_string_free(str, TRUE); |
9244 | 4309 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4310 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4311 g_free(title); |
8700 | 4312 g_free(tmp); |
4151 | 4313 |
2086 | 4314 return 1; |
4315 } | |
4316 | |
8341 | 4317 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4318 { | |
4319 aim_session_t *sess = data; | |
4320 GaimConnection *gc = sess->aux_data; | |
4321 OscarData *od = (OscarData *)gc->proto_data; | |
4322 | |
4323 aim_locate_dorequest(data); | |
4324 od->getinfotimer = 0; | |
4325 | |
4326 return FALSE; | |
4327 } | |
4328 | |
4329 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4330 { | |
4331 GaimConnection *gc = sess->aux_data; | |
4332 OscarData *od = (OscarData *)gc->proto_data; | |
4333 | |
4334 /* | |
4335 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4336 * us from hitting the rate limit due to request away messages and info | |
4337 * too quickly. | |
4338 */ | |
4339 if (od->getinfotimer == 0) | |
10198 | 4340 od->getinfotimer = gaim_timeout_add(1500, gaim_reqinfo_timeout_cb, sess); |
8341 | 4341 |
4342 return 1; | |
4343 } | |
4344 | |
4345 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4346 { | |
2086 | 4347 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4348 fu16_t id; |
2086 | 4349 va_list ap; |
4350 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4351 va_start(ap, fr); |
4199 | 4352 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4353 msg = va_arg(ap, char *); |
4354 va_end(ap); | |
4355 | |
8660 | 4356 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4357 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4358 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4359 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4360 _("Your AIM connection may be lost."), NULL); |
2086 | 4361 |
4362 return 1; | |
4363 } | |
4364 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4365 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4366 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4367 fu16_t type; |
5575 | 4368 GaimConnection *gc = sess->aux_data; |
7283 | 4369 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4370 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4371 va_start(ap, fr); |
4199 | 4372 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4373 |
4374 switch(type) { | |
4375 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4376 fu8_t maxrooms; |
2086 | 4377 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4378 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4379 |
4199 | 4380 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4381 exchangecount = va_arg(ap, int); |
4382 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4383 | |
8660 | 4384 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4385 "chat info: Chat Rights:\n"); |
8660 | 4386 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4387 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4388 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4389 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4390 for (i = 0; i < exchangecount; i++) |
8660 | 4391 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4392 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4393 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4394 while (od->create_rooms) { |
4395 struct create_room *cr = od->create_rooms->data; | |
8660 | 4396 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4397 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4398 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4399 g_free(cr->name); |
4617 | 4400 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4401 g_free(cr); |
2086 | 4402 } |
4403 } | |
4404 break; | |
4405 case 0x0008: { | |
4406 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4407 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4408 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4409 fu32_t createtime; |
2086 | 4410 |
4411 fqcn = va_arg(ap, char *); | |
4200 | 4412 instance = (fu16_t)va_arg(ap, unsigned int); |
4413 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4414 flags = (fu16_t)va_arg(ap, unsigned int); | |
4415 createtime = va_arg(ap, fu32_t); | |
4416 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4417 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4418 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4419 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4420 name = va_arg(ap, char *); | |
4421 ck = va_arg(ap, char *); | |
4194 | 4422 |
8660 | 4423 gaim_debug_misc("oscar", |
5556 | 4424 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4425 fqcn, |
4426 exchange, instance, flags, | |
4427 createtime, | |
4428 maxmsglen, maxoccupancy, createperms, unknown, | |
4429 name, ck); | |
4617 | 4430 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4431 } |
4432 break; | |
4433 default: | |
8660 | 4434 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4435 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4436 break; |
4437 } | |
4194 | 4438 |
4439 va_end(ap); | |
4440 | |
2086 | 4441 return 1; |
4442 } | |
4443 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4444 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4445 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4446 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4447 aim_userinfo_t *info; |
5575 | 4448 GaimConnection *g = sess->aux_data; |
2086 | 4449 |
4450 struct chat_connection *c = NULL; | |
4451 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4452 va_start(ap, fr); |
2086 | 4453 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4454 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4455 va_end(ap); |
4456 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4457 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4458 if (!c) |
4459 return 1; | |
4460 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4461 for (i = 0; i < count; i++) |
9846 | 4462 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4463 |
4464 return 1; | |
4465 } | |
4466 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4467 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4468 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4469 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4470 aim_userinfo_t *info; |
5575 | 4471 GaimConnection *g = sess->aux_data; |
2086 | 4472 |
4473 struct chat_connection *c = NULL; | |
4474 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4475 va_start(ap, fr); |
2086 | 4476 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4477 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4478 va_end(ap); |
4479 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4480 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4481 if (!c) |
4482 return 1; | |
4483 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4484 for (i = 0; i < count; i++) |
8733 | 4485 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4486 |
4487 return 1; | |
4488 } | |
4489 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4490 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
|
4491 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4492 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4493 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4494 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4495 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4496 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4497 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4498 fu32_t creationtime; |
5575 | 4499 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4500 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
|
4501 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4502 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4503 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4504 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4505 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4506 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4507 roomdesc = va_arg(ap, char *); |
4200 | 4508 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4509 creationtime = va_arg(ap, fu32_t); | |
4510 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4511 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4512 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4513 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4514 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4515 |
8660 | 4516 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4517 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4518 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4519 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4520 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4521 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4522 |
2086 | 4523 return 1; |
4524 } | |
4525 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4526 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4527 GaimConnection *gc = sess->aux_data; |
8225 | 4528 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4529 gchar *utf8; | |
2086 | 4530 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4531 aim_userinfo_t *info; |
8225 | 4532 int len; |
2086 | 4533 char *msg; |
8219 | 4534 char *charset; |
2086 | 4535 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4536 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4537 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4538 len = va_arg(ap, int); |
4194 | 4539 msg = va_arg(ap, char *); |
8219 | 4540 charset = va_arg(ap, char *); |
4194 | 4541 va_end(ap); |
2086 | 4542 |
8225 | 4543 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4544 if (utf8 == NULL) |
4545 /* The conversion failed! */ | |
8668 | 4546 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4547 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4548 g_free(utf8); | |
2086 | 4549 |
4550 return 1; | |
4551 } | |
4552 | |
3694 | 4553 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4554 va_list ap; | |
5575 | 4555 GaimConnection *gc = sess->aux_data; |
3694 | 4556 struct aim_emailinfo *emailinfo; |
3725 | 4557 int havenewmail; |
7297 | 4558 char *alertitle, *alerturl; |
3694 | 4559 |
4560 va_start(ap, fr); | |
4561 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4562 havenewmail = va_arg(ap, int); |
7301 | 4563 alertitle = va_arg(ap, char *); |
4564 alerturl = va_arg(ap, char *); | |
3694 | 4565 va_end(ap); |
4566 | |
9661 | 4567 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4568 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4569 emailinfo->domain ? "@" : "", | |
4570 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4571 if (emailinfo->unread && havenewmail) |
4572 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4573 g_free(to); |
3694 | 4574 } |
10157 | 4575 |
7301 | 4576 if (alertitle) |
8660 | 4577 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4578 |
4579 return 1; | |
4580 } | |
4581 | |
4804 | 4582 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4583 GaimConnection *gc = sess->aux_data; |
7283 | 4584 OscarData *od = gc->proto_data; |
4804 | 4585 char *sn; |
4586 | |
4587 sn = od->requesticon->data; | |
8660 | 4588 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4589 "removing %s from hash table\n", sn); |
4804 | 4590 od->requesticon = g_slist_remove(od->requesticon, sn); |
4591 free(sn); | |
4592 | |
4593 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4594 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4595 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4596 |
4597 return 1; | |
4598 } | |
4599 | |
4600 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4601 GaimConnection *gc = sess->aux_data; |
7283 | 4602 OscarData *od = gc->proto_data; |
4804 | 4603 GSList *cur; |
4604 va_list ap; | |
4605 char *sn; | |
4853 | 4606 fu8_t *iconcsum, *icon; |
4607 fu16_t iconcsumlen, iconlen; | |
4804 | 4608 |
4609 va_start(ap, fr); | |
4610 sn = va_arg(ap, char *); | |
4853 | 4611 iconcsum = va_arg(ap, fu8_t *); |
4612 iconcsumlen = va_arg(ap, int); | |
4804 | 4613 icon = va_arg(ap, fu8_t *); |
4614 iconlen = va_arg(ap, int); | |
4615 va_end(ap); | |
4616 | |
4853 | 4617 if (iconlen > 0) { |
4618 char *b16; | |
6695 | 4619 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4620 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4621 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4622 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4623 if (b16) { |
7693 | 4624 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4625 g_free(b16); |
5129 | 4626 } |
4853 | 4627 } |
4804 | 4628 |
4629 cur = od->requesticon; | |
4630 while (cur) { | |
4631 char *cursn = cur->data; | |
4632 if (!aim_sncmp(cursn, sn)) { | |
4633 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4634 free(cursn); | |
4635 cur = od->requesticon; | |
4636 } else | |
4637 cur = cur->next; | |
4638 } | |
4639 | |
4640 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4641 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4642 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4643 |
4644 return 1; | |
4645 } | |
4646 | |
4647 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4648 GaimConnection *gc = data; |
7283 | 4649 OscarData *od = gc->proto_data; |
7011 | 4650 aim_userinfo_t *userinfo; |
4804 | 4651 aim_conn_t *conn; |
4652 | |
4653 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4654 if (!conn) { |
4655 if (!od->iconconnecting) { | |
4656 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4657 od->iconconnecting = TRUE; | |
4658 } | |
4804 | 4659 return FALSE; |
4660 } | |
4661 | |
5842 | 4662 if (od->set_icon) { |
6039 | 4663 struct stat st; |
4664 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4665 if (iconfile == NULL) { | |
8363 | 4666 aim_ssi_delicon(od->sess); |
6039 | 4667 } else if (!stat(iconfile, &st)) { |
4668 char *buf = g_malloc(st.st_size); | |
4669 FILE *file = fopen(iconfile, "rb"); | |
4670 if (file) { | |
9532 | 4671 /* XXX - Use g_file_get_contents()? */ |
6039 | 4672 fread(buf, 1, st.st_size, file); |
4673 fclose(file); | |
8660 | 4674 gaim_debug_info("oscar", |
6039 | 4675 "Uploading icon to icon server\n"); |
6879 | 4676 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4677 } else |
8660 | 4678 gaim_debug_error("oscar", |
6039 | 4679 "Can't open buddy icon file!\n"); |
4680 g_free(buf); | |
4681 } else { | |
8660 | 4682 gaim_debug_error("oscar", |
6039 | 4683 "Can't stat buddy icon file!\n"); |
5842 | 4684 } |
4685 od->set_icon = FALSE; | |
4686 } | |
4687 | |
4688 if (!od->requesticon) { | |
8660 | 4689 gaim_debug_misc("oscar", |
5842 | 4690 "no more icons to request\n"); |
4691 return FALSE; | |
4692 } | |
4693 | |
7045 | 4694 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4695 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4696 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4697 return FALSE; |
4698 } else { | |
4699 char *sn = od->requesticon->data; | |
4700 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4701 free(sn); | |
4702 } | |
4703 | |
4704 return TRUE; | |
4705 } | |
4706 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4707 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4708 * 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
|
4709 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4710 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4711 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4712 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4713 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4714 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4715 va_start(ap, fr); |
4199 | 4716 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4717 sn = va_arg(ap, char *); |
4718 va_end(ap); | |
4719 | |
8660 | 4720 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4721 |
4722 return 1; | |
4723 } | |
4724 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4725 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
|
4726 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4727 "invalid", |
4194 | 4728 "change", |
4729 "warning", | |
4730 "limit", | |
4731 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4732 }; |
2086 | 4733 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4734 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4735 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4736 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4737 va_start(ap, fr); |
4200 | 4738 code = (fu16_t)va_arg(ap, unsigned int); |
4739 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4740 windowsize = va_arg(ap, fu32_t); | |
4741 clear = va_arg(ap, fu32_t); | |
4742 alert = va_arg(ap, fu32_t); | |
4743 limit = va_arg(ap, fu32_t); | |
4744 disconnect = va_arg(ap, fu32_t); | |
4745 currentavg = va_arg(ap, fu32_t); | |
4746 maxavg = va_arg(ap, fu32_t); | |
2086 | 4747 va_end(ap); |
4748 | |
8660 | 4749 gaim_debug_misc("oscar", |
5556 | 4750 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4751 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4752 (code < 5) ? codes[code] : codes[0], |
4753 rateclass, | |
4754 currentavg, maxavg, | |
4755 alert, clear, | |
4756 limit, disconnect, | |
4757 windowsize); | |
4758 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4759 /* XXX fix these values */ |
2086 | 4760 if (code == AIM_RATE_CODE_CHANGE) { |
4761 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4762 aim_conn_setlatency(fr->conn, 0); |
2086 | 4763 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4764 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4765 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4766 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4767 _("The last action you attempted could not be " |
4768 "performed because you are over the rate limit. " | |
4769 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4770 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4771 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4772 aim_conn_setlatency(fr->conn, 0); |
2086 | 4773 } |
4774 | |
4775 return 1; | |
4776 } | |
4777 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4778 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4779 GaimConnection *gc = sess->aux_data; |
4780 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4781 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4782 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4783 aim_userinfo_t *userinfo; |
2086 | 4784 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4785 va_start(ap, fr); |
4199 | 4786 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4787 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4788 va_end(ap); |
4789 | |
9982 | 4790 /* XXX - What's with the + 0.5? */ |
4791 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4792 |
4793 return 1; | |
4794 } | |
4795 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4796 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4797 GaimConnection *gc = sess->aux_data; |
4798 GaimAccount *account = gaim_connection_get_account(gc); | |
10152 | 4799 GaimPresence *presence = gaim_account_get_presence(account); |
9982 | 4800 int warning_level; |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4801 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4802 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4803 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4804 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4805 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4806 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4807 |
9982 | 4808 warning_level = info->warnlevel/10.0 + 0.5; |
4809 | |
10152 | 4810 gaim_presence_set_warning_level(presence, warning_level); |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4811 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4812 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4813 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4814 |
4649 | 4815 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4816 GaimConnection *gc = sess->aux_data; |
7283 | 4817 OscarData *od = gc->proto_data; |
4649 | 4818 va_list ap; |
4819 fu16_t code; | |
4820 char *msg; | |
4821 | |
4822 va_start(ap, fr); | |
4823 code = (fu16_t)va_arg(ap, int); | |
4824 msg = va_arg(ap, char *); | |
4825 va_end(ap); | |
4826 | |
10458 | 4827 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
4828 code, (msg != NULL ? msg : "")); | |
4829 | |
4830 g_return_val_if_fail(fr != NULL, 1); | |
4831 g_return_val_if_fail(fr->conn != NULL, 1); | |
4832 | |
4833 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
4651 | 4834 if (code == 0x0001) { |
6113 | 4835 gc->wants_to_die = TRUE; |
5579 | 4836 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4837 } else { |
5579 | 4838 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4839 } |
4666 | 4840 od->killme = TRUE; |
10458 | 4841 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
4842 struct chat_connection *cc; | |
4843 GaimConversation *conv; | |
4844 | |
4845 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
4846 conv = gaim_find_chat(gc, cc->id); | |
4847 | |
4848 if (conv != NULL) | |
4849 { | |
4850 gchar *buf; | |
4851 buf = g_strdup_printf(_("You have been disconnected from chat " | |
4852 "room %s."), cc->name); | |
4853 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
4854 g_free(buf); | |
4855 } | |
4856 oscar_chat_kill(gc, cc); | |
4649 | 4857 } |
4858 | |
4859 return 1; | |
4860 } | |
4861 | |
2675 | 4862 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4863 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4864 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4865 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4866 |
4867 #ifndef NOSSI | |
8660 | 4868 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4869 aim_ssi_reqrights(sess); |
6350 | 4870 aim_ssi_reqdata(sess); |
4230 | 4871 #endif |
4872 | |
7011 | 4873 aim_locate_reqrights(sess); |
7285 | 4874 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4875 aim_im_reqparams(sess); |
7334 | 4876 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4877 |
4878 #ifdef NOSSI | |
8660 | 4879 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4880 aim_bos_reqrights(sess, fr->conn); |
4230 | 4881 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4882 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4883 #endif | |
2086 | 4884 |
7283 | 4885 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4886 | |
2086 | 4887 return 1; |
4888 } | |
4889 | |
2675 | 4890 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4891 GaimConnection *gc = sess->aux_data; |
7283 | 4892 OscarData *od = gc->proto_data; |
2647 | 4893 |
6905 | 4894 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4895 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4896 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4897 | |
2672 | 4898 aim_clientready(sess, fr->conn); |
8660 | 4899 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4900 |
2647 | 4901 if (od->chpass) { |
8660 | 4902 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4903 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4904 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4905 od->oldp = NULL; |
2647 | 4906 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4907 od->newp = NULL; |
2647 | 4908 od->chpass = FALSE; |
4909 } | |
2979 | 4910 if (od->setnick) { |
8660 | 4911 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4912 aim_admin_setnick(sess, fr->conn, od->newsn); |
4913 g_free(od->newsn); | |
4914 od->newsn = NULL; | |
4915 od->setnick = FALSE; | |
4916 } | |
2647 | 4917 if (od->conf) { |
8660 | 4918 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4919 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4920 od->conf = FALSE; |
4921 } | |
4922 if (od->reqemail) { | |
8660 | 4923 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4924 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4925 od->reqemail = FALSE; |
4926 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4927 if (od->setemail) { |
8660 | 4928 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4929 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4930 g_free(od->email); |
5497 | 4931 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4932 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4933 } |
2647 | 4934 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4935 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4936 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4937 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4938 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
|
4939 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4940 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4941 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4942 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4943 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4944 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4945 |
4194 | 4946 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4947 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4948 "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
|
4949 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4950 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4951 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4952 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4953 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4954 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4955 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4956 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4957 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4958 |
4617 | 4959 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4960 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4961 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4962 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4963 |
2993 | 4964 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4965 { | |
5575 | 4966 GaimConnection *gc = sess->aux_data; |
7283 | 4967 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4968 va_list ap; |
4969 fu16_t maxsiglen; | |
2993 | 4970 |
4971 va_start(ap, fr); | |
4199 | 4972 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4973 va_end(ap); |
4974 | |
8660 | 4975 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4976 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4977 |
4617 | 4978 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4979 | |
4980 if (od->icq) | |
7334 | 4981 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4982 else |
7334 | 4983 aim_locate_setcaps(od->sess, caps_aim); |
4984 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4985 |
4986 return 1; | |
4987 } | |
4988 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4989 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
|
4990 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4991 fu16_t maxbuddies, maxwatchers; |
5575 | 4992 GaimConnection *gc = sess->aux_data; |
7283 | 4993 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4994 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4995 va_start(ap, fr); |
4199 | 4996 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4997 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4998 va_end(ap); |
4999 | |
8660 | 5000 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5001 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 5002 |
4617 | 5003 od->rights.maxbuddies = (guint)maxbuddies; |
5004 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 5005 |
2086 | 5006 return 1; |
5007 } | |
5008 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5009 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5010 GaimConnection *gc = sess->aux_data; |
7283 | 5011 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 5012 va_list ap; |
5013 fu16_t maxpermits, maxdenies; | |
2086 | 5014 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5015 va_start(ap, fr); |
4199 | 5016 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
5017 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 5018 va_end(ap); |
5019 | |
8660 | 5020 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5021 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 5022 |
4617 | 5023 od->rights.maxpermits = (guint)maxpermits; |
5024 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 5025 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
5026 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 5027 serv_finish_login(gc); |
5028 | |
8660 | 5029 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 5030 |
2672 | 5031 aim_clientready(sess, fr->conn); |
5948 | 5032 aim_srv_setavailmsg(sess, NULL); |
7474 | 5033 aim_srv_setidle(sess, 0); |
4617 | 5034 |
4664 | 5035 if (od->icq) { |
5036 aim_icq_reqofflinemsgs(sess); | |
5037 aim_icq_hideip(sess); | |
5038 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5039 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5040 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 5041 if (sess->authinfo->email) |
5042 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 5043 |
5044 return 1; | |
5045 } | |
5046 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5047 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
|
5048 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5049 struct aim_icq_offlinemsg *msg; |
4075 | 5050 struct aim_incomingim_ch4_args args; |
5051 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5052 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5053 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5054 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5055 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5056 |
8660 | 5057 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5058 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 5059 args.uin = msg->sender; |
5060 args.type = msg->type; | |
4173 | 5061 args.flags = msg->flags; |
4076 | 5062 args.msglen = msg->msglen; |
4075 | 5063 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5064 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 5065 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5066 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5067 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5068 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5069 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5070 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
|
5071 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5072 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5073 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5074 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
5075 |
7388 | 5076 #if 0 |
5077 /* | |
7465 | 5078 * Update, 2003-11-09: |
5079 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
5080 * | |
7388 | 5081 * It may not be my place to do this, but... |
5082 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
5083 * stupid, and should not exist for % switches (%x in our case) that request | |
5084 * a year in the preferred representation for the current locale. For that | |
5085 * reason I've chosen to not use this workaround (n., see kluge). | |
5086 * | |
5087 * I have a date. I want to show it to the user in the "preferred" way. | |
5088 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
5089 * what the locale wanted. | |
5090 * | |
5091 * If I have a necessity for a full representation of the year in the current | |
5092 * locale, then I'll use a switch that returns a full representation of the | |
5093 * year. | |
5094 * | |
5095 * If you think the preferred locale should show 4 digits instead of 2 digits | |
5096 * (because you're anal, or whatever), then change the f***ing locale. | |
5097 * | |
5098 * I guess the bottom line is--I'm trying to show a date to the user how they | |
5099 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 5100 * |
5101 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
5102 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 5103 */ |
5104 | |
5105 /* | |
5106 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 5107 * "last 2 digits" warning. |
5108 */ | |
10157 | 5109 static size_t my_strftime(char *s, size_t max, const char *fmt, |
7386 | 5110 const struct tm *tm) |
5111 { | |
5112 return strftime(s, max, fmt, tm); | |
5113 } | |
7388 | 5114 #endif |
7386 | 5115 |
4624 | 5116 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
|
5117 { |
5575 | 5118 GaimConnection *gc = sess->aux_data; |
8670 | 5119 OscarData *od = (OscarData *)gc->proto_data; |
5120 GaimBuddy *buddy; | |
8853 | 5121 struct buddyinfo *bi = NULL; |
4624 | 5122 gchar who[16]; |
8670 | 5123 GString *str; |
5124 gchar *primary, *utf8; | |
9634 | 5125 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5126 va_list ap; |
4151 | 5127 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5128 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5129 va_start(ap, fr); |
4151 | 5130 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5131 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5132 |
4664 | 5133 if (!info->uin) |
5134 return 0; | |
5135 | |
8670 | 5136 str = g_string_sized_new(100); |
5556 | 5137 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5138 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5139 if (buddy != NULL) | |
5140 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5141 | |
5142 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5143 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5144 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5145 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5146 (bi->ipaddr & 0xff000000) >> 24, | |
5147 (bi->ipaddr & 0x00ff0000) >> 16, | |
5148 (bi->ipaddr & 0x0000ff00) >> 8, | |
5149 (bi->ipaddr & 0x000000ff)); | |
8701 | 5150 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5151 g_free(tstr); |
5152 } | |
8701 | 5153 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5154 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5155 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5156 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5157 g_free(utf8); | |
4625 | 5158 } |
5159 if (info->numaddresses && info->email2) { | |
5160 int i; | |
5161 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5162 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5163 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5164 g_free(utf8); | |
4643 | 5165 } |
4625 | 5166 } |
4624 | 5167 } |
8701 | 5168 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5169 if (info->gender != 0) |
5170 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5171 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5172 char date[30]; |
5173 struct tm tm; | |
5174 tm.tm_mday = (int)info->birthday; | |
5175 tm.tm_mon = (int)info->birthmonth-1; | |
5176 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5177 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5178 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5179 } |
4624 | 5180 if (info->age) { |
5181 char age[5]; | |
5182 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5183 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5184 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5185 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5186 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5187 g_free(utf8); | |
4819 | 5188 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5189 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5190 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5191 g_free(utf8); | |
5192 } | |
5193 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5194 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5195 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5196 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5197 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5198 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5199 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5200 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5201 } |
4641 | 5202 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5203 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5204 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5205 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5206 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5207 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5208 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5209 } |
4641 | 5210 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5211 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5212 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5213 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5214 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5215 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5216 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5217 g_free(utf8); | |
4624 | 5218 } |
8670 | 5219 g_string_append_printf(str, "\n<hr>\n"); |
5220 } | |
5221 | |
9634 | 5222 if (buddy != NULL) |
5223 alias = gaim_buddy_get_alias(buddy); | |
5224 else | |
5225 alias = who; | |
5226 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5227 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5228 g_free(primary); |
8670 | 5229 g_string_free(str, TRUE); |
4151 | 5230 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5231 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5232 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5233 |
4759 | 5234 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5235 { | |
5575 | 5236 GaimConnection *gc = sess->aux_data; |
4820 | 5237 gchar who[16], *utf8; |
6695 | 5238 GaimBuddy *b; |
4759 | 5239 va_list ap; |
5240 struct aim_icq_info *info; | |
5241 | |
5242 va_start(ap, fr); | |
5243 info = va_arg(ap, struct aim_icq_info *); | |
5244 va_end(ap); | |
5245 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5246 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5247 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5248 serv_got_alias(gc, who, utf8); |
4759 | 5249 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5250 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5251 } |
4820 | 5252 g_free(utf8); |
4759 | 5253 } |
5254 | |
5255 return 1; | |
5256 } | |
5257 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5258 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
|
5259 { |
7032 | 5260 GaimConnection *gc = sess->aux_data; |
5261 gchar *text; | |
5262 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5263 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5264 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5265 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5266 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5267 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5268 url = va_arg(ap, char *); |
4199 | 5269 wid = (fu16_t) va_arg(ap, int); |
5270 hei = (fu16_t) va_arg(ap, int); | |
5271 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5272 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5273 |
7032 | 5274 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5275 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5276 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5277 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5278 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5279 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5280 |
7032 | 5281 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5282 { | |
6873 | 5283 GaimConnection *gc = sess->aux_data; |
5284 gchar *secondary; | |
10439 | 5285 gchar **screennames; |
6873 | 5286 int i, num; |
2086 | 5287 va_list ap; |
6873 | 5288 char *email, *SNs; |
2086 | 5289 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5290 va_start(ap, fr); |
6873 | 5291 email = va_arg(ap, char *); |
2086 | 5292 num = va_arg(ap, int); |
5293 SNs = va_arg(ap, char *); | |
5294 va_end(ap); | |
5295 | |
10439 | 5296 /* TODO: Need to use ngettext() here */ |
8152 | 5297 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
10439 | 5298 |
5299 screennames = g_malloc((num + 1) * sizeof(gchar *)); | |
2086 | 5300 for (i = 0; i < num; i++) |
10439 | 5301 screennames[i] = g_strdup(&SNs[i * (MAXSNLEN + 1)]); |
5302 screennames[num] = NULL; | |
5303 | |
5304 gaim_notify_searchresults(gc, NULL, NULL, secondary, | |
5305 (const char **)screennames, NULL, NULL); | |
6873 | 5306 |
5307 g_free(secondary); | |
10439 | 5308 g_strfreev(screennames); |
2086 | 5309 |
5310 return 1; | |
5311 } | |
5312 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5313 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5314 va_list ap; |
6873 | 5315 char *email; |
5420 | 5316 char *buf; |
2086 | 5317 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5318 va_start(ap, fr); |
6873 | 5319 email = va_arg(ap, char *); |
2086 | 5320 va_end(ap); |
5321 | |
6873 | 5322 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
|
5323 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5324 g_free(buf); |
2086 | 5325 |
5326 return 1; | |
5327 } | |
5328 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5329 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5330 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5331 fu16_t status; |
2086 | 5332 va_list ap; |
5333 char msg[256]; | |
5334 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5335 va_start(ap, fr); |
4199 | 5336 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5337 va_end(ap); |
5338 | |
8660 | 5339 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5340 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5341 status ? "unknown" : "email sent"); |
5342 if (!status) { | |
5302 | 5343 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5344 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5345 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5346 } |
5347 | |
5348 return 1; | |
5349 } | |
5350 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5351 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5352 GaimConnection *gc = sess->aux_data; |
2086 | 5353 va_list ap; |
3912 | 5354 fu16_t perms, err; |
5355 char *url, *sn, *email; | |
5356 int change; | |
2086 | 5357 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5358 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5359 change = va_arg(ap, int); |
4199 | 5360 perms = (fu16_t) va_arg(ap, unsigned int); |
5361 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5362 url = va_arg(ap, char *); |
5363 sn = va_arg(ap, char *); | |
5364 email = va_arg(ap, char *); | |
2086 | 5365 va_end(ap); |
5366 | |
8660 | 5367 gaim_debug_misc("oscar", |
9626 | 5368 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5369 change ? "change" : "request", perms, err, | |
5370 (url != NULL) ? url : "(null)", | |
5371 (sn != NULL) ? sn : "(null)", | |
5372 (email != NULL) ? email : "(null)"); | |
5373 | |
5374 if ((err > 0) && (url != NULL)) { | |
3912 | 5375 char *dialog_msg; |
5376 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5377 switch (err) { | |
5378 case 0x0001: { | |
5379 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5380 } break; | |
5381 case 0x0006: { | |
5382 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5383 } break; | |
5384 case 0x000b: { | |
5385 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5386 } break; | |
5387 case 0x001d: { | |
5388 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); | |
5389 } break; | |
5390 case 0x0021: { | |
5391 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); | |
5392 } break; | |
5393 case 0x0023: { | |
5394 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5395 } break; | |
5396 default: { | |
5397 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5398 } break; | |
5399 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5400 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5401 g_free(dialog_top); |
5402 g_free(dialog_msg); | |
5403 return 1; | |
5404 } | |
5405 | |
9626 | 5406 if (sn != NULL) { |
4585 | 5407 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
|
5408 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5409 g_free(dialog_msg); |
5410 } | |
5411 | |
9626 | 5412 if (email != NULL) { |
5575 | 5413 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5414 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5415 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5416 g_free(dialog_msg); |
2086 | 5417 } |
5418 | |
5419 return 1; | |
5420 } | |
5421 | |
5575 | 5422 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5423 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5424 aim_flap_nop(od->sess, od->conn); |
2086 | 5425 } |
5426 | |
6059 | 5427 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5428 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5429 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5430 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5431 if (typing == GAIM_TYPING) |
4870 | 5432 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5433 else if (typing == GAIM_TYPED) |
4870 | 5434 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5435 else | |
5436 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5437 else { |
5300 | 5438 /* Don't send if this turkey is in our deny list */ |
5439 GSList *list; | |
5440 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5441 if (!list) { | |
7261 | 5442 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5443 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5444 if (typing == GAIM_TYPING) |
5300 | 5445 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5446 else if (typing == GAIM_TYPED) |
5300 | 5447 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5448 else | |
5449 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5450 } | |
3595 | 5451 } |
5452 } | |
2993 | 5453 return 0; |
5454 } | |
9030 | 5455 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5456 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
|
5457 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5458 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5459 OscarData *od = (OscarData *)gc->proto_data; |
10246 | 5460 GaimAccount *account = gaim_connection_get_account(gc); |
8971 | 5461 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5462 int ret = 0; |
10246 | 5463 const char *iconfile = gaim_account_get_buddy_icon(account); |
8800 | 5464 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5465 |
4838 | 5466 if (dim && dim->connected) { |
5467 /* If we're directly connected, send a direct IM */ | |
6982 | 5468 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5469 } else { |
4738 | 5470 struct buddyinfo *bi; |
3008 | 5471 struct aim_sendimext_args args; |
5472 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5473 gsize len; |
10246 | 5474 GaimConversation *conv; |
5475 | |
5476 conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); | |
8962 | 5477 |
5478 if (strstr(message, "<IMG ")) | |
5479 gaim_conversation_write(conv, "", | |
5480 _("Your IM Image was not sent. " | |
5481 "You must be Direct Connected to send IM Images."), | |
5482 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5483 |
10246 | 5484 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
4738 | 5485 if (!bi) { |
5486 bi = g_new0(struct buddyinfo, 1); | |
10246 | 5487 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
4738 | 5488 } |
5489 | |
3008 | 5490 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5491 if (od->icq) { |
5492 args.features = features_icq; | |
5493 args.featureslen = sizeof(features_icq); | |
3008 | 5494 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5495 } else { |
5496 args.features = features_aim; | |
5497 args.featureslen = sizeof(features_aim); | |
4972 | 5498 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5499 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5500 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5501 } |
4269 | 5502 |
4738 | 5503 if (bi->ico_need) { |
8660 | 5504 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5505 "Sending buddy icon request with message\n"); |
3008 | 5506 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5507 bi->ico_need = FALSE; |
3008 | 5508 } |
4269 | 5509 |
5575 | 5510 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5511 FILE *file = fopen(iconfile, "rb"); |
3008 | 5512 if (file) { |
5513 char *buf = g_malloc(st.st_size); | |
9532 | 5514 /* XXX - Use g_file_get_contents()? */ |
3008 | 5515 fread(buf, 1, st.st_size, file); |
6039 | 5516 fclose(file); |
4269 | 5517 |
3008 | 5518 args.iconlen = st.st_size; |
4617 | 5519 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5520 args.iconstamp = st.st_mtime; |
5521 | |
7406 | 5522 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5523 bi->ico_informed = FALSE; |
7406 | 5524 bi->ico_sent = FALSE; |
5525 } | |
4738 | 5526 |
5527 if (!bi->ico_informed) { | |
8660 | 5528 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5529 "Claiming to have a buddy icon\n"); |
4738 | 5530 args.flags |= AIM_IMFLAGS_HASICON; |
5531 bi->ico_me_len = args.iconlen; | |
5532 bi->ico_me_csum = args.iconsum; | |
5533 bi->ico_me_time = args.iconstamp; | |
5534 bi->ico_informed = TRUE; | |
5535 } | |
5536 | |
3008 | 5537 g_free(buf); |
2086 | 5538 } |
5539 } | |
4269 | 5540 |
3008 | 5541 args.destsn = name; |
4269 | 5542 |
8985 | 5543 /* |
5544 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5545 * strip all HTML | |
5546 */ | |
9975 | 5547 if (aim_sn_is_icq(name) ) { |
8995 | 5548 /* being sent to an ICQ user */ |
10246 | 5549 if (!aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5550 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5551 tmpmsg = gaim_str_add_cr(message); | |
5552 } else { | |
5553 /* from an ICQ user - do nothing */ | |
5554 tmpmsg = g_strdup(message); | |
5555 } | |
5556 } else { | |
5557 /* being sent to an AIM user */ | |
10246 | 5558 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
8995 | 5559 /* from an ICQ user */ |
5560 tmpmsg2 = gaim_strdup_withhtml(message); | |
5561 tmpmsg = gaim_escape_html(tmpmsg2); | |
5562 g_free(tmpmsg2); | |
5563 } else | |
5564 tmpmsg = gaim_strdup_withhtml(message); | |
5565 } | |
6310 | 5566 len = strlen(tmpmsg); |
5567 | |
9830 | 5568 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5569 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5570 args.charset, args.charsubset, args.msglen); | |
4617 | 5571 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5572 g_free((char *)args.msg); |
2086 | 5573 } |
4838 | 5574 |
6310 | 5575 g_free(tmpmsg); |
5576 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5577 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5578 return 1; |
6310 | 5579 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5580 return ret; |
2086 | 5581 } |
5582 | |
7011 | 5583 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5584 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5585 |
9975 | 5586 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5587 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5588 else |
7235 | 5589 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5590 } |
5591 | |
8950 | 5592 #if 0 |
7011 | 5593 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5594 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5595 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5596 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5597 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5598 maiden, NULL, NULL, city, state, NULL, 0, web); |
5599 } | |
8950 | 5600 #endif |
2086 | 5601 |
5575 | 5602 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5603 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5604 aim_srv_setidle(od->sess, time); |
2086 | 5605 } |
5606 | |
5954 | 5607 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5608 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5609 int charset = 0; |
6019 | 5610 char *text_html = NULL; |
5129 | 5611 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5612 gsize msglen = 0; |
2993 | 5613 |
4617 | 5614 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5615 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5616 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5617 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5618 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5619 "again when you are fully connected.")); |
4617 | 5620 |
7334 | 5621 if (!text) { |
5622 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5623 return; | |
5624 } | |
10097 | 5625 |
7334 | 5626 text_html = gaim_strdup_withhtml(text); |
9807 | 5627 charset = oscar_charset_check(text_html); |
9826 | 5628 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5629 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5630 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5631 g_free(msg); | |
9826 | 5632 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5633 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5634 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5635 g_free(msg); | |
5636 } else { | |
5637 msglen = strlen(text_html); | |
5638 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5639 } | |
5640 | |
5641 if (msglen > od->rights.maxsiglen) { | |
5642 gchar *errstr; | |
5643 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5644 "has been exceeded. Gaim has truncated it for you.", | |
5645 "The maximum profile length of %d bytes " | |
5646 "has been exceeded. Gaim has truncated it for you.", | |
5647 od->rights.maxsiglen), od->rights.maxsiglen); | |
5648 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5649 g_free(errstr); | |
5650 } | |
5651 | |
5652 g_free(text_html); | |
2993 | 5653 |
5654 return; | |
2086 | 5655 } |
5656 | |
9991 | 5657 static void |
5658 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5659 { |
9991 | 5660 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5661 OscarData *od = NULL; |
9992 | 5662 GaimStatusType *status_type; |
9991 | 5663 GaimStatusPrimitive primitive; |
5664 GaimPresence *presence; | |
5665 const gchar *status_id; | |
9807 | 5666 int charset = 0; |
10196 | 5667 const gchar *text_html = NULL; |
5129 | 5668 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5669 gsize msglen = 0; |
2993 | 5670 |
9992 | 5671 status_type = gaim_status_get_type(status); |
5672 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5673 status_id = gaim_status_get_id(status); |
5674 presence = gaim_account_get_presence(account); | |
5675 | |
10400 | 5676 if (!gaim_status_is_active(status)) /* Is this right? I'm confused. */ |
5677 return; | |
5678 | |
10196 | 5679 gaim_debug_info("oscar", "Setting status to %s\n", status_id); |
5680 | |
10400 | 5681 if (gc) |
5682 od = (OscarData *)gc->proto_data; | |
10401 | 5683 |
5684 if ((od == NULL) || (od->rights.maxawaymsglen == 0)) { | |
9991 | 5685 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
10400 | 5686 _("You have probably requested to set your " |
5687 "away message before the login procedure " | |
5688 "completed. You remain in a \"present\" " | |
5689 "state; try setting it again when you are " | |
5690 "fully connected.")); | |
10401 | 5691 return; |
5692 } | |
5129 | 5693 |
9992 | 5694 if (primitive == GAIM_STATUS_AVAILABLE) { |
10197 | 5695 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5696 | |
7334 | 5697 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
10198 | 5698 |
5699 text_html = gaim_status_get_attr_string(status, "message"); | |
5700 if (text_html != NULL) { | |
5701 aim_srv_setavailmsg(od->sess, text_html); | |
5702 } | |
10196 | 5703 |
5704 } else if (primitive == GAIM_STATUS_AWAY) { | |
10197 | 5705 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5706 | |
10196 | 5707 text_html = gaim_status_get_attr_string(status, "message"); |
5708 | |
5709 if (text_html == NULL) { | |
5710 text_html = _("Away"); | |
5711 } | |
5712 | |
5713 charset = oscar_charset_check(text_html); | |
5714 if (charset == AIM_CHARSET_UNICODE) { | |
5715 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
5716 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | |
5717 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5718 g_free(msg); | |
5719 } else if (charset == AIM_CHARSET_CUSTOM) { | |
5720 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
5721 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | |
5722 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5723 g_free(msg); | |
5724 } else { | |
5725 msglen = strlen(text_html); | |
5726 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | |
5727 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); | |
5728 } | |
5729 | |
5730 if (msglen > od->rights.maxawaymsglen) { | |
5731 gchar *errstr; | |
5732 | |
5733 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
5734 "has been exceeded. Gaim has truncated it for you.", | |
5735 "The maximum away message length of %d bytes " | |
5736 "has been exceeded. Gaim has truncated it for you.", | |
5737 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5738 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
5739 g_free(errstr); | |
5740 } | |
5741 | |
10197 | 5742 } else if (primitive == GAIM_STATUS_HIDDEN) { |
5743 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
5744 | |
5129 | 5745 } else { |
10196 | 5746 gaim_debug_info("oscar", "Don't know what to do for this status\n"); |
5747 | |
5748 } | |
2993 | 5749 } |
5750 | |
9991 | 5751 static void |
5752 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5753 { |
9991 | 5754 GaimConnection *gc = gaim_account_get_connection(account); |
5755 OscarData *od = (OscarData *)gc->proto_data; | |
5756 const gchar *status_id = gaim_status_get_id(status); | |
5757 | |
5758 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5759 account->perm_deny = 4; |
8265 | 5760 else |
5575 | 5761 account->perm_deny = 3; |
9991 | 5762 |
8265 | 5763 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5764 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5765 |
9991 | 5766 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5767 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5768 |
5769 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5770 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5771 |
5772 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5773 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5774 |
5775 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5776 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5777 |
5778 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5779 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5780 |
5781 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5782 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5783 |
5784 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5785 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5786 |
5787 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5788 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5789 |
5790 return; | |
5791 } | |
5792 | |
9991 | 5793 static void |
5794 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5795 { |
9991 | 5796 GaimConnection *gc = gaim_account_get_connection(account); |
10400 | 5797 GaimStatusType *type = gaim_status_get_type(status); |
5798 int primitive = gaim_status_type_get_primitive(type); | |
5799 | |
10485 | 5800 if(!gaim_status_is_active(status)) |
5801 return; | |
5802 | |
10400 | 5803 if (primitive == !GAIM_STATUS_OFFLINE && !gc) { |
5804 gaim_account_connect(account, status); | |
5805 } else if (primitive == GAIM_STATUS_OFFLINE && gc) { | |
5806 gaim_account_disconnect(account); | |
5807 } else { | |
5808 | |
5809 if (aim_sn_is_icq(gaim_account_get_username(account))) | |
5810 oscar_set_status_icq(account, status); | |
5811 else | |
5812 oscar_set_status_aim(account, status); | |
5813 } | |
2993 | 5814 return; |
2086 | 5815 } |
5816 | |
9991 | 5817 static void |
5818 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5819 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5820 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5821 } |
5822 | |
9285 | 5823 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5824 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5825 |
5826 if (!aim_snvalid(buddy->name)) { | |
8092 | 5827 gchar *buf; |
9285 | 5828 buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name); |
9627 | 5829 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5830 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5831 g_free(buf); |
8150 | 5832 |
5833 /* Remove from local list */ | |
9285 | 5834 gaim_blist_remove_buddy(buddy); |
8150 | 5835 |
8092 | 5836 return; |
5837 } | |
5838 | |
4230 | 5839 #ifdef NOSSI |
9285 | 5840 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5841 #else |
9285 | 5842 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5843 if (buddy && group) { | |
8660 | 5844 gaim_debug_info("oscar", |
9285 | 5845 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5846 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5847 } |
5848 } | |
5849 #endif | |
8150 | 5850 |
10157 | 5851 /* XXX - Should this be done from AIM accounts, as well? */ |
4759 | 5852 if (od->icq) |
9285 | 5853 aim_icq_getalias(od->sess, buddy->name); |
5854 } | |
5855 | |
5856 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5857 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5858 #ifdef NOSSI |
5859 char buf[MSG_LEN]; | |
5860 int n=0; | |
9285 | 5861 |
4230 | 5862 while (buddies) { |
9381 | 5863 GaimBuddy *buddy = buddies->data; |
4230 | 5864 if (n > MSG_LEN - 18) { |
7285 | 5865 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5866 n = 0; |
3092 | 5867 } |
9381 | 5868 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5869 buddies = buddies->next; |
5870 } | |
7285 | 5871 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5872 #else |
9285 | 5873 |
4230 | 5874 if (od->sess->ssi.received_data) { |
9285 | 5875 GList *curb = buddies; |
5876 GList *curg = groups; | |
5877 while ((curb != NULL) && (curg != NULL)) { | |
5878 GaimBuddy *buddy = curb->data; | |
5879 GaimGroup *group = curg->data; | |
5880 oscar_add_buddy(gc, buddy, group); | |
5881 curb = curb->next; | |
5882 curg = curg->next; | |
4230 | 5883 } |
5884 } | |
5885 #endif | |
5886 } | |
5887 | |
9285 | 5888 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5889 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5890 |
4230 | 5891 #ifdef NOSSI |
9285 | 5892 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5893 #else |
5894 if (od->sess->ssi.received_data) { | |
8660 | 5895 gaim_debug_info("oscar", |
9285 | 5896 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5897 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5898 } |
5899 #endif | |
5900 } | |
5901 | |
9285 | 5902 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5903 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5904 |
4230 | 5905 #ifdef NOSSI |
9285 | 5906 for (cur = buddies; cur != NULL; cur = cur->next) { |
5907 GaimBuddy *buddy = cur->data; | |
5908 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5909 } | |
4230 | 5910 #else |
5911 if (od->sess->ssi.received_data) { | |
9285 | 5912 GList *curb = buddies; |
5913 GList *curg = groups; | |
5914 while ((curb != NULL) && (curg != NULL)) { | |
5915 GaimBuddy *buddy = curb->data; | |
5916 GaimGroup *group = curg->data; | |
5917 oscar_remove_buddy(gc, buddy, group); | |
5918 curb = curb->next; | |
5919 curg = curg->next; | |
3092 | 5920 } |
4230 | 5921 } |
5922 #endif | |
5923 } | |
5924 | |
5925 #ifndef NOSSI | |
5575 | 5926 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5927 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5928 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5929 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5930 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5931 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5932 } |
5933 } | |
5934 | |
5575 | 5935 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5936 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5937 if (od->sess->ssi.received_data) { |
5938 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5939 if (gname) { | |
8660 | 5940 gaim_debug_info("oscar", |
9586 | 5941 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5942 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5943 } |
5944 } | |
5945 } | |
5946 | |
9285 | 5947 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5948 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5949 |
5950 if (od->sess->ssi.received_data) { | |
9285 | 5951 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5952 GList *cur, *groups = NULL; | |
5953 | |
5954 /* Make a list of what the groups each buddy is in */ | |
5955 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5956 GaimBlistNode *node = cur->data; | |
5957 groups = g_list_append(groups, node->parent); | |
5958 } | |
5959 | |
5960 oscar_remove_buddies(gc, moved_buddies, groups); | |
5961 oscar_add_buddies(gc, moved_buddies, groups); | |
5962 g_list_free(groups); | |
8660 | 5963 gaim_debug_info("oscar", |
9285 | 5964 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5965 } else { |
9285 | 5966 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5967 gaim_debug_info("oscar", |
9285 | 5968 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5969 } |
5970 } | |
5971 } | |
5972 | |
5968 | 5973 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5974 aim_session_t *sess = data; | |
6350 | 5975 aim_ssi_reqdata(sess); |
5968 | 5976 return FALSE; |
5977 } | |
5978 | |
4642 | 5979 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5980 GaimConnection *gc = sess->aux_data; |
7283 | 5981 OscarData *od = gc->proto_data; |
4642 | 5982 va_list ap; |
5983 fu16_t reason; | |
5984 | |
5985 va_start(ap, fr); | |
5986 reason = (fu16_t)va_arg(ap, unsigned int); | |
5987 va_end(ap); | |
5988 | |
8660 | 5989 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5990 |
5991 if (reason == 0x0005) { | |
5892 | 5992 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5993 _("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
|
5994 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5995 } |
5996 | |
5997 /* Activate SSI */ | |
5998 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5999 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6000 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 6001 aim_ssi_enable(od->sess); |
6002 | |
6003 return 1; | |
6004 } | |
6005 | |
2991 | 6006 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6007 GaimConnection *gc = sess->aux_data; |
7283 | 6008 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 6009 int i; |
6010 va_list ap; | |
6011 int numtypes; | |
4230 | 6012 fu16_t *maxitems; |
2991 | 6013 |
6014 va_start(ap, fr); | |
4230 | 6015 numtypes = va_arg(ap, int); |
6016 maxitems = va_arg(ap, fu16_t *); | |
2991 | 6017 va_end(ap); |
6018 | |
8660 | 6019 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6020 |
4230 | 6021 for (i=0; i<numtypes; i++) |
8660 | 6022 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6023 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6024 |
8660 | 6025 gaim_debug_misc(NULL, "\n"); |
4230 | 6026 |
6027 if (numtypes >= 0) | |
6028 od->rights.maxbuddies = maxitems[0]; | |
6029 if (numtypes >= 1) | |
6030 od->rights.maxgroups = maxitems[1]; | |
6031 if (numtypes >= 2) | |
6032 od->rights.maxpermits = maxitems[2]; | |
6033 if (numtypes >= 3) | |
6034 od->rights.maxdenies = maxitems[3]; | |
2991 | 6035 |
6036 return 1; | |
6037 } | |
6038 | |
6039 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6040 GaimConnection *gc = sess->aux_data; |
6041 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 6042 GaimStatus *status; |
7283 | 6043 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 6044 GaimGroup *g; |
6045 GaimBuddy *b; | |
2995 | 6046 struct aim_ssi_item *curitem; |
2991 | 6047 int tmp; |
4230 | 6048 va_list ap; |
8219 | 6049 fu16_t fmtver, numitems; |
6050 struct aim_ssi_item *items; | |
6051 fu32_t timestamp; | |
4230 | 6052 |
6053 va_start(ap, fr); | |
6054 fmtver = (fu16_t)va_arg(ap, int); | |
6055 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 6056 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 6057 timestamp = va_arg(ap, fu32_t); |
8219 | 6058 va_end(ap); |
2991 | 6059 |
8660 | 6060 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6061 "ssi: syncing local list and server list\n"); |
2991 | 6062 |
8219 | 6063 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 6064 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 | 6065 return 1; |
6066 } | |
6067 | |
2991 | 6068 /* Clean the buddy list */ |
4889 | 6069 aim_ssi_cleanlist(sess); |
2991 | 6070 |
8150 | 6071 { /* If not in server list then prune from local list */ |
6072 GaimBlistNode *gnode, *cnode, *bnode; | |
6073 GaimBuddyList *blist; | |
9539 | 6074 GSList *cur, *next; |
8150 | 6075 |
6076 /* Buddies */ | |
6077 cur = NULL; | |
6078 if ((blist = gaim_get_blist()) != NULL) { | |
6079 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
6080 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
6081 continue; | |
6082 g = (GaimGroup *)gnode; | |
6083 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
6084 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
6085 continue; | |
6086 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
6087 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6088 continue; | |
6089 b = (GaimBuddy *)bnode; | |
6090 if (b->account == gc->account) { | |
6091 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
6092 /* If the buddy is an ICQ user then load his nickname */ | |
6093 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 6094 char *alias; |
8150 | 6095 if (servernick) |
6096 serv_got_alias(gc, b->name, servernick); | |
6097 | |
6098 /* Store local alias on server */ | |
8214 | 6099 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 6100 if (!alias && b->alias && strlen(b->alias)) |
6101 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
6102 free(alias); | |
6103 } else { | |
8660 | 6104 gaim_debug_info("oscar", |
8150 | 6105 "ssi: removing buddy %s from local list\n", b->name); |
6106 /* We can't actually remove now because it will screw up our looping */ | |
6107 cur = g_slist_prepend(cur, b); | |
6108 } | |
6109 } | |
6110 } | |
6111 } | |
6112 } | |
6113 } | |
8175 | 6114 |
8150 | 6115 while (cur != NULL) { |
6116 b = cur->data; | |
6117 cur = g_slist_remove(cur, b); | |
6118 gaim_blist_remove_buddy(b); | |
6119 } | |
6120 | |
6121 /* Permit list */ | |
6122 if (gc->account->permit) { | |
9539 | 6123 next = gc->account->permit; |
6124 while (next != NULL) { | |
6125 cur = next; | |
6126 next = next->next; | |
8150 | 6127 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 6128 gaim_debug_info("oscar", |
8150 | 6129 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
6130 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
6131 } | |
9539 | 6132 } |
8150 | 6133 } |
6134 | |
6135 /* Deny list */ | |
6136 if (gc->account->deny) { | |
9539 | 6137 next = gc->account->deny; |
6138 while (next != NULL) { | |
6139 cur = next; | |
6140 next = next->next; | |
8150 | 6141 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6142 gaim_debug_info("oscar", |
8150 | 6143 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6144 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6145 } | |
9539 | 6146 } |
8150 | 6147 } |
6148 /* Presence settings (idle time visibility) */ | |
6149 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6150 if (!(tmp & 0x400)) | |
6151 aim_ssi_setpresence(sess, tmp | 0x400); | |
6152 } /* end pruning buddies from local list */ | |
6153 | |
2991 | 6154 /* Add from server list to local list */ |
4230 | 6155 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6156 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6157 switch (curitem->type) { |
4230 | 6158 case 0x0000: { /* Buddy */ |
4251 | 6159 if (curitem->name) { |
4292 | 6160 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6161 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6162 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6163 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6164 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6165 /* Should gname be freed here? -- elb */ |
4754 | 6166 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6167 free(alias); |
8150 | 6168 if (b) { |
4292 | 6169 /* Get server stored alias */ |
4705 | 6170 if (alias_utf8) { |
8150 | 6171 g_free(b->alias); |
6172 b->alias = g_strdup(alias_utf8); | |
4705 | 6173 } |
4282 | 6174 } else { |
8150 | 6175 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6176 |
4754 | 6177 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6178 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6179 gaim_blist_add_group(g, NULL); |
6180 } | |
5146 | 6181 |
8660 | 6182 gaim_debug_info("oscar", |
9285 | 6183 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6184 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6185 } |
8341 | 6186 if (!aim_sncmp(curitem->name, account->username)) { |
6187 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6188 gaim_check_comment(od, comment); | |
6189 free(comment); | |
6190 } | |
7162 | 6191 g_free(gname_utf8); |
6192 g_free(alias_utf8); | |
2991 | 6193 } |
4230 | 6194 } break; |
6195 | |
6196 case 0x0001: { /* Group */ | |
4282 | 6197 /* Shouldn't add empty groups */ |
4230 | 6198 } break; |
6199 | |
6200 case 0x0002: { /* Permit buddy */ | |
2991 | 6201 if (curitem->name) { |
4230 | 6202 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6203 GSList *list; |
5575 | 6204 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6205 if (!list) { |
8660 | 6206 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6207 "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
|
6208 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6209 } |
6210 } | |
4230 | 6211 } break; |
6212 | |
6213 case 0x0003: { /* Deny buddy */ | |
2991 | 6214 if (curitem->name) { |
6215 GSList *list; | |
5575 | 6216 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6217 if (!list) { |
8660 | 6218 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6219 "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
|
6220 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6221 } |
6222 } | |
4230 | 6223 } break; |
6224 | |
6225 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6226 if (curitem->data) { |
6227 fu8_t permdeny; | |
5575 | 6228 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6229 gaim_debug_info("oscar", |
5575 | 6230 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6231 account->perm_deny = permdeny; | |
6232 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6233 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6234 } |
2991 | 6235 } |
6236 } | |
4230 | 6237 } break; |
6238 | |
6239 case 0x0005: { /* Presence setting */ | |
3109 | 6240 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6241 } break; |
2991 | 6242 } /* End of switch on curitem->type */ |
6243 } /* End of for loop */ | |
4230 | 6244 |
9991 | 6245 /* |
6246 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6247 * this. We probably want the SSI status setting to override the local | |
6248 * setting. | |
6249 */ | |
9982 | 6250 status = gaim_presence_get_active_status(account->presence); |
6251 if (gaim_status_is_available(status)) | |
4901 | 6252 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6253 | |
4342 | 6254 /* Activate SSI */ |
6255 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6256 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6257 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6258 "ssi: activating server-stored buddy list\n"); |
4642 | 6259 aim_ssi_enable(sess); |
4342 | 6260 |
2991 | 6261 return 1; |
2086 | 6262 } |
4230 | 6263 |
6264 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6265 GaimConnection *gc = sess->aux_data; |
4230 | 6266 va_list ap; |
6267 struct aim_ssi_tmp *retval; | |
6268 | |
6269 va_start(ap, fr); | |
6270 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6271 va_end(ap); | |
6272 | |
6273 while (retval) { | |
8660 | 6274 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6275 "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 | 6276 |
6277 if (retval->ack != 0xffff) | |
6278 switch (retval->ack) { | |
6279 case 0x0000: { /* added successfully */ | |
6280 } break; | |
6281 | |
4829 | 6282 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6283 gchar *buf; | |
6284 buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)"))); | |
9758 | 6285 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6286 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6287 g_free(buf); |
6288 } | |
6289 | |
7023 | 6290 case 0x000e: { /* buddy requires authorization */ |
4828 | 6291 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6292 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6293 } break; |
6294 | |
6295 default: { /* La la la */ | |
5197 | 6296 gchar *buf; |
8660 | 6297 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6298 buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason. The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)"))); |
9758 | 6299 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6300 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6301 g_free(buf); |
4230 | 6302 } break; |
6303 } | |
6304 | |
6305 retval = retval->next; | |
6306 } | |
6307 | |
6308 return 1; | |
6309 } | |
6310 | |
8227 | 6311 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6312 GaimConnection *gc = sess->aux_data; | |
6313 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6314 GaimBuddy *b; | |
6315 GaimGroup *g; | |
6316 va_list ap; | |
6317 fu16_t type; | |
6318 const char *name; | |
6319 | |
6320 va_start(ap, fr); | |
6321 type = (fu16_t)va_arg(ap, int); | |
6322 name = va_arg(ap, char *); | |
6323 va_end(ap); | |
6324 | |
6325 if ((type != 0x0000) || (name == NULL)) | |
6326 return 1; | |
6327 | |
6328 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6329 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6330 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6331 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6332 b = gaim_find_buddy(gc->account, name); | |
6333 free(alias); | |
6334 | |
6335 if (b) { | |
6336 /* Get server stored alias */ | |
6337 if (alias_utf8) { | |
6338 g_free(b->alias); | |
6339 b->alias = g_strdup(alias_utf8); | |
6340 } | |
6341 } else { | |
6342 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6343 | |
6344 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6345 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6346 gaim_blist_add_group(g, NULL); | |
6347 } | |
6348 | |
8660 | 6349 gaim_debug_info("oscar", |
9285 | 6350 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6351 gaim_blist_add_buddy(b, NULL, g, NULL); |
6352 } | |
6353 g_free(gname_utf8); | |
6354 g_free(alias_utf8); | |
6355 | |
6356 return 1; | |
6357 } | |
6358 | |
4230 | 6359 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6360 GaimConnection *gc = sess->aux_data; |
4230 | 6361 va_list ap; |
6362 char *sn, *msg; | |
4236 | 6363 gchar *dialog_msg, *nombre; |
4230 | 6364 struct name_data *data; |
6695 | 6365 GaimBuddy *buddy; |
4230 | 6366 |
6367 va_start(ap, fr); | |
6368 sn = va_arg(ap, char *); | |
6369 msg = va_arg(ap, char *); | |
6370 va_end(ap); | |
6371 | |
8660 | 6372 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6373 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6374 |
4687 | 6375 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6376 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6377 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6378 else |
6379 nombre = g_strdup(sn); | |
6380 | |
6381 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 | 6382 data = g_new(struct name_data, 1); |
6383 data->gc = gc; | |
6384 data->name = g_strdup(sn); | |
6385 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6386 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6387 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
10116 | 6388 GAIM_DEFAULT_ACTION_NONE, data, |
7023 | 6389 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6390 G_CALLBACK(oscar_free_name_data)); |
4236 | 6391 |
4230 | 6392 g_free(dialog_msg); |
4236 | 6393 g_free(nombre); |
4230 | 6394 |
6395 return 1; | |
6396 } | |
6397 | |
6398 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6399 GaimConnection *gc = sess->aux_data; |
4230 | 6400 va_list ap; |
6401 char *sn, *msg; | |
4236 | 6402 gchar *dialog_msg, *nombre; |
4230 | 6403 struct name_data *data; |
6695 | 6404 GaimBuddy *buddy; |
4230 | 6405 |
6406 va_start(ap, fr); | |
6407 sn = va_arg(ap, char *); | |
6408 msg = va_arg(ap, char *); | |
6409 va_end(ap); | |
6410 | |
8660 | 6411 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6412 "ssi: received authorization request from %s\n", sn); |
4230 | 6413 |
4687 | 6414 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6415 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6416 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6417 else |
6418 nombre = g_strdup(sn); | |
6419 | |
4337 | 6420 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 | 6421 data = g_new(struct name_data, 1); |
6422 data->gc = gc; | |
6423 data->name = g_strdup(sn); | |
6424 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6425 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6426 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6427 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6428 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6429 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6430 |
4230 | 6431 g_free(dialog_msg); |
4236 | 6432 g_free(nombre); |
4230 | 6433 |
6434 return 1; | |
6435 } | |
6436 | |
6437 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6438 GaimConnection *gc = sess->aux_data; |
4230 | 6439 va_list ap; |
6440 char *sn, *msg; | |
4236 | 6441 gchar *dialog_msg, *nombre; |
4230 | 6442 fu8_t reply; |
6695 | 6443 GaimBuddy *buddy; |
4230 | 6444 |
6445 va_start(ap, fr); | |
6446 sn = va_arg(ap, char *); | |
6447 reply = (fu8_t)va_arg(ap, int); | |
6448 msg = va_arg(ap, char *); | |
6449 va_end(ap); | |
6450 | |
8660 | 6451 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6452 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6453 |
4687 | 6454 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6455 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6456 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6457 else |
6458 nombre = g_strdup(sn); | |
6459 | |
4230 | 6460 if (reply) { |
6461 /* Granted */ | |
7023 | 6462 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
|
6463 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6464 } else { |
6465 /* Denied */ | |
7023 | 6466 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
|
6467 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6468 } |
6469 g_free(dialog_msg); | |
4236 | 6470 g_free(nombre); |
4230 | 6471 |
6472 return 1; | |
6473 } | |
6474 | |
6475 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6476 GaimConnection *gc = sess->aux_data; |
4230 | 6477 va_list ap; |
6478 char *sn; | |
6695 | 6479 GaimBuddy *buddy; |
4230 | 6480 |
6481 va_start(ap, fr); | |
6482 sn = va_arg(ap, char *); | |
6483 va_end(ap); | |
6484 | |
4687 | 6485 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6486 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6487 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6488 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6489 |
6490 return 1; | |
6491 } | |
4269 | 6492 #endif |
2086 | 6493 |
5575 | 6494 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6495 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6496 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6497 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6498 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6499 pce->label = _("_Room:"); |
5234 | 6500 pce->identifier = "room"; |
10475 | 6501 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6502 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6503 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6504 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6505 pce->label = _("_Exchange:"); |
5234 | 6506 pce->identifier = "exchange"; |
10475 | 6507 pce->required = TRUE; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6508 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6509 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6510 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6511 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6512 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6513 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6514 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6515 |
9754 | 6516 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6517 { | |
6518 GHashTable *defaults; | |
6519 | |
6520 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6521 | |
6522 if (chat_name != NULL) | |
6523 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6524 | |
6525 return defaults; | |
6526 } | |
6527 | |
9917 | 6528 static char *oscar_get_chat_name(GHashTable *data) { |
6529 return g_strdup(g_hash_table_lookup(data, "room")); | |
6530 } | |
6531 | |
8308 | 6532 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6533 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6534 aim_conn_t *cur; |
5234 | 6535 char *name, *exchange; |
6536 | |
6537 name = g_hash_table_lookup(data, "room"); | |
6538 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6539 |
8660 | 6540 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6541 "Attempting to join chat room %s.\n", name); |
8308 | 6542 |
6543 if ((name == NULL) || (*name == '\0')) { | |
6544 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6545 return; | |
6546 } | |
6547 | |
4617 | 6548 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6549 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6550 "chatnav exists, creating room\n"); |
5234 | 6551 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6552 } else { |
6553 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6554 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6555 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6556 "chatnav does not exist, opening chatnav\n"); |
5234 | 6557 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6558 cr->name = g_strdup(name); |
4617 | 6559 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6560 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6561 } |
6562 } | |
6563 | |
8308 | 6564 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6565 OscarData *od = (OscarData *)gc->proto_data; | |
6566 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
10404 | 6567 |
6568 if (ccon == NULL) | |
2086 | 6569 return; |
10404 | 6570 |
8225 | 6571 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6572 ccon->exchange, ccon->name, 0x0); |
6573 } | |
6574 | |
10458 | 6575 static void |
6576 oscar_chat_leave(GaimConnection *gc, int id) | |
6577 { | |
6578 GaimConversation *conv; | |
6579 struct chat_connection *cc; | |
6580 | |
6581 conv = gaim_find_chat(gc, id); | |
6582 | |
6583 g_return_if_fail(conv != NULL); | |
6584 | |
6585 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
6586 | |
6587 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
6588 oscar_chat_kill(gc, cc); | |
2086 | 6589 } |
6590 | |
8219 | 6591 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6592 OscarData *od = (OscarData *)gc->proto_data; | |
6593 GaimConversation *conv = NULL; | |
2086 | 6594 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6595 char *buf, *buf2; |
9830 | 6596 fu16_t charset, charsubset; |
9807 | 6597 char *charsetstr = NULL; |
10111 | 6598 int len; |
8219 | 6599 |
6600 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6601 return -EINVAL; |
2086 | 6602 |
8219 | 6603 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6604 return -EINVAL; |
2086 | 6605 |
8219 | 6606 buf = gaim_strdup_withhtml(message); |
6607 len = strlen(buf); | |
6608 | |
8962 | 6609 if (strstr(buf, "<IMG ")) |
6610 gaim_conversation_write(conv, "", | |
6611 _("Your IM Image was not sent. " | |
6612 "You cannot send IM Images in AIM chats."), | |
6613 GAIM_MESSAGE_ERROR, time(NULL)); | |
6614 | |
9830 | 6615 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6616 if ((len > c->maxlen) || (len > c->maxvis)) { |
6617 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6618 return -E2BIG; |
8359 | 6619 } |
6620 | |
9831 | 6621 if (charset == AIM_CHARSET_ASCII) |
6622 charsetstr = "us-ascii"; | |
6623 else if (charset == AIM_CHARSET_UNICODE) | |
6624 charsetstr = "unicode-2-0"; | |
6625 else if (charset == AIM_CHARSET_CUSTOM) | |
6626 charsetstr = "iso-8859-1"; | |
9807 | 6627 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6628 g_free(buf2); |
8359 | 6629 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6630 return 0; |
2086 | 6631 } |
6632 | |
10042 | 6633 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
6634 { | |
4766 | 6635 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6636 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6637 return "icq"; |
6638 else | |
6639 return "aim"; | |
6640 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6641 |
9975 | 6642 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6643 return "icq"; |
6644 return "aim"; | |
6645 } | |
6646 | |
9972 | 6647 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6648 { |
7334 | 6649 GaimConnection *gc = NULL; |
6650 OscarData *od = NULL; | |
10042 | 6651 GaimAccount *account = NULL; |
6652 GaimPresence *presence; | |
6653 GaimStatus *status; | |
6654 const char *status_id; | |
4687 | 6655 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6656 int i = 0; | |
7334 | 6657 aim_userinfo_t *userinfo = NULL; |
6658 | |
6659 if (b != NULL) | |
6660 account = b->account; | |
6661 if (account != NULL) | |
6662 gc = account->gc; | |
6663 if (gc != NULL) | |
6664 od = gc->proto_data; | |
7945 | 6665 if (od != NULL) |
6666 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6667 |
10042 | 6668 presence = gaim_buddy_get_presence(b); |
6669 status = gaim_presence_get_active_status(presence); | |
6670 status_id = gaim_status_get_id(status); | |
6671 | |
6672 if (gaim_presence_is_online(presence) == FALSE) { | |
5131 | 6673 char *gname; |
7334 | 6674 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6675 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6676 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6677 emblems[i++] = "notauthorized"; | |
6678 } else { | |
6679 emblems[i++] = "offline"; | |
6680 } | |
6681 } | |
4916 | 6682 |
10042 | 6683 if (b->name && aim_sn_is_icq(b->name)) { |
6684 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
6685 emblems[i++] = "invisible"; | |
6686 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4960 | 6687 emblems[i++] = "freeforchat"; |
10042 | 6688 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
4960 | 6689 emblems[i++] = "dnd"; |
10042 | 6690 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
4960 | 6691 emblems[i++] = "na"; |
10042 | 6692 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
4960 | 6693 emblems[i++] = "occupied"; |
10042 | 6694 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
4766 | 6695 emblems[i++] = "away"; |
10042 | 6696 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
6697 emblems[i++] = "away"; | |
6698 } | |
6699 | |
6700 if (userinfo != NULL ) { | |
6701 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
6702 emblems[i++] = "unconfirmed"; */ | |
6703 if (userinfo->flags & AIM_FLAG_ADMINISTRATOR) | |
6704 emblems[i++] = "admin"; | |
6705 if (userinfo->flags & AIM_FLAG_AOL) | |
6706 emblems[i++] = "aol"; | |
6707 if (userinfo->flags & AIM_FLAG_WIRELESS) | |
6708 emblems[i++] = "wireless"; | |
6709 if (userinfo->flags & AIM_FLAG_ACTIVEBUDDY) | |
6710 emblems[i++] = "activebuddy"; | |
6711 | |
6712 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
7945 | 6713 emblems[i++] = "hiptop"; |
6714 | |
10042 | 6715 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
7334 | 6716 emblems[i++] = "secure"; |
10042 | 6717 } |
7334 | 6718 |
4687 | 6719 *se = emblems[0]; |
6720 *sw = emblems[1]; | |
6721 *nw = emblems[2]; | |
6722 *ne = emblems[3]; | |
6723 } | |
6724 | |
6695 | 6725 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6726 GaimConnection *gc = b->account->gc; |
7283 | 6727 OscarData *od = gc->proto_data; |
7045 | 6728 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6729 GString *str = g_string_new(""); |
5131 | 6730 |
6731 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6732 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6733 |
6734 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6735 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6736 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6737 g_free(charset); |
7011 | 6738 if (away_utf8 != NULL) { |
7091 | 6739 gchar *tmp1, *tmp2; |
9627 | 6740 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6741 g_free(away_utf8); |
8571 | 6742 tmp1 = gaim_escape_html(tmp2); |
7091 | 6743 g_free(tmp2); |
8700 | 6744 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6745 g_free(tmp1); |
8701 | 6746 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6747 g_free(tmp2); |
5836 | 6748 } |
5131 | 6749 } |
8701 | 6750 } |
6751 | |
6752 return g_string_free(str, FALSE); | |
5131 | 6753 } |
6754 | |
10042 | 6755 static char *oscar_status_text(GaimBuddy *b) |
6756 { | |
6757 GaimConnection *gc; | |
6758 OscarData *od; | |
6759 GaimStatus *status; | |
5167 | 6760 gchar *ret = NULL; |
6761 | |
10042 | 6762 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
6763 od = gc->proto_data; | |
6764 status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); | |
6765 | |
6766 if (gaim_status_is_available(status) == FALSE || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6767 if (aim_sn_is_icq(b->name)) |
8701 | 6768 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6769 else |
6770 ret = g_strdup(_("Away")); | |
5836 | 6771 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6772 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
10116 | 6773 if ((bi != NULL) && (bi->availmsg != NULL)) |
6292 | 6774 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); |
5836 | 6775 } else { |
5167 | 6776 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6777 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6778 ret = g_strdup(_("Not Authorized")); | |
6779 else | |
6780 ret = g_strdup(_("Offline")); | |
6781 } | |
6782 | |
6783 return ret; | |
6784 } | |
6785 | |
5842 | 6786 |
5844 | 6787 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6788 GaimConnection *gc = sess->aux_data; |
7283 | 6789 OscarData *od = gc->proto_data; |
5892 | 6790 va_list ap; |
5842 | 6791 fu16_t type; |
5892 | 6792 fu8_t flags = 0, length = 0; |
6793 char *md5 = NULL; | |
6794 | |
7334 | 6795 |
5842 | 6796 va_start(ap, fr); |
6797 type = va_arg(ap, int); | |
5892 | 6798 |
6799 switch(type) { | |
6800 case 0x0000: | |
6801 case 0x0001: { | |
6802 flags = va_arg(ap, int); | |
6803 length = va_arg(ap, int); | |
6804 md5 = va_arg(ap, char *); | |
6805 | |
6806 if (flags == 0x41) { | |
6807 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6808 od->iconconnecting = TRUE; | |
6809 od->set_icon = TRUE; | |
6810 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6811 } else { | |
6039 | 6812 struct stat st; |
6813 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6814 if (iconfile == NULL) { | |
8363 | 6815 aim_ssi_delicon(od->sess); |
6039 | 6816 } else if (!stat(iconfile, &st)) { |
6817 char *buf = g_malloc(st.st_size); | |
6818 FILE *file = fopen(iconfile, "rb"); | |
6819 if (file) { | |
9532 | 6820 /* XXX - Use g_file_get_contents()? */ |
6039 | 6821 fread(buf, 1, st.st_size, file); |
6822 fclose(file); | |
8660 | 6823 gaim_debug_info("oscar", |
10042 | 6824 "Uploading icon to icon server\n"); |
6879 | 6825 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6826 } else |
8660 | 6827 gaim_debug_error("oscar", |
10042 | 6828 "Can't open buddy icon file!\n"); |
6039 | 6829 g_free(buf); |
6830 } else { | |
8660 | 6831 gaim_debug_error("oscar", |
10042 | 6832 "Can't stat buddy icon file!\n"); |
5892 | 6833 } |
6834 } | |
8363 | 6835 } else if (flags == 0x81) { |
6836 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6837 if (iconfile == NULL) | |
6838 aim_ssi_delicon(od->sess); | |
6839 else | |
6840 aim_ssi_seticon(od->sess, md5, length); | |
6841 } | |
5892 | 6842 } break; |
6843 | |
6844 case 0x0002: { /* We just set an "available" message? */ | |
6845 } break; | |
6846 } | |
6847 | |
5842 | 6848 va_end(ap); |
5844 | 6849 |
6850 return 0; | |
5842 | 6851 } |
5892 | 6852 |
5575 | 6853 static void oscar_set_permit_deny(GaimConnection *gc) { |
6854 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6855 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6856 #ifdef NOSSI |
8143 | 6857 GSList *list; |
4230 | 6858 char buf[MAXMSGLEN]; |
6859 int at; | |
6860 | |
5575 | 6861 switch(account->perm_deny) { |
8175 | 6862 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6863 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6864 break; |
8175 | 6865 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6866 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6867 break; |
8175 | 6868 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6869 list = account->permit; |
4230 | 6870 at = 0; |
6871 while (list) { | |
6872 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6873 list = list->next; | |
6874 } | |
6875 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6876 break; | |
8175 | 6877 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6878 list = account->deny; |
4230 | 6879 at = 0; |
6880 while (list) { | |
6881 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6882 list = list->next; | |
6883 } | |
6884 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6885 break; | |
6886 default: | |
6887 break; | |
2086 | 6888 } |
4230 | 6889 #else |
8175 | 6890 if (od->sess->ssi.received_data) { |
6891 switch (account->perm_deny) { | |
6892 case GAIM_PRIVACY_ALLOW_ALL: | |
6893 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6894 break; | |
6895 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6896 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6897 break; | |
6898 case GAIM_PRIVACY_ALLOW_USERS: | |
6899 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6900 break; | |
6901 case GAIM_PRIVACY_DENY_ALL: | |
6902 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6903 break; | |
6904 case GAIM_PRIVACY_DENY_USERS: | |
6905 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6906 break; | |
6907 default: | |
6908 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6909 break; | |
6910 } | |
6911 } | |
4230 | 6912 #endif |
2086 | 6913 } |
6914 | |
5575 | 6915 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6916 #ifdef NOSSI |
8143 | 6917 if (gc->account->perm_deny == 3) |
4269 | 6918 oscar_set_permit_deny(gc); |
6919 #else | |
7283 | 6920 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6921 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6922 if (od->sess->ssi.received_data) |
4889 | 6923 aim_ssi_addpermit(od->sess, who); |
4230 | 6924 #endif |
2086 | 6925 } |
6926 | |
5575 | 6927 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6928 #ifdef NOSSI |
8143 | 6929 if (gc->account->perm_deny == 4) |
4269 | 6930 oscar_set_permit_deny(gc); |
6931 #else | |
7283 | 6932 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6933 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6934 if (od->sess->ssi.received_data) |
4889 | 6935 aim_ssi_adddeny(od->sess, who); |
4230 | 6936 #endif |
2086 | 6937 } |
6938 | |
5575 | 6939 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6940 #ifdef NOSSI |
8143 | 6941 if (gc->account->perm_deny == 3) |
4269 | 6942 oscar_set_permit_deny(gc); |
6943 #else | |
7283 | 6944 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6945 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6946 if (od->sess->ssi.received_data) |
4889 | 6947 aim_ssi_delpermit(od->sess, who); |
4230 | 6948 #endif |
2086 | 6949 } |
6950 | |
5575 | 6951 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6952 #ifdef NOSSI |
8143 | 6953 if (gc->account->perm_deny == 4) |
4269 | 6954 oscar_set_permit_deny(gc); |
6955 #else | |
7283 | 6956 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6957 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6958 if (od->sess->ssi.received_data) |
4889 | 6959 aim_ssi_deldeny(od->sess, who); |
4230 | 6960 #endif |
2086 | 6961 } |
6962 | |
9975 | 6963 static GList * |
6964 oscar_status_types(GaimAccount *account) | |
2086 | 6965 { |
9975 | 6966 GList *status_types = NULL; |
6967 GaimStatusType *type; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6968 |
9973 | 6969 g_return_val_if_fail(account != NULL, NULL); |
6970 | |
10042 | 6971 /* Oscar-common status types */ |
9991 | 6972 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6973 OSCAR_STATUS_ID_OFFLINE, | |
10400 | 6974 _("Offline"), FALSE, TRUE, FALSE); |
9976 | 6975 status_types = g_list_append(status_types, type); |
6976 | |
9991 | 6977 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6978 OSCAR_STATUS_ID_ONLINE, | |
10400 | 6979 _("Online"), FALSE, TRUE, FALSE); |
9976 | 6980 status_types = g_list_append(status_types, type); |
6981 | |
10198 | 6982 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, |
6983 OSCAR_STATUS_ID_AVAILABLE, | |
6984 _("Available"), TRUE, TRUE, FALSE, | |
6985 "message", _("Message"), | |
6986 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
9976 | 6987 status_types = g_list_append(status_types, type); |
6988 | |
10195 | 6989 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
6990 OSCAR_STATUS_ID_AWAY, | |
6991 _("Away"), TRUE, TRUE, FALSE, | |
6992 "message", _("Message"), | |
6993 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
10042 | 6994 status_types = g_list_append(status_types, type); |
6995 | |
6996 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, | |
6997 OSCAR_STATUS_ID_INVISIBLE, | |
10198 | 6998 _("Invisible"), TRUE, TRUE, FALSE); |
10042 | 6999 status_types = g_list_append(status_types, type); |
7000 | |
7001 if (aim_sn_is_icq(gaim_account_get_username(account)) == FALSE ) | |
7002 return status_types; | |
7003 | |
7004 /* ICQ-specific status types */ | |
7005 | |
9991 | 7006 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
7007 OSCAR_STATUS_ID_FREE4CHAT, | |
7008 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 7009 status_types = g_list_append(status_types, type); |
7010 | |
9991 | 7011 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
7012 OSCAR_STATUS_ID_OCCUPIED, | |
7013 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 7014 status_types = g_list_append(status_types, type); |
7015 | |
9991 | 7016 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7017 OSCAR_STATUS_ID_DND, | |
7018 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 7019 status_types = g_list_append(status_types, type); |
7020 | |
9991 | 7021 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
7022 OSCAR_STATUS_ID_NA, | |
7023 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 7024 status_types = g_list_append(status_types, type); |
9975 | 7025 |
7026 return status_types; | |
4333 | 7027 } |
7028 | |
7172 | 7029 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 7030 GaimConnection *gc = data->gc; |
7031 OscarData *od = gc->proto_data; | |
7172 | 7032 GaimBuddy *b; |
7033 GaimGroup *g; | |
7034 | |
7035 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
7036 oscar_free_name_data(data); | |
7037 return; | |
7038 } | |
7039 | |
7040 if (!(g = gaim_find_buddys_group(b))) { | |
7041 oscar_free_name_data(data); | |
7042 return; | |
7043 } | |
7044 | |
7045 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 7046 |
7047 if (!aim_sncmp(data->name, gc->account->username)) | |
7048 gaim_check_comment(od, text); | |
7049 | |
7172 | 7050 oscar_free_name_data(data); |
7051 } | |
7052 | |
9030 | 7053 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
7054 | |
7055 GaimBuddy *buddy; | |
7056 GaimConnection *gc; | |
7057 OscarData *od; | |
7058 struct name_data *data; | |
7172 | 7059 GaimGroup *g; |
7060 char *comment; | |
7061 gchar *comment_utf8; | |
9631 | 7062 gchar *title; |
7172 | 7063 |
9030 | 7064 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
7065 | |
7066 buddy = (GaimBuddy *) node; | |
7067 gc = gaim_account_get_connection(buddy->account); | |
7068 od = gc->proto_data; | |
7069 | |
7070 data = g_new(struct name_data, 1); | |
7071 | |
7072 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 7073 return; |
9030 | 7074 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 7075 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
7076 | |
7077 data->gc = gc; | |
9030 | 7078 data->name = g_strdup(buddy->name); |
7172 | 7079 data->nick = NULL; |
7080 | |
9631 | 7081 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
7082 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 7083 comment_utf8, TRUE, FALSE, NULL, |
7172 | 7084 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
7085 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
7086 data); | |
9631 | 7087 g_free(title); |
7172 | 7088 |
7089 free(comment); | |
7090 g_free(comment_utf8); | |
7091 } | |
7092 | |
9030 | 7093 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
7094 | |
7095 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 7096 OscarData *od = gc->proto_data; |
9030 | 7097 |
4333 | 7098 GList *m = NULL; |
9030 | 7099 GaimBlistNodeAction *act; |
7100 | |
7101 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
7102 oscar_buddycb_edit_comment, NULL); | |
7103 m = g_list_append(m, act); | |
7172 | 7104 |
4333 | 7105 if (od->icq) { |
4624 | 7106 #if 0 |
9030 | 7107 act = gaim_blist_node_action_new(_("Get Status Msg"), |
7108 oscar_get_icqstatusmsg, NULL); | |
7109 m = g_list_append(m, act); | |
4624 | 7110 #endif |
4333 | 7111 } else { |
7011 | 7112 aim_userinfo_t *userinfo; |
9030 | 7113 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
7114 | |
7115 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
7116 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
7117 | |
7011 | 7118 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 7119 act = gaim_blist_node_action_new(_("Direct IM"), |
7120 oscar_ask_direct_im, NULL); | |
7121 m = g_list_append(m, act); | |
5917 | 7122 } |
9466 | 7123 #if 0 |
7011 | 7124 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 7125 act = gaim_blist_node_action_new(_("Get File"), |
7126 oscar_ask_getfile, NULL); | |
7127 m = g_list_append(m, act); | |
5917 | 7128 } |
4826 | 7129 #endif |
4333 | 7130 } |
5131 | 7131 } |
5197 | 7132 |
5131 | 7133 if (od->sess->ssi.received_data) { |
9030 | 7134 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7135 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7136 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7137 gaim_auth_sendrequest_menu, NULL); | |
7138 m = g_list_append(m, act); | |
4333 | 7139 } |
4916 | 7140 } |
10157 | 7141 |
4333 | 7142 return m; |
7143 } | |
7144 | |
9030 | 7145 |
7146 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7147 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7148 return oscar_buddy_menu((GaimBuddy *) node); | |
7149 } else { | |
7150 return NULL; | |
7151 } | |
7152 } | |
7153 | |
7154 | |
5575 | 7155 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7156 OscarData *od = gc->proto_data; |
5575 | 7157 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7158 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7159 od->setnick = TRUE; | |
7160 od->newsn = g_strdup(nick); | |
7161 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7162 } else { | |
7163 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7164 } | |
7165 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7166 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7167 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7168 } |
7169 } | |
7170 | |
9015 | 7171 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7172 { |
9015 | 7173 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7174 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7175 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7176 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7177 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7178 gc); |
4333 | 7179 } |
7180 | |
9015 | 7181 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7182 { |
9015 | 7183 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7184 OscarData *od = gc->proto_data; |
4333 | 7185 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7186 | |
7187 if (conn) { | |
7188 aim_admin_reqconfirm(od->sess, conn); | |
7189 } else { | |
7190 od->conf = TRUE; | |
7191 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7192 } | |
7193 } | |
7194 | |
9015 | 7195 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7196 { |
9015 | 7197 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7198 OscarData *od = gc->proto_data; |
4333 | 7199 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7200 | |
7201 if (conn) { | |
7202 aim_admin_getinfo(od->sess, conn, 0x11); | |
7203 } else { | |
7204 od->reqemail = TRUE; | |
7205 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7206 } | |
7207 } | |
7208 | |
5575 | 7209 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7210 { |
7283 | 7211 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7212 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
|
7213 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7214 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7215 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7216 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7217 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7218 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7219 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7220 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7221 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7222 |
9015 | 7223 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7224 { |
9015 | 7225 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7226 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7227 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7228 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7229 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7230 gc); |
4333 | 7231 } |
7232 | |
9015 | 7233 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7234 { |
9015 | 7235 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7236 OscarData *od = gc->proto_data; |
4333 | 7237 gchar *nombre, *text, *tmp; |
6695 | 7238 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7239 int num=0; |
7240 | |
6873 | 7241 text = g_strdup(""); |
4333 | 7242 |
4785 | 7243 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7244 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7245 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7246 continue; | |
6695 | 7247 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7248 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7249 continue; |
6695 | 7250 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7251 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7252 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7253 continue; | |
7254 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7255 if (gaim_buddy_get_alias_only(buddy)) |
7256 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7257 else |
7258 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7259 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7260 g_free(text); |
7261 text = tmp; | |
7262 g_free(nombre); | |
7263 num++; | |
7264 } | |
4333 | 7265 } |
2979 | 7266 } |
4333 | 7267 } |
7268 | |
7269 if (!num) { | |
7270 g_free(text); | |
6873 | 7271 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7272 } | |
7273 | |
7274 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7275 "the following buddies"), _("You can re-request " | |
7276 "authorization from these buddies by " | |
7277 "right-clicking on them and selecting " | |
7278 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7279 g_free(text); |
2979 | 7280 } |
7281 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7282 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7283 { |
8950 | 7284 OscarData *od = (OscarData *)gc->proto_data; |
7285 | |
7286 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7287 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7288 |
9015 | 7289 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7290 { |
9015 | 7291 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7292 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7293 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7294 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7295 "searching for."), |
8697 | 7296 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7297 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7298 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7299 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7300 |
9015 | 7301 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7302 { |
9015 | 7303 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7304 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7305 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7306 |
9015 | 7307 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7308 { |
9015 | 7309 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7310 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7311 } |
7312 | |
9015 | 7313 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7314 { |
9015 | 7315 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7316 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7317 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7318 |
9015 | 7319 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7320 { |
9015 | 7321 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7322 OscarData *od = gc->proto_data; |
5575 | 7323 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7324 gaim_notify_uri(gc, substituted); |
5517 | 7325 g_free(substituted); |
4333 | 7326 } |
7327 | |
9015 | 7328 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7329 { |
9015 | 7330 GaimConnection *gc = (GaimConnection *) action->context; |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
7331 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7026 | 7332 } |
7333 | |
5842 | 7334 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7335 { | |
7283 | 7336 OscarData *od = gc->proto_data; |
5844 | 7337 aim_session_t *sess = od->sess; |
5842 | 7338 FILE *file; |
7339 struct stat st; | |
5844 | 7340 |
6039 | 7341 if (iconfile == NULL) { |
8363 | 7342 aim_ssi_delicon(od->sess); |
6039 | 7343 } else if (!stat(iconfile, &st)) { |
5842 | 7344 char *buf = g_malloc(st.st_size); |
7345 file = fopen(iconfile, "rb"); | |
7346 if (file) { | |
6052 | 7347 md5_state_t *state; |
6039 | 7348 char md5[16]; |
9532 | 7349 /* XXX - Use g_file_get_contents()? */ |
5842 | 7350 int len = fread(buf, 1, st.st_size, file); |
6039 | 7351 fclose(file); |
6052 | 7352 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7353 md5_init(state); |
7354 md5_append(state, buf, len); | |
7355 md5_finish(state, md5); | |
7356 g_free(state); | |
7357 aim_ssi_seticon(sess, md5, 16); | |
7358 } else | |
8660 | 7359 gaim_debug_error("oscar", |
5842 | 7360 "Can't open buddy icon file!\n"); |
7361 g_free(buf); | |
7362 } else | |
8660 | 7363 gaim_debug_error("oscar", |
5842 | 7364 "Can't stat buddy icon file!\n"); |
7365 } | |
7366 | |
7367 | |
9015 | 7368 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7369 { |
9015 | 7370 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7371 OscarData *od = gc->proto_data; |
4333 | 7372 GList *m = NULL; |
9015 | 7373 GaimPluginAction *act; |
7374 | |
7375 act = gaim_plugin_action_new(_("Set User Info..."), | |
7376 oscar_show_set_info); | |
7377 m = g_list_append(m, act); | |
4333 | 7378 |
8576 | 7379 if (od->icq) { |
9015 | 7380 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7381 oscar_show_set_info_icqurl); | |
7382 m = g_list_append(m, act); | |
8576 | 7383 } |
7384 | |
9015 | 7385 act = gaim_plugin_action_new(_("Change Password..."), |
7386 oscar_change_pass); | |
7387 m = g_list_append(m, act); | |
4617 | 7388 |
7389 if (od->sess->authinfo->chpassurl) { | |
9015 | 7390 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7391 oscar_show_chpassurl); | |
7392 m = g_list_append(m, act); | |
7393 | |
7394 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7395 oscar_show_imforwardingurl); | |
7396 m = g_list_append(m, act); | |
7026 | 7397 } |
7398 | |
5238 | 7399 if (!od->icq) { |
4617 | 7400 /* AIM actions */ |
7401 m = g_list_append(m, NULL); | |
4333 | 7402 |
9015 | 7403 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7404 oscar_show_format_screenname); | |
7405 m = g_list_append(m, act); | |
7406 | |
7407 act = gaim_plugin_action_new(_("Confirm Account"), | |
7408 oscar_confirm_account); | |
7409 m = g_list_append(m, act); | |
7410 | |
7411 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7412 oscar_show_email); | |
7413 m = g_list_append(m, act); | |
7414 | |
7415 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7416 oscar_show_change_email); | |
7417 m = g_list_append(m, act); | |
2086 | 7418 } |
4333 | 7419 |
7420 m = g_list_append(m, NULL); | |
7421 | |
9015 | 7422 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7423 oscar_show_awaitingauth); | |
7424 m = g_list_append(m, act); | |
4333 | 7425 |
2086 | 7426 m = g_list_append(m, NULL); |
4333 | 7427 |
9015 | 7428 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7429 oscar_show_find_email); | |
7430 m = g_list_append(m, act); | |
4333 | 7431 |
8591 | 7432 #if 0 |
9015 | 7433 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7434 show_find_info); | |
7435 m = g_list_append(m, act); | |
8591 | 7436 #endif |
2086 | 7437 |
7438 return m; | |
7439 } | |
7440 | |
5575 | 7441 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7442 { |
7283 | 7443 OscarData *od = gc->proto_data; |
4617 | 7444 |
7445 if (od->icq) { | |
7446 aim_icq_changepasswd(od->sess, new); | |
2086 | 7447 } else { |
4617 | 7448 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7449 if (conn) { | |
7450 aim_admin_changepasswd(od->sess, conn, new, old); | |
7451 } else { | |
7452 od->chpass = TRUE; | |
7453 od->oldp = g_strdup(old); | |
7454 od->newp = g_strdup(new); | |
7455 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7456 } | |
2086 | 7457 } |
7458 } | |
7459 | |
6059 | 7460 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7461 { |
7283 | 7462 OscarData *od = gc->proto_data; |
8971 | 7463 struct oscar_direct_im *dim = oscar_direct_im_find(od, who); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7464 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7465 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7466 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7467 |
8971 | 7468 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7469 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7470 |
9935 | 7471 static void |
7472 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7473 { | |
7474 GaimConnection *gc = data; | |
7475 OscarData *od = gc->proto_data; | |
7476 aim_session_t *sess = od->sess; | |
7477 fu32_t presence; | |
7478 | |
7479 presence = aim_ssi_getpresence(sess->ssi.local); | |
7480 | |
7481 if (value) { | |
9992 | 7482 /* Based on the packet capture I thought it was the first one */ |
7483 /* Stu thinks it's the second one. */ | |
7484 /* presence |= 0x00400000; */ | |
9971 | 7485 presence &= ~0x00020000; |
9935 | 7486 aim_ssi_setpresence(sess, presence); |
7487 } else { | |
9992 | 7488 /* presence &= ~0x00400000; */ |
9971 | 7489 presence |= 0x00020000; |
9935 | 7490 aim_ssi_setpresence(sess, presence); |
7491 } | |
7492 } | |
7493 | |
7494 static GaimPluginPrefFrame * | |
9936 | 7495 get_plugin_pref_frame(GaimPlugin *plugin) |
7496 { | |
9935 | 7497 GaimPluginPrefFrame *frame; |
7498 GaimPluginPref *ppref; | |
7499 | |
7500 frame = gaim_plugin_pref_frame_new(); | |
7501 | |
7502 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7503 gaim_plugin_pref_frame_add(frame, ppref); | |
7504 | |
7505 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7506 gaim_plugin_pref_frame_add(frame, ppref); | |
7507 | |
7508 return frame; | |
7509 } | |
7510 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7511 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7512 { |
9308 | 7513 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7514 NULL, /* user_splits */ |
7515 NULL, /* protocol_options */ | |
7516 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7517 oscar_list_icon, /* list_icon */ | |
7518 oscar_list_emblems, /* list_emblems */ | |
7519 oscar_status_text, /* status_text */ | |
7520 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7521 oscar_status_types, /* status_types */ |
9475 | 7522 oscar_blist_node_menu, /* blist_node_menu */ |
7523 oscar_chat_info, /* chat_info */ | |
9754 | 7524 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7525 oscar_login, /* login */ |
7526 oscar_close, /* close */ | |
7527 oscar_send_im, /* send_im */ | |
7528 oscar_set_info, /* set_info */ | |
7529 oscar_send_typing, /* send_typing */ | |
7530 oscar_get_info, /* get_info */ | |
9973 | 7531 oscar_set_status, /* set_status */ |
9475 | 7532 oscar_set_idle, /* set_idle */ |
7533 oscar_change_passwd, /* change_passwd */ | |
7534 oscar_add_buddy, /* add_buddy */ | |
7535 oscar_add_buddies, /* add_buddies */ | |
7536 oscar_remove_buddy, /* remove_buddy */ | |
7537 oscar_remove_buddies, /* remove_buddies */ | |
7538 oscar_add_permit, /* add_permit */ | |
7539 oscar_add_deny, /* add_deny */ | |
7540 oscar_rem_permit, /* rem_permit */ | |
7541 oscar_rem_deny, /* rem_deny */ | |
7542 oscar_set_permit_deny, /* set_permit_deny */ | |
7543 oscar_warn, /* warn */ | |
7544 oscar_join_chat, /* join_chat */ | |
7545 NULL, /* reject_chat */ | |
9973 | 7546 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7547 oscar_chat_invite, /* chat_invite */ |
7548 oscar_chat_leave, /* chat_leave */ | |
7549 NULL, /* chat_whisper */ | |
7550 oscar_send_chat, /* chat_send */ | |
7551 oscar_keepalive, /* keepalive */ | |
7552 NULL, /* register_user */ | |
7553 NULL, /* get_cb_info */ | |
7554 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7555 #ifndef NOSSI |
9475 | 7556 oscar_alias_buddy, /* alias_buddy */ |
7557 oscar_move_buddy, /* group_buddy */ | |
7558 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7559 #else |
9475 | 7560 NULL, /* alias_buddy */ |
7561 NULL, /* group_buddy */ | |
7562 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7563 #endif |
9475 | 7564 NULL, /* buddy_free */ |
7565 oscar_convo_closed, /* convo_closed */ | |
7566 NULL, /* normalize */ | |
7567 oscar_set_icon, /* set_buddy_icon */ | |
7568 NULL, /* remove_group */ | |
7569 NULL, /* get_cb_real_name */ | |
7570 NULL, /* set_chat_topic */ | |
7571 NULL, /* find_blist_chat */ | |
7572 NULL, /* roomlist_get_list */ | |
7573 NULL, /* roomlist_cancel */ | |
7574 NULL, /* roomlist_expand_category */ | |
7575 oscar_can_receive_file, /* can_receive_file */ | |
7576 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7577 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7578 |
9935 | 7579 static GaimPluginUiInfo prefs_info = { |
7580 get_plugin_pref_frame | |
7581 }; | |
7582 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7583 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7584 { |
9943 | 7585 GAIM_PLUGIN_MAGIC, |
7586 GAIM_MAJOR_VERSION, | |
7587 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7588 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7589 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7590 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7591 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7592 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7593 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7594 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7595 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7596 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7597 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7598 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7599 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7600 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7601 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7602 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7603 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7604 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7605 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7606 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7607 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7608 NULL, /**< ui_info */ |
8993 | 7609 &prpl_info, /**< extra_info */ |
10487 | 7610 NULL, /**< prefs_info */ |
9015 | 7611 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7612 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7613 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7614 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7615 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7616 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7617 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7618 |
9830 | 7619 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7620 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7621 | |
7622 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7623 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7624 | |
7625 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7626 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7627 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7628 my_protocol = plugin; |
9935 | 7629 |
7630 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7631 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7632 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7633 } |
7634 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7635 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |