Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 10039:cf02e7104706
[gaim-migrate @ 10998]
A patch from rian hunter (chrono86):
In src/protocols/oscar/oscar.c, in the function
gaim_plugin_oscar_convert_to_best_encoding. g_convert
is called multiple times. As its 5th argument g_convert
takes a gsize* (8 byte), yet the argument to
gaim_plugin_oscar_convert_to_best_encoding is a int* (4
byte).
On LP64 machines this can allow the int* to be
overwritten. This is especially bad on big endian
64-bit machines, causing the high 32-bits to be written
into the low 32-bits of the int.
This is a quick fix patch that lets g_convert deal with
a gsize* pointer instead, then casting the value at
gsize* to the value at the int*.
A real fix would be to fix the aim_sendimext_args
structure to have a gsize instead of an int (and all
functions that use the aim_sendimext_args struct), and
changing gaim_plugin_oscar_convert_to_best_encoding to
accept a gsize*. of course, this woudl promote glib2
dependence, so that's probably not the best thing to do.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 18 Sep 2004 23:17:18 +0000 |
parents | 00a7ccf8ccd7 |
children | ae6157393415 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
6 * Some code copyright (C) 2001-2003, Sean Egan | |
8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
6302 | 8 * |
9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
2086 | 11 * |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 * | |
26 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
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 |
60 #define UC_UNAVAILABLE 0x01 | |
61 #define UC_AOL 0x02 | |
62 #define UC_ADMIN 0x04 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
63 #define UC_UNCONFIRMED 0x08 |
9975 | 64 #define UC_NORMAL 0x10 |
65 #define UC_AB 0x20 | |
66 #define UC_WIRELESS 0x40 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
67 |
2086 | 68 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
69 | |
7283 | 70 #define OSCAR_CONNECT_STEPS 6 |
9830 | 71 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
7283 | 72 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
73 static GaimPlugin *my_protocol = NULL; |
4249 | 74 |
7376 | 75 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
76 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
3458 | 77 |
4665 | 78 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
79 static fu8_t features_icq[] = {0x01, 0x06}; | |
8341 | 80 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
2086 | 81 |
7283 | 82 typedef struct _OscarData OscarData; |
83 struct _OscarData { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
84 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
85 aim_conn_t *conn; |
2086 | 86 |
87 guint cnpa; | |
88 guint paspa; | |
3694 | 89 guint emlpa; |
4804 | 90 guint icopa; |
2086 | 91 |
4823 | 92 gboolean iconconnecting; |
5842 | 93 gboolean set_icon; |
4823 | 94 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
95 GSList *create_rooms; |
2086 | 96 |
97 gboolean conf; | |
98 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
99 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
100 char *email; |
2979 | 101 gboolean setnick; |
102 char *newsn; | |
2086 | 103 gboolean chpass; |
104 char *oldp; | |
105 char *newp; | |
9971 | 106 |
2086 | 107 GSList *oscar_chats; |
108 GSList *direct_ims; | |
3630 | 109 GSList *file_transfers; |
4738 | 110 GHashTable *buddyinfo; |
4804 | 111 GSList *requesticon; |
2086 | 112 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
113 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
114 gboolean icq; |
4804 | 115 guint icontimer; |
5968 | 116 guint getblisttimer; |
8341 | 117 guint getinfotimer; |
9971 | 118 guint recentbuddies_cbid; |
2993 | 119 |
120 struct { | |
4230 | 121 guint maxwatchers; /* max users who can watch you */ |
2993 | 122 guint maxbuddies; /* max users you can watch */ |
4230 | 123 guint maxgroups; /* max groups in server list */ |
2993 | 124 guint maxpermits; /* max users on permit list */ |
125 guint maxdenies; /* max users on deny list */ | |
126 guint maxsiglen; /* max size (bytes) of profile */ | |
127 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
128 } rights; | |
2086 | 129 }; |
130 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
133 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
134 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
135 |
2086 | 136 struct chat_connection { |
137 char *name; | |
138 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
139 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
140 fu16_t instance; |
2086 | 141 int fd; /* this is redundant since we have the conn below */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
142 aim_conn_t *conn; |
2086 | 143 int inpa; |
144 int id; | |
5575 | 145 GaimConnection *gc; /* i hate this. */ |
8733 | 146 GaimConversation *conv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
147 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
148 int maxvis; |
2086 | 149 }; |
150 | |
8971 | 151 struct oscar_direct_im { |
5575 | 152 GaimConnection *gc; |
2086 | 153 char name[80]; |
154 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
155 aim_conn_t *conn; |
3008 | 156 gboolean connected; |
8978 | 157 gboolean gpc_pend; |
158 gboolean killme; | |
8984 | 159 gboolean donttryagain; |
2086 | 160 }; |
161 | |
162 struct ask_direct { | |
5575 | 163 GaimConnection *gc; |
2086 | 164 char *sn; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
165 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
166 fu8_t cookie[8]; |
8984 | 167 gboolean donttryagain; |
2086 | 168 }; |
169 | |
7011 | 170 /* |
171 * Various PRPL-specific buddy info that we want to keep track of | |
172 * Some other info is maintained by locate.c, and I'd like to move | |
173 * the rest of this to libfaim, mostly im.c | |
174 */ | |
4738 | 175 struct buddyinfo { |
176 gboolean typingnot; | |
6292 | 177 gchar *availmsg; |
6857 | 178 fu32_t ipaddr; |
5836 | 179 |
180 unsigned long ico_me_len; | |
181 unsigned long ico_me_csum; | |
182 time_t ico_me_time; | |
183 gboolean ico_informed; | |
4738 | 184 |
185 unsigned long ico_len; | |
186 unsigned long ico_csum; | |
187 time_t ico_time; | |
188 gboolean ico_need; | |
7406 | 189 gboolean ico_sent; |
2086 | 190 }; |
191 | |
4230 | 192 struct name_data { |
5575 | 193 GaimConnection *gc; |
4230 | 194 gchar *name; |
3453 | 195 gchar *nick; |
3141 | 196 }; |
197 | |
5129 | 198 static char *msgerrreason[] = { |
199 N_("Invalid error"), | |
200 N_("Invalid SNAC"), | |
201 N_("Rate to host"), | |
202 N_("Rate to client"), | |
203 N_("Not logged in"), | |
204 N_("Service unavailable"), | |
205 N_("Service not defined"), | |
206 N_("Obsolete SNAC"), | |
207 N_("Not supported by host"), | |
208 N_("Not supported by client"), | |
209 N_("Refused by client"), | |
210 N_("Reply too big"), | |
211 N_("Responses lost"), | |
212 N_("Request denied"), | |
213 N_("Busted SNAC payload"), | |
214 N_("Insufficient rights"), | |
215 N_("In local permit/deny"), | |
216 N_("Too evil (sender)"), | |
217 N_("Too evil (receiver)"), | |
218 N_("User temporarily unavailable"), | |
219 N_("No match"), | |
220 N_("List overflow"), | |
221 N_("Request ambiguous"), | |
222 N_("Queue full"), | |
223 N_("Not while on AOL") | |
224 }; | |
225 static int msgerrreasonlen = 25; | |
226 | |
227 /* All the libfaim->gaim callback functions */ | |
228 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
229 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
230 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
231 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
232 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
233 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
234 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
235 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
236 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
237 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
7011 | 238 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
8341 | 239 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
5129 | 240 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
241 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
|
242 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
|
243 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
|
244 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
|
245 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
5129 | 246 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
247 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
248 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
5844 | 249 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
5129 | 250 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
251 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
252 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
253 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
254 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
255 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
256 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
257 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
258 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
259 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
260 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
261 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
262 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
263 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
264 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
265 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
266 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
267 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
268 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
269 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
270 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
271 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
272 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
273 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
274 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
275 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
276 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
277 #ifndef NOSSI | |
278 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
279 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
280 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
281 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
8227 | 282 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
5129 | 283 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
284 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
285 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
286 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
287 #endif | |
288 | |
289 /* for DirectIM/image transfer */ | |
290 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
291 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
292 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
6982 | 293 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
5129 | 294 |
295 /* for file transfer */ | |
296 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
297 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
298 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
299 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
300 | |
301 static gboolean gaim_icon_timerfunc(gpointer data); | |
8971 | 302 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
8983 | 303 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
5954 | 304 static void oscar_set_info(GaimConnection *gc, const char *text); |
9935 | 305 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
306 | |
5836 | 307 static void oscar_free_name_data(struct name_data *data) { |
4230 | 308 g_free(data->name); |
309 g_free(data->nick); | |
310 g_free(data); | |
311 } | |
312 | |
5836 | 313 static void oscar_free_buddyinfo(void *data) { |
314 struct buddyinfo *bi = data; | |
6292 | 315 g_free(bi->availmsg); |
5836 | 316 g_free(bi); |
317 } | |
318 | |
9807 | 319 static fu32_t oscar_charset_check(const char *utf8) |
5129 | 320 { |
321 int i = 0; | |
9826 | 322 int charset = AIM_CHARSET_ASCII; |
5129 | 323 |
324 /* Determine how we can send this message. Per the warnings elsewhere | |
325 * in this file, these little checks determine the simplest encoding | |
326 * we can use for a given message send using it. */ | |
327 while (utf8[i]) { | |
328 if ((unsigned char)utf8[i] > 0x7f) { | |
329 /* not ASCII! */ | |
9826 | 330 charset = AIM_CHARSET_CUSTOM; |
5129 | 331 break; |
332 } | |
333 i++; | |
334 } | |
335 while (utf8[i]) { | |
336 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
337 * followed by 0xc0-0xc3 in the second */ | |
338 if ((unsigned char)utf8[i] < 0x80) { | |
339 i++; | |
340 continue; | |
341 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
342 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
343 i += 2; | |
344 continue; | |
345 } | |
9826 | 346 charset = AIM_CHARSET_UNICODE; |
5129 | 347 break; |
348 } | |
349 | |
9807 | 350 return charset; |
5129 | 351 } |
352 | |
8225 | 353 /* |
354 * Take a string of the form charset="bleh" where bleh is | |
355 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
356 * return a newly allocated string containing bleh. | |
357 */ | |
358 static gchar *oscar_encoding_extract(const char *encoding) | |
5129 | 359 { |
8225 | 360 gchar *ret = NULL; |
361 char *begin, *end; | |
362 | |
9933 | 363 g_return_val_if_fail(encoding != NULL, NULL); |
364 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
365 /* Make sure encoding begins with charset= */ |
8225 | 366 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
367 return NULL; | |
368 | |
369 begin = strchr(encoding, '"'); | |
370 end = strrchr(encoding, '"'); | |
371 | |
372 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
373 return NULL; | |
374 | |
375 ret = g_strndup(begin+1, (end-1) - begin); | |
376 | |
377 return ret; | |
378 } | |
379 | |
9830 | 380 static gchar * |
381 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
5129 | 382 { |
383 gchar *utf8 = NULL; | |
9595 | 384 |
385 if ((encoding == NULL) || encoding[0] == '\0') { | |
386 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
387 | |
9639 | 388 } else if (!strcmp(encoding, "iso-8859-1") |
389 || !strcmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { | |
9595 | 390 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); |
391 | |
392 } else if (!strcmp(encoding, "unicode-2-0")) { | |
393 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
394 | |
395 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
396 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
397 "attempting to convert to UTF-8 anyway\n"); | |
398 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
399 } | |
400 | |
401 /* | |
402 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
403 * we have been unable to convert the text to utf-8 from the encoding | |
404 * that was specified. So we check if the text is valid utf-8 then | |
405 * just copy it. | |
406 */ | |
407 if (utf8 == NULL) { | |
9638 | 408 if (textlen != 0 && *text != '\0' |
409 && !g_utf8_validate(text, textlen, NULL)) | |
9908 | 410 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
9476 | 411 else |
9481 | 412 utf8 = g_strndup(text, textlen); |
5129 | 413 } |
414 | |
415 return utf8; | |
416 } | |
417 | |
9830 | 418 static gchar * |
9908 | 419 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) |
9830 | 420 { |
421 gchar *ret = NULL; | |
422 GError *err = NULL; | |
423 | |
9908 | 424 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
425 return NULL; | |
426 | |
427 if (strcasecmp("UTF-8", charsetstr)) { | |
428 if (fallback) | |
429 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
430 else | |
431 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
432 if (err != NULL) { | |
433 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
434 charsetstr, err->message); | |
435 g_error_free(err); | |
436 } | |
437 } else { | |
438 if (g_utf8_validate(data, datalen, NULL)) | |
439 ret = g_strndup(data, datalen); | |
440 else | |
441 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
442 } | |
443 | |
444 return ret; | |
445 } | |
446 | |
447 /* | |
448 * We try decoding using two different character sets. The charset | |
449 * specified in the IM determines the order in which we attempt to | |
450 * decode. We do this because there are lots of broken ICQ clients | |
451 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
452 * able to deal with that crap, then people complain like banshees. | |
453 * charsetstr1 is always set to what the correct encoding should be. | |
454 */ | |
455 static gchar * | |
456 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | |
457 { | |
458 gchar *ret = NULL; | |
459 const gchar *charsetstr1, *charsetstr2; | |
460 | |
461 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
9830 | 462 |
463 if ((datalen == 0) || (data == NULL)) | |
464 return NULL; | |
465 | |
9908 | 466 if (charset == AIM_CHARSET_UNICODE) { |
467 charsetstr1 = "UCS-2BE"; | |
468 charsetstr2 = "UTF-8"; | |
469 } else if (charset == AIM_CHARSET_CUSTOM) { | |
9975 | 470 if ((sourcesn != NULL) && aim_sn_is_icq(sourcesn)) |
9908 | 471 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
9830 | 472 else |
9908 | 473 charsetstr1 = "ISO-8859-1"; |
474 charsetstr2 = "UTF-8"; | |
475 } else if (charset == AIM_CHARSET_ASCII) { | |
476 /* Should just be "ASCII" */ | |
9914 | 477 charsetstr1 = "ASCII"; |
9908 | 478 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
479 } else if (charset == 0x000d) { | |
9830 | 480 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
9908 | 481 charsetstr1 = "ISO-8859-1"; |
482 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
483 } else { | |
9830 | 484 /* Unknown, hope for valid UTF-8... */ |
9908 | 485 charsetstr1 = "UTF-8"; |
486 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
487 } | |
488 | |
489 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
490 if (ret == NULL) | |
491 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
492 if (ret == NULL) | |
493 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); | |
9830 | 494 |
495 return ret; | |
496 } | |
497 | |
498 static void | |
499 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, const char *destsn, const gchar *from, | |
10039 | 500 gchar **msg, int *msglen_int, |
9830 | 501 fu16_t *charset, fu16_t *charsubset) |
502 { | |
503 OscarData *od = gc->proto_data; | |
504 GaimAccount *account = gaim_connection_get_account(gc); | |
505 GError *err = NULL; | |
506 aim_userinfo_t *userinfo = NULL; | |
507 const gchar *charsetstr; | |
10039 | 508 gsize msglen; |
9830 | 509 |
510 /* Attempt to send as ASCII */ | |
10039 | 511 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
9830 | 512 if (*msg != NULL) { |
513 *charset = AIM_CHARSET_ASCII; | |
514 *charsubset = 0x0000; | |
10039 | 515 *msglen_int = msglen; |
9830 | 516 return; |
517 } | |
518 | |
519 /* | |
9908 | 520 * If we're sending to an ICQ user, and they are advertising the |
521 * Unicode capability, then attempt to send as UCS-2BE. | |
9830 | 522 */ |
9975 | 523 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 524 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
525 | |
526 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) { | |
10039 | 527 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
9830 | 528 if (*msg != NULL) { |
529 *charset = AIM_CHARSET_UNICODE; | |
530 *charsubset = 0x0000; | |
10039 | 531 *msglen_int = msglen; |
9830 | 532 return; |
533 } | |
534 } | |
535 | |
536 /* | |
537 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
538 * ICQ then attempt to send as the user specified character encoding. | |
539 */ | |
540 charsetstr = "ISO-8859-1"; | |
9975 | 541 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
9830 | 542 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
543 | |
10039 | 544 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
9830 | 545 if (*msg != NULL) { |
546 *charset = AIM_CHARSET_CUSTOM; | |
547 *charsubset = 0x0000; | |
10039 | 548 *msglen_int = msglen; |
9830 | 549 return; |
550 } | |
551 | |
552 /* | |
553 * Nothing else worked, so send as UCS-2BE. | |
554 */ | |
10039 | 555 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
9830 | 556 if (*msg != NULL) { |
557 *charset = AIM_CHARSET_UNICODE; | |
558 *charsubset = 0x0000; | |
10039 | 559 *msglen_int = msglen; |
9830 | 560 return; |
561 } | |
562 | |
9908 | 563 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
9830 | 564 g_error_free(err); |
565 | |
566 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
567 *msg = g_strdup(from); | |
10039 | 568 *msglen_int = strlen(*msg); |
9830 | 569 *charset = AIM_CHARSET_ASCII; |
570 *charsubset = 0x0000; | |
571 return; | |
572 } | |
573 | |
9407 | 574 gchar *oscar_caps_to_string(guint caps) |
8701 | 575 { |
9407 | 576 GString *str; |
577 gchar *tmp; | |
8701 | 578 guint bit = 1; |
579 | |
9407 | 580 str = g_string_new(""); |
581 | |
8701 | 582 if (!caps) { |
583 return NULL; | |
584 } else while (bit <= AIM_CAPS_LAST) { | |
585 if (bit & caps) { | |
586 switch (bit) { | |
587 case AIM_CAPS_BUDDYICON: | |
588 tmp = _("Buddy Icon"); | |
589 break; | |
590 case AIM_CAPS_TALK: | |
591 tmp = _("Voice"); | |
592 break; | |
593 case AIM_CAPS_DIRECTIM: | |
594 tmp = _("AIM Direct IM"); | |
595 break; | |
596 case AIM_CAPS_CHAT: | |
597 tmp = _("Chat"); | |
598 break; | |
599 case AIM_CAPS_GETFILE: | |
600 tmp = _("Get File"); | |
601 break; | |
602 case AIM_CAPS_SENDFILE: | |
603 tmp = _("Send File"); | |
604 break; | |
605 case AIM_CAPS_GAMES: | |
606 case AIM_CAPS_GAMES2: | |
607 tmp = _("Games"); | |
608 break; | |
609 case AIM_CAPS_ADDINS: | |
610 tmp = _("Add-Ins"); | |
611 break; | |
612 case AIM_CAPS_SENDBUDDYLIST: | |
613 tmp = _("Send Buddy List"); | |
614 break; | |
615 case AIM_CAPS_ICQ_DIRECT: | |
616 tmp = _("ICQ Direct Connect"); | |
617 break; | |
618 case AIM_CAPS_APINFO: | |
619 tmp = _("AP User"); | |
620 break; | |
621 case AIM_CAPS_ICQRTF: | |
622 tmp = _("ICQ RTF"); | |
623 break; | |
624 case AIM_CAPS_EMPTY: | |
625 tmp = _("Nihilist"); | |
626 break; | |
627 case AIM_CAPS_ICQSERVERRELAY: | |
628 tmp = _("ICQ Server Relay"); | |
629 break; | |
630 case AIM_CAPS_ICQUTF8OLD: | |
631 tmp = _("Old ICQ UTF8"); | |
632 break; | |
633 case AIM_CAPS_TRILLIANCRYPT: | |
634 tmp = _("Trillian Encryption"); | |
635 break; | |
636 case AIM_CAPS_ICQUTF8: | |
637 tmp = _("ICQ UTF8"); | |
638 break; | |
639 case AIM_CAPS_HIPTOP: | |
640 tmp = _("Hiptop"); | |
641 break; | |
642 case AIM_CAPS_SECUREIM: | |
643 tmp = _("Security Enabled"); | |
644 break; | |
645 case AIM_CAPS_VIDEO: | |
646 tmp = _("Video Chat"); | |
647 break; | |
648 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
649 case AIM_CAPS_ICHATAV: | |
650 tmp = _("iChat AV"); | |
651 break; | |
652 case AIM_CAPS_LIVEVIDEO: | |
653 tmp = _("Live Video"); | |
654 break; | |
655 case AIM_CAPS_CAMERA: | |
656 tmp = _("Camera"); | |
657 break; | |
658 default: | |
659 tmp = NULL; | |
660 break; | |
661 } | |
662 if (tmp) | |
9532 | 663 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
8701 | 664 } |
665 bit <<= 1; | |
666 } | |
9407 | 667 |
668 return g_string_free(str, FALSE); | |
8701 | 669 } |
670 | |
671 static char *oscar_icqstatus(int state) { | |
672 /* Make a cute little string that shows the status of the dude or dudet */ | |
673 if (state & AIM_ICQ_STATE_CHAT) | |
674 return g_strdup_printf(_("Free For Chat")); | |
675 else if (state & AIM_ICQ_STATE_DND) | |
676 return g_strdup_printf(_("Do Not Disturb")); | |
677 else if (state & AIM_ICQ_STATE_OUT) | |
678 return g_strdup_printf(_("Not Available")); | |
679 else if (state & AIM_ICQ_STATE_BUSY) | |
680 return g_strdup_printf(_("Occupied")); | |
681 else if (state & AIM_ICQ_STATE_AWAY) | |
682 return g_strdup_printf(_("Away")); | |
683 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
684 return g_strdup_printf(_("Web Aware")); | |
685 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
686 return g_strdup_printf(_("Invisible")); | |
687 else | |
688 return g_strdup_printf(_("Online")); | |
689 } | |
690 | |
9973 | 691 static void |
692 oscar_string_append(GString *str, const char *newline, const char *name, const char *value) | |
8700 | 693 { |
694 gchar *utf8; | |
695 | |
696 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
8701 | 697 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
8700 | 698 g_free(utf8); |
699 } | |
700 } | |
701 | |
9973 | 702 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
8701 | 703 { |
704 OscarData *od = gc->proto_data; | |
705 GaimAccount *account = gaim_connection_get_account(gc); | |
706 GaimGroup *g = NULL; | |
707 struct buddyinfo *bi = NULL; | |
708 char *tmp; | |
709 | |
710 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
711 return; | |
712 | |
713 if (userinfo == NULL) | |
714 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
715 | |
716 if (b == NULL) | |
717 b = gaim_find_buddy(gc->account, userinfo->sn); | |
718 | |
719 if (b != NULL) | |
720 g = gaim_find_buddys_group(b); | |
721 | |
722 if (userinfo != NULL) | |
723 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
724 | |
8733 | 725 if (b != NULL) { |
726 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
9975 | 727 if (aim_sn_is_icq(b->name)) { |
8733 | 728 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
729 oscar_string_append(str, newline, _("Status"), tmp); | |
730 g_free(tmp); | |
731 } | |
732 } else { | |
9625 | 733 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
8733 | 734 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
735 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
736 else | |
737 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
8701 | 738 } |
8733 | 739 } |
8701 | 740 |
741 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
9625 | 742 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
8701 | 743 (bi->ipaddr & 0xff000000) >> 24, |
744 (bi->ipaddr & 0x00ff0000) >> 16, | |
745 (bi->ipaddr & 0x0000ff00) >> 8, | |
746 (bi->ipaddr & 0x000000ff)); | |
747 oscar_string_append(str, newline, _("IP Address"), tmp); | |
748 g_free(tmp); | |
749 } | |
750 | |
751 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
752 tmp = oscar_caps_to_string(userinfo->capabilities); | |
753 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
9407 | 754 g_free(tmp); |
8701 | 755 } |
756 | |
757 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
758 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
759 if (tmp != NULL) { | |
9625 | 760 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
8701 | 761 g_free(tmp); |
9625 | 762 oscar_string_append(str, newline, _("Buddy Comment"), tmp2); |
763 g_free(tmp2); | |
8701 | 764 } |
765 } | |
766 | |
767 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
768 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
769 oscar_string_append(str, newline, _("Available"), tmp); | |
770 g_free(tmp); | |
771 } | |
772 } | |
773 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
774 static char *extract_name(const char *name) { |
4121 | 775 char *tmp, *x; |
2086 | 776 int i, j; |
4120 | 777 |
778 if (!name) | |
4121 | 779 return NULL; |
780 | |
4120 | 781 x = strchr(name, '-'); |
4121 | 782 |
2086 | 783 if (!x) return NULL; |
784 x = strchr(++x, '-'); | |
785 if (!x) return NULL; | |
786 tmp = g_strdup(++x); | |
787 | |
788 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
789 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
790 if (x[i] != '%') { |
2086 | 791 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
792 continue; |
2086 | 793 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
794 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
795 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
796 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 797 } |
798 | |
799 tmp[j] = 0; | |
800 return tmp; | |
801 } | |
802 | |
5575 | 803 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
7283 | 804 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 805 struct chat_connection *c = NULL; |
806 | |
807 while (g) { | |
808 c = (struct chat_connection *)g->data; | |
809 if (c->id == id) | |
810 break; | |
811 g = g->next; | |
812 c = NULL; | |
813 } | |
814 | |
815 return c; | |
816 } | |
817 | |
5575 | 818 static struct chat_connection *find_oscar_chat_by_conn(GaimConnection *gc, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
819 aim_conn_t *conn) { |
7283 | 820 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
2086 | 821 struct chat_connection *c = NULL; |
822 | |
823 while (g) { | |
824 c = (struct chat_connection *)g->data; | |
825 if (c->conn == conn) | |
826 break; | |
827 g = g->next; | |
828 c = NULL; | |
829 } | |
830 | |
831 return c; | |
832 } | |
833 | |
8219 | 834 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
835 GaimConversation *conv) { | |
836 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
837 struct chat_connection *c = NULL; | |
838 | |
839 while (g) { | |
840 c = (struct chat_connection *)g->data; | |
8733 | 841 if (c->conv == conv) |
8219 | 842 break; |
843 g = g->next; | |
844 c = NULL; | |
845 } | |
846 | |
847 return c; | |
848 } | |
849 | |
8971 | 850 /***************************************************************************** |
851 * Begin scary direct im stuff | |
852 *****************************************************************************/ | |
853 | |
854 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
855 GSList *d = od->direct_ims; | |
856 struct oscar_direct_im *m = NULL; | |
857 | |
858 while (d) { | |
859 m = (struct oscar_direct_im *)d->data; | |
860 if (!aim_sncmp(who, m->name)) | |
861 return m; | |
862 d = d->next; | |
863 } | |
864 | |
865 return NULL; | |
866 } | |
867 | |
868 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
869 { | |
870 gaim_debug_info("oscar", | |
871 "destroying Direct IM for %s.\n", dim->name); | |
872 | |
873 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
8978 | 874 if (dim->gpc_pend) { |
875 dim->killme = TRUE; | |
876 return; | |
877 } | |
8971 | 878 if (dim->watcher) |
879 gaim_input_remove(dim->watcher); | |
880 if (dim->conn) { | |
881 aim_conn_close(dim->conn); | |
882 aim_conn_kill(od->sess, &dim->conn); | |
883 } | |
884 g_free(dim); | |
885 } | |
886 | |
887 /* the only difference between this and destroy is this writes a conv message */ | |
888 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
889 { | |
890 GaimConversation *conv; | |
891 char buf[256]; | |
892 | |
893 gaim_debug_info("oscar", | |
894 "%s disconnected Direct IM.\n", dim->name); | |
895 | |
896 if (dim->connected) | |
897 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
8978 | 898 else |
8971 | 899 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
900 | |
901 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
902 if (conv) { | |
903 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
9463 | 904 gaim_conversation_update_progress(conv, 0); |
8971 | 905 } else { |
906 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
907 } | |
908 | |
909 oscar_direct_im_destroy(od, dim); | |
910 | |
911 return; | |
912 } | |
913 | |
914 /* oops i made two of these. this one just calls the other one. */ | |
915 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
916 { | |
917 GaimConnection *gc = sess->aux_data; | |
918 OscarData *od = (OscarData *)gc->proto_data; | |
919 struct oscar_direct_im *dim; | |
920 char *sn; | |
921 | |
922 sn = g_strdup(aim_odc_getsn(conn)); | |
923 dim = oscar_direct_im_find(od, sn); | |
924 oscar_direct_im_disconnect(od, dim); | |
925 g_free(sn); | |
926 } | |
927 | |
928 static void destroy_direct_im_request(struct ask_direct *d) { | |
929 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
930 | |
931 g_free(d->sn); | |
932 g_free(d); | |
933 } | |
934 | |
935 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
936 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
937 struct oscar_direct_im *dim = data; | |
938 GaimConnection *gc = dim->gc; | |
939 OscarData *od = gc->proto_data; | |
940 GaimConversation *conv; | |
941 char buf[256]; | |
942 struct sockaddr name; | |
943 socklen_t name_len = 1; | |
944 | |
945 g_return_if_fail(gc != NULL); | |
946 | |
8978 | 947 dim->gpc_pend = FALSE; |
948 if (dim->killme) { | |
949 oscar_direct_im_destroy(od, dim); | |
950 return; | |
951 } | |
952 | |
8971 | 953 if (!g_list_find(gaim_connections_get_all(), gc)) { |
954 oscar_direct_im_destroy(od, dim); | |
955 return; | |
956 } | |
957 | |
958 if (source < 0) { | |
8984 | 959 if (dim->donttryagain) { |
960 oscar_direct_im_disconnect(od, dim); | |
961 return; | |
962 } else { | |
963 fu8_t cookie[8]; | |
964 char *who = g_strdup(dim->name); | |
965 const char *tmp = aim_odc_getcookie(dim->conn); | |
966 | |
967 memcpy(cookie, tmp, 8); | |
968 oscar_direct_im_destroy(od, dim); | |
969 oscar_direct_im_initiate(gc, who, cookie); | |
970 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
971 g_free(who); | |
972 return; | |
973 } | |
8971 | 974 } |
975 | |
976 dim->conn->fd = source; | |
977 aim_conn_completeconnect(od->sess, dim->conn); | |
978 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
979 | |
980 /* This is the best way to see if we're connected or not */ | |
8983 | 981 /* Is this really needed? */ |
8971 | 982 if (getpeername(source, &name, &name_len) == 0) { |
983 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
984 dim->connected = TRUE; | |
985 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
8983 | 986 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
987 } else { | |
8984 | 988 if (dim->donttryagain) { |
989 oscar_direct_im_disconnect(od, dim); | |
990 return; | |
991 } else { | |
992 fu8_t cookie[8]; | |
993 char *who = g_strdup(dim->name); | |
994 const char *tmp = aim_odc_getcookie(dim->conn); | |
995 | |
996 memcpy(cookie, tmp, 8); | |
997 oscar_direct_im_destroy(od, dim); | |
998 oscar_direct_im_initiate(gc, who, cookie); | |
999 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
1000 g_free(who); | |
1001 return; | |
1002 } | |
8983 | 1003 } |
1004 | |
1005 | |
8971 | 1006 } |
1007 | |
1008 static void accept_direct_im_request(struct ask_direct *d) { | |
1009 GaimConnection *gc = d->gc; | |
1010 OscarData *od; | |
1011 struct oscar_direct_im *dim; | |
1012 char *host; int port = 5190; | |
1013 int i, rc; | |
8982 | 1014 char *tmp; |
1015 GaimConversation *conv; | |
8971 | 1016 |
1017 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1018 destroy_direct_im_request(d); | |
1019 return; | |
1020 } | |
1021 | |
1022 od = (OscarData *)gc->proto_data; | |
1023 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
1024 | |
1025 dim = oscar_direct_im_find(od, d->sn); | |
1026 if (dim && dim->connected) { | |
1027 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
1028 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
1029 return; | |
1030 } | |
1031 dim = g_new0(struct oscar_direct_im, 1); | |
1032 dim->gc = d->gc; | |
8984 | 1033 dim->donttryagain = d->donttryagain; |
8971 | 1034 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
1035 | |
1036 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
1037 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
1038 if (!dim->conn) { | |
1039 oscar_direct_im_disconnect(od, dim); | |
1040 destroy_direct_im_request(d); | |
1041 return; | |
1042 } | |
1043 | |
1044 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
1045 gaim_odc_incoming, 0); | |
1046 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1047 gaim_odc_typing, 0); | |
1048 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
1049 gaim_odc_update_ui, 0); | |
1050 | |
1051 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
1052 for (i = 0; i < (int)strlen(d->ip); i++) { | |
1053 if (d->ip[i] == ':') { | |
1054 port = atoi(&(d->ip[i+1])); | |
1055 break; | |
1056 } | |
1057 } | |
1058 host = g_strndup(d->ip, i); | |
1059 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
8978 | 1060 dim->gpc_pend = TRUE; |
8971 | 1061 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
8982 | 1062 |
1063 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
1064 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
1065 port); | |
1066 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1067 g_free(tmp); | |
8983 | 1068 |
8971 | 1069 g_free(host); |
1070 if (rc < 0) { | |
8978 | 1071 dim->gpc_pend = FALSE; |
8971 | 1072 oscar_direct_im_disconnect(od, dim); |
1073 destroy_direct_im_request(d); | |
1074 return; | |
1075 } | |
1076 | |
1077 destroy_direct_im_request(d); | |
1078 | |
1079 return; | |
1080 } | |
1081 | |
1082 /* | |
1083 * We have just established a socket with the other dude, so set up some handlers. | |
1084 */ | |
1085 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 1086 GaimConnection *gc = sess->aux_data; |
7283 | 1087 OscarData *od = (OscarData *)gc->proto_data; |
8733 | 1088 GaimConversation *conv; |
8971 | 1089 struct oscar_direct_im *dim; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1090 char buf[256]; |
8971 | 1091 char *sn; |
1092 va_list ap; | |
1093 aim_conn_t *newconn, *listenerconn; | |
1094 | |
1095 va_start(ap, fr); | |
1096 newconn = va_arg(ap, aim_conn_t *); | |
1097 listenerconn = va_arg(ap, aim_conn_t *); | |
1098 va_end(ap); | |
1099 | |
1100 aim_conn_close(listenerconn); | |
1101 aim_conn_kill(sess, &listenerconn); | |
1102 | |
1103 sn = g_strdup(aim_odc_getsn(newconn)); | |
1104 | |
1105 gaim_debug_info("oscar", | |
1106 "DirectIM: initiate success to %s\n", sn); | |
1107 dim = oscar_direct_im_find(od, sn); | |
1108 | |
1109 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
1110 gaim_input_remove(dim->watcher); | |
1111 dim->conn = newconn; | |
1112 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
1113 dim->connected = TRUE; | |
1114 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
1115 g_free(sn); | |
1116 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1117 | |
1118 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
1119 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
1120 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
1121 | |
1122 return 1; | |
1123 } | |
1124 | |
1125 /* | |
1126 * This is called when each chunk of an image is received. It can be used to | |
1127 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
1128 * nasty, you sicko. | |
1129 */ | |
1130 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1131 va_list ap; | |
1132 char *sn; | |
1133 double percent; | |
1134 GaimConnection *gc = sess->aux_data; | |
1135 OscarData *od = (OscarData *)gc->proto_data; | |
1136 GaimConversation *c; | |
1137 struct oscar_direct_im *dim; | |
1138 | |
1139 va_start(ap, fr); | |
1140 sn = va_arg(ap, char *); | |
1141 percent = va_arg(ap, double); | |
1142 va_end(ap); | |
1143 | |
1144 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
1145 return 1; | |
1146 if (dim->watcher) { | |
1147 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
1148 /* The callback will callback? I don't get how that would happen here. */ | |
1149 dim->watcher = 0; | |
1150 } | |
1151 | |
1152 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
1153 if (c != NULL) | |
1154 gaim_conversation_update_progress(c, percent); | |
1155 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1156 oscar_callback, dim->conn); | |
1157 | |
1158 return 1; | |
1159 } | |
1160 | |
1161 /* | |
1162 * This is called after a direct IM has been received in its entirety. This | |
1163 * function is passed a long chunk of data which contains the IM with any | |
1164 * data chunks (images) appended to it. | |
1165 * | |
1166 * This function rips out all the data chunks and creates an imgstore for | |
1167 * each one. In order to do this, it first goes through the IM and takes | |
1168 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
1169 * with one compatible with the imgstore Gaim core code. For each one, we | |
1170 * then read in chunks of data from the end of the message and actually | |
1171 * create the img store using the given data. | |
1172 * | |
1173 * For somewhat easy reference, here's a sample message | |
1174 * (without the whitespace and asterisks): | |
1175 * | |
1176 * <HTML><BODY BGCOLOR="#ffffff"> | |
1177 * <FONT LANG="0"> | |
1178 * This is a really stupid picture:<BR> | |
1179 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
1180 * Yeah it is<BR> | |
1181 * Here is another one:<BR> | |
1182 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
1183 * </FONT> | |
1184 * </BODY></HTML> | |
1185 * <BINARY> | |
1186 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
1187 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
1188 * </BINARY> | |
1189 */ | |
1190 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1191 GaimConnection *gc = sess->aux_data; | |
1192 GaimConvImFlags imflags = 0; | |
1193 gchar *utf8; | |
1194 GString *newmsg = g_string_new(""); | |
1195 GSList *images = NULL; | |
1196 va_list ap; | |
1197 const char *sn, *msg, *msgend, *binary; | |
1198 size_t len; | |
1199 int encoding, isawaymsg; | |
1200 | |
1201 va_start(ap, fr); | |
1202 sn = va_arg(ap, const char *); | |
1203 msg = va_arg(ap, const char *); | |
1204 len = va_arg(ap, size_t); | |
1205 encoding = va_arg(ap, int); | |
1206 isawaymsg = va_arg(ap, int); | |
1207 va_end(ap); | |
1208 msgend = msg + len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1209 |
8660 | 1210 gaim_debug_info("oscar", |
8971 | 1211 "Got DirectIM message from %s\n", sn); |
1212 | |
1213 if (isawaymsg) | |
1214 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
1215 | |
1216 /* message has a binary trailer */ | |
1217 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
1218 GData *attribs; | |
1219 const char *tmp, *start, *end, *last = NULL; | |
1220 | |
1221 tmp = msg; | |
1222 | |
1223 /* for each valid image tag... */ | |
1224 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1225 const char *id, *src, *datasize; | |
1226 const char *tag = NULL, *data = NULL; | |
1227 size_t size; | |
1228 int imgid = 0; | |
1229 | |
1230 /* update the location of the last img tag */ | |
1231 last = end; | |
1232 | |
1233 /* grab attributes */ | |
1234 id = g_datalist_get_data(&attribs, "id"); | |
1235 src = g_datalist_get_data(&attribs, "src"); | |
1236 datasize = g_datalist_get_data(&attribs, "datasize"); | |
1237 | |
1238 /* if we have id & datasize, build the data tag */ | |
1239 if (id && datasize) | |
1240 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
1241 | |
1242 /* if we have a tag, find the start of the data */ | |
1243 if (tag && (data = gaim_strcasestr(binary, tag))) | |
1244 data += strlen(tag); | |
1245 | |
1246 /* check the data is here and store it */ | |
1247 if (data + (size = atoi(datasize)) <= msgend) | |
1248 imgid = gaim_imgstore_add(data, size, src); | |
1249 | |
1250 /* | |
1251 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
1252 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
1253 */ | |
1254 /* if we have a stored image... */ | |
1255 if (imgid) { | |
1256 /* append the message up to the tag */ | |
1257 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
1258 if (utf8 != NULL) { | |
1259 newmsg = g_string_append(newmsg, utf8); | |
1260 g_free(utf8); | |
1261 } | |
1262 | |
1263 /* write the new image tag */ | |
1264 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
1265 | |
1266 /* and record the image number */ | |
1267 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
1268 } else { | |
1269 /* otherwise, copy up to the end of the tag */ | |
1270 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
1271 if (utf8 != NULL) { | |
1272 newmsg = g_string_append(newmsg, utf8); | |
1273 g_free(utf8); | |
1274 } | |
1275 } | |
1276 | |
1277 /* clear the attribute list */ | |
1278 g_datalist_clear(&attribs); | |
1279 | |
1280 /* continue from the end of the tag */ | |
1281 tmp = end + 1; | |
1282 } | |
1283 | |
1284 /* append any remaining message data (without the > :-) */ | |
1285 if (last++ && (last < binary)) | |
1286 newmsg = g_string_append_len(newmsg, last, binary - last); | |
1287 | |
1288 /* set the flag if we caught any images */ | |
1289 if (images) | |
1290 imflags |= GAIM_CONV_IM_IMAGES; | |
1291 } else { | |
1292 g_string_append_len(newmsg, msg, len); | |
1293 } | |
1294 | |
1295 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
1296 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
1297 | |
1298 /* free up the message */ | |
1299 g_string_free(newmsg, TRUE); | |
1300 | |
1301 /* unref any images we allocated */ | |
1302 if (images) { | |
1303 GSList *tmp; | |
1304 int id; | |
1305 | |
1306 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
1307 id = GPOINTER_TO_INT(tmp->data); | |
1308 gaim_imgstore_unref(id); | |
1309 } | |
1310 | |
1311 g_slist_free(images); | |
1312 } | |
1313 | |
1314 return 1; | |
1315 } | |
1316 | |
1317 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
1318 va_list ap; | |
1319 char *sn; | |
1320 int typing; | |
1321 GaimConnection *gc = sess->aux_data; | |
1322 | |
1323 va_start(ap, fr); | |
1324 sn = va_arg(ap, char *); | |
1325 typing = va_arg(ap, int); | |
1326 va_end(ap); | |
1327 | |
1328 if (typing == 0x0002) { | |
1329 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
1330 gaim_debug_info("oscar", | |
1331 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
1332 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
1333 } else if (typing == 0x0001) | |
1334 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
1335 else | |
1336 serv_got_typing_stopped(gc, sn); | |
1337 return 1; | |
1338 } | |
1339 | |
1340 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
1341 char *buf; | |
1342 size_t len; | |
1343 int ret; | |
1344 GString *msg = g_string_new("<HTML><BODY>"); | |
1345 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
1346 GData *attribs; | |
1347 const char *start, *end, *last; | |
1348 int oscar_id = 0; | |
1349 | |
1350 last = message; | |
1351 | |
1352 /* for each valid IMG tag... */ | |
1353 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
1354 GaimStoredImage *image = NULL; | |
1355 const char *id; | |
1356 | |
1357 if (start - last) { | |
1358 g_string_append_len(msg, last, start - last); | |
1359 } | |
1360 | |
1361 id = g_datalist_get_data(&attribs, "id"); | |
1362 | |
1363 /* ... if it refers to a valid gaim image ... */ | |
1364 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
1365 /* ... append the message from start to the tag ... */ | |
9126 | 1366 unsigned long size = gaim_imgstore_get_size(image); |
8971 | 1367 const char *filename = gaim_imgstore_get_filename(image); |
1368 gpointer imgdata = gaim_imgstore_get_data(image); | |
1369 | |
1370 oscar_id++; | |
1371 | |
1372 /* ... insert a new img tag with the oscar id ... */ | |
1373 if (filename) | |
1374 g_string_append_printf(msg, | |
9126 | 1375 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1376 filename, oscar_id, size); |
1377 else | |
1378 g_string_append_printf(msg, | |
9126 | 1379 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
8971 | 1380 oscar_id, size); |
1381 | |
1382 /* ... and append the data to the binary section ... */ | |
9126 | 1383 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
8971 | 1384 oscar_id, size); |
1385 data = g_string_append_len(data, imgdata, size); | |
1386 data = g_string_append(data, "</DATA>"); | |
1387 } | |
1388 /* If the tag is invalid, skip it, thus no else here */ | |
1389 | |
1390 g_datalist_clear(&attribs); | |
1391 | |
1392 /* continue from the end of the tag */ | |
1393 last = end + 1; | |
1394 } | |
1395 | |
1396 /* append any remaining message data (without the > :-) */ | |
1397 if (last && *last) | |
1398 msg = g_string_append(msg, last); | |
1399 | |
1400 /* if we inserted any images in the binary section, append it */ | |
1401 if (oscar_id) { | |
1402 msg = g_string_append_len(msg, data->str, data->len); | |
1403 msg = g_string_append(msg, "</BINARY>"); | |
1404 } | |
1405 | |
1406 len = msg->len; | |
1407 buf = msg->str; | |
1408 g_string_free(msg, FALSE); | |
1409 g_string_free(data, TRUE); | |
1410 | |
1411 | |
1412 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
1413 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
1414 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
1415 else | |
1416 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
1417 | |
1418 g_free(buf); | |
1419 | |
1420 return ret; | |
1421 } | |
1422 | |
1423 struct ask_do_dir_im { | |
1424 char *who; | |
1425 GaimConnection *gc; | |
1426 }; | |
1427 | |
1428 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
1429 g_free(data->who); | |
1430 g_free(data); | |
1431 } | |
1432 | |
8983 | 1433 /* this function is used to initiate a direct im session with someone. |
1434 * we start listening on a port and send a request. they either connect | |
1435 * or send some kind of reply. If they can't connect, they ask us to | |
1436 * connect to them, and so we do that. | |
1437 * | |
1438 * this function will also get called if the other side initiate's a direct | |
1439 * im and we try to connect and fail. in that case cookie will not be null. | |
1440 * | |
1441 * note that cookie is an 8 byte string that isn't NULL terminated | |
1442 */ | |
1443 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
8971 | 1444 OscarData *od; |
1445 struct oscar_direct_im *dim; | |
1446 int listenfd; | |
8982 | 1447 const char *ip; |
8971 | 1448 |
1449 od = (OscarData *)gc->proto_data; | |
1450 | |
8983 | 1451 dim = oscar_direct_im_find(od, who); |
8971 | 1452 if (dim) { |
1453 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
1454 oscar_direct_im_disconnect(od, dim); | |
1455 gaim_debug_info("oscar", | |
1456 "Gave up on old direct IM, trying again\n"); | |
1457 } else { | |
1458 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
8980 | 1459 return; |
8971 | 1460 } |
1461 } | |
1462 dim = g_new0(struct oscar_direct_im, 1); | |
1463 dim->gc = gc; | |
8983 | 1464 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
8971 | 1465 |
1466 listenfd = gaim_network_listen_range(5190, 5199); | |
8982 | 1467 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9455 | 1468 if (listenfd >= 0) |
1469 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
8971 | 1470 if (dim->conn != NULL) { |
8982 | 1471 char *tmp; |
1472 GaimConversation *conv; | |
1473 | |
8971 | 1474 od->direct_ims = g_slist_append(od->direct_ims, dim); |
1475 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
1476 oscar_callback, dim->conn); | |
1477 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
1478 gaim_odc_initiate, 0); | |
8982 | 1479 |
8983 | 1480 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
1481 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
8982 | 1482 gaim_network_get_port_from_fd(listenfd)); |
1483 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
1484 g_free(tmp); | |
8971 | 1485 } else { |
1486 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
1487 oscar_direct_im_destroy(od, dim); | |
1488 } | |
8983 | 1489 } |
1490 | |
1491 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
1492 GaimConnection *gc = data->gc; | |
1493 | |
1494 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
1495 g_free(data->who); | |
1496 g_free(data); | |
1497 return; | |
1498 } | |
1499 | |
1500 oscar_direct_im_initiate(gc, data->who, NULL); | |
8971 | 1501 g_free(data->who); |
1502 g_free(data); | |
1503 } | |
1504 | |
1505 /* this is the right click menu cb thingy */ | |
9030 | 1506 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
1507 | |
1508 GaimBuddy *buddy; | |
1509 GaimConnection *gc; | |
8971 | 1510 gchar *buf; |
9030 | 1511 struct ask_do_dir_im *data; |
1512 | |
1513 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
1514 | |
1515 buddy = (GaimBuddy *) node; | |
1516 gc = gaim_account_get_connection(buddy->account); | |
1517 | |
1518 data = g_new0(struct ask_do_dir_im, 1); | |
1519 data->who = g_strdup(buddy->name); | |
8971 | 1520 data->gc = gc; |
9030 | 1521 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
1522 buddy->name); | |
8971 | 1523 |
1524 gaim_request_action(gc, NULL, buf, | |
9030 | 1525 _("Because this reveals your IP address, it " |
1526 "may be considered a privacy risk. Do you " | |
1527 "wish to continue?"), | |
1528 0, data, 2, | |
1529 _("Connect"), G_CALLBACK(oscar_direct_im), | |
1530 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
8971 | 1531 g_free(buf); |
1532 } | |
1533 | |
1534 /***************************************************************************** | |
1535 * End scary direct im stuff | |
1536 *****************************************************************************/ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1537 |
4617 | 1538 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1539 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1540 aim_session_t *sess = aim_conn_getsess(conn); |
5575 | 1541 GaimConnection *gc = sess ? sess->aux_data : NULL; |
7283 | 1542 OscarData *od; |
2086 | 1543 |
1544 if (!gc) { | |
8660 | 1545 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1546 "oscar callback for closed connection (1).\n"); |
2086 | 1547 return; |
1548 } | |
1549 | |
7283 | 1550 od = (OscarData *)gc->proto_data; |
2086 | 1551 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1552 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1553 /* oh boy. this is probably bad. i guess the only thing we |
1554 * can really do is return? */ | |
8660 | 1555 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1556 "oscar callback for closed connection (2).\n"); |
8660 | 1557 gaim_debug_misc("oscar", "gc = %p\n", gc); |
2086 | 1558 return; |
1559 } | |
1560 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1561 if (condition & GAIM_INPUT_READ) { |
4617 | 1562 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
8660 | 1563 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1564 "got information on rendezvous listener\n"); |
4617 | 1565 if (aim_handlerendconnect(od->sess, conn) < 0) { |
8660 | 1566 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1567 "connection error (rendezvous listener)\n"); |
4617 | 1568 aim_conn_kill(od->sess, &conn); |
8446 | 1569 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
2086 | 1570 } |
1571 } else { | |
4617 | 1572 if (aim_get_command(od->sess, conn) >= 0) { |
1573 aim_rxdispatch(od->sess); | |
6029 | 1574 if (od->killme) { |
8660 | 1575 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
6029 | 1576 return; |
1577 } | |
2086 | 1578 } else { |
1579 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 1580 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
8660 | 1581 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1582 "major connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1583 gaim_connection_error(gc, _("Disconnected.")); |
2086 | 1584 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
1585 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
9627 | 1586 GaimConversation *conv = gaim_find_chat(gc, c->id); |
5420 | 1587 char *buf; |
8660 | 1588 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1589 "disconnected from chat room %s\n", c->name); |
2086 | 1590 c->conn = NULL; |
1591 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1592 gaim_input_remove(c->inpa); |
2086 | 1593 c->inpa = 0; |
1594 c->fd = -1; | |
4617 | 1595 aim_conn_kill(od->sess, &conn); |
5420 | 1596 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
9627 | 1597 if (conv) |
1598 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
1599 else | |
1600 gaim_notify_error(gc, NULL, buf, NULL); | |
5420 | 1601 g_free(buf); |
2086 | 1602 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 1603 if (od->cnpa > 0) |
1604 gaim_input_remove(od->cnpa); | |
1605 od->cnpa = 0; | |
8660 | 1606 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1607 "removing chatnav input watcher\n"); |
4617 | 1608 while (od->create_rooms) { |
1609 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1610 g_free(cr->name); |
4617 | 1611 od->create_rooms = |
1612 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1613 g_free(cr); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1614 gaim_notify_error(gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1615 _("Chat is currently unavailable"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1616 NULL); |
2086 | 1617 } |
4617 | 1618 aim_conn_kill(od->sess, &conn); |
2086 | 1619 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 1620 if (od->paspa > 0) |
1621 gaim_input_remove(od->paspa); | |
1622 od->paspa = 0; | |
8660 | 1623 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1624 "removing authconn input watcher\n"); |
4617 | 1625 aim_conn_kill(od->sess, &conn); |
3694 | 1626 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 1627 if (od->emlpa > 0) |
1628 gaim_input_remove(od->emlpa); | |
1629 od->emlpa = 0; | |
8660 | 1630 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1631 "removing email input watcher\n"); |
4617 | 1632 aim_conn_kill(od->sess, &conn); |
4804 | 1633 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
1634 if (od->icopa > 0) | |
1635 gaim_input_remove(od->icopa); | |
1636 od->icopa = 0; | |
8660 | 1637 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1638 "removing icon input watcher\n"); |
4804 | 1639 aim_conn_kill(od->sess, &conn); |
2086 | 1640 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1641 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 1642 gaim_odc_disconnect(od->sess, conn); |
1643 aim_conn_kill(od->sess, &conn); | |
2086 | 1644 } else { |
8660 | 1645 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1646 "holy crap! generic connection error! %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1647 conn->type); |
4617 | 1648 aim_conn_kill(od->sess, &conn); |
2086 | 1649 } |
1650 } | |
1651 } | |
1652 } | |
1653 } | |
1654 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1655 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
5575 | 1656 GaimConnection *gc = sess->aux_data; |
7285 | 1657 gchar *s = g_strdup_vprintf(format, va); |
1658 gchar *buf; | |
1659 | |
1660 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
8660 | 1661 gaim_debug_info("oscar", buf); |
7285 | 1662 if (buf[strlen(buf)-1] != '\n') |
8660 | 1663 gaim_debug_info(NULL, "\n"); |
7285 | 1664 g_free(buf); |
2086 | 1665 g_free(s); |
1666 } | |
1667 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1668 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1669 { |
5575 | 1670 GaimConnection *gc = data; |
7283 | 1671 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1672 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1673 aim_conn_t *conn; |
2086 | 1674 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1675 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1676 close(source); |
1677 return; | |
1678 } | |
1679 | |
4617 | 1680 od = gc->proto_data; |
1681 sess = od->sess; | |
2086 | 1682 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1683 conn->fd = source; |
2086 | 1684 |
1685 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1686 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1687 return; |
1688 } | |
1689 | |
1690 aim_conn_completeconnect(sess, conn); | |
4617 | 1691 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
7282 | 1692 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
1693 | |
8660 | 1694 gaim_debug_info("oscar", |
7282 | 1695 "Screen name sent, waiting for response\n"); |
7283 | 1696 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
8341 | 1697 ck[1] = 0x65; |
2086 | 1698 } |
1699 | |
5575 | 1700 static void oscar_login(GaimAccount *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1701 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1702 aim_conn_t *conn; |
5575 | 1703 GaimConnection *gc = gaim_account_get_connection(account); |
7283 | 1704 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
2086 | 1705 |
8660 | 1706 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1707 |
8437 | 1708 if (!aim_snvalid(gaim_account_get_username(account))) { |
1709 gchar *buf; | |
8590 | 1710 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 | 1711 gaim_connection_error(gc, buf); |
1712 g_free(buf); | |
1713 } | |
1714 | |
9975 | 1715 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
4617 | 1716 od->icq = TRUE; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1717 } else { |
6622 | 1718 gc->flags |= GAIM_CONNECTION_HTML; |
1719 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1720 } |
5836 | 1721 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
2086 | 1722 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1723 sess = g_new0(aim_session_t, 1); |
7285 | 1724 aim_session_init(sess, TRUE, 0); |
2086 | 1725 aim_setdebuggingcb(sess, oscar_debug); |
7282 | 1726 /* |
1727 * We need an immediate queue because we don't use a while-loop | |
1728 * to see if things need to be sent. | |
1729 */ | |
2086 | 1730 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
4617 | 1731 od->sess = sess; |
2086 | 1732 sess->aux_data = gc; |
1733 | |
9935 | 1734 /* Connect to core Gaim signals */ |
9971 | 1735 od->recentbuddies_cbid = gaim_prefs_connect_callback("/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
9935 | 1736 |
2086 | 1737 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
1738 if (conn == NULL) { | |
8660 | 1739 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1740 "internal connection error\n"); |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1741 gaim_connection_error(gc, _("Unable to login to AIM")); |
2086 | 1742 return; |
1743 } | |
1744 | |
4649 | 1745 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 1746 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
1747 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
1748 | |
1749 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1750 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
5575 | 1751 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
1752 oscar_login_connect, gc) < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1753 gaim_connection_error(gc, _("Couldn't connect to host")); |
2086 | 1754 return; |
1755 } | |
7282 | 1756 |
7283 | 1757 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
8341 | 1758 ck[0] = 0x5a; |
5575 | 1759 } |
1760 | |
1761 static void oscar_close(GaimConnection *gc) { | |
7283 | 1762 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 1763 |
1764 while (od->oscar_chats) { | |
1765 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 1766 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1767 gaim_input_remove(n->inpa); |
2086 | 1768 g_free(n->name); |
1769 g_free(n->show); | |
4617 | 1770 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 1771 g_free(n); |
1772 } | |
4617 | 1773 while (od->direct_ims) { |
8971 | 1774 struct oscar_direct_im *n = od->direct_ims->data; |
1775 oscar_direct_im_destroy(od, n); | |
2086 | 1776 } |
4617 | 1777 /* BBB */ |
1778 while (od->file_transfers) { | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1779 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1780 xfer = (GaimXfer *)od->file_transfers->data; |
7805 | 1781 gaim_xfer_cancel_local(xfer); |
3630 | 1782 } |
4804 | 1783 while (od->requesticon) { |
1784 char *sn = od->requesticon->data; | |
1785 od->requesticon = g_slist_remove(od->requesticon, sn); | |
1786 free(sn); | |
1787 } | |
4738 | 1788 g_hash_table_destroy(od->buddyinfo); |
4617 | 1789 while (od->create_rooms) { |
1790 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1791 g_free(cr->name); |
4617 | 1792 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1793 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1794 } |
4617 | 1795 if (od->email) |
1796 g_free(od->email); | |
1797 if (od->newp) | |
1798 g_free(od->newp); | |
1799 if (od->oldp) | |
1800 g_free(od->oldp); | |
2086 | 1801 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1802 gaim_input_remove(gc->inpa); |
4617 | 1803 if (od->cnpa > 0) |
1804 gaim_input_remove(od->cnpa); | |
1805 if (od->paspa > 0) | |
1806 gaim_input_remove(od->paspa); | |
1807 if (od->emlpa > 0) | |
1808 gaim_input_remove(od->emlpa); | |
4804 | 1809 if (od->icopa > 0) |
1810 gaim_input_remove(od->icopa); | |
6907 | 1811 if (od->icontimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1812 gaim_timeout_remove(od->icontimer); |
8341 | 1813 if (od->getblisttimer > 0) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1814 gaim_timeout_remove(od->getblisttimer); |
8341 | 1815 if (od->getinfotimer > 0) |
1816 gaim_timeout_remove(od->getinfotimer); | |
9975 | 1817 gaim_prefs_disconnect_callback(od->recentbuddies_cbid); |
9971 | 1818 |
4617 | 1819 aim_session_kill(od->sess); |
1820 g_free(od->sess); | |
1821 od->sess = NULL; | |
2086 | 1822 g_free(gc->proto_data); |
1823 gc->proto_data = NULL; | |
8660 | 1824 gaim_debug_info("oscar", "Signed off.\n"); |
2086 | 1825 } |
1826 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1827 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 1828 GaimConnection *gc = data; |
7283 | 1829 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1830 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1831 aim_conn_t *bosconn; |
2086 | 1832 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1833 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 1834 close(source); |
1835 return; | |
1836 } | |
1837 | |
4617 | 1838 od = gc->proto_data; |
1839 sess = od->sess; | |
1840 bosconn = od->conn; | |
4366 | 1841 bosconn->fd = source; |
2086 | 1842 |
1843 if (source < 0) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1844 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 1845 return; |
1846 } | |
1847 | |
1848 aim_conn_completeconnect(sess, bosconn); | |
4617 | 1849 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
7283 | 1850 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1851 gaim_connection_update_progress(gc, |
7283 | 1852 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
8341 | 1853 ck[4] = 0x61; |
2086 | 1854 } |
1855 | |
4617 | 1856 /* BBB */ |
4656 | 1857 /* |
1858 * This little area in oscar.c is the nexus of file transfer code, | |
1859 * so I wrote a little explanation of what happens. I am such a | |
1860 * ninja. | |
1861 * | |
1862 * The series of events for a file send is: | |
1863 * -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
|
1864 * -User chooses a file and oscar_xfer_init is called. It establishes a |
4656 | 1865 * listening socket, then asks the remote user to connect to us (and |
1866 * gives them the file name, port, IP, etc.) | |
1867 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
1868 * in oscar_sendfile_estblsh) | |
1869 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
1870 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
1871 * connection. | |
1872 * -We get drunk because file transfer kicks ass. | |
1873 * | |
1874 * The series of events for a file receive is: | |
1875 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
1876 * -Gaim user selects file to name and location to save file to and | |
1877 * oscar_xfer_init is called | |
1878 * -It connects to the remote user using the IP they gave us earlier | |
1879 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
1880 * them an AIM_CB_OFT_ACK. | |
1881 * -They begin to send us lots of raw data. | |
1882 * -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
|
1883 * the connection. |
4656 | 1884 */ |
1885 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
1886 | |
8446 | 1887 /* |
1888 * Miscellaneous xfer functions | |
1889 */ | |
1890 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
4656 | 1891 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1892 GaimXfer *xfer; |
5146 | 1893 struct aim_oft_info *oft_info; |
4656 | 1894 |
1895 while (fts) { | |
1896 xfer = fts->data; | |
5146 | 1897 oft_info = xfer->data; |
1898 | |
8446 | 1899 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
4656 | 1900 return xfer; |
1901 | |
1902 fts = g_slist_next(fts); | |
1903 } | |
1904 | |
1905 return NULL; | |
1906 } | |
1907 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1908 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
4656 | 1909 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1910 GaimXfer *xfer; |
5146 | 1911 struct aim_oft_info *oft_info; |
4656 | 1912 |
1913 while (fts) { | |
1914 xfer = fts->data; | |
5146 | 1915 oft_info = xfer->data; |
1916 | |
1917 if (oft_info && (conn == oft_info->conn)) | |
4656 | 1918 return xfer; |
1919 | |
1920 fts = g_slist_next(fts); | |
1921 } | |
1922 | |
1923 return NULL; | |
1924 } | |
1925 | |
8446 | 1926 static void oscar_xfer_end(GaimXfer *xfer) |
1927 { | |
1928 struct aim_oft_info *oft_info = xfer->data; | |
1929 GaimConnection *gc = oft_info->sess->aux_data; | |
1930 OscarData *od = gc->proto_data; | |
1931 | |
8660 | 1932 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
8446 | 1933 |
1934 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
1935 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
1936 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
1937 } | |
1938 | |
1939 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1940 aim_oft_destroyinfo(oft_info); | |
1941 xfer->data = NULL; | |
1942 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1943 } | |
1944 | |
1945 /* | |
1946 * xfer functions used when receiving files | |
1947 */ | |
1948 | |
1949 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
1950 { | |
1951 struct aim_oft_info *oft_info = xfer->data; | |
1952 GaimConnection *gc = oft_info->sess->aux_data; | |
1953 OscarData *od = gc->proto_data; | |
1954 | |
8660 | 1955 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
8446 | 1956 |
1957 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
1958 if (oft_info->conn) { | |
1959 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
1960 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
1961 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
1962 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
1963 if (xfer->fd == -1) { | |
1964 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1965 _("Unable to establish file descriptor.")); | |
1966 gaim_xfer_cancel_local(xfer); | |
1967 } | |
1968 } else { | |
1969 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
1970 _("Unable to create new connection.")); | |
1971 gaim_xfer_cancel_local(xfer); | |
1972 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
1973 } | |
1974 | |
1975 } | |
1976 | |
1977 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
1978 { | |
1979 struct aim_oft_info *oft_info = xfer->data; | |
1980 GaimConnection *gc = oft_info->sess->aux_data; | |
1981 OscarData *od = gc->proto_data; | |
1982 | |
8660 | 1983 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
8446 | 1984 |
9771 | 1985 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
1986 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 1987 |
1988 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
1989 aim_oft_destroyinfo(oft_info); | |
1990 xfer->data = NULL; | |
1991 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
1992 } | |
1993 | |
1994 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
1995 { | |
1996 struct aim_oft_info *oft_info = xfer->data; | |
1997 | |
1998 /* Update our rolling checksum. Like Walmart, yo. */ | |
1999 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
2000 } | |
2001 | |
2002 /* | |
2003 * xfer functions used when sending files | |
2004 */ | |
2005 | |
2006 static void oscar_xfer_init_send(GaimXfer *xfer) | |
2007 { | |
2008 struct aim_oft_info *oft_info = xfer->data; | |
2009 GaimConnection *gc = oft_info->sess->aux_data; | |
2010 OscarData *od = gc->proto_data; | |
2011 int listenfd; | |
2012 | |
8660 | 2013 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
8446 | 2014 |
2015 xfer->filename = g_path_get_basename(xfer->local_filename); | |
2016 strncpy(oft_info->fh.name, xfer->filename, 64); | |
2017 oft_info->fh.name[63] = '\0'; | |
2018 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
2019 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
2020 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
2021 | |
2022 /* Create a listening socket and an associated libfaim conn */ | |
2023 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
2024 gaim_xfer_cancel_local(xfer); | |
2025 return; | |
2026 } | |
2027 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
2028 oft_info->port = xfer->local_port; | |
2029 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
2030 gaim_xfer_cancel_local(xfer); | |
2031 return; | |
2032 } | |
8660 | 2033 gaim_debug_misc("oscar", |
8446 | 2034 "port is %hu, ip is %s\n", |
2035 xfer->local_port, oft_info->clientip); | |
2036 if (oft_info->conn) { | |
2037 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2038 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
2039 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
2040 } else { | |
2041 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
2042 _("Unable to establish listener socket.")); | |
2043 gaim_xfer_cancel_local(xfer); | |
2044 } | |
2045 } | |
2046 | |
2047 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
2048 { | |
2049 struct aim_oft_info *oft_info = xfer->data; | |
2050 GaimConnection *gc = oft_info->sess->aux_data; | |
2051 OscarData *od = gc->proto_data; | |
2052 | |
8660 | 2053 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
8446 | 2054 |
9771 | 2055 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
2056 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
8446 | 2057 |
2058 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
2059 aim_oft_destroyinfo(oft_info); | |
2060 xfer->data = NULL; | |
2061 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
2062 } | |
2063 | |
2064 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
2065 { | |
2066 struct aim_oft_info *oft_info = xfer->data; | |
2067 | |
2068 /* I'm not sure I like how we do this. --marv | |
2069 * I do. AIM file transfers aren't really meant to be thought | |
2070 * of as a transferring just a single file. The rendezvous | |
2071 * establishes a connection between two computers, and then | |
2072 * those computers can use the same connection for transferring | |
2073 * multiple files. So we don't want the Gaim core up and closing | |
2074 * the socket all willy-nilly. We want to do that in the oscar | |
2075 * prpl, whenever one side or the other says they're finished | |
2076 * using the connection. There might be a better way to intercept | |
2077 * the socket from the core, however... --KingAnt | |
2078 */ | |
2079 | |
2080 /* | |
2081 * If we're done sending, intercept the socket from the core ft code | |
2082 * and wait for the other guy to send the "done" OFT packet. | |
2083 */ | |
2084 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
2085 gaim_input_remove(xfer->watcher); | |
2086 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
2087 xfer->fd = 0; | |
2088 gaim_xfer_set_completed(xfer, TRUE); | |
2089 } | |
2090 } | |
2091 | |
9466 | 2092 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
2093 gboolean can_receive = FALSE; | |
2094 OscarData *od = gc->proto_data; | |
2095 | |
2096 if (!od->icq) { | |
2097 aim_userinfo_t *userinfo; | |
2098 userinfo = aim_locate_finduserinfo(od->sess, who); | |
2099 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
2100 can_receive = TRUE; | |
2101 } | |
2102 | |
2103 return can_receive; | |
2104 } | |
2105 | |
2106 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
9030 | 2107 |
2108 OscarData *od; | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2109 GaimXfer *xfer; |
5146 | 2110 struct aim_oft_info *oft_info; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2111 const char *ip; |
3752 | 2112 |
9030 | 2113 od = (OscarData *)gc->proto_data; |
2114 | |
4617 | 2115 /* You want to send a file to someone else, you're so generous */ |
2116 | |
2117 /* Build the file transfer handle */ | |
9466 | 2118 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
4617 | 2119 |
5146 | 2120 /* Create the oscar-specific data */ |
8838 | 2121 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
9466 | 2122 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
5146 | 2123 xfer->data = oft_info; |
2124 | |
4617 | 2125 /* Setup our I/O op functions */ |
8446 | 2126 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
4617 | 2127 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2128 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
8446 | 2129 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
2130 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
4617 | 2131 |
2132 /* Keep track of this transfer for later */ | |
2133 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2134 | |
2135 /* Now perform the request */ | |
9466 | 2136 if (file) |
2137 gaim_xfer_request_accepted(xfer, file); | |
2138 else | |
2139 gaim_xfer_request(xfer); | |
3630 | 2140 } |
2141 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2142 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
6029 | 2143 GaimConnection *gc = sess->aux_data; |
7283 | 2144 OscarData *od = gc->proto_data; |
6029 | 2145 GaimAccount *account = gc->account; |
2146 aim_conn_t *bosconn; | |
2147 char *host; int port; | |
2148 int i, rc; | |
2086 | 2149 va_list ap; |
2704 | 2150 struct aim_authresp_info *info; |
6029 | 2151 |
5575 | 2152 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2153 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2154 va_start(ap, fr); |
2704 | 2155 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 2156 va_end(ap); |
2157 | |
8660 | 2158 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2159 "inside auth_resp (Screen name: %s)\n", info->sn); |
2704 | 2160 |
4293 | 2161 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 2162 char buf[256]; |
2704 | 2163 switch (info->errorcode) { |
2086 | 2164 case 0x05: |
2165 /* Incorrect nick/password */ | |
6498 | 2166 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2167 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
2086 | 2168 break; |
2169 case 0x11: | |
2170 /* Suspended account */ | |
6498 | 2171 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2172 gaim_connection_error(gc, _("Your account is currently suspended.")); |
2086 | 2173 break; |
3498 | 2174 case 0x14: |
2175 /* service temporarily unavailable */ | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2176 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
3498 | 2177 break; |
2086 | 2178 case 0x18: |
2179 /* connecting too frequently */ | |
6498 | 2180 gc->wants_to_die = TRUE; |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2181 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 | 2182 break; |
2183 case 0x1c: | |
2184 /* client too old */ | |
6498 | 2185 gc->wants_to_die = TRUE; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2186 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
|
2187 gaim_connection_error(gc, buf); |
2086 | 2188 break; |
2189 default: | |
6623 | 2190 gaim_connection_error(gc, _("Authentication failed")); |
2086 | 2191 break; |
2192 } | |
8660 | 2193 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2194 "Login Error Code 0x%04hx\n", info->errorcode); |
8660 | 2195 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2196 "Error URL: %s\n", info->errorurl); |
2086 | 2197 od->killme = TRUE; |
2198 return 1; | |
2199 } | |
2200 | |
2201 | |
9992 | 2202 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2203 |
2704 | 2204 if (info->email) { |
8660 | 2205 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
2086 | 2206 } else { |
8660 | 2207 gaim_debug_misc("oscar", "Email is NULL\n"); |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2208 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2209 |
8660 | 2210 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
2211 gaim_debug_info("oscar", | |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2212 "Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2213 aim_conn_kill(sess, &fr->conn); |
2086 | 2214 |
2215 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
2216 if (bosconn == NULL) { | |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2217 gaim_connection_error(gc, _("Internal Error")); |
2086 | 2218 od->killme = TRUE; |
2219 return 0; | |
2220 } | |
2221 | |
4649 | 2222 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2223 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 2224 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
2225 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
2226 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 2227 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 2228 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
2229 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
2230 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
2231 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
2232 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
2233 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 2234 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 2235 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
2236 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
2237 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
2238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
2239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 2240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
7011 | 2241 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
8341 | 2242 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
2086 | 2243 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
2244 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
|
2245 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 2246 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
2247 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
2248 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
2249 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2250 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
5844 | 2251 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
|
2252 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
|
2253 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
|
2254 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 2255 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 2256 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 2257 #ifndef NOSSI |
4642 | 2258 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 2259 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
2260 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
2261 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 2262 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
8227 | 2263 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
4230 | 2264 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
2265 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
2266 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
2267 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
2268 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2269 |
7283 | 2270 od->conn = bosconn; |
2704 | 2271 for (i = 0; i < (int)strlen(info->bosip); i++) { |
2272 if (info->bosip[i] == ':') { | |
2273 port = atoi(&(info->bosip[i+1])); | |
2086 | 2274 break; |
2275 } | |
2276 } | |
2704 | 2277 host = g_strndup(info->bosip, i); |
2086 | 2278 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2279 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 2280 g_free(host); |
4366 | 2281 if (rc < 0) { |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2282 gaim_connection_error(gc, _("Could Not Connect")); |
2086 | 2283 od->killme = TRUE; |
2284 return 0; | |
2285 } | |
4293 | 2286 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2287 gaim_input_remove(gc->inpa); |
2704 | 2288 |
7283 | 2289 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
8341 | 2290 ck[3] = 0x64; |
7282 | 2291 |
2086 | 2292 return 1; |
2293 } | |
2294 | |
7285 | 2295 /* XXX - Should use gaim_url_fetch for the below stuff */ |
2086 | 2296 struct pieceofcrap { |
5575 | 2297 GaimConnection *gc; |
2086 | 2298 unsigned long offset; |
2299 unsigned long len; | |
2300 char *modname; | |
2301 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2302 aim_conn_t *conn; |
2086 | 2303 unsigned int inpa; |
2304 }; | |
2305 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2306 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 2307 { |
2308 struct pieceofcrap *pos = data; | |
7283 | 2309 OscarData *od = pos->gc->proto_data; |
2086 | 2310 char in = '\0'; |
2311 int x = 0; | |
2312 unsigned char m[17]; | |
2313 | |
2314 while (read(pos->fd, &in, 1) == 1) { | |
2315 if (in == '\n') | |
2316 x++; | |
2317 else if (in != '\r') | |
2318 x = 0; | |
2319 if (x == 2) | |
2320 break; | |
2321 in = '\0'; | |
2322 } | |
2323 if (in != '\n') { | |
4056 | 2324 char buf[256]; |
2325 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
|
2326 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2327 gaim_notify_warning(pos->gc, NULL, |
7422 | 2328 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2329 buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2330 gaim_input_remove(pos->inpa); |
2086 | 2331 close(pos->fd); |
2332 g_free(pos); | |
2333 return; | |
2334 } | |
2335 read(pos->fd, m, 16); | |
2336 m[16] = '\0'; | |
8660 | 2337 gaim_debug_misc("oscar", "Sending hash: "); |
2086 | 2338 for (x = 0; x < 16; x++) |
8660 | 2339 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
2340 | |
2341 gaim_debug_misc(NULL, "\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2342 gaim_input_remove(pos->inpa); |
2086 | 2343 close(pos->fd); |
2344 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
2345 g_free(pos); | |
2346 } | |
2347 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2348 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 2349 struct pieceofcrap *pos = data; |
5420 | 2350 gchar *buf; |
2086 | 2351 |
4366 | 2352 pos->fd = source; |
2353 | |
2086 | 2354 if (source < 0) { |
5420 | 2355 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
|
2356 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2357 gaim_notify_warning(pos->gc, NULL, |
7422 | 2358 _("Gaim was unable to get a valid AIM login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2359 buf); |
5420 | 2360 g_free(buf); |
2086 | 2361 if (pos->modname) |
2362 g_free(pos->modname); | |
2363 g_free(pos); | |
2364 return; | |
2365 } | |
2366 | |
5420 | 2367 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
2086 | 2368 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
2369 write(pos->fd, buf, strlen(buf)); | |
5420 | 2370 g_free(buf); |
2086 | 2371 if (pos->modname) |
2372 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2373 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 2374 return; |
2375 } | |
2376 | |
2377 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
2378 #define AIM_MAX_FILE_SIZE 98304 | |
2379 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2380 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2381 va_list ap; |
2382 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2383 fu32_t offset, len; |
2086 | 2384 char *modname; |
2385 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2386 va_start(ap, fr); |
4200 | 2387 offset = va_arg(ap, fu32_t); |
2388 len = va_arg(ap, fu32_t); | |
2086 | 2389 modname = va_arg(ap, char *); |
2390 va_end(ap); | |
2391 | |
8660 | 2392 gaim_debug_misc("oscar", |
5556 | 2393 "offset: %u, len: %u, file: %s\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2394 offset, len, (modname ? modname : "aim.exe")); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2395 |
2086 | 2396 if (len == 0) { |
8660 | 2397 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2398 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 2399 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2400 return 1; | |
2401 } | |
9625 | 2402 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
2403 #if 0 | |
2086 | 2404 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
2405 char *buf; | |
2406 int i = 8; | |
2407 if (modname) | |
2408 i += strlen(modname); | |
2409 buf = g_malloc(i); | |
2410 i = 0; | |
2411 if (modname) { | |
2412 memcpy(buf, modname, strlen(modname)); | |
2413 i += strlen(modname); | |
2414 } | |
2415 buf[i++] = offset & 0xff; | |
2416 buf[i++] = (offset >> 8) & 0xff; | |
2417 buf[i++] = (offset >> 16) & 0xff; | |
2418 buf[i++] = (offset >> 24) & 0xff; | |
2419 buf[i++] = len & 0xff; | |
2420 buf[i++] = (len >> 8) & 0xff; | |
2421 buf[i++] = (len >> 16) & 0xff; | |
2422 buf[i++] = (len >> 24) & 0xff; | |
8660 | 2423 gaim_debug_misc("oscar", "len + offset is invalid, " |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2424 "hashing request\n"); |
2086 | 2425 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
2426 g_free(buf); | |
2427 return 1; | |
2428 } | |
9625 | 2429 #endif |
2086 | 2430 |
2431 pos = g_new0(struct pieceofcrap, 1); | |
2432 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2433 pos->conn = fr->conn; |
2086 | 2434 |
2435 pos->offset = offset; | |
2436 pos->len = len; | |
2437 pos->modname = modname ? g_strdup(modname) : NULL; | |
2438 | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2439 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 2440 char buf[256]; |
2086 | 2441 if (pos->modname) |
2442 g_free(pos->modname); | |
2443 g_free(pos); | |
4056 | 2444 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
|
2445 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2446 gaim_notify_warning(pos->gc, NULL, |
7422 | 2447 _("Gaim was unable to get a valid login hash."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2448 buf); |
2086 | 2449 } |
2450 | |
2451 return 1; | |
2452 } | |
2453 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2454 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2455 GaimConnection *gc = sess->aux_data; |
7283 | 2456 OscarData *od = gc->proto_data; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2457 GaimAccount *account = gaim_connection_get_account(gc); |
5575 | 2458 GaimAccount *ac = gaim_connection_get_account(gc); |
7282 | 2459 #if 0 |
2460 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
2461 #endif | |
7011 | 2462 va_list ap; |
2463 char *key; | |
2086 | 2464 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2465 va_start(ap, fr); |
2086 | 2466 key = va_arg(ap, char *); |
2467 va_end(ap); | |
2468 | |
4617 | 2469 if (od->icq) { |
3458 | 2470 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2471 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2472 gaim_account_get_password(account), &info, key); |
3458 | 2473 } else { |
2474 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2475 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2476 gaim_account_get_password(account), &info, key); |
3458 | 2477 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2478 |
7283 | 2479 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
8341 | 2480 ck[2] = 0x6c; |
7282 | 2481 |
2086 | 2482 return 1; |
2483 } | |
2484 | |
2675 | 2485 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2486 GaimConnection *gc = sess->aux_data; |
2647 | 2487 struct chat_connection *chatcon; |
2488 static int id = 1; | |
2489 | |
6905 | 2490 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
|
2491 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
|
2492 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
|
2493 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
|
2494 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
2675 | 2495 |
2672 | 2496 aim_clientready(sess, fr->conn); |
2675 | 2497 |
2647 | 2498 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
2499 chatcon->id = id; | |
8733 | 2500 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
2647 | 2501 |
2502 return 1; | |
2503 } | |
2504 | |
2675 | 2505 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
2506 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2507 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 2508 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 2509 |
2510 aim_clientready(sess, fr->conn); | |
2511 | |
2512 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2513 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2514 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2515 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2516 |
3694 | 2517 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
2518 | |
2519 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2520 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
2521 | |
7282 | 2522 aim_email_sendcookies(sess); |
2523 aim_email_activate(sess); | |
3694 | 2524 aim_clientready(sess, fr->conn); |
2525 | |
2526 return 1; | |
2527 } | |
2528 | |
4804 | 2529 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2530 GaimConnection *gc = sess->aux_data; |
7283 | 2531 OscarData *od = gc->proto_data; |
4804 | 2532 |
2533 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
2534 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
2535 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
2536 | |
2537 aim_clientready(sess, fr->conn); | |
2538 | |
4823 | 2539 od->iconconnecting = FALSE; |
2540 | |
4804 | 2541 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2542 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2543 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
4804 | 2544 |
2545 return 1; | |
2546 } | |
2547 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2548 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2549 GaimConnection *gc = data; |
7283 | 2550 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2551 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2552 aim_conn_t *tstconn; |
2086 | 2553 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2554 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2555 close(source); |
2556 return; | |
2557 } | |
2558 | |
4617 | 2559 od = gc->proto_data; |
2560 sess = od->sess; | |
2086 | 2561 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 2562 tstconn->fd = source; |
2086 | 2563 |
2564 if (source < 0) { | |
2565 aim_conn_kill(sess, &tstconn); | |
8660 | 2566 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2567 "unable to connect to chatnav server\n"); |
2086 | 2568 return; |
2569 } | |
2570 | |
2571 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2572 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2573 gaim_debug_info("oscar", "chatnav: connected\n"); |
2086 | 2574 } |
2575 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2576 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2577 { |
5575 | 2578 GaimConnection *gc = data; |
7283 | 2579 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2580 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2581 aim_conn_t *tstconn; |
2086 | 2582 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2583 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2584 close(source); |
2585 return; | |
2586 } | |
2587 | |
4617 | 2588 od = gc->proto_data; |
2589 sess = od->sess; | |
2086 | 2590 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 2591 tstconn->fd = source; |
2086 | 2592 |
2593 if (source < 0) { | |
2594 aim_conn_kill(sess, &tstconn); | |
8660 | 2595 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2596 "unable to connect to authorizer\n"); |
2086 | 2597 return; |
2598 } | |
2599 | |
2600 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2601 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2602 gaim_debug_info("oscar", "admin: connected\n"); |
2086 | 2603 } |
2604 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2605 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 2606 { |
2607 struct chat_connection *ccon = data; | |
5575 | 2608 GaimConnection *gc = ccon->gc; |
7283 | 2609 OscarData *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2610 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2611 aim_conn_t *tstconn; |
2086 | 2612 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2613 if (!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 2614 close(source); |
2615 g_free(ccon->show); | |
2616 g_free(ccon->name); | |
2617 g_free(ccon); | |
2618 return; | |
2619 } | |
2620 | |
4617 | 2621 od = gc->proto_data; |
2622 sess = od->sess; | |
2086 | 2623 tstconn = ccon->conn; |
4366 | 2624 tstconn->fd = source; |
2086 | 2625 |
2626 if (source < 0) { | |
2627 aim_conn_kill(sess, &tstconn); | |
2628 g_free(ccon->show); | |
2629 g_free(ccon->name); | |
2630 g_free(ccon); | |
2631 return; | |
2632 } | |
2633 | |
2634 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 2635 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2636 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 2637 } |
2638 | |
3694 | 2639 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2640 GaimConnection *gc = data; |
7283 | 2641 OscarData *od; |
3694 | 2642 aim_session_t *sess; |
2643 aim_conn_t *tstconn; | |
2644 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2645 if (!g_list_find(gaim_connections_get_all(), gc)) { |
3694 | 2646 close(source); |
2647 return; | |
2648 } | |
2649 | |
4617 | 2650 od = gc->proto_data; |
2651 sess = od->sess; | |
3694 | 2652 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 2653 tstconn->fd = source; |
3694 | 2654 |
2655 if (source < 0) { | |
2656 aim_conn_kill(sess, &tstconn); | |
8660 | 2657 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2658 "unable to connect to email server\n"); |
3694 | 2659 return; |
2660 } | |
2661 | |
2662 aim_conn_completeconnect(sess, tstconn); | |
4617 | 2663 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
8660 | 2664 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2665 "email: connected\n"); |
3694 | 2666 } |
2667 | |
4804 | 2668 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
5575 | 2669 GaimConnection *gc = data; |
7283 | 2670 OscarData *od; |
4804 | 2671 aim_session_t *sess; |
2672 aim_conn_t *tstconn; | |
2673 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2674 if (!g_list_find(gaim_connections_get_all(), gc)) { |
4804 | 2675 close(source); |
2676 return; | |
2677 } | |
2678 | |
2679 od = gc->proto_data; | |
2680 sess = od->sess; | |
2681 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
2682 tstconn->fd = source; | |
2683 | |
2684 if (source < 0) { | |
2685 aim_conn_kill(sess, &tstconn); | |
8660 | 2686 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2687 "unable to connect to icon server\n"); |
4804 | 2688 return; |
2689 } | |
2690 | |
2691 aim_conn_completeconnect(sess, tstconn); | |
2692 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
8660 | 2693 gaim_debug_info("oscar", "icon: connected\n"); |
4804 | 2694 } |
2695 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2696 /* 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
|
2697 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2698 GaimConnection *gc = sess->aux_data; |
2699 GaimAccount *account = gaim_connection_get_account(gc); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2700 aim_conn_t *tstconn; |
4452 | 2701 int i; |
2086 | 2702 char *host; |
2703 int port; | |
4821 | 2704 va_list ap; |
2705 struct aim_redirect_data *redir; | |
2086 | 2706 |
5575 | 2707 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
2086 | 2708 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2709 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2710 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2711 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2712 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2713 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2714 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2715 port = atoi(&(redir->ip[i+1])); |
2086 | 2716 break; |
2717 } | |
2718 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2719 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2720 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2721 switch(redir->group) { |
2086 | 2722 case 0x7: /* Authorizer */ |
8660 | 2723 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2724 "Reconnecting with authorizor...\n"); |
2086 | 2725 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
2726 if (tstconn == NULL) { | |
8660 | 2727 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2728 "unable to reconnect with authorizer\n"); |
2086 | 2729 g_free(host); |
2730 return 1; | |
2731 } | |
4649 | 2732 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2733 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 2734 |
2735 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2736 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 2737 aim_conn_kill(sess, &tstconn); |
8660 | 2738 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2739 "unable to reconnect with authorizer\n"); |
2086 | 2740 g_free(host); |
2741 return 1; | |
2742 } | |
4293 | 2743 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2744 break; |
2745 | |
2086 | 2746 case 0xd: /* ChatNav */ |
2747 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
2748 if (tstconn == NULL) { | |
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 chatnav server\n"); |
2086 | 2751 g_free(host); |
2752 return 1; | |
2753 } | |
4649 | 2754 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2755 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 2756 |
2757 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2758 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 2759 aim_conn_kill(sess, &tstconn); |
8660 | 2760 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2761 "unable to connect to chatnav server\n"); |
2086 | 2762 g_free(host); |
2763 return 1; | |
2764 } | |
4293 | 2765 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 2766 break; |
2767 | |
2768 case 0xe: { /* Chat */ | |
2086 | 2769 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2770 |
2086 | 2771 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
2772 if (tstconn == NULL) { | |
8660 | 2773 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2774 "unable to connect to chat server\n"); |
2086 | 2775 g_free(host); |
2776 return 1; | |
2777 } | |
2778 | |
4649 | 2779 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 2780 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
2781 | |
2086 | 2782 ccon = g_new0(struct chat_connection, 1); |
2783 ccon->conn = tstconn; | |
2784 ccon->gc = gc; | |
2785 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2786 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2787 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2788 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2789 ccon->show = extract_name(redir->chat.room); |
4634 | 2790 |
2086 | 2791 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2792 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 2793 aim_conn_kill(sess, &tstconn); |
8660 | 2794 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2795 "unable to connect to chat server\n"); |
2086 | 2796 g_free(host); |
2797 g_free(ccon->show); | |
2798 g_free(ccon->name); | |
2799 g_free(ccon); | |
2800 return 1; | |
2801 } | |
4293 | 2802 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
8660 | 2803 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2804 "Connected to chat room %s exchange %hu\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2805 ccon->name, ccon->exchange); |
4194 | 2806 } break; |
3694 | 2807 |
4804 | 2808 case 0x0010: { /* icon */ |
2809 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
8660 | 2810 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2811 "unable to connect to icon server\n"); |
4804 | 2812 g_free(host); |
2813 return 1; | |
2814 } | |
2815 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
2816 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
2817 | |
2818 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2819 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
4804 | 2820 aim_conn_kill(sess, &tstconn); |
8660 | 2821 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2822 "unable to connect to icon server\n"); |
4804 | 2823 g_free(host); |
2824 return 1; | |
2825 } | |
2826 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
2827 } break; | |
2828 | |
3694 | 2829 case 0x0018: { /* email */ |
2830 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
8660 | 2831 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2832 "unable to connect to email server\n"); |
3694 | 2833 g_free(host); |
2834 return 1; | |
2835 } | |
4649 | 2836 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 2837 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
2838 | |
2839 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2840 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 2841 aim_conn_kill(sess, &tstconn); |
8660 | 2842 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2843 "unable to connect to email server\n"); |
3694 | 2844 g_free(host); |
2845 return 1; | |
2846 } | |
4293 | 2847 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 2848 } break; |
2849 | |
2086 | 2850 default: /* huh? */ |
8660 | 2851 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2852 "got redirect for unknown service 0x%04hx\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2853 redir->group); |
2086 | 2854 break; |
2855 } | |
2856 | |
2857 g_free(host); | |
2858 return 1; | |
2859 } | |
2860 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2861 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 2862 GaimConnection *gc = sess->aux_data; |
9058 | 2863 GaimAccount *account = gaim_connection_get_account(gc); |
7283 | 2864 OscarData *od = gc->proto_data; |
4738 | 2865 struct buddyinfo *bi; |
2993 | 2866 time_t time_idle = 0, signon = 0; |
2867 int type = 0; | |
2868 int caps = 0; | |
2086 | 2869 va_list ap; |
4738 | 2870 aim_userinfo_t *info; |
4194 | 2871 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2872 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2873 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2874 va_end(ap); |
2875 | |
2993 | 2876 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
2877 caps = info->capabilities; | |
3267 | 2878 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
2879 type |= UC_AB; | |
2880 | |
4766 | 2881 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2882 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
2883 type |= UC_UNCONFIRMED; | |
2884 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
2885 type |= UC_ADMIN; | |
2886 if (info->flags & AIM_FLAG_AOL) | |
2887 type |= UC_AOL; | |
2888 if (info->flags & AIM_FLAG_FREE) | |
2889 type |= UC_NORMAL; | |
2890 if (info->flags & AIM_FLAG_AWAY) | |
2891 type |= UC_UNAVAILABLE; | |
2892 if (info->flags & AIM_FLAG_WIRELESS) | |
2893 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2894 } |
2993 | 2895 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 2896 type = (info->icqinfo.status << 16); |
3013 | 2897 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
2898 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 2899 type |= UC_UNAVAILABLE; |
3013 | 2900 } |
2993 | 2901 } |
2902 | |
7141 | 2903 if (caps & AIM_CAPS_ICQ_DIRECT) |
2904 caps ^= AIM_CAPS_ICQ_DIRECT; | |
2993 | 2905 |
2906 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 2907 time(&time_idle); |
2908 time_idle -= info->idletime*60; | |
9295 | 2909 /* time_idle should be the seconds since epoch at which the user became idle */ |
2993 | 2910 } |
2911 | |
5836 | 2912 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
2913 signon = info->onlinesince; | |
2914 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
2993 | 2915 signon = time(NULL) - info->sessionlen; |
2086 | 2916 |
9982 | 2917 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) |
5575 | 2918 gaim_connection_set_display_name(gc, info->sn); |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2919 |
9982 | 2920 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
4738 | 2921 if (!bi) { |
2922 bi = g_new0(struct buddyinfo, 1); | |
9982 | 2923 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
4738 | 2924 } |
4739 | 2925 bi->typingnot = FALSE; |
2926 bi->ico_informed = FALSE; | |
6857 | 2927 bi->ipaddr = info->icqinfo.ipaddr; |
2928 | |
2929 /* Available message stuff */ | |
6292 | 2930 free(bi->availmsg); |
7011 | 2931 if (info->avail != NULL) |
8225 | 2932 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
5837 | 2933 else |
6292 | 2934 bi->availmsg = NULL; |
4732 | 2935 |
4804 | 2936 /* Server stored icon stuff */ |
4853 | 2937 if (info->iconcsumlen) { |
7125 | 2938 const char *filename = NULL, *saved_b16 = NULL; |
9801 | 2939 char *b16 = NULL, *filepath = NULL; |
7093 | 2940 GaimBuddy *b = NULL; |
4853 | 2941 |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2942 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
9982 | 2943 b = gaim_find_buddy(account, info->sn); |
7093 | 2944 /* |
2945 * If for some reason the checksum is valid, but cached file is not.. | |
2946 * we want to know. | |
2947 */ | |
7693 | 2948 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
7093 | 2949 if (filename != NULL) { |
2950 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
7693 | 2951 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
2952 "icon_checksum"); | |
9801 | 2953 else { |
2954 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
2955 filename, NULL); | |
2956 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
2957 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
2958 "icon_checksum"); | |
2959 g_free(filepath); | |
2960 } | |
7093 | 2961 } else |
2962 saved_b16 = NULL; | |
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2963 |
4853 | 2964 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
2965 GSList *cur = od->requesticon; | |
2966 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
2967 cur = cur->next; | |
2968 if (!cur) { | |
9982 | 2969 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
4853 | 2970 if (od->icontimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2971 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2972 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4853 | 2973 } |
2974 } | |
6053 | 2975 g_free(b16); |
4853 | 2976 } |
2977 | |
9982 | 2978 gaim_debug_info("oscar", "Signaling got online status for buddy '%s'\n", info->sn); |
2979 | |
2980 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_ONLINE, NULL); | |
2981 gaim_prpl_got_user_login_time(account, info->sn, signon); | |
2982 gaim_prpl_got_user_warning_level(account, info->sn, info->warnlevel/10.0 + 0.5); | |
2983 | |
2984 if (time_idle > 0) | |
2985 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
10009 | 2986 else |
2987 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
2086 | 2988 |
2989 return 1; | |
2990 } | |
2991 | |
8341 | 2992 static void gaim_check_comment(OscarData *od, const char *str) { |
2993 if ((str == NULL) || strcmp(str, ck)) | |
2994 aim_locate_setcaps(od->sess, caps_aim); | |
2995 else | |
2996 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
2997 } | |
2998 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2999 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3000 GaimConnection *gc = sess->aux_data; |
7283 | 3001 OscarData *od = gc->proto_data; |
9982 | 3002 GaimAccount *account = gaim_connection_get_account(gc); |
2086 | 3003 va_list ap; |
4739 | 3004 aim_userinfo_t *info; |
2086 | 3005 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3006 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3007 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3008 va_end(ap); |
3009 | |
9982 | 3010 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
2086 | 3011 |
7261 | 3012 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
5837 | 3013 |
2086 | 3014 return 1; |
3015 } | |
3016 | |
4617 | 3017 /* BBB */ |
3952 | 3018 /* |
4617 | 3019 * This is called after a remote AIM user has connected to us. We |
3020 * want to do some voodoo with the socket file descriptors, add a | |
3021 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 3022 */ |
4656 | 3023 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3024 GaimConnection *gc = sess->aux_data; |
7283 | 3025 OscarData *od = (OscarData *)gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3026 GaimXfer *xfer; |
5146 | 3027 struct aim_oft_info *oft_info; |
3630 | 3028 va_list ap; |
3029 aim_conn_t *conn, *listenerconn; | |
4656 | 3030 |
8660 | 3031 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3032 "AAA - in oscar_sendfile_estblsh\n"); |
3630 | 3033 va_start(ap, fr); |
3034 conn = va_arg(ap, aim_conn_t *); | |
3035 listenerconn = va_arg(ap, aim_conn_t *); | |
3036 va_end(ap); | |
3037 | |
4617 | 3038 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
3039 return 1; | |
3040 | |
5146 | 3041 if (!(oft_info = xfer->data)) |
4617 | 3042 return 1; |
3043 | |
3630 | 3044 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 3045 gaim_input_remove(xfer->watcher); |
3630 | 3046 aim_conn_kill(sess, &listenerconn); |
3047 | |
5146 | 3048 oft_info->conn = conn; |
3049 xfer->fd = oft_info->conn->fd; | |
3050 | |
3051 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
3052 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
3053 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3054 |
3055 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3056 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
3630 | 3057 |
3058 return 0; | |
3059 } | |
3060 | |
3952 | 3061 /* |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3062 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
4617 | 3063 * user in order to transfer a file. |
3952 | 3064 */ |
4617 | 3065 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
|
3066 GaimXfer *xfer; |
5146 | 3067 struct aim_oft_info *oft_info; |
4656 | 3068 |
8660 | 3069 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3070 "AAA - in oscar_sendfile_connected\n"); |
4617 | 3071 if (!(xfer = data)) |
3072 return; | |
5146 | 3073 if (!(oft_info = xfer->data)) |
3630 | 3074 return; |
8446 | 3075 if (source < 0) { |
3076 gaim_xfer_cancel_remote(xfer); | |
4617 | 3077 return; |
8446 | 3078 } |
4617 | 3079 |
3080 xfer->fd = source; | |
5146 | 3081 oft_info->conn->fd = source; |
3082 | |
3083 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
3084 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
4617 | 3085 |
3086 /* Inform the other user that we are connected and ready to transfer */ | |
5146 | 3087 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
4617 | 3088 |
3089 return; | |
3630 | 3090 } |
3091 | |
3952 | 3092 /* |
4617 | 3093 * This is called when a buddy sends us some file info. This happens when they |
3094 * are sending a file to you, and you have just established a connection to them. | |
4650 | 3095 * You should send them the exact same info except use the real cookie. We also |
4617 | 3096 * get like totally ready to like, receive the file, kay? |
3952 | 3097 */ |
4617 | 3098 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3099 GaimConnection *gc = sess->aux_data; |
7283 | 3100 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3101 GaimXfer *xfer; |
5146 | 3102 struct aim_oft_info *oft_info; |
4617 | 3103 va_list ap; |
3104 aim_conn_t *conn; | |
3105 fu8_t *cookie; | |
3106 struct aim_fileheader_t *fh; | |
4656 | 3107 |
8660 | 3108 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3109 "AAA - in oscar_sendfile_prompt\n"); |
4617 | 3110 va_start(ap, fr); |
3111 conn = va_arg(ap, aim_conn_t *); | |
3112 cookie = va_arg(ap, fu8_t *); | |
3113 fh = va_arg(ap, struct aim_fileheader_t *); | |
3114 va_end(ap); | |
3115 | |
3116 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3117 return 1; | |
3118 | |
5146 | 3119 if (!(oft_info = xfer->data)) |
4617 | 3120 return 1; |
3121 | |
3122 /* We want to stop listening with a normal thingy */ | |
3123 gaim_input_remove(xfer->watcher); | |
3124 xfer->watcher = 0; | |
3125 | |
5146 | 3126 /* They sent us some information about the file they're sending */ |
3127 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
3128 | |
3129 /* Fill in the cookie */ | |
3130 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
3131 | |
4617 | 3132 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
5146 | 3133 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
4617 | 3134 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3135 | |
3136 return 0; | |
3630 | 3137 } |
3138 | |
3952 | 3139 /* |
4657 | 3140 * We are sending a file to someone else. They have just acknowledged our |
4617 | 3141 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 3142 */ |
4617 | 3143 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 3144 GaimConnection *gc = sess->aux_data; |
7283 | 3145 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3146 GaimXfer *xfer; |
4617 | 3147 va_list ap; |
3148 aim_conn_t *conn; | |
3149 fu8_t *cookie; | |
3150 struct aim_fileheader_t *fh; | |
4656 | 3151 |
8660 | 3152 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
4617 | 3153 va_start(ap, fr); |
3154 conn = va_arg(ap, aim_conn_t *); | |
3155 cookie = va_arg(ap, fu8_t *); | |
3156 fh = va_arg(ap, struct aim_fileheader_t *); | |
3157 va_end(ap); | |
3158 | |
3159 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
3160 return 1; | |
3161 | |
4656 | 3162 /* We want to stop listening with a normal thingy */ |
3163 gaim_input_remove(xfer->watcher); | |
3164 xfer->watcher = 0; | |
3165 | |
4617 | 3166 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
3167 | |
3168 return 0; | |
3630 | 3169 } |
4617 | 3170 |
3171 /* | |
3172 * We just sent a file to someone. They said they got it and everything, | |
3173 * so we can close our direct connection and what not. | |
3174 */ | |
3175 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 3176 GaimConnection *gc = sess->aux_data; |
7283 | 3177 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3178 GaimXfer *xfer; |
4617 | 3179 va_list ap; |
3180 aim_conn_t *conn; | |
3181 fu8_t *cookie; | |
3182 struct aim_fileheader_t *fh; | |
4656 | 3183 |
8660 | 3184 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
4617 | 3185 va_start(ap, fr); |
3186 conn = va_arg(ap, aim_conn_t *); | |
3187 cookie = va_arg(ap, fu8_t *); | |
3188 fh = va_arg(ap, struct aim_fileheader_t *); | |
3189 va_end(ap); | |
3190 | |
3191 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
3192 return 1; | |
3193 | |
4656 | 3194 xfer->fd = conn->fd; |
4617 | 3195 gaim_xfer_end(xfer); |
3196 | |
3197 return 0; | |
3198 } | |
3630 | 3199 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3200 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
5575 | 3201 GaimConnection *gc = sess->aux_data; |
7283 | 3202 OscarData *od = gc->proto_data; |
8708 | 3203 GaimAccount *account = gaim_connection_get_account(gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3204 GaimConvImFlags flags = 0; |
4738 | 3205 struct buddyinfo *bi; |
5575 | 3206 const char *iconfile; |
9806 | 3207 GString *message; |
3208 gchar *tmp; | |
3209 aim_mpmsg_section_t *curpart; | |
3210 | |
3211 gaim_debug_misc("oscar", "Recived IM from %s with %d parts\n", | |
3212 userinfo->sn, args->mpmsg.numparts); | |
4738 | 3213 |
8708 | 3214 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
4738 | 3215 if (!bi) { |
3216 bi = g_new0(struct buddyinfo, 1); | |
8708 | 3217 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
4738 | 3218 } |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3219 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3220 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3221 flags |= GAIM_CONV_IM_AUTO_RESP; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3222 |
4738 | 3223 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3224 bi->typingnot = TRUE; | |
3225 else | |
3226 bi->typingnot = FALSE; | |
3227 | |
4380 | 3228 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
8660 | 3229 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3230 "%s has an icon\n", userinfo->sn); |
4738 | 3231 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
3232 bi->ico_need = TRUE; | |
3233 bi->ico_len = args->iconlen; | |
3234 bi->ico_csum = args->iconsum; | |
3235 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3236 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3237 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3238 |
8708 | 3239 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
7406 | 3240 (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
|
3241 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3242 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3243 |
5575 | 3244 if (!stat(iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3245 char *buf = g_malloc(st.st_size); |
5575 | 3246 file = fopen(iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3247 if (file) { |
9532 | 3248 /* XXX - Use g_file_get_contents() */ |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3249 int len = fread(buf, 1, st.st_size, file); |
8660 | 3250 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3251 "Sending buddy icon to %s (%d bytes, " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3252 "%lu reported)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3253 userinfo->sn, len, st.st_size); |
4617 | 3254 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
3255 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3256 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3257 } else |
8660 | 3258 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3259 "Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3260 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3261 } else |
8660 | 3262 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3263 "Can't stat buddy icon file!\n"); |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3264 } |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3265 |
9806 | 3266 message = g_string_new(""); |
3267 curpart = args->mpmsg.parts; | |
3268 while (curpart != NULL) { | |
9908 | 3269 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, |
9806 | 3270 curpart->data, curpart->datalen); |
3271 if (tmp != NULL) { | |
3272 g_string_append(message, tmp); | |
3273 g_free(tmp); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3274 } |
9806 | 3275 |
3276 curpart = curpart->next; | |
3277 } | |
3278 tmp = g_string_free(message, FALSE); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3279 |
8666 | 3280 /* |
8995 | 3281 * If the message is being received by an ICQ user then escape any HTML, |
9016 | 3282 * because HTML is not sent over ICQ as a means to format a message. |
8995 | 3283 * so any HTML we receive is intended to be displayed |
3284 * | |
3285 * Note: There *may* be some clients which send messages as HTML formatted - | |
3286 * they need to be special-cased somehow. | |
8666 | 3287 */ |
9982 | 3288 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
8995 | 3289 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
3290 gchar *tmp2 = gaim_escape_html(tmp); | |
8493 | 3291 g_free(tmp); |
3292 tmp = tmp2; | |
3293 } | |
3294 | |
6982 | 3295 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3296 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3297 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3298 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3299 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3300 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3301 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
9070 | 3302 GaimConnection *gc; |
9933 | 3303 GaimAccount *account; |
9070 | 3304 OscarData *od; |
9933 | 3305 const char *username = NULL; |
3306 char *message = NULL; | |
9070 | 3307 |
3308 g_return_val_if_fail(sess != NULL, 0); | |
3309 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
3310 | |
3311 gc = sess->aux_data; | |
9933 | 3312 account = gaim_connection_get_account(gc); |
9070 | 3313 od = gc->proto_data; |
9933 | 3314 username = gaim_account_get_username(account); |
3315 | |
3316 if (args == NULL) | |
4121 | 3317 return 0; |
4194 | 3318 |
9933 | 3319 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3320 userinfo->sn, args->status); | |
3321 | |
3322 if (args->msg != NULL) | |
3323 { | |
3324 if (args->encoding != NULL) | |
3325 { | |
3326 char *encoding = NULL; | |
3327 encoding = oscar_encoding_extract(args->encoding); | |
3328 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3329 g_free(encoding); | |
3330 } else { | |
3331 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3332 message = g_strdup(args->msg); | |
3333 } | |
3334 } | |
2869 | 3335 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3336 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 3337 char *name; |
5234 | 3338 GHashTable *components; |
3339 | |
9933 | 3340 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3341 g_free(message); | |
4121 | 3342 return 1; |
9933 | 3343 } |
5234 | 3344 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3345 g_free); | |
4121 | 3346 name = extract_name(args->info.chat.roominfo.name); |
5234 | 3347 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3348 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
|
3349 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3350 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3351 userinfo->sn, |
9933 | 3352 message, |
5234 | 3353 components); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3354 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3355 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3356 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 3357 /* BBB */ |
3358 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
3359 /* Someone wants to send a file (or files) to us */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3360 GaimXfer *xfer; |
5146 | 3361 struct aim_oft_info *oft_info; |
3362 | |
3363 if (!args->cookie || !args->port || !args->verifiedip || | |
3364 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 3365 !args->info.sendfile.totfiles || !args->reqclass) { |
8660 | 3366 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3367 "%s tried to send you a file with incomplete " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3368 "information.\n", userinfo->sn); |
5146 | 3369 if (args->proxyip) |
8660 | 3370 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3371 "IP for a proxy server was given. Gaim " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3372 "does not support this yet.\n"); |
9933 | 3373 g_free(message); |
4617 | 3374 return 1; |
4656 | 3375 } |
4617 | 3376 |
3377 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
3378 /* 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
|
3379 * directory -- remove the star and trailing slash so we don't save |
4617 | 3380 * directories that look like 'dirname\*' -- arl */ |
3381 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
3382 if (tmp && (tmp[1] == '*')) { | |
3383 tmp[0] = '\0'; | |
3384 } | |
8660 | 3385 gaim_debug_warning("oscar", |
8446 | 3386 "We're receiving a whole directory! What fun! " |
3387 "Especially since we don't support that!\n"); | |
4617 | 3388 } |
3389 | |
3390 /* Build the file transfer handle */ | |
3391 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
5163 | 3392 xfer->remote_ip = g_strdup(args->verifiedip); |
5146 | 3393 xfer->remote_port = args->port; |
4617 | 3394 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3395 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
9933 | 3396 gaim_xfer_set_message(xfer, message); |
5146 | 3397 |
3398 /* Create the oscar-specific data */ | |
5163 | 3399 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
4898 | 3400 if (args->proxyip) |
5146 | 3401 oft_info->proxyip = g_strdup(args->proxyip); |
4898 | 3402 if (args->verifiedip) |
5146 | 3403 oft_info->verifiedip = g_strdup(args->verifiedip); |
3404 xfer->data = oft_info; | |
4617 | 3405 |
3406 /* Setup our I/O op functions */ | |
8446 | 3407 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
4617 | 3408 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
8446 | 3409 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
|
3410 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
8446 | 3411 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
4617 | 3412 |
3413 /* Keep track of this transfer for later */ | |
3414 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
3415 | |
3416 /* Now perform the request */ | |
3417 gaim_xfer_request(xfer); | |
3418 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
3419 /* The other user wants to cancel a file transfer */ | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3420 GaimXfer *xfer; |
8660 | 3421 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3422 "AAA - File transfer canceled by remote user\n"); |
4617 | 3423 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
|
3424 gaim_xfer_cancel_remote(xfer); |
4617 | 3425 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
3426 /* | |
3427 * This gets sent by the receiver of a file | |
3428 * as they connect directly to us. If we don't | |
3429 * get this, then maybe a third party connected | |
3430 * to us, and we shouldn't send them anything. | |
3431 */ | |
3432 } else { | |
8660 | 3433 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3434 "unknown rendezvous status!\n"); |
3630 | 3435 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3436 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
8092 | 3437 } else if (args->reqclass & AIM_CAPS_TALK) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3438 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
9933 | 3439 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3440 args->info.icon.icon, | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3441 args->info.icon.length); |
6871 | 3442 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
8971 | 3443 /* 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
|
3444 struct ask_direct *d = g_new0(struct ask_direct, 1); |
8971 | 3445 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
|
3446 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3447 |
4212 | 3448 if (!args->verifiedip) { |
8983 | 3449 /* TODO: do something about this, after figuring out what it means */ |
8660 | 3450 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3451 "directim kill blocked (%s)\n", userinfo->sn); |
9933 | 3452 g_free(message); |
4650 | 3453 return 1; |
4212 | 3454 } |
3455 | |
8660 | 3456 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3457 "%s received direct im request from %s (%s)\n", |
8983 | 3458 username, userinfo->sn, args->clientip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3459 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3460 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3461 d->sn = g_strdup(userinfo->sn); |
8983 | 3462 /* Let's use the clientip here, because I think that's what AIM does. |
3463 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
3464 * and then ask them to connect to us. */ | |
3465 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
|
3466 memcpy(d->cookie, args->cookie, 8); |
9070 | 3467 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
3468 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
3469 | |
8971 | 3470 oscar_direct_im_destroy(od, dim); |
8984 | 3471 d->donttryagain = TRUE; |
8971 | 3472 accept_direct_im_request(d); |
3473 } else { | |
8983 | 3474 if (dim && !dim->connected) |
8971 | 3475 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
3476 "already connected to that buddy!"); | |
5575 | 3477 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
|
3478 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3479 gaim_request_action(gc, NULL, buf, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3480 _("This requires a direct connection between " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3481 "the two computers and is necessary for IM " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3482 "Images. Because your IP address will be " |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3483 "revealed, this may be considered a privacy " |
9972 | 3484 "risk."), |
3485 GAIM_DEFAULT_ACTION_NONE, d, 2, | |
8971 | 3486 _("Connect"), G_CALLBACK(accept_direct_im_request), |
3487 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
3488 /* FIXME: we should actually send a packet on cancel */ | |
3489 } | |
8708 | 3490 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
3491 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
|
3492 } else { |
8660 | 3493 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3494 "Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3495 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3496 |
9933 | 3497 g_free(message); |
3498 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3499 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3500 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3501 |
3453 | 3502 /* |
4230 | 3503 * Authorization Functions |
3504 * Most of these are callbacks from dialogs. They're used by both | |
3505 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 3506 */ |
4269 | 3507 /* When you ask other people for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3508 static void gaim_auth_request(struct name_data *data, char *msg) { |
5575 | 3509 GaimConnection *gc = data->gc; |
4244 | 3510 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3511 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3512 OscarData *od = gc->proto_data; |
6695 | 3513 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
3514 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4244 | 3515 if (buddy && group) { |
8660 | 3516 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3517 "ssi: adding buddy %s to group %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3518 buddy->name, group->name); |
4889 | 3519 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 3520 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
9620 | 3521 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
4244 | 3522 } |
4230 | 3523 } |
4337 | 3524 } |
3525 | |
3526 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3527 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
8697 | 3528 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3529 _("OK"), G_CALLBACK(gaim_auth_request), |
5836 | 3530 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3531 data); |
4230 | 3532 } |
3533 | |
3534 static void gaim_auth_dontrequest(struct name_data *data) { | |
5575 | 3535 GaimConnection *gc = data->gc; |
4244 | 3536 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3537 if (g_list_find(gaim_connections_get_all(), gc)) { |
8151 | 3538 /* Remove from local list */ |
3539 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
3540 gaim_blist_remove_buddy(b); | |
4244 | 3541 } |
3542 | |
5836 | 3543 oscar_free_name_data(data); |
4230 | 3544 } |
3545 | |
9030 | 3546 |
3547 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
4269 | 3548 struct name_data *data = g_new(struct name_data, 1); |
6695 | 3549 GaimBuddy *buddy; |
4269 | 3550 gchar *dialog_msg, *nombre; |
3551 | |
4687 | 3552 buddy = gaim_find_buddy(gc->account, name); |
9620 | 3553 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
3554 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
4269 | 3555 else |
4830 | 3556 nombre = NULL; |
3557 | |
3558 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 | 3559 data->gc = gc; |
3560 data->name = g_strdup(name); | |
3561 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3562 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3563 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3564 0, data, 2, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3565 _("Request Authorization"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3566 G_CALLBACK(gaim_auth_request_msgprompt), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3567 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
4269 | 3568 |
3569 g_free(dialog_msg); | |
3570 g_free(nombre); | |
3571 } | |
3572 | |
9030 | 3573 |
3574 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
3575 GaimBuddy *buddy; | |
3576 GaimConnection *gc; | |
3577 | |
3578 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3579 | |
3580 buddy = (GaimBuddy *) node; | |
3581 gc = gaim_account_get_connection(buddy->account); | |
3582 gaim_auth_sendrequest(gc, buddy->name); | |
3583 } | |
3584 | |
4230 | 3585 /* When other people ask you for authorization */ |
3586 static void gaim_auth_grant(struct name_data *data) { | |
5575 | 3587 GaimConnection *gc = data->gc; |
4244 | 3588 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3589 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3590 OscarData *od = gc->proto_data; |
4236 | 3591 #ifdef NOSSI |
6695 | 3592 GaimBuddy *buddy; |
4244 | 3593 gchar message; |
3594 message = 0; | |
4687 | 3595 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 3596 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
9620 | 3597 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 3598 #else |
4889 | 3599 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 3600 #endif |
4244 | 3601 } |
3602 | |
5836 | 3603 oscar_free_name_data(data); |
3141 | 3604 } |
3605 | |
4230 | 3606 /* When other people ask you for authorization */ |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3607 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
5575 | 3608 GaimConnection *gc = data->gc; |
4244 | 3609 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3610 if (g_list_find(gaim_connections_get_all(), gc)) { |
7283 | 3611 OscarData *od = gc->proto_data; |
4230 | 3612 #ifdef NOSSI |
4617 | 3613 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 3614 #else |
4889 | 3615 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 3616 #endif |
4244 | 3617 } |
4337 | 3618 } |
3619 | |
3620 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3621 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
8697 | 3622 NULL, _("No reason given."), TRUE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3623 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
5836 | 3624 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3625 data); |
3141 | 3626 } |
3627 | |
7023 | 3628 /* When someone sends you buddies */ |
3629 static void gaim_icq_buddyadd(struct name_data *data) { | |
5575 | 3630 GaimConnection *gc = data->gc; |
4244 | 3631 |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3632 if (g_list_find(gaim_connections_get_all(), gc)) { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3633 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
4244 | 3634 } |
3635 | |
5836 | 3636 oscar_free_name_data(data); |
3453 | 3637 } |
3638 | |
4075 | 3639 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 | 3640 GaimConnection *gc = sess->aux_data; |
9908 | 3641 GaimAccount *account = gaim_connection_get_account(gc); |
4076 | 3642 gchar **msg1, **msg2; |
6051 | 3643 int i, numtoks; |
4076 | 3644 |
4121 | 3645 if (!args->type || !args->msg || !args->uin) |
3646 return 1; | |
4194 | 3647 |
8660 | 3648 gaim_debug_info("oscar", |
9908 | 3649 "Received a channel 4 message of type 0x%02hhx.\n", |
3650 args->type); | |
4076 | 3651 |
9919 | 3652 /* |
3653 * Split up the message at the delimeter character, then convert each | |
3654 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
3655 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
3656 * character in whatever encoding the message was sent in. Type 1 | |
3657 * messages are always made up of only one part, so we can easily account | |
3658 * for this suck-ass part of the protocol by splitting the string into at | |
3659 * most 1 baby string. | |
3660 */ | |
3661 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
6051 | 3662 for (numtoks=0; msg1[numtoks]; numtoks++); |
3663 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
4076 | 3664 for (i=0; msg1[i]; i++) { |
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3665 gaim_str_strip_cr(msg1[i]); |
9908 | 3666 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
4076 | 3667 } |
3668 msg2[i] = NULL; | |
3669 | |
3952 | 3670 switch (args->type) { |
4173 | 3671 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 3672 if (i >= 1) { |
5556 | 3673 gchar *uin = g_strdup_printf("%u", args->uin); |
8493 | 3674 gchar *tmp; |
3675 | |
3676 /* If the message came from an ICQ user then escape any HTML */ | |
8501 | 3677 tmp = gaim_escape_html(msg2[0]); |
8493 | 3678 |
4076 | 3679 if (t) { /* This is an offline message */ |
9680 | 3680 /* The timestamp is UTC-ish, so we need to get the offset */ |
9698 | 3681 #ifdef HAVE_TM_GMTOFF |
9724 | 3682 time_t now; |
3683 struct tm *tm; | |
3684 now = time(NULL); | |
3685 tm = localtime(&now); | |
3686 t += tm->tm_gmtoff; | |
9698 | 3687 #else |
3688 # ifdef HAVE_TIMEZONE | |
9680 | 3689 tzset(); |
3690 t -= timezone; | |
9698 | 3691 # endif |
3692 #endif | |
8514 | 3693 serv_got_im(gc, uin, tmp, 0, t); |
4076 | 3694 } else { /* This is a message from MacICQ/Miranda */ |
8514 | 3695 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
4076 | 3696 } |
3697 g_free(uin); | |
8493 | 3698 g_free(tmp); |
4075 | 3699 } |
3316 | 3700 } break; |
3701 | |
4173 | 3702 case 0x04: { /* Someone sent you a URL */ |
4076 | 3703 if (i >= 2) { |
7385 | 3704 if (msg2[1] != NULL) { |
3705 gchar *uin = g_strdup_printf("%u", args->uin); | |
3706 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
3707 msg2[1], | |
3708 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
3709 serv_got_im(gc, uin, message, 0, time(NULL)); | |
3710 g_free(uin); | |
3711 g_free(message); | |
3712 } | |
3453 | 3713 } |
3714 } break; | |
3715 | |
4173 | 3716 case 0x06: { /* Someone requested authorization */ |
4076 | 3717 if (i >= 6) { |
4230 | 3718 struct name_data *data = g_new(struct name_data, 1); |
5556 | 3719 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 | 3720 gaim_debug_info("oscar", |
5556 | 3721 "Received an authorization request from UIN %u\n", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3722 args->uin); |
4076 | 3723 data->gc = gc; |
5556 | 3724 data->name = g_strdup_printf("%u", args->uin); |
4230 | 3725 data->nick = NULL; |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3726 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3727 gaim_request_action(gc, NULL, _("Authorization Request"), |
9948 | 3728 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
3729 2, _("Authorize"), | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3730 G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3731 _("Deny"), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3732 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4076 | 3733 g_free(dialog_msg); |
3734 } | |
3141 | 3735 } break; |
3736 | |
4173 | 3737 case 0x07: { /* Someone has denied you authorization */ |
4076 | 3738 if (i >= 1) { |
7023 | 3739 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
|
3740 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3741 dialog_msg); |
4076 | 3742 g_free(dialog_msg); |
3743 } | |
3141 | 3744 } break; |
3745 | |
4173 | 3746 case 0x08: { /* Someone has granted you authorization */ |
7023 | 3747 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
|
3748 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3749 dialog_msg); |
3141 | 3750 g_free(dialog_msg); |
3751 } break; | |
3752 | |
4333 | 3753 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
3754 if (i >= 5) { | |
3755 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
|
3756 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
4333 | 3757 g_free(dialog_msg); |
3758 } | |
3759 } break; | |
3760 | |
4173 | 3761 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 3762 if (i >= 6) { |
4194 | 3763 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
|
3764 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
4076 | 3765 g_free(dialog_msg); |
3766 } | |
4075 | 3767 } break; |
3768 | |
4173 | 3769 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 3770 if (i >= 6) { |
4308 | 3771 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
|
3772 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
4076 | 3773 g_free(dialog_msg); |
3774 } | |
4075 | 3775 } break; |
3776 | |
4173 | 3777 case 0x12: { |
3141 | 3778 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
7023 | 3779 /* Someone added you to their buddy list? */ |
3141 | 3780 } break; |
3781 | |
7023 | 3782 case 0x13: { /* Someone has sent you some ICQ buddies */ |
7631 | 3783 guint i, num; |
3453 | 3784 gchar **text; |
4173 | 3785 text = g_strsplit(args->msg, "\376", 0); |
3453 | 3786 if (text) { |
3787 num = 0; | |
3788 for (i=0; i<strlen(text[0]); i++) | |
3789 num = num*10 + text[0][i]-48; | |
3790 for (i=0; i<num; i++) { | |
4230 | 3791 struct name_data *data = g_new(struct name_data, 1); |
7023 | 3792 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 | 3793 data->gc = gc; |
4790 | 3794 data->name = g_strdup(text[i*2+1]); |
3795 data->nick = g_strdup(text[i*2+2]); | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3796 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3797 gaim_request_action(gc, NULL, message, |
7023 | 3798 _("Do you want to add this buddy " |
3799 "to your buddy list?"), | |
9972 | 3800 GAIM_DEFAULT_ACTION_NONE, data, 2, |
7023 | 3801 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
5836 | 3802 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
3453 | 3803 g_free(message); |
3804 } | |
3805 g_strfreev(text); | |
3806 } | |
3807 } break; | |
3808 | |
7023 | 3809 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
3453 | 3810 /* This is boring and silly. */ |
3811 } break; | |
3812 | |
3141 | 3813 default: { |
8660 | 3814 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3815 "Received a channel 4 message of unknown type " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3816 "(type 0x%02hhx).\n", args->type); |
3141 | 3817 } break; |
3818 } | |
3819 | |
4076 | 3820 g_strfreev(msg1); |
3821 g_strfreev(msg2); | |
3822 | |
3141 | 3823 return 1; |
3824 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3825 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3826 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 3827 fu16_t channel; |
3828 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3829 aim_userinfo_t *userinfo; |
2086 | 3830 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3831 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3832 va_start(ap, fr); |
4200 | 3833 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3834 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3835 |
3141 | 3836 switch (channel) { |
3837 case 1: { /* standard message */ | |
3838 struct aim_incomingim_ch1_args *args; | |
3839 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
3840 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
3841 } break; | |
3842 | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3843 case 2: { /* rendezvous */ |
3141 | 3844 struct aim_incomingim_ch2_args *args; |
3845 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
3846 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
3847 } break; | |
3848 | |
3849 case 4: { /* ICQ */ | |
3850 struct aim_incomingim_ch4_args *args; | |
3851 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 3852 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 3853 } break; |
3854 | |
3855 default: { | |
8660 | 3856 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3857 "ICBM received on unsupported channel (channel " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3858 "0x%04hx).", channel); |
3141 | 3859 } break; |
2086 | 3860 } |
3861 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3862 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3863 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3864 return ret; |
2086 | 3865 } |
3866 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3867 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
8733 | 3868 GaimConnection *gc = sess->aux_data; |
3869 GaimAccount *account = gaim_connection_get_account(gc); | |
5420 | 3870 char *buf; |
2086 | 3871 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3872 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3873 aim_userinfo_t *userinfo; |
2086 | 3874 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3875 va_start(ap, fr); |
4200 | 3876 chan = (fu16_t)va_arg(ap, unsigned int); |
3877 userinfo = va_arg(ap, aim_userinfo_t *); | |
3878 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
3879 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 3880 va_end(ap); |
3881 | |
3882 switch(reason) { | |
5420 | 3883 case 0: /* Invalid (0) */ |
3884 buf = g_strdup_printf( | |
3885 ngettext( | |
4276 | 3886 "You missed %hu message from %s because it was invalid.", |
3887 "You missed %hu messages from %s because they were invalid.", | |
3888 nummissed), | |
4282 | 3889 nummissed, |
3890 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3891 break; |
5420 | 3892 case 1: /* Message too large */ |
3893 buf = g_strdup_printf( | |
3894 ngettext( | |
4276 | 3895 "You missed %hu message from %s because it was too large.", |
3896 "You missed %hu messages from %s because they were too large.", | |
3897 nummissed), | |
4282 | 3898 nummissed, |
3899 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3900 break; |
5420 | 3901 case 2: /* Rate exceeded */ |
3902 buf = g_strdup_printf( | |
3903 ngettext( | |
4276 | 3904 "You missed %hu message from %s because the rate limit has been exceeded.", |
3905 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
3906 nummissed), | |
4282 | 3907 nummissed, |
3908 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3909 break; |
5420 | 3910 case 3: /* Evil Sender */ |
3911 buf = g_strdup_printf( | |
3912 ngettext( | |
4276 | 3913 "You missed %hu message from %s because he/she was too evil.", |
3914 "You missed %hu messages from %s because he/she was too evil.", | |
3915 nummissed), | |
4282 | 3916 nummissed, |
3917 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3918 break; |
5420 | 3919 case 4: /* Evil Receiver */ |
3920 buf = g_strdup_printf( | |
3921 ngettext( | |
4276 | 3922 "You missed %hu message from %s because you are too evil.", |
3923 "You missed %hu messages from %s because you are too evil.", | |
3924 nummissed), | |
4282 | 3925 nummissed, |
3926 userinfo->sn); | |
2086 | 3927 break; |
3928 default: | |
5420 | 3929 buf = g_strdup_printf( |
3930 ngettext( | |
4276 | 3931 "You missed %hu message from %s for an unknown reason.", |
3932 "You missed %hu messages from %s for an unknown reason.", | |
3933 nummissed), | |
4282 | 3934 nummissed, |
3935 userinfo->sn); | |
2086 | 3936 break; |
3937 } | |
8733 | 3938 |
9627 | 3939 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
8733 | 3940 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 3941 g_free(buf); |
2086 | 3942 |
3943 return 1; | |
3944 } | |
3945 | |
4194 | 3946 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
5575 | 3947 GaimConnection *gc = sess->aux_data; |
7283 | 3948 OscarData *od = gc->proto_data; |
4617 | 3949 |
3950 /* BBB */ | |
3630 | 3951 switch (reason) { |
4151 | 3952 case 3: { /* Decline sendfile. */ |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3953 GaimXfer *xfer; |
8971 | 3954 struct oscar_direct_im *dim; |
3955 | |
8660 | 3956 gaim_debug_info("oscar", |
9070 | 3957 "AAA - Other user declined some sort of direct " |
8971 | 3958 "connect attempt (automaticly?)\n"); |
4617 | 3959 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
|
3960 gaim_xfer_cancel_remote(xfer); |
8971 | 3961 else if ((dim = oscar_direct_im_find(od, who))) { |
3962 /* AAA should use find by cookie or something here */ | |
3963 oscar_direct_im_disconnect(od, dim); | |
3964 } | |
4151 | 3965 } break; |
3966 | |
3967 default: { | |
8660 | 3968 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3969 "Received an unknown rendezvous client auto-response " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3970 "from %s. Type 0x%04hx\n", who, reason); |
4151 | 3971 } |
3630 | 3972 |
3973 } | |
3974 | |
3975 return 0; | |
3976 } | |
3977 | |
4194 | 3978 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
5575 | 3979 GaimConnection *gc = sess->aux_data; |
4151 | 3980 |
3981 switch(reason) { | |
3982 case 0x0003: { /* Reply from an ICQ status message request */ | |
9244 | 3983 char *title, *statusmsg, **splitmsg, *dialogmsg; |
3984 | |
3985 title = g_strdup_printf(_("Info for %s"), who); | |
4151 | 3986 |
3987 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
9244 | 3988 statusmsg = oscar_icqstatus(state); |
4151 | 3989 splitmsg = g_strsplit(msg, "\r\n", 0); |
9244 | 3990 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
3991 g_free(statusmsg); | |
4151 | 3992 g_strfreev(splitmsg); |
9244 | 3993 |
9797 | 3994 gaim_notify_userinfo(gc, who, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); |
9244 | 3995 |
3996 g_free(title); | |
3997 g_free(dialogmsg); | |
4151 | 3998 } break; |
3999 | |
4000 default: { | |
8660 | 4001 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4002 "Received an unknown client auto-response from %s. " |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4003 "Type 0x%04hx\n", who, reason); |
4151 | 4004 } break; |
4005 } /* end of switch */ | |
4006 | |
4007 return 0; | |
4008 } | |
4009 | |
3212 | 4010 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
4011 va_list ap; | |
4012 fu16_t chan, reason; | |
4013 char *who; | |
4014 | |
4015 va_start(ap, fr); | |
4200 | 4016 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4017 who = va_arg(ap, char *); |
4200 | 4018 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 4019 |
3952 | 4020 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 4021 char *cookie = va_arg(ap, char *); |
4151 | 4022 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 4023 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 4024 fu32_t state = 0; |
4151 | 4025 char *msg = NULL; |
4026 if (reason == 0x0003) { | |
4200 | 4027 state = va_arg(ap, fu32_t); |
4151 | 4028 msg = va_arg(ap, char *); |
4029 } | |
4030 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
4031 } | |
3952 | 4032 |
3212 | 4033 va_end(ap); |
4034 | |
4035 return 1; | |
4036 } | |
4037 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4038 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4039 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4040 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4041 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4042 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4043 va_start(ap, fr); |
4199 | 4044 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4045 va_end(ap); |
4046 | |
8660 | 4047 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4048 "snac threw error (reason 0x%04hx: %s)\n", reason, |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4049 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2086 | 4050 |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4051 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
5411 | 4052 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4053 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4054 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
4055 |
2086 | 4056 return 1; |
4057 } | |
4058 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4059 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9627 | 4060 GaimConnection *gc = sess->aux_data; |
4617 | 4061 #if 0 |
7283 | 4062 OscarData *od = gc->proto_data; |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4063 GaimXfer *xfer; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4064 #endif |
4617 | 4065 va_list ap; |
4066 fu16_t reason; | |
4067 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4068 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4069 va_start(ap, fr); |
4617 | 4070 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 4071 data = va_arg(ap, char *); |
2086 | 4072 va_end(ap); |
4073 | |
8660 | 4074 gaim_debug_error("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4075 "Message error with data %s and reason %hu\n", data, reason); |
4617 | 4076 |
4077 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4078 #if 0 |
4617 | 4079 /* If this was a file transfer request, data is a cookie */ |
4080 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
|
4081 gaim_xfer_cancel_remote(xfer); |
3630 | 4082 return 1; |
4083 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
4084 #endif |
3630 | 4085 |
4617 | 4086 /* Data is assumed to be the destination sn */ |
9826 | 4087 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
4088 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
4089 g_free(buf); | |
4090 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
9627 | 4091 gaim_notify_error(sess->aux_data, NULL, buf, |
9826 | 4092 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4093 } | |
4094 g_free(buf); | |
4095 | |
2086 | 4096 return 1; |
4097 } | |
4098 | |
3595 | 4099 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4100 GaimConnection *gc = sess->aux_data; |
3595 | 4101 va_list ap; |
4102 fu16_t type1, type2; | |
4103 char *sn; | |
4104 | |
4105 va_start(ap, fr); | |
4199 | 4106 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4107 sn = va_arg(ap, char *); |
4199 | 4108 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 4109 va_end(ap); |
4110 | |
4111 switch (type2) { | |
4112 case 0x0000: { /* Text has been cleared */ | |
4113 serv_got_typing_stopped(gc, sn); | |
4114 } break; | |
4115 | |
4116 case 0x0001: { /* Paused typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4117 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
3595 | 4118 } break; |
4119 | |
4120 case 0x0002: { /* Typing */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
4121 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
3595 | 4122 } break; |
4123 | |
4124 default: { | |
8660 | 4125 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 | 4126 } break; |
4127 } | |
4128 | |
4129 return 1; | |
4130 } | |
4131 | |
7141 | 4132 /* |
4133 * We get this error when there was an error in the locate family. This | |
7259 | 4134 * happens when you request info of someone who is offline. |
7141 | 4135 */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4136 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
9826 | 4137 gchar *buf; |
2086 | 4138 va_list ap; |
5420 | 4139 fu16_t reason; |
2086 | 4140 char *destn; |
4141 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4142 va_start(ap, fr); |
4199 | 4143 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4144 destn = va_arg(ap, char *); |
4145 va_end(ap); | |
4146 | |
7781 | 4147 if (destn == NULL) |
7793 | 4148 return 1; |
9627 | 4149 |
9826 | 4150 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4151 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
4152 g_free(buf); | |
9627 | 4153 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
9826 | 4154 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
4155 } | |
4156 g_free(buf); | |
2086 | 4157 |
4158 return 1; | |
4159 } | |
4160 | |
7011 | 4161 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4162 GaimConnection *gc = sess->aux_data; |
8700 | 4163 GaimAccount *account = gaim_connection_get_account(gc); |
4164 GString *str; | |
9244 | 4165 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
4791 | 4166 va_list ap; |
7011 | 4167 aim_userinfo_t *userinfo; |
2086 | 4168 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4169 va_start(ap, fr); |
7011 | 4170 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4171 va_end(ap); |
4172 | |
8700 | 4173 str = g_string_new(""); |
4174 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
4175 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
7011 | 4176 |
4177 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
8701 | 4178 oscar_string_append(str, "\n<br>", _("Online Since"), |
8700 | 4179 asctime(localtime((time_t *)&userinfo->onlinesince))); |
7011 | 4180 |
4181 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
8701 | 4182 oscar_string_append(str, "\n<br>", _("Member Since"), |
8700 | 4183 asctime(localtime((time_t *)&userinfo->membersince))); |
7011 | 4184 |
4185 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
8700 | 4186 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
8701 | 4187 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
8700 | 4188 g_free(tmp); |
4189 } | |
4190 | |
8701 | 4191 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
7011 | 4192 |
4193 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8700 | 4194 tmp = oscar_encoding_extract(userinfo->away_encoding); |
4195 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
4196 g_free(tmp); | |
7011 | 4197 if (away_utf8 != NULL) { |
8700 | 4198 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
7011 | 4199 g_free(away_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4200 } |
7011 | 4201 } |
4202 | |
4203 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
8700 | 4204 tmp = oscar_encoding_extract(userinfo->info_encoding); |
4205 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
4206 g_free(tmp); | |
7011 | 4207 if (info_utf8 != NULL) { |
8700 | 4208 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
7011 | 4209 g_free(info_utf8); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4210 } |
7011 | 4211 } |
4212 | |
8701 | 4213 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
8700 | 4214 g_string_free(str, TRUE); |
9244 | 4215 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
9797 | 4216 gaim_notify_userinfo(gc, userinfo->sn, title, _("Buddy Information"), NULL, tmp, NULL, NULL); |
9244 | 4217 g_free(title); |
8700 | 4218 g_free(tmp); |
4151 | 4219 |
2086 | 4220 return 1; |
4221 } | |
4222 | |
8341 | 4223 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4224 { | |
4225 aim_session_t *sess = data; | |
4226 GaimConnection *gc = sess->aux_data; | |
4227 OscarData *od = (OscarData *)gc->proto_data; | |
4228 | |
4229 aim_locate_dorequest(data); | |
4230 od->getinfotimer = 0; | |
4231 | |
4232 return FALSE; | |
4233 } | |
4234 | |
4235 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
4236 { | |
4237 GaimConnection *gc = sess->aux_data; | |
4238 OscarData *od = (OscarData *)gc->proto_data; | |
4239 | |
4240 /* | |
4241 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
4242 * us from hitting the rate limit due to request away messages and info | |
4243 * too quickly. | |
4244 */ | |
4245 if (od->getinfotimer == 0) | |
4246 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
4247 | |
4248 return 1; | |
4249 } | |
4250 | |
4251 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
4252 { | |
2086 | 4253 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4254 fu16_t id; |
2086 | 4255 va_list ap; |
4256 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4257 va_start(ap, fr); |
4199 | 4258 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4259 msg = va_arg(ap, char *); |
4260 va_end(ap); | |
4261 | |
8660 | 4262 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4263 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4264 if (id < 4) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4265 gaim_notify_warning(sess->aux_data, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4266 _("Your AIM connection may be lost."), NULL); |
2086 | 4267 |
4268 return 1; | |
4269 } | |
4270 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4271 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4272 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4273 fu16_t type; |
5575 | 4274 GaimConnection *gc = sess->aux_data; |
7283 | 4275 OscarData *od = (OscarData *)gc->proto_data; |
2086 | 4276 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4277 va_start(ap, fr); |
4199 | 4278 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4279 |
4280 switch(type) { | |
4281 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4282 fu8_t maxrooms; |
2086 | 4283 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4284 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4285 |
4199 | 4286 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 4287 exchangecount = va_arg(ap, int); |
4288 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
4289 | |
8660 | 4290 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4291 "chat info: Chat Rights:\n"); |
8660 | 4292 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4293 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
8660 | 4294 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4295 "chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4296 for (i = 0; i < exchangecount; i++) |
8660 | 4297 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4298 "chat info: \t\t%hu %s\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4299 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 4300 while (od->create_rooms) { |
4301 struct create_room *cr = od->create_rooms->data; | |
8660 | 4302 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4303 "creating room %s\n", cr->name); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4304 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4305 g_free(cr->name); |
4617 | 4306 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4307 g_free(cr); |
2086 | 4308 } |
4309 } | |
4310 break; | |
4311 case 0x0008: { | |
4312 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4313 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4314 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4315 fu32_t createtime; |
2086 | 4316 |
4317 fqcn = va_arg(ap, char *); | |
4200 | 4318 instance = (fu16_t)va_arg(ap, unsigned int); |
4319 exchange = (fu16_t)va_arg(ap, unsigned int); | |
4320 flags = (fu16_t)va_arg(ap, unsigned int); | |
4321 createtime = va_arg(ap, fu32_t); | |
4322 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4323 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
4324 createperms = (fu8_t)va_arg(ap, unsigned int); | |
4325 unknown = (fu16_t)va_arg(ap, unsigned int); | |
4326 name = va_arg(ap, char *); | |
4327 ck = va_arg(ap, char *); | |
4194 | 4328 |
8660 | 4329 gaim_debug_misc("oscar", |
5556 | 4330 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
2086 | 4331 fqcn, |
4332 exchange, instance, flags, | |
4333 createtime, | |
4334 maxmsglen, maxoccupancy, createperms, unknown, | |
4335 name, ck); | |
4617 | 4336 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 4337 } |
4338 break; | |
4339 default: | |
8660 | 4340 gaim_debug_warning("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4341 "chatnav info: unknown type (%04hx)\n", type); |
2086 | 4342 break; |
4343 } | |
4194 | 4344 |
4345 va_end(ap); | |
4346 | |
2086 | 4347 return 1; |
4348 } | |
4349 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4350 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4351 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4352 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4353 aim_userinfo_t *info; |
5575 | 4354 GaimConnection *g = sess->aux_data; |
2086 | 4355 |
4356 struct chat_connection *c = NULL; | |
4357 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4358 va_start(ap, fr); |
2086 | 4359 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4360 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4361 va_end(ap); |
4362 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4363 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4364 if (!c) |
4365 return 1; | |
4366 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4367 for (i = 0; i < count; i++) |
9846 | 4368 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
2086 | 4369 |
4370 return 1; | |
4371 } | |
4372 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4373 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4374 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4375 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4376 aim_userinfo_t *info; |
5575 | 4377 GaimConnection *g = sess->aux_data; |
2086 | 4378 |
4379 struct chat_connection *c = NULL; | |
4380 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4381 va_start(ap, fr); |
2086 | 4382 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4383 info = va_arg(ap, aim_userinfo_t *); |
2086 | 4384 va_end(ap); |
4385 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4386 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 4387 if (!c) |
4388 return 1; | |
4389 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4390 for (i = 0; i < count; i++) |
8733 | 4391 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
2086 | 4392 |
4393 return 1; | |
4394 } | |
4395 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4396 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
|
4397 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4398 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4399 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4400 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4401 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4402 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4403 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4404 fu32_t creationtime; |
5575 | 4405 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4406 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
|
4407 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4408 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4409 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4410 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4411 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4412 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4413 roomdesc = va_arg(ap, char *); |
4200 | 4414 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
4415 creationtime = va_arg(ap, fu32_t); | |
4416 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
4417 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
4418 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
4419 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4420 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4421 |
8660 | 4422 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4423 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4424 maxmsglen, maxvisiblemsglen); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4425 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4426 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4427 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4428 |
2086 | 4429 return 1; |
4430 } | |
4431 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4432 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4433 GaimConnection *gc = sess->aux_data; |
8225 | 4434 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
4435 gchar *utf8; | |
2086 | 4436 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4437 aim_userinfo_t *info; |
8225 | 4438 int len; |
2086 | 4439 char *msg; |
8219 | 4440 char *charset; |
2086 | 4441 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4442 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4443 info = va_arg(ap, aim_userinfo_t *); |
8219 | 4444 len = va_arg(ap, int); |
4194 | 4445 msg = va_arg(ap, char *); |
8219 | 4446 charset = va_arg(ap, char *); |
4194 | 4447 va_end(ap); |
2086 | 4448 |
8225 | 4449 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
8667 | 4450 if (utf8 == NULL) |
4451 /* The conversion failed! */ | |
8668 | 4452 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
8225 | 4453 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
4454 g_free(utf8); | |
2086 | 4455 |
4456 return 1; | |
4457 } | |
4458 | |
3694 | 4459 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
4460 va_list ap; | |
5575 | 4461 GaimConnection *gc = sess->aux_data; |
3694 | 4462 struct aim_emailinfo *emailinfo; |
3725 | 4463 int havenewmail; |
7297 | 4464 char *alertitle, *alerturl; |
3694 | 4465 |
4466 va_start(ap, fr); | |
4467 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 4468 havenewmail = va_arg(ap, int); |
7301 | 4469 alertitle = va_arg(ap, char *); |
4470 alerturl = va_arg(ap, char *); | |
3694 | 4471 va_end(ap); |
4472 | |
9661 | 4473 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
4474 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
4475 emailinfo->domain ? "@" : "", | |
4476 emailinfo->domain ? emailinfo->domain : ""); | |
5542 | 4477 if (emailinfo->unread && havenewmail) |
4478 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
5537 | 4479 g_free(to); |
3694 | 4480 } |
7297 | 4481 |
7301 | 4482 if (alertitle) |
8660 | 4483 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
3694 | 4484 |
4485 return 1; | |
4486 } | |
4487 | |
4804 | 4488 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4489 GaimConnection *gc = sess->aux_data; |
7283 | 4490 OscarData *od = gc->proto_data; |
4804 | 4491 char *sn; |
4492 | |
4493 sn = od->requesticon->data; | |
8660 | 4494 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4495 "removing %s from hash table\n", sn); |
4804 | 4496 od->requesticon = g_slist_remove(od->requesticon, sn); |
4497 free(sn); | |
4498 | |
4499 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4500 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4501 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
4804 | 4502 |
4503 return 1; | |
4504 } | |
4505 | |
4506 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 4507 GaimConnection *gc = sess->aux_data; |
7283 | 4508 OscarData *od = gc->proto_data; |
4804 | 4509 GSList *cur; |
4510 va_list ap; | |
4511 char *sn; | |
4853 | 4512 fu8_t *iconcsum, *icon; |
4513 fu16_t iconcsumlen, iconlen; | |
4804 | 4514 |
4515 va_start(ap, fr); | |
4516 sn = va_arg(ap, char *); | |
4853 | 4517 iconcsum = va_arg(ap, fu8_t *); |
4518 iconcsumlen = va_arg(ap, int); | |
4804 | 4519 icon = va_arg(ap, fu8_t *); |
4520 iconlen = va_arg(ap, int); | |
4521 va_end(ap); | |
4522 | |
4853 | 4523 if (iconlen > 0) { |
4524 char *b16; | |
6695 | 4525 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4526 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4527 sn, icon, iconlen); |
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4528 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
5129 | 4529 if (b16) { |
7693 | 4530 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
7162 | 4531 g_free(b16); |
5129 | 4532 } |
4853 | 4533 } |
4804 | 4534 |
4535 cur = od->requesticon; | |
4536 while (cur) { | |
4537 char *cursn = cur->data; | |
4538 if (!aim_sncmp(cursn, sn)) { | |
4539 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
4540 free(cursn); | |
4541 cur = od->requesticon; | |
4542 } else | |
4543 cur = cur->next; | |
4544 } | |
4545 | |
4546 if (od->icontimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4547 gaim_timeout_remove(od->icontimer); |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4548 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
4804 | 4549 |
4550 return 1; | |
4551 } | |
4552 | |
4553 static gboolean gaim_icon_timerfunc(gpointer data) { | |
5575 | 4554 GaimConnection *gc = data; |
7283 | 4555 OscarData *od = gc->proto_data; |
7011 | 4556 aim_userinfo_t *userinfo; |
4804 | 4557 aim_conn_t *conn; |
4558 | |
4559 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
5892 | 4560 if (!conn) { |
4561 if (!od->iconconnecting) { | |
4562 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
4563 od->iconconnecting = TRUE; | |
4564 } | |
4804 | 4565 return FALSE; |
4566 } | |
4567 | |
5842 | 4568 if (od->set_icon) { |
6039 | 4569 struct stat st; |
4570 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
4571 if (iconfile == NULL) { | |
8363 | 4572 aim_ssi_delicon(od->sess); |
6039 | 4573 } else if (!stat(iconfile, &st)) { |
4574 char *buf = g_malloc(st.st_size); | |
4575 FILE *file = fopen(iconfile, "rb"); | |
4576 if (file) { | |
9532 | 4577 /* XXX - Use g_file_get_contents()? */ |
6039 | 4578 fread(buf, 1, st.st_size, file); |
4579 fclose(file); | |
8660 | 4580 gaim_debug_info("oscar", |
6039 | 4581 "Uploading icon to icon server\n"); |
6879 | 4582 aim_bart_upload(od->sess, buf, st.st_size); |
5842 | 4583 } else |
8660 | 4584 gaim_debug_error("oscar", |
6039 | 4585 "Can't open buddy icon file!\n"); |
4586 g_free(buf); | |
4587 } else { | |
8660 | 4588 gaim_debug_error("oscar", |
6039 | 4589 "Can't stat buddy icon file!\n"); |
5842 | 4590 } |
4591 od->set_icon = FALSE; | |
4592 } | |
4593 | |
4594 if (!od->requesticon) { | |
8660 | 4595 gaim_debug_misc("oscar", |
5842 | 4596 "no more icons to request\n"); |
4597 return FALSE; | |
4598 } | |
4599 | |
7045 | 4600 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
7011 | 4601 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
4602 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
4804 | 4603 return FALSE; |
4604 } else { | |
4605 char *sn = od->requesticon->data; | |
4606 od->requesticon = g_slist_remove(od->requesticon, sn); | |
4607 free(sn); | |
4608 } | |
4609 | |
4610 return TRUE; | |
4611 } | |
4612 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4613 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4614 * 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
|
4615 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4616 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4617 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4618 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4619 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4620 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4621 va_start(ap, fr); |
4199 | 4622 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 4623 sn = va_arg(ap, char *); |
4624 va_end(ap); | |
4625 | |
8660 | 4626 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
2086 | 4627 |
4628 return 1; | |
4629 } | |
4630 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4631 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
|
4632 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4633 "invalid", |
4194 | 4634 "change", |
4635 "warning", | |
4636 "limit", | |
4637 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4638 }; |
2086 | 4639 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4640 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4641 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4642 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4643 va_start(ap, fr); |
4200 | 4644 code = (fu16_t)va_arg(ap, unsigned int); |
4645 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
4646 windowsize = va_arg(ap, fu32_t); | |
4647 clear = va_arg(ap, fu32_t); | |
4648 alert = va_arg(ap, fu32_t); | |
4649 limit = va_arg(ap, fu32_t); | |
4650 disconnect = va_arg(ap, fu32_t); | |
4651 currentavg = va_arg(ap, fu32_t); | |
4652 maxavg = va_arg(ap, fu32_t); | |
2086 | 4653 va_end(ap); |
4654 | |
8660 | 4655 gaim_debug_misc("oscar", |
5556 | 4656 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
4657 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
2086 | 4658 (code < 5) ? codes[code] : codes[0], |
4659 rateclass, | |
4660 currentavg, maxavg, | |
4661 alert, clear, | |
4662 limit, disconnect, | |
4663 windowsize); | |
4664 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4665 /* XXX fix these values */ |
2086 | 4666 if (code == AIM_RATE_CODE_CHANGE) { |
4667 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4668 aim_conn_setlatency(fr->conn, 0); |
2086 | 4669 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4670 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4671 } else if (code == AIM_RATE_CODE_LIMIT) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4672 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
6040 | 4673 _("The last action you attempted could not be " |
4674 "performed because you are over the rate limit. " | |
4675 "Please wait 10 seconds and try again.")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4676 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 4677 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4678 aim_conn_setlatency(fr->conn, 0); |
2086 | 4679 } |
4680 | |
4681 return 1; | |
4682 } | |
4683 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4684 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4685 GaimConnection *gc = sess->aux_data; |
4686 GaimAccount *account = gaim_connection_get_account(gc); | |
2086 | 4687 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4688 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4689 aim_userinfo_t *userinfo; |
2086 | 4690 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4691 va_start(ap, fr); |
4199 | 4692 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4693 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 4694 va_end(ap); |
4695 | |
9982 | 4696 /* XXX - What's with the + 0.5? */ |
4697 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
2086 | 4698 |
4699 return 1; | |
4700 } | |
4701 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4702 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
9982 | 4703 GaimConnection *gc = sess->aux_data; |
4704 GaimAccount *account = gaim_connection_get_account(gc); | |
4705 int warning_level; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4706 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4707 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4708 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4709 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4710 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4711 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4712 |
9982 | 4713 warning_level = info->warnlevel/10.0 + 0.5; |
4714 | |
4715 /* | |
4716 * XXX - Calling this is probably not good. We just want to set the | |
4717 * warning level for our account, not tell the user that we were just | |
4718 * warned. | |
4719 */ | |
4720 gaim_prpl_got_account_warning_level(account, NULL, warning_level); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4721 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4722 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4723 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4724 |
4649 | 4725 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4726 GaimConnection *gc = sess->aux_data; |
7283 | 4727 OscarData *od = gc->proto_data; |
4649 | 4728 va_list ap; |
4729 fu16_t code; | |
4730 char *msg; | |
4731 | |
4732 va_start(ap, fr); | |
4733 code = (fu16_t)va_arg(ap, int); | |
4734 msg = va_arg(ap, char *); | |
4735 va_end(ap); | |
4736 | |
8660 | 4737 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4738 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
4649 | 4739 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
4651 | 4740 if (code == 0x0001) { |
6113 | 4741 gc->wants_to_die = TRUE; |
5579 | 4742 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 4743 } else { |
5579 | 4744 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 4745 } |
4666 | 4746 od->killme = TRUE; |
4649 | 4747 } |
4748 | |
4749 return 1; | |
4750 } | |
4751 | |
2675 | 4752 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
7283 | 4753 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4754 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4755 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 4756 |
4757 #ifndef NOSSI | |
8660 | 4758 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
4889 | 4759 aim_ssi_reqrights(sess); |
6350 | 4760 aim_ssi_reqdata(sess); |
4230 | 4761 #endif |
4762 | |
7011 | 4763 aim_locate_reqrights(sess); |
7285 | 4764 aim_buddylist_reqrights(sess, fr->conn); |
4617 | 4765 aim_im_reqparams(sess); |
7334 | 4766 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
4230 | 4767 |
4768 #ifdef NOSSI | |
8660 | 4769 gaim_debug_info("oscar", "bos: requesting rights\n"); |
7334 | 4770 aim_bos_reqrights(sess, fr->conn); |
4230 | 4771 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
4772 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
4773 #endif | |
2086 | 4774 |
7283 | 4775 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
4776 | |
2086 | 4777 return 1; |
4778 } | |
4779 | |
2675 | 4780 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4781 GaimConnection *gc = sess->aux_data; |
7283 | 4782 OscarData *od = gc->proto_data; |
2647 | 4783 |
6905 | 4784 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
4785 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
4786 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
4787 | |
2672 | 4788 aim_clientready(sess, fr->conn); |
8660 | 4789 gaim_debug_info("oscar", "connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4790 |
2647 | 4791 if (od->chpass) { |
8660 | 4792 gaim_debug_info("oscar", "changing password\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4793 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 4794 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4795 od->oldp = NULL; |
2647 | 4796 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4797 od->newp = NULL; |
2647 | 4798 od->chpass = FALSE; |
4799 } | |
2979 | 4800 if (od->setnick) { |
8660 | 4801 gaim_debug_info("oscar", "formatting screen name\n"); |
2979 | 4802 aim_admin_setnick(sess, fr->conn, od->newsn); |
4803 g_free(od->newsn); | |
4804 od->newsn = NULL; | |
4805 od->setnick = FALSE; | |
4806 } | |
2647 | 4807 if (od->conf) { |
8660 | 4808 gaim_debug_info("oscar", "confirming account\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4809 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 4810 od->conf = FALSE; |
4811 } | |
4812 if (od->reqemail) { | |
8660 | 4813 gaim_debug_info("oscar", "requesting email\n"); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4814 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 4815 od->reqemail = FALSE; |
4816 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4817 if (od->setemail) { |
8660 | 4818 gaim_debug_info("oscar", "setting email\n"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4819 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4820 g_free(od->email); |
5497 | 4821 od->email = NULL; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4822 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4823 } |
2647 | 4824 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4825 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4826 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4827 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4828 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
|
4829 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4830 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4831 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4832 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4833 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4834 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4835 |
4194 | 4836 /* XXX - evidently this crashes on solaris. i have no clue why |
8660 | 4837 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
5556 | 4838 "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
|
4839 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4840 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4841 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4842 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4843 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4844 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 4845 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4846 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4847 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4848 |
4617 | 4849 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4850 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4851 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4852 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4853 |
2993 | 4854 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
4855 { | |
5575 | 4856 GaimConnection *gc = sess->aux_data; |
7283 | 4857 OscarData *od = (OscarData *)gc->proto_data; |
5306 | 4858 va_list ap; |
4859 fu16_t maxsiglen; | |
2993 | 4860 |
4861 va_start(ap, fr); | |
4199 | 4862 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 4863 va_end(ap); |
4864 | |
8660 | 4865 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4866 "locate rights: max sig len = %d\n", maxsiglen); |
2993 | 4867 |
4617 | 4868 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
4869 | |
4870 if (od->icq) | |
7334 | 4871 aim_locate_setcaps(od->sess, caps_icq); |
5301 | 4872 else |
7334 | 4873 aim_locate_setcaps(od->sess, caps_aim); |
4874 oscar_set_info(gc, gc->account->user_info); | |
2993 | 4875 |
4876 return 1; | |
4877 } | |
4878 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4879 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
|
4880 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4881 fu16_t maxbuddies, maxwatchers; |
5575 | 4882 GaimConnection *gc = sess->aux_data; |
7283 | 4883 OscarData *od = (OscarData *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4884 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4885 va_start(ap, fr); |
4199 | 4886 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
4887 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4888 va_end(ap); |
4889 | |
8660 | 4890 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4891 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 4892 |
4617 | 4893 od->rights.maxbuddies = (guint)maxbuddies; |
4894 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 4895 |
2086 | 4896 return 1; |
4897 } | |
4898 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4899 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 4900 GaimConnection *gc = sess->aux_data; |
7283 | 4901 OscarData *od = (OscarData *)gc->proto_data; |
7334 | 4902 va_list ap; |
4903 fu16_t maxpermits, maxdenies; | |
2086 | 4904 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4905 va_start(ap, fr); |
4199 | 4906 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
4907 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 4908 va_end(ap); |
4909 | |
8660 | 4910 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4911 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 4912 |
4617 | 4913 od->rights.maxpermits = (guint)maxpermits; |
4914 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 4915 |
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4916 gaim_connection_set_state(gc, GAIM_CONNECTED); |
2993 | 4917 serv_finish_login(gc); |
4918 | |
8660 | 4919 gaim_debug_info("oscar", "buddy list loaded\n"); |
2993 | 4920 |
2672 | 4921 aim_clientready(sess, fr->conn); |
5948 | 4922 aim_srv_setavailmsg(sess, NULL); |
7474 | 4923 aim_srv_setidle(sess, 0); |
4617 | 4924 |
4664 | 4925 if (od->icq) { |
4926 aim_icq_reqofflinemsgs(sess); | |
4927 aim_icq_hideip(sess); | |
4928 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4929 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4930 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 4931 if (sess->authinfo->email) |
4932 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 4933 |
4934 return 1; | |
4935 } | |
4936 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4937 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
|
4938 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4939 struct aim_icq_offlinemsg *msg; |
4075 | 4940 struct aim_incomingim_ch4_args args; |
4941 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4942 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4943 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4944 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4945 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4946 |
8660 | 4947 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4948 "Received offline message. Converting to channel 4 ICBM...\n"); |
4075 | 4949 args.uin = msg->sender; |
4950 args.type = msg->type; | |
4173 | 4951 args.flags = msg->flags; |
4076 | 4952 args.msglen = msg->msglen; |
4075 | 4953 args.msg = msg->msg; |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4954 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
4075 | 4955 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4956 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4957 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4958 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4959 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4960 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
|
4961 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4962 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4963 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4964 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4965 |
7388 | 4966 #if 0 |
4967 /* | |
7465 | 4968 * Update, 2003-11-09: |
4969 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
4970 * | |
7388 | 4971 * It may not be my place to do this, but... |
4972 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
4973 * stupid, and should not exist for % switches (%x in our case) that request | |
4974 * a year in the preferred representation for the current locale. For that | |
4975 * reason I've chosen to not use this workaround (n., see kluge). | |
4976 * | |
4977 * I have a date. I want to show it to the user in the "preferred" way. | |
4978 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
4979 * what the locale wanted. | |
4980 * | |
4981 * If I have a necessity for a full representation of the year in the current | |
4982 * locale, then I'll use a switch that returns a full representation of the | |
4983 * year. | |
4984 * | |
4985 * If you think the preferred locale should show 4 digits instead of 2 digits | |
4986 * (because you're anal, or whatever), then change the f***ing locale. | |
4987 * | |
4988 * I guess the bottom line is--I'm trying to show a date to the user how they | |
4989 * prefer to see it, why the hell does gcc want me to change that? | |
7389 | 4990 * |
4991 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
4992 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
7388 | 4993 */ |
4994 | |
4995 /* | |
4996 * This function was recommended by the STRFTIME(3) man page to remove the | |
7386 | 4997 * "last 2 digits" warning. |
4998 */ | |
4999 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
5000 const struct tm *tm) | |
5001 { | |
5002 return strftime(s, max, fmt, tm); | |
5003 } | |
7388 | 5004 #endif |
7386 | 5005 |
4624 | 5006 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
|
5007 { |
5575 | 5008 GaimConnection *gc = sess->aux_data; |
8670 | 5009 OscarData *od = (OscarData *)gc->proto_data; |
5010 GaimBuddy *buddy; | |
8853 | 5011 struct buddyinfo *bi = NULL; |
4624 | 5012 gchar who[16]; |
8670 | 5013 GString *str; |
5014 gchar *primary, *utf8; | |
9634 | 5015 const gchar *alias; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5016 va_list ap; |
4151 | 5017 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5018 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5019 va_start(ap, fr); |
4151 | 5020 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5021 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5022 |
4664 | 5023 if (!info->uin) |
5024 return 0; | |
5025 | |
8670 | 5026 str = g_string_sized_new(100); |
5556 | 5027 g_snprintf(who, sizeof(who), "%u", info->uin); |
8670 | 5028 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
5029 if (buddy != NULL) | |
5030 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
5031 | |
5032 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
8701 | 5033 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
8670 | 5034 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5035 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5036 (bi->ipaddr & 0xff000000) >> 24, | |
5037 (bi->ipaddr & 0x00ff0000) >> 16, | |
5038 (bi->ipaddr & 0x0000ff00) >> 8, | |
5039 (bi->ipaddr & 0x000000ff)); | |
8701 | 5040 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
8670 | 5041 g_free(tstr); |
5042 } | |
8701 | 5043 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
5044 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5045 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
8670 | 5046 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
5047 g_free(utf8); | |
4625 | 5048 } |
5049 if (info->numaddresses && info->email2) { | |
5050 int i; | |
5051 for (i = 0; i < info->numaddresses; i++) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5052 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
8670 | 5053 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
5054 g_free(utf8); | |
4643 | 5055 } |
4625 | 5056 } |
4624 | 5057 } |
8701 | 5058 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
10022 | 5059 if (info->gender != 0) |
5060 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); | |
4624 | 5061 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 5062 char date[30]; |
5063 struct tm tm; | |
5064 tm.tm_mday = (int)info->birthday; | |
5065 tm.tm_mon = (int)info->birthmonth-1; | |
5066 tm.tm_year = (int)info->birthyear-1900; | |
7388 | 5067 strftime(date, sizeof(date), "%x", &tm); |
8701 | 5068 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4151 | 5069 } |
4624 | 5070 if (info->age) { |
5071 char age[5]; | |
5072 snprintf(age, sizeof(age), "%hhd", info->age); | |
8701 | 5073 oscar_string_append(str, "\n<br>", _("Age"), age); |
4819 | 5074 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5075 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
8670 | 5076 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
5077 g_free(utf8); | |
4819 | 5078 } |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5079 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
8670 | 5080 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
5081 g_free(utf8); | |
5082 } | |
5083 g_string_append_printf(str, "<hr>\n"); | |
4641 | 5084 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
8670 | 5085 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
8701 | 5086 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
5087 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
5088 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
5089 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
8670 | 5090 g_string_append_printf(str, "\n<hr>\n"); |
4151 | 5091 } |
4641 | 5092 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
8670 | 5093 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
8701 | 5094 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
5095 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
5096 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
5097 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
8670 | 5098 g_string_append_printf(str, "\n<hr>\n"); |
4624 | 5099 } |
4641 | 5100 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
8670 | 5101 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
8701 | 5102 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
5103 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
5104 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5105 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
8670 | 5106 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
5107 g_free(utf8); | |
4624 | 5108 } |
8670 | 5109 g_string_append_printf(str, "\n<hr>\n"); |
5110 } | |
5111 | |
9634 | 5112 if (buddy != NULL) |
5113 alias = gaim_buddy_get_alias(buddy); | |
5114 else | |
5115 alias = who; | |
5116 primary = g_strdup_printf(_("ICQ Info for %s"), alias); | |
9810 | 5117 gaim_notify_userinfo(gc, who, NULL, primary, NULL, str->str, NULL, NULL); |
6873 | 5118 g_free(primary); |
8670 | 5119 g_string_free(str, TRUE); |
4151 | 5120 |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5121 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5122 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5123 |
4759 | 5124 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5125 { | |
5575 | 5126 GaimConnection *gc = sess->aux_data; |
4820 | 5127 gchar who[16], *utf8; |
6695 | 5128 GaimBuddy *b; |
4759 | 5129 va_list ap; |
5130 struct aim_icq_info *info; | |
5131 | |
5132 va_start(ap, fr); | |
5133 info = va_arg(ap, struct aim_icq_info *); | |
5134 va_end(ap); | |
5135 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5136 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
5556 | 5137 g_snprintf(who, sizeof(who), "%u", info->uin); |
4820 | 5138 serv_got_alias(gc, who, utf8); |
4759 | 5139 if ((b = gaim_find_buddy(gc->account, who))) { |
7693 | 5140 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
4759 | 5141 } |
4820 | 5142 g_free(utf8); |
4759 | 5143 } |
5144 | |
5145 return 1; | |
5146 } | |
5147 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5148 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
|
5149 { |
7032 | 5150 GaimConnection *gc = sess->aux_data; |
5151 gchar *text; | |
5152 va_list ap; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5153 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5154 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5155 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5156 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5157 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5158 url = va_arg(ap, char *); |
4199 | 5159 wid = (fu16_t) va_arg(ap, int); |
5160 hei = (fu16_t) va_arg(ap, int); | |
5161 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5162 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5163 |
7032 | 5164 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
5165 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
5166 g_free(text); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5167 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5168 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5169 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5170 |
7032 | 5171 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
5172 { | |
6873 | 5173 GaimConnection *gc = sess->aux_data; |
5174 gchar *secondary; | |
5175 GString *text; | |
5176 int i, num; | |
2086 | 5177 va_list ap; |
6873 | 5178 char *email, *SNs; |
2086 | 5179 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5180 va_start(ap, fr); |
6873 | 5181 email = va_arg(ap, char *); |
2086 | 5182 num = va_arg(ap, int); |
5183 SNs = va_arg(ap, char *); | |
5184 va_end(ap); | |
5185 | |
8152 | 5186 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
6873 | 5187 text = g_string_new(""); |
2086 | 5188 for (i = 0; i < num; i++) |
6873 | 5189 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
5190 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
5191 | |
5192 g_free(secondary); | |
5193 g_string_free(text, TRUE); | |
2086 | 5194 |
5195 return 1; | |
5196 } | |
5197 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5198 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5199 va_list ap; |
6873 | 5200 char *email; |
5420 | 5201 char *buf; |
2086 | 5202 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5203 va_start(ap, fr); |
6873 | 5204 email = va_arg(ap, char *); |
2086 | 5205 va_end(ap); |
5206 | |
6873 | 5207 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
|
5208 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
5420 | 5209 g_free(buf); |
2086 | 5210 |
5211 return 1; | |
5212 } | |
5213 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5214 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
6873 | 5215 GaimConnection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5216 fu16_t status; |
2086 | 5217 va_list ap; |
5218 char msg[256]; | |
5219 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5220 va_start(ap, fr); |
4199 | 5221 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 5222 va_end(ap); |
5223 | |
8660 | 5224 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5225 "account confirmation returned status 0x%04x (%s)\n", status, |
3912 | 5226 status ? "unknown" : "email sent"); |
5227 if (!status) { | |
5302 | 5228 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
5575 | 5229 gaim_account_get_username(gaim_connection_get_account(gc))); |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5230 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
2086 | 5231 } |
5232 | |
5233 return 1; | |
5234 } | |
5235 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5236 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5237 GaimConnection *gc = sess->aux_data; |
2086 | 5238 va_list ap; |
3912 | 5239 fu16_t perms, err; |
5240 char *url, *sn, *email; | |
5241 int change; | |
2086 | 5242 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5243 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5244 change = va_arg(ap, int); |
4199 | 5245 perms = (fu16_t) va_arg(ap, unsigned int); |
5246 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 5247 url = va_arg(ap, char *); |
5248 sn = va_arg(ap, char *); | |
5249 email = va_arg(ap, char *); | |
2086 | 5250 va_end(ap); |
5251 | |
8660 | 5252 gaim_debug_misc("oscar", |
9626 | 5253 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
5254 change ? "change" : "request", perms, err, | |
5255 (url != NULL) ? url : "(null)", | |
5256 (sn != NULL) ? sn : "(null)", | |
5257 (email != NULL) ? email : "(null)"); | |
5258 | |
5259 if ((err > 0) && (url != NULL)) { | |
3912 | 5260 char *dialog_msg; |
5261 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
5262 switch (err) { | |
5263 case 0x0001: { | |
5264 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
5265 } break; | |
5266 case 0x0006: { | |
5267 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
5268 } break; | |
5269 case 0x000b: { | |
5270 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
5271 } break; | |
5272 case 0x001d: { | |
5273 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); | |
5274 } break; | |
5275 case 0x0021: { | |
5276 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); | |
5277 } break; | |
5278 case 0x0023: { | |
5279 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
5280 } break; | |
5281 default: { | |
5282 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
5283 } break; | |
5284 } | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5285 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
3912 | 5286 g_free(dialog_top); |
5287 g_free(dialog_msg); | |
5288 return 1; | |
5289 } | |
5290 | |
9626 | 5291 if (sn != NULL) { |
4585 | 5292 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
|
5293 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5294 g_free(dialog_msg); |
5295 } | |
5296 | |
9626 | 5297 if (email != NULL) { |
5575 | 5298 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
5299 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5300 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
3912 | 5301 g_free(dialog_msg); |
2086 | 5302 } |
5303 | |
5304 return 1; | |
5305 } | |
5306 | |
5575 | 5307 static void oscar_keepalive(GaimConnection *gc) { |
7283 | 5308 OscarData *od = (OscarData *)gc->proto_data; |
4617 | 5309 aim_flap_nop(od->sess, od->conn); |
2086 | 5310 } |
5311 | |
6059 | 5312 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
7283 | 5313 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5314 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
5315 if (dim && dim->connected) | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5316 if (typing == GAIM_TYPING) |
4870 | 5317 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5318 else if (typing == GAIM_TYPED) |
4870 | 5319 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
5320 else | |
5321 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 5322 else { |
5300 | 5323 /* Don't send if this turkey is in our deny list */ |
5324 GSList *list; | |
5325 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
5326 if (!list) { | |
7261 | 5327 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
5300 | 5328 if (bi && bi->typingnot) { |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5329 if (typing == GAIM_TYPING) |
5300 | 5330 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5331 else if (typing == GAIM_TYPED) |
5300 | 5332 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
5333 else | |
5334 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
5335 } | |
3595 | 5336 } |
5337 } | |
2993 | 5338 return 0; |
5339 } | |
9030 | 5340 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5341 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
|
5342 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5343 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
7283 | 5344 OscarData *od = (OscarData *)gc->proto_data; |
8971 | 5345 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
|
5346 int ret = 0; |
5575 | 5347 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
8800 | 5348 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
3458 | 5349 |
4838 | 5350 if (dim && dim->connected) { |
5351 /* If we're directly connected, send a direct IM */ | |
6982 | 5352 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
2086 | 5353 } else { |
4738 | 5354 struct buddyinfo *bi; |
3008 | 5355 struct aim_sendimext_args args; |
5356 struct stat st; | |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5357 gsize len; |
8962 | 5358 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
5359 | |
5360 if (strstr(message, "<IMG ")) | |
5361 gaim_conversation_write(conv, "", | |
5362 _("Your IM Image was not sent. " | |
5363 "You must be Direct Connected to send IM Images."), | |
5364 GAIM_MESSAGE_ERROR, time(NULL)); | |
4269 | 5365 |
7261 | 5366 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
4738 | 5367 if (!bi) { |
5368 bi = g_new0(struct buddyinfo, 1); | |
7261 | 5369 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
4738 | 5370 } |
5371 | |
3008 | 5372 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 5373 if (od->icq) { |
5374 args.features = features_icq; | |
5375 args.featureslen = sizeof(features_icq); | |
3008 | 5376 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 5377 } else { |
5378 args.features = features_aim; | |
5379 args.featureslen = sizeof(features_aim); | |
4972 | 5380 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5381 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
4972 | 5382 args.flags |= AIM_IMFLAGS_AWAY; |
4665 | 5383 } |
4269 | 5384 |
4738 | 5385 if (bi->ico_need) { |
8660 | 5386 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5387 "Sending buddy icon request with message\n"); |
3008 | 5388 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 5389 bi->ico_need = FALSE; |
3008 | 5390 } |
4269 | 5391 |
5575 | 5392 if (iconfile && !stat(iconfile, &st)) { |
8361 | 5393 FILE *file = fopen(iconfile, "rb"); |
3008 | 5394 if (file) { |
5395 char *buf = g_malloc(st.st_size); | |
9532 | 5396 /* XXX - Use g_file_get_contents()? */ |
3008 | 5397 fread(buf, 1, st.st_size, file); |
6039 | 5398 fclose(file); |
4269 | 5399 |
3008 | 5400 args.iconlen = st.st_size; |
4617 | 5401 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 5402 args.iconstamp = st.st_mtime; |
5403 | |
7406 | 5404 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
4738 | 5405 bi->ico_informed = FALSE; |
7406 | 5406 bi->ico_sent = FALSE; |
5407 } | |
4738 | 5408 |
5409 if (!bi->ico_informed) { | |
8660 | 5410 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5411 "Claiming to have a buddy icon\n"); |
4738 | 5412 args.flags |= AIM_IMFLAGS_HASICON; |
5413 bi->ico_me_len = args.iconlen; | |
5414 bi->ico_me_csum = args.iconsum; | |
5415 bi->ico_me_time = args.iconstamp; | |
5416 bi->ico_informed = TRUE; | |
5417 } | |
5418 | |
3008 | 5419 g_free(buf); |
2086 | 5420 } |
5421 } | |
4269 | 5422 |
3008 | 5423 args.destsn = name; |
4269 | 5424 |
8985 | 5425 /* |
5426 * If we're IMing an ICQ user then send newlines as CR/LF and | |
5427 * strip all HTML | |
5428 */ | |
9975 | 5429 if (aim_sn_is_icq(name) ) { |
8995 | 5430 /* being sent to an ICQ user */ |
9975 | 5431 if (!aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5432 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ |
5433 tmpmsg = gaim_str_add_cr(message); | |
5434 } else { | |
5435 /* from an ICQ user - do nothing */ | |
5436 tmpmsg = g_strdup(message); | |
5437 } | |
5438 } else { | |
5439 /* being sent to an AIM user */ | |
9975 | 5440 if (aim_sn_is_icq(gaim_account_get_username(gc->account))) { |
8995 | 5441 /* from an ICQ user */ |
5442 tmpmsg2 = gaim_strdup_withhtml(message); | |
5443 tmpmsg = gaim_escape_html(tmpmsg2); | |
5444 g_free(tmpmsg2); | |
5445 } else | |
5446 tmpmsg = gaim_strdup_withhtml(message); | |
5447 } | |
6310 | 5448 len = strlen(tmpmsg); |
5449 | |
9830 | 5450 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmpmsg, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); |
5451 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", | |
5452 args.charset, args.charsubset, args.msglen); | |
4617 | 5453 ret = aim_im_sendch1_ext(od->sess, &args); |
9830 | 5454 g_free((char *)args.msg); |
2086 | 5455 } |
4838 | 5456 |
6310 | 5457 g_free(tmpmsg); |
5458 | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5459 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5460 return 1; |
6310 | 5461 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5462 return ret; |
2086 | 5463 } |
5464 | |
7011 | 5465 static void oscar_get_info(GaimConnection *gc, const char *name) { |
7283 | 5466 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5467 |
9975 | 5468 if (od->icq && aim_sn_is_icq(name)) |
4624 | 5469 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5470 else |
7235 | 5471 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
7011 | 5472 } |
5473 | |
8950 | 5474 #if 0 |
7011 | 5475 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
3466 | 5476 const char *maiden, const char *city, const char *state, const char *country, int web) { |
4617 | 5477 /* XXX - some of these things are wrong, but i'm lazy */ |
7283 | 5478 OscarData *od = (OscarData *)gc->proto_data; |
7011 | 5479 aim_locate_setdirinfo(od->sess, first, middle, last, |
2086 | 5480 maiden, NULL, NULL, city, state, NULL, 0, web); |
5481 } | |
8950 | 5482 #endif |
2086 | 5483 |
5575 | 5484 static void oscar_set_idle(GaimConnection *gc, int time) { |
7283 | 5485 OscarData *od = (OscarData *)gc->proto_data; |
7474 | 5486 aim_srv_setidle(od->sess, time); |
2086 | 5487 } |
5488 | |
5954 | 5489 static void oscar_set_info(GaimConnection *gc, const char *text) { |
7283 | 5490 OscarData *od = (OscarData *)gc->proto_data; |
9807 | 5491 int charset = 0; |
6019 | 5492 char *text_html = NULL; |
5129 | 5493 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5494 gsize msglen = 0; |
2993 | 5495 |
4617 | 5496 if (od->rights.maxsiglen == 0) |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5497 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5498 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5499 "profile before the login procedure completed. " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5500 "Your profile remains unset; try setting it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5501 "again when you are fully connected.")); |
4617 | 5502 |
7334 | 5503 if (!text) { |
5504 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
5505 return; | |
5506 } | |
6019 | 5507 |
7334 | 5508 text_html = gaim_strdup_withhtml(text); |
9807 | 5509 charset = oscar_charset_check(text_html); |
9826 | 5510 if (charset == AIM_CHARSET_UNICODE) { |
7334 | 5511 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5512 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5513 g_free(msg); | |
9826 | 5514 } else if (charset == AIM_CHARSET_CUSTOM) { |
7334 | 5515 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
5516 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5517 g_free(msg); | |
5518 } else { | |
5519 msglen = strlen(text_html); | |
5520 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
5521 } | |
5522 | |
5523 if (msglen > od->rights.maxsiglen) { | |
5524 gchar *errstr; | |
5525 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
5526 "has been exceeded. Gaim has truncated it for you.", | |
5527 "The maximum profile length of %d bytes " | |
5528 "has been exceeded. Gaim has truncated it for you.", | |
5529 od->rights.maxsiglen), od->rights.maxsiglen); | |
5530 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
5531 g_free(errstr); | |
5532 } | |
5533 | |
5534 g_free(text_html); | |
2993 | 5535 |
5536 return; | |
2086 | 5537 } |
5538 | |
9991 | 5539 static void |
5540 oscar_set_status_aim(GaimAccount *account, GaimStatus *status) | |
2993 | 5541 { |
9991 | 5542 GaimConnection *gc = gaim_account_get_connection(account); |
5543 OscarData *od = (OscarData *)gc->proto_data; | |
9992 | 5544 GaimStatusType *status_type; |
9991 | 5545 GaimStatusPrimitive primitive; |
5546 GaimPresence *presence; | |
5547 const gchar *status_id; | |
9807 | 5548 int charset = 0; |
6019 | 5549 gchar *text_html = NULL; |
5129 | 5550 char *msg = NULL; |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5551 gsize msglen = 0; |
2993 | 5552 |
9992 | 5553 status_type = gaim_status_get_type(status); |
5554 primitive = gaim_status_type_get_primitive(status_type); | |
9991 | 5555 status_id = gaim_status_get_id(status); |
5556 presence = gaim_account_get_presence(account); | |
5557 | |
5558 if (primitive == GAIM_STATUS_HIDDEN) | |
8257 | 5559 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5560 else |
5561 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
5562 | |
8476 | 5563 |
8257 | 5564 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
5565 | |
2993 | 5566 if (od->rights.maxawaymsglen == 0) |
9991 | 5567 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5568 _("You have probably requested to set your " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5569 "away message before the login procedure " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5570 "completed. You remain in a \"present\" " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5571 "state; try setting it again when you are " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5572 "fully connected.")); |
5129 | 5573 |
9992 | 5574 if (primitive == GAIM_STATUS_AVAILABLE) { |
7334 | 5575 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
9995 | 5576 #if 0 |
5577 /* Set an available message */ | |
5578 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); | |
5579 aim_srv_setavailmsg(od->sess, text); | |
5580 #endif | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5581 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5582 } |
9995 | 5583 |
5584 /* | |
5585 * XXX - Using status_id below is definitely wrong. We want to get | |
5586 * the away message that the Gaim user just set. We probably want | |
5587 * to get a certain attribute from status->attr_values, but I don't | |
5588 * think any of that is implemented yet. | |
5589 * | |
5590 * Something like | |
5591 * text_html = gaim_status_get_attr_string(status, "message"); | |
5592 */ | |
5593 status_id = gaim_status_get_name(status); | |
9991 | 5594 text_html = gaim_strdup_withhtml(status_id); |
5595 | |
9807 | 5596 charset = oscar_charset_check(text_html); |
9826 | 5597 if (charset == AIM_CHARSET_UNICODE) { |
6019 | 5598 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
7011 | 5599 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
7334 | 5600 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5601 g_free(msg); |
9826 | 5602 } else if (charset == AIM_CHARSET_CUSTOM) { |
6019 | 5603 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
7011 | 5604 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
7334 | 5605 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5606 g_free(msg); |
5607 } else { | |
6019 | 5608 msglen = strlen(text_html); |
7011 | 5609 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
7334 | 5610 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
5129 | 5611 } |
5612 | |
5613 if (msglen > od->rights.maxawaymsglen) { | |
2993 | 5614 gchar *errstr; |
5615 | |
6308 | 5616 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
5617 "has been exceeded. Gaim has truncated it for you.", | |
5618 "The maximum away message length of %d bytes " | |
5619 "has been exceeded. Gaim has truncated it for you.", | |
5620 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5621 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
2993 | 5622 g_free(errstr); |
5623 } | |
6019 | 5624 |
5625 g_free(text_html); | |
8257 | 5626 |
2993 | 5627 return; |
5628 } | |
5629 | |
9991 | 5630 static void |
5631 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
2993 | 5632 { |
9991 | 5633 GaimConnection *gc = gaim_account_get_connection(account); |
5634 OscarData *od = (OscarData *)gc->proto_data; | |
5635 const gchar *status_id = gaim_status_get_id(status); | |
5636 | |
5637 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_HIDDEN) | |
5575 | 5638 account->perm_deny = 4; |
8265 | 5639 else |
5575 | 5640 account->perm_deny = 3; |
9991 | 5641 |
8265 | 5642 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
5643 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
4342 | 5644 |
9991 | 5645 if (!strcmp(status_id, OSCAR_STATUS_ID_ONLINE)) |
4901 | 5646 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
9991 | 5647 |
5648 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
4901 | 5649 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
9991 | 5650 |
5651 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
4901 | 5652 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
9991 | 5653 |
5654 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
4901 | 5655 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
9991 | 5656 |
5657 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
4901 | 5658 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
9991 | 5659 |
5660 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
4901 | 5661 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
9991 | 5662 |
5663 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
4901 | 5664 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
9991 | 5665 |
5666 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) | |
5667 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); | |
2993 | 5668 |
5669 return; | |
5670 } | |
5671 | |
9991 | 5672 static void |
5673 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
2993 | 5674 { |
9991 | 5675 GaimConnection *gc = gaim_account_get_connection(account); |
5676 OscarData *od = (OscarData *)gc->proto_data; | |
2993 | 5677 |
5678 if (od->icq) | |
9988 | 5679 oscar_set_status_icq(account, status); |
2993 | 5680 else |
9988 | 5681 oscar_set_status_aim(account, status); |
2993 | 5682 |
5683 return; | |
2086 | 5684 } |
5685 | |
9991 | 5686 static void |
5687 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
7283 | 5688 OscarData *od = (OscarData *)gc->proto_data; |
9753 | 5689 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
2086 | 5690 } |
5691 | |
9285 | 5692 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5693 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5694 |
5695 if (!aim_snvalid(buddy->name)) { | |
8092 | 5696 gchar *buf; |
9285 | 5697 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 | 5698 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
5699 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
8092 | 5700 g_free(buf); |
8150 | 5701 |
5702 /* Remove from local list */ | |
9285 | 5703 gaim_blist_remove_buddy(buddy); |
8150 | 5704 |
8092 | 5705 return; |
5706 } | |
5707 | |
4230 | 5708 #ifdef NOSSI |
9285 | 5709 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
4230 | 5710 #else |
9285 | 5711 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
5712 if (buddy && group) { | |
8660 | 5713 gaim_debug_info("oscar", |
9285 | 5714 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
9620 | 5715 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
4230 | 5716 } |
5717 } | |
5718 #endif | |
8150 | 5719 |
4759 | 5720 if (od->icq) |
9285 | 5721 aim_icq_getalias(od->sess, buddy->name); |
5722 } | |
5723 | |
5724 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
7283 | 5725 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5726 #ifdef NOSSI |
5727 char buf[MSG_LEN]; | |
5728 int n=0; | |
9285 | 5729 |
4230 | 5730 while (buddies) { |
9381 | 5731 GaimBuddy *buddy = buddies->data; |
4230 | 5732 if (n > MSG_LEN - 18) { |
7285 | 5733 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5734 n = 0; |
3092 | 5735 } |
9381 | 5736 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
4230 | 5737 buddies = buddies->next; |
5738 } | |
7285 | 5739 aim_buddylist_set(od->sess, od->conn, buf); |
4230 | 5740 #else |
9285 | 5741 |
4230 | 5742 if (od->sess->ssi.received_data) { |
9285 | 5743 GList *curb = buddies; |
5744 GList *curg = groups; | |
5745 while ((curb != NULL) && (curg != NULL)) { | |
5746 GaimBuddy *buddy = curb->data; | |
5747 GaimGroup *group = curg->data; | |
5748 oscar_add_buddy(gc, buddy, group); | |
5749 curb = curb->next; | |
5750 curg = curg->next; | |
4230 | 5751 } |
5752 } | |
5753 #endif | |
5754 } | |
5755 | |
9285 | 5756 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
7283 | 5757 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5758 |
4230 | 5759 #ifdef NOSSI |
9285 | 5760 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
4230 | 5761 #else |
5762 if (od->sess->ssi.received_data) { | |
8660 | 5763 gaim_debug_info("oscar", |
9285 | 5764 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
5765 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
4230 | 5766 } |
5767 #endif | |
5768 } | |
5769 | |
9285 | 5770 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
7283 | 5771 OscarData *od = (OscarData *)gc->proto_data; |
9285 | 5772 |
4230 | 5773 #ifdef NOSSI |
9285 | 5774 for (cur = buddies; cur != NULL; cur = cur->next) { |
5775 GaimBuddy *buddy = cur->data; | |
5776 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
5777 } | |
4230 | 5778 #else |
5779 if (od->sess->ssi.received_data) { | |
9285 | 5780 GList *curb = buddies; |
5781 GList *curg = groups; | |
5782 while ((curb != NULL) && (curg != NULL)) { | |
5783 GaimBuddy *buddy = curb->data; | |
5784 GaimGroup *group = curg->data; | |
5785 oscar_remove_buddy(gc, buddy, group); | |
5786 curb = curb->next; | |
5787 curg = curg->next; | |
3092 | 5788 } |
4230 | 5789 } |
5790 #endif | |
5791 } | |
5792 | |
5793 #ifndef NOSSI | |
5575 | 5794 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
7283 | 5795 OscarData *od = (OscarData *)gc->proto_data; |
4303 | 5796 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
8660 | 5797 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5798 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 5799 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 5800 } |
5801 } | |
5802 | |
5575 | 5803 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
7283 | 5804 OscarData *od = (OscarData *)gc->proto_data; |
4269 | 5805 if (od->sess->ssi.received_data) { |
5806 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
5807 if (gname) { | |
8660 | 5808 gaim_debug_info("oscar", |
9586 | 5809 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
4889 | 5810 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 5811 } |
5812 } | |
5813 } | |
5814 | |
9285 | 5815 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
8341 | 5816 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 5817 |
5818 if (od->sess->ssi.received_data) { | |
9285 | 5819 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
5820 GList *cur, *groups = NULL; | |
5821 | |
5822 /* Make a list of what the groups each buddy is in */ | |
5823 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
5824 GaimBlistNode *node = cur->data; | |
5825 groups = g_list_append(groups, node->parent); | |
5826 } | |
5827 | |
5828 oscar_remove_buddies(gc, moved_buddies, groups); | |
5829 oscar_add_buddies(gc, moved_buddies, groups); | |
5830 g_list_free(groups); | |
8660 | 5831 gaim_debug_info("oscar", |
9285 | 5832 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
4230 | 5833 } else { |
9285 | 5834 aim_ssi_rename_group(od->sess, old_name, group->name); |
8660 | 5835 gaim_debug_info("oscar", |
9285 | 5836 "ssi: renamed group %s to %s\n", old_name, group->name); |
2995 | 5837 } |
5838 } | |
5839 } | |
5840 | |
5968 | 5841 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
5842 aim_session_t *sess = data; | |
6350 | 5843 aim_ssi_reqdata(sess); |
5968 | 5844 return FALSE; |
5845 } | |
5846 | |
4642 | 5847 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5848 GaimConnection *gc = sess->aux_data; |
7283 | 5849 OscarData *od = gc->proto_data; |
4642 | 5850 va_list ap; |
5851 fu16_t reason; | |
5852 | |
5853 va_start(ap, fr); | |
5854 reason = (fu16_t)va_arg(ap, unsigned int); | |
5855 va_end(ap); | |
5856 | |
8660 | 5857 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
4642 | 5858 |
5859 if (reason == 0x0005) { | |
5892 | 5860 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
5828 | 5861 _("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
|
5862 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
4642 | 5863 } |
5864 | |
5865 /* Activate SSI */ | |
5866 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
5867 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 5868 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
4642 | 5869 aim_ssi_enable(od->sess); |
5870 | |
5871 return 1; | |
5872 } | |
5873 | |
2991 | 5874 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 5875 GaimConnection *gc = sess->aux_data; |
7283 | 5876 OscarData *od = (OscarData *)gc->proto_data; |
9982 | 5877 int i; |
5878 va_list ap; | |
5879 int numtypes; | |
4230 | 5880 fu16_t *maxitems; |
2991 | 5881 |
5882 va_start(ap, fr); | |
4230 | 5883 numtypes = va_arg(ap, int); |
5884 maxitems = va_arg(ap, fu16_t *); | |
2991 | 5885 va_end(ap); |
5886 | |
8660 | 5887 gaim_debug_misc("oscar", "ssi rights:"); |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5888 |
4230 | 5889 for (i=0; i<numtypes; i++) |
8660 | 5890 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5891 i, maxitems[i]); |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5892 |
8660 | 5893 gaim_debug_misc(NULL, "\n"); |
4230 | 5894 |
5895 if (numtypes >= 0) | |
5896 od->rights.maxbuddies = maxitems[0]; | |
5897 if (numtypes >= 1) | |
5898 od->rights.maxgroups = maxitems[1]; | |
5899 if (numtypes >= 2) | |
5900 od->rights.maxpermits = maxitems[2]; | |
5901 if (numtypes >= 3) | |
5902 od->rights.maxdenies = maxitems[3]; | |
2991 | 5903 |
5904 return 1; | |
5905 } | |
5906 | |
5907 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 5908 GaimConnection *gc = sess->aux_data; |
5909 GaimAccount *account = gaim_connection_get_account(gc); | |
9988 | 5910 GaimStatus *status; |
7283 | 5911 OscarData *od = (OscarData *)gc->proto_data; |
8150 | 5912 GaimGroup *g; |
5913 GaimBuddy *b; | |
2995 | 5914 struct aim_ssi_item *curitem; |
2991 | 5915 int tmp; |
4230 | 5916 va_list ap; |
8219 | 5917 fu16_t fmtver, numitems; |
5918 struct aim_ssi_item *items; | |
5919 fu32_t timestamp; | |
4230 | 5920 |
5921 va_start(ap, fr); | |
5922 fmtver = (fu16_t)va_arg(ap, int); | |
5923 numitems = (fu16_t)va_arg(ap, int); | |
8219 | 5924 items = va_arg(ap, struct aim_ssi_item *); |
4230 | 5925 timestamp = va_arg(ap, fu32_t); |
8219 | 5926 va_end(ap); |
2991 | 5927 |
8660 | 5928 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5929 "ssi: syncing local list and server list\n"); |
2991 | 5930 |
8219 | 5931 if ((timestamp == 0) || (numitems == 0)) { |
8660 | 5932 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 | 5933 return 1; |
5934 } | |
5935 | |
2991 | 5936 /* Clean the buddy list */ |
4889 | 5937 aim_ssi_cleanlist(sess); |
2991 | 5938 |
8150 | 5939 { /* If not in server list then prune from local list */ |
5940 GaimBlistNode *gnode, *cnode, *bnode; | |
5941 GaimBuddyList *blist; | |
9539 | 5942 GSList *cur, *next; |
8150 | 5943 |
5944 /* Buddies */ | |
5945 cur = NULL; | |
5946 if ((blist = gaim_get_blist()) != NULL) { | |
5947 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
5948 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5949 continue; | |
5950 g = (GaimGroup *)gnode; | |
5951 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
5952 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
5953 continue; | |
5954 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
5955 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5956 continue; | |
5957 b = (GaimBuddy *)bnode; | |
5958 if (b->account == gc->account) { | |
5959 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
5960 /* If the buddy is an ICQ user then load his nickname */ | |
5961 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
8214 | 5962 char *alias; |
8150 | 5963 if (servernick) |
5964 serv_got_alias(gc, b->name, servernick); | |
5965 | |
5966 /* Store local alias on server */ | |
8214 | 5967 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
8150 | 5968 if (!alias && b->alias && strlen(b->alias)) |
5969 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
5970 free(alias); | |
5971 } else { | |
8660 | 5972 gaim_debug_info("oscar", |
8150 | 5973 "ssi: removing buddy %s from local list\n", b->name); |
5974 /* We can't actually remove now because it will screw up our looping */ | |
5975 cur = g_slist_prepend(cur, b); | |
5976 } | |
5977 } | |
5978 } | |
5979 } | |
5980 } | |
5981 } | |
8175 | 5982 |
8150 | 5983 while (cur != NULL) { |
5984 b = cur->data; | |
5985 cur = g_slist_remove(cur, b); | |
5986 gaim_blist_remove_buddy(b); | |
5987 } | |
5988 | |
5989 /* Permit list */ | |
5990 if (gc->account->permit) { | |
9539 | 5991 next = gc->account->permit; |
5992 while (next != NULL) { | |
5993 cur = next; | |
5994 next = next->next; | |
8150 | 5995 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
8660 | 5996 gaim_debug_info("oscar", |
8150 | 5997 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
5998 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
5999 } | |
9539 | 6000 } |
8150 | 6001 } |
6002 | |
6003 /* Deny list */ | |
6004 if (gc->account->deny) { | |
9539 | 6005 next = gc->account->deny; |
6006 while (next != NULL) { | |
6007 cur = next; | |
6008 next = next->next; | |
8150 | 6009 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
8660 | 6010 gaim_debug_info("oscar", |
8150 | 6011 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
6012 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
6013 } | |
9539 | 6014 } |
8150 | 6015 } |
6016 /* Presence settings (idle time visibility) */ | |
6017 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
6018 if (!(tmp & 0x400)) | |
6019 aim_ssi_setpresence(sess, tmp | 0x400); | |
6020 } /* end pruning buddies from local list */ | |
6021 | |
2991 | 6022 /* Add from server list to local list */ |
4230 | 6023 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
7328 | 6024 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
2991 | 6025 switch (curitem->type) { |
4230 | 6026 case 0x0000: { /* Buddy */ |
4251 | 6027 if (curitem->name) { |
4292 | 6028 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
7166 | 6029 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
4282 | 6030 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
7166 | 6031 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
8150 | 6032 b = gaim_find_buddy(gc->account, curitem->name); |
4458 | 6033 /* Should gname be freed here? -- elb */ |
4754 | 6034 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 6035 free(alias); |
8150 | 6036 if (b) { |
4292 | 6037 /* Get server stored alias */ |
4705 | 6038 if (alias_utf8) { |
8150 | 6039 g_free(b->alias); |
6040 b->alias = g_strdup(alias_utf8); | |
4705 | 6041 } |
4282 | 6042 } else { |
8150 | 6043 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
5146 | 6044 |
4754 | 6045 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 6046 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 6047 gaim_blist_add_group(g, NULL); |
6048 } | |
5146 | 6049 |
8660 | 6050 gaim_debug_info("oscar", |
9285 | 6051 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8150 | 6052 gaim_blist_add_buddy(b, NULL, g, NULL); |
4251 | 6053 } |
8341 | 6054 if (!aim_sncmp(curitem->name, account->username)) { |
6055 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
6056 gaim_check_comment(od, comment); | |
6057 free(comment); | |
6058 } | |
7162 | 6059 g_free(gname_utf8); |
6060 g_free(alias_utf8); | |
2991 | 6061 } |
4230 | 6062 } break; |
6063 | |
6064 case 0x0001: { /* Group */ | |
4282 | 6065 /* Shouldn't add empty groups */ |
4230 | 6066 } break; |
6067 | |
6068 case 0x0002: { /* Permit buddy */ | |
2991 | 6069 if (curitem->name) { |
4230 | 6070 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 6071 GSList *list; |
5575 | 6072 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6073 if (!list) { |
8660 | 6074 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6075 "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
|
6076 gaim_privacy_permit_add(account, curitem->name, TRUE); |
2991 | 6077 } |
6078 } | |
4230 | 6079 } break; |
6080 | |
6081 case 0x0003: { /* Deny buddy */ | |
2991 | 6082 if (curitem->name) { |
6083 GSList *list; | |
5575 | 6084 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 6085 if (!list) { |
8660 | 6086 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6087 "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
|
6088 gaim_privacy_deny_add(account, curitem->name, TRUE); |
2991 | 6089 } |
6090 } | |
4230 | 6091 } break; |
6092 | |
6093 case 0x0004: { /* Permit/deny setting */ | |
2991 | 6094 if (curitem->data) { |
6095 fu8_t permdeny; | |
5575 | 6096 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
8660 | 6097 gaim_debug_info("oscar", |
5575 | 6098 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
6099 account->perm_deny = permdeny; | |
6100 if (od->icq && account->perm_deny == 0x03) { | |
9991 | 6101 gaim_presence_switch_status(account->presence, OSCAR_STATUS_ID_INVISIBLE); |
4342 | 6102 } |
2991 | 6103 } |
6104 } | |
4230 | 6105 } break; |
6106 | |
6107 case 0x0005: { /* Presence setting */ | |
3109 | 6108 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 6109 } break; |
2991 | 6110 } /* End of switch on curitem->type */ |
6111 } /* End of for loop */ | |
4230 | 6112 |
9991 | 6113 /* |
6114 * XXX - STATUS - Set our ICQ status. We probably don't want to do | |
6115 * this. We probably want the SSI status setting to override the local | |
6116 * setting. | |
6117 */ | |
9982 | 6118 status = gaim_presence_get_active_status(account->presence); |
6119 if (gaim_status_is_available(status)) | |
4901 | 6120 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
6121 | |
4342 | 6122 /* Activate SSI */ |
6123 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
6124 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
8660 | 6125 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6126 "ssi: activating server-stored buddy list\n"); |
4642 | 6127 aim_ssi_enable(sess); |
4342 | 6128 |
2991 | 6129 return 1; |
2086 | 6130 } |
4230 | 6131 |
6132 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6133 GaimConnection *gc = sess->aux_data; |
4230 | 6134 va_list ap; |
6135 struct aim_ssi_tmp *retval; | |
6136 | |
6137 va_start(ap, fr); | |
6138 retval = va_arg(ap, struct aim_ssi_tmp *); | |
6139 va_end(ap); | |
6140 | |
6141 while (retval) { | |
8660 | 6142 gaim_debug_misc("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6143 "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 | 6144 |
6145 if (retval->ack != 0xffff) | |
6146 switch (retval->ack) { | |
6147 case 0x0000: { /* added successfully */ | |
6148 } break; | |
6149 | |
4829 | 6150 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
6151 gchar *buf; | |
6152 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 | 6153 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6154 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
4829 | 6155 g_free(buf); |
6156 } | |
6157 | |
7023 | 6158 case 0x000e: { /* buddy requires authorization */ |
4828 | 6159 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 6160 gaim_auth_sendrequest(gc, retval->name); |
4230 | 6161 } break; |
6162 | |
6163 default: { /* La la la */ | |
5197 | 6164 gchar *buf; |
8660 | 6165 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
5402 | 6166 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 | 6167 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
9627 | 6168 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
5197 | 6169 g_free(buf); |
4230 | 6170 } break; |
6171 } | |
6172 | |
6173 retval = retval->next; | |
6174 } | |
6175 | |
6176 return 1; | |
6177 } | |
6178 | |
8227 | 6179 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
6180 GaimConnection *gc = sess->aux_data; | |
6181 char *gname, *gname_utf8, *alias, *alias_utf8; | |
6182 GaimBuddy *b; | |
6183 GaimGroup *g; | |
6184 va_list ap; | |
6185 fu16_t type; | |
6186 const char *name; | |
6187 | |
6188 va_start(ap, fr); | |
6189 type = (fu16_t)va_arg(ap, int); | |
6190 name = va_arg(ap, char *); | |
6191 va_end(ap); | |
6192 | |
6193 if ((type != 0x0000) || (name == NULL)) | |
6194 return 1; | |
6195 | |
6196 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
6197 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
6198 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
6199 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
6200 b = gaim_find_buddy(gc->account, name); | |
6201 free(alias); | |
6202 | |
6203 if (b) { | |
6204 /* Get server stored alias */ | |
6205 if (alias_utf8) { | |
6206 g_free(b->alias); | |
6207 b->alias = g_strdup(alias_utf8); | |
6208 } | |
6209 } else { | |
6210 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
6211 | |
6212 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
6213 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
6214 gaim_blist_add_group(g, NULL); | |
6215 } | |
6216 | |
8660 | 6217 gaim_debug_info("oscar", |
9285 | 6218 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
8227 | 6219 gaim_blist_add_buddy(b, NULL, g, NULL); |
6220 } | |
6221 g_free(gname_utf8); | |
6222 g_free(alias_utf8); | |
6223 | |
6224 return 1; | |
6225 } | |
6226 | |
4230 | 6227 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
5575 | 6228 GaimConnection *gc = sess->aux_data; |
4230 | 6229 va_list ap; |
6230 char *sn, *msg; | |
4236 | 6231 gchar *dialog_msg, *nombre; |
4230 | 6232 struct name_data *data; |
6695 | 6233 GaimBuddy *buddy; |
4230 | 6234 |
6235 va_start(ap, fr); | |
6236 sn = va_arg(ap, char *); | |
6237 msg = va_arg(ap, char *); | |
6238 va_end(ap); | |
6239 | |
8660 | 6240 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6241 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
4230 | 6242 |
4687 | 6243 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6244 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6245 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6246 else |
6247 nombre = g_strdup(sn); | |
6248 | |
6249 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 | 6250 data = g_new(struct name_data, 1); |
6251 data->gc = gc; | |
6252 data->name = g_strdup(sn); | |
6253 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6254 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6255 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6256 0, data, |
7023 | 6257 G_CALLBACK(gaim_icq_buddyadd), |
5836 | 6258 G_CALLBACK(oscar_free_name_data)); |
4236 | 6259 |
4230 | 6260 g_free(dialog_msg); |
4236 | 6261 g_free(nombre); |
4230 | 6262 |
6263 return 1; | |
6264 } | |
6265 | |
6266 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6267 GaimConnection *gc = sess->aux_data; |
4230 | 6268 va_list ap; |
6269 char *sn, *msg; | |
4236 | 6270 gchar *dialog_msg, *nombre; |
4230 | 6271 struct name_data *data; |
6695 | 6272 GaimBuddy *buddy; |
4230 | 6273 |
6274 va_start(ap, fr); | |
6275 sn = va_arg(ap, char *); | |
6276 msg = va_arg(ap, char *); | |
6277 va_end(ap); | |
6278 | |
8660 | 6279 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6280 "ssi: received authorization request from %s\n", sn); |
4230 | 6281 |
4687 | 6282 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6283 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6284 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6285 else |
6286 nombre = g_strdup(sn); | |
6287 | |
4337 | 6288 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 | 6289 data = g_new(struct name_data, 1); |
6290 data->gc = gc; | |
6291 data->name = g_strdup(sn); | |
6292 data->nick = NULL; | |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6293 |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6294 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
9972 | 6295 GAIM_DEFAULT_ACTION_NONE, data, 2, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6296 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6297 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
4236 | 6298 |
4230 | 6299 g_free(dialog_msg); |
4236 | 6300 g_free(nombre); |
4230 | 6301 |
6302 return 1; | |
6303 } | |
6304 | |
6305 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6306 GaimConnection *gc = sess->aux_data; |
4230 | 6307 va_list ap; |
6308 char *sn, *msg; | |
4236 | 6309 gchar *dialog_msg, *nombre; |
4230 | 6310 fu8_t reply; |
6695 | 6311 GaimBuddy *buddy; |
4230 | 6312 |
6313 va_start(ap, fr); | |
6314 sn = va_arg(ap, char *); | |
6315 reply = (fu8_t)va_arg(ap, int); | |
6316 msg = va_arg(ap, char *); | |
6317 va_end(ap); | |
6318 | |
8660 | 6319 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6320 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4236 | 6321 |
4687 | 6322 buddy = gaim_find_buddy(gc->account, sn); |
9620 | 6323 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
6324 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
4236 | 6325 else |
6326 nombre = g_strdup(sn); | |
6327 | |
4230 | 6328 if (reply) { |
6329 /* Granted */ | |
7023 | 6330 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
|
6331 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
4230 | 6332 } else { |
6333 /* Denied */ | |
7023 | 6334 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
|
6335 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
4230 | 6336 } |
6337 g_free(dialog_msg); | |
4236 | 6338 g_free(nombre); |
4230 | 6339 |
6340 return 1; | |
6341 } | |
6342 | |
6343 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5575 | 6344 GaimConnection *gc = sess->aux_data; |
4230 | 6345 va_list ap; |
6346 char *sn; | |
6695 | 6347 GaimBuddy *buddy; |
4230 | 6348 |
6349 va_start(ap, fr); | |
6350 sn = va_arg(ap, char *); | |
6351 va_end(ap); | |
6352 | |
4687 | 6353 buddy = gaim_find_buddy(gc->account, sn); |
8660 | 6354 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6355 "ssi: %s added you to their buddy list\n", sn); |
9620 | 6356 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
4230 | 6357 |
6358 return 1; | |
6359 } | |
4269 | 6360 #endif |
2086 | 6361 |
5575 | 6362 static GList *oscar_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6363 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6364 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6365 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6366 pce = g_new0(struct proto_chat_entry, 1); |
9770 | 6367 pce->label = _("_Room:"); |
5234 | 6368 pce->identifier = "room"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6369 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6370 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6371 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 6372 pce->label = _("_Exchange:"); |
5234 | 6373 pce->identifier = "exchange"; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6374 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6375 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6376 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6377 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6378 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6379 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6380 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6381 |
9754 | 6382 GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
6383 { | |
6384 GHashTable *defaults; | |
6385 | |
6386 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
6387 | |
6388 if (chat_name != NULL) | |
6389 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
6390 | |
6391 return defaults; | |
6392 } | |
6393 | |
9917 | 6394 static char *oscar_get_chat_name(GHashTable *data) { |
6395 return g_strdup(g_hash_table_lookup(data, "room")); | |
6396 } | |
6397 | |
8308 | 6398 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
6399 OscarData *od = (OscarData *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6400 aim_conn_t *cur; |
5234 | 6401 char *name, *exchange; |
6402 | |
6403 name = g_hash_table_lookup(data, "room"); | |
6404 exchange = g_hash_table_lookup(data, "exchange"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6405 |
8660 | 6406 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6407 "Attempting to join chat room %s.\n", name); |
8308 | 6408 |
6409 if ((name == NULL) || (*name == '\0')) { | |
6410 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
6411 return; | |
6412 } | |
6413 | |
4617 | 6414 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
8660 | 6415 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6416 "chatnav exists, creating room\n"); |
5234 | 6417 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
2086 | 6418 } else { |
6419 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6420 struct create_room *cr = g_new0(struct create_room, 1); |
8660 | 6421 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6422 "chatnav does not exist, opening chatnav\n"); |
5234 | 6423 cr->exchange = atoi(exchange); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6424 cr->name = g_strdup(name); |
4617 | 6425 od->create_rooms = g_slist_append(od->create_rooms, cr); |
6426 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 6427 } |
6428 } | |
6429 | |
8308 | 6430 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
6431 OscarData *od = (OscarData *)gc->proto_data; | |
6432 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
2086 | 6433 |
6434 if (!ccon) | |
6435 return; | |
6436 | |
8225 | 6437 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
2086 | 6438 ccon->exchange, ccon->name, 0x0); |
6439 } | |
6440 | |
8308 | 6441 static void oscar_chat_leave(GaimConnection *gc, int id) { |
6442 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
6443 GSList *bcs = gc->buddy_chats; | |
5679 | 6444 GaimConversation *b = NULL; |
2086 | 6445 struct chat_connection *c = NULL; |
6446 int count = 0; | |
6447 | |
6448 while (bcs) { | |
6449 count++; | |
5679 | 6450 b = (GaimConversation *)bcs->data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6451 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
2086 | 6452 break; |
6453 bcs = bcs->next; | |
6454 b = NULL; | |
6455 } | |
6456 | |
6457 if (!b) | |
6458 return; | |
6459 | |
8660 | 6460 gaim_debug_info("oscar", |
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6461 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
2086 | 6462 |
8308 | 6463 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6464 if (c != NULL) { |
4617 | 6465 if (od) |
6466 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 6467 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6468 gaim_input_remove(c->inpa); |
8308 | 6469 if (gc && od->sess) |
4617 | 6470 aim_conn_kill(od->sess, &c->conn); |
2086 | 6471 g_free(c->name); |
6472 g_free(c->show); | |
6473 g_free(c); | |
6474 } | |
6475 /* we do this because with Oscar it doesn't tell us we left */ | |
8308 | 6476 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
2086 | 6477 } |
6478 | |
8219 | 6479 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
6480 OscarData *od = (OscarData *)gc->proto_data; | |
6481 GaimConversation *conv = NULL; | |
2086 | 6482 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6483 char *buf, *buf2; |
9830 | 6484 fu16_t charset, charsubset; |
9807 | 6485 char *charsetstr = NULL; |
8907 | 6486 gsize len; |
8219 | 6487 |
6488 if (!(conv = gaim_find_chat(gc, id))) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6489 return -EINVAL; |
2086 | 6490 |
8219 | 6491 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6492 return -EINVAL; |
2086 | 6493 |
8219 | 6494 buf = gaim_strdup_withhtml(message); |
6495 len = strlen(buf); | |
6496 | |
8962 | 6497 if (strstr(buf, "<IMG ")) |
6498 gaim_conversation_write(conv, "", | |
6499 _("Your IM Image was not sent. " | |
6500 "You cannot send IM Images in AIM chats."), | |
6501 GAIM_MESSAGE_ERROR, time(NULL)); | |
6502 | |
9830 | 6503 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
8359 | 6504 if ((len > c->maxlen) || (len > c->maxvis)) { |
6505 g_free(buf2); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6506 return -E2BIG; |
8359 | 6507 } |
6508 | |
9831 | 6509 if (charset == AIM_CHARSET_ASCII) |
6510 charsetstr = "us-ascii"; | |
6511 else if (charset == AIM_CHARSET_UNICODE) | |
6512 charsetstr = "unicode-2-0"; | |
6513 else if (charset == AIM_CHARSET_CUSTOM) | |
6514 charsetstr = "iso-8859-1"; | |
9807 | 6515 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
8219 | 6516 g_free(buf2); |
8359 | 6517 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6518 return 0; |
2086 | 6519 } |
6520 | |
6695 | 6521 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
4766 | 6522 if (!b || (b && b->name && b->name[0] == '+')) { |
9975 | 6523 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
4687 | 6524 return "icq"; |
6525 else | |
6526 return "aim"; | |
6527 } | |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6528 |
9975 | 6529 if (b != NULL && aim_sn_is_icq(b->name)) |
4687 | 6530 return "icq"; |
6531 return "aim"; | |
6532 } | |
6533 | |
9972 | 6534 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
4687 | 6535 { |
7334 | 6536 GaimAccount *account = NULL; |
6537 GaimConnection *gc = NULL; | |
6538 OscarData *od = NULL; | |
4687 | 6539 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
6540 int i = 0; | |
7334 | 6541 aim_userinfo_t *userinfo = NULL; |
6542 | |
6543 if (b != NULL) | |
6544 account = b->account; | |
6545 if (account != NULL) | |
6546 gc = account->gc; | |
6547 if (gc != NULL) | |
6548 od = gc->proto_data; | |
7945 | 6549 if (od != NULL) |
6550 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
4687 | 6551 |
5131 | 6552 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
6553 char *gname; | |
7334 | 6554 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5131 | 6555 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
6556 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
6557 emblems[i++] = "notauthorized"; | |
6558 } else { | |
6559 emblems[i++] = "offline"; | |
6560 } | |
6561 } | |
4916 | 6562 |
9975 | 6563 if (b->name && (b->uc & 0xffff0000) && aim_sn_is_icq(b->name)) { |
4960 | 6564 int uc = b->uc >> 16; |
4766 | 6565 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4960 | 6566 emblems[i++] = "invisible"; |
4766 | 6567 else if (uc & AIM_ICQ_STATE_CHAT) |
4960 | 6568 emblems[i++] = "freeforchat"; |
4766 | 6569 else if (uc & AIM_ICQ_STATE_DND) |
4960 | 6570 emblems[i++] = "dnd"; |
4766 | 6571 else if (uc & AIM_ICQ_STATE_OUT) |
4960 | 6572 emblems[i++] = "na"; |
4766 | 6573 else if (uc & AIM_ICQ_STATE_BUSY) |
4960 | 6574 emblems[i++] = "occupied"; |
4766 | 6575 else if (uc & AIM_ICQ_STATE_AWAY) |
6576 emblems[i++] = "away"; | |
6577 } else { | |
6578 if (b->uc & UC_UNAVAILABLE) | |
6579 emblems[i++] = "away"; | |
6580 } | |
4687 | 6581 if (b->uc & UC_WIRELESS) |
6582 emblems[i++] = "wireless"; | |
6583 if (b->uc & UC_AOL) | |
6584 emblems[i++] = "aol"; | |
6585 if (b->uc & UC_ADMIN) | |
6586 emblems[i++] = "admin"; | |
6587 if (b->uc & UC_AB && i < 4) | |
6588 emblems[i++] = "activebuddy"; | |
4766 | 6589 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
6590 emblems[i++] = "unconfirmed"; */ | |
7334 | 6591 |
7945 | 6592 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
6593 emblems[i++] = "hiptop"; | |
6594 | |
6595 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
7334 | 6596 emblems[i++] = "secure"; |
6597 | |
4687 | 6598 *se = emblems[0]; |
6599 *sw = emblems[1]; | |
6600 *nw = emblems[2]; | |
6601 *ne = emblems[3]; | |
6602 } | |
6603 | |
6695 | 6604 static char *oscar_tooltip_text(GaimBuddy *b) { |
5575 | 6605 GaimConnection *gc = b->account->gc; |
7283 | 6606 OscarData *od = gc->proto_data; |
7045 | 6607 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
8701 | 6608 GString *str = g_string_new(""); |
5131 | 6609 |
6610 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
8701 | 6611 oscar_string_append_info(gc, str, "\n", b, userinfo); |
7011 | 6612 |
6613 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
8225 | 6614 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
8392 | 6615 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
8225 | 6616 g_free(charset); |
7011 | 6617 if (away_utf8 != NULL) { |
7091 | 6618 gchar *tmp1, *tmp2; |
9627 | 6619 tmp2 = gaim_markup_strip_html(away_utf8); |
8341 | 6620 g_free(away_utf8); |
8571 | 6621 tmp1 = gaim_escape_html(tmp2); |
7091 | 6622 g_free(tmp2); |
8700 | 6623 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
8461 | 6624 g_free(tmp1); |
8701 | 6625 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
8700 | 6626 g_free(tmp2); |
5836 | 6627 } |
5131 | 6628 } |
8701 | 6629 } |
6630 | |
6631 return g_string_free(str, FALSE); | |
5131 | 6632 } |
6633 | |
6695 | 6634 static char *oscar_status_text(GaimBuddy *b) { |
5575 | 6635 GaimConnection *gc = b->account->gc; |
7283 | 6636 OscarData *od = gc->proto_data; |
5167 | 6637 gchar *ret = NULL; |
6638 | |
6639 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
9975 | 6640 if (aim_sn_is_icq(b->name)) |
8701 | 6641 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
7038 | 6642 else |
6643 ret = g_strdup(_("Away")); | |
5836 | 6644 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
7261 | 6645 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
6292 | 6646 if (bi->availmsg) |
6647 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5836 | 6648 } else { |
5167 | 6649 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
6650 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
6651 ret = g_strdup(_("Not Authorized")); | |
6652 else | |
6653 ret = g_strdup(_("Offline")); | |
6654 } | |
6655 | |
6656 return ret; | |
6657 } | |
6658 | |
5842 | 6659 |
5844 | 6660 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
5842 | 6661 GaimConnection *gc = sess->aux_data; |
7283 | 6662 OscarData *od = gc->proto_data; |
5892 | 6663 va_list ap; |
5842 | 6664 fu16_t type; |
5892 | 6665 fu8_t flags = 0, length = 0; |
6666 char *md5 = NULL; | |
6667 | |
7334 | 6668 |
5842 | 6669 va_start(ap, fr); |
6670 type = va_arg(ap, int); | |
5892 | 6671 |
6672 switch(type) { | |
6673 case 0x0000: | |
6674 case 0x0001: { | |
6675 flags = va_arg(ap, int); | |
6676 length = va_arg(ap, int); | |
6677 md5 = va_arg(ap, char *); | |
6678 | |
6679 if (flags == 0x41) { | |
6680 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
6681 od->iconconnecting = TRUE; | |
6682 od->set_icon = TRUE; | |
6683 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
6684 } else { | |
6039 | 6685 struct stat st; |
6686 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6687 if (iconfile == NULL) { | |
8363 | 6688 aim_ssi_delicon(od->sess); |
6039 | 6689 } else if (!stat(iconfile, &st)) { |
6690 char *buf = g_malloc(st.st_size); | |
6691 FILE *file = fopen(iconfile, "rb"); | |
6692 if (file) { | |
9532 | 6693 /* XXX - Use g_file_get_contents()? */ |
6039 | 6694 fread(buf, 1, st.st_size, file); |
6695 fclose(file); | |
8660 | 6696 gaim_debug_info("oscar", |
6039 | 6697 "Uploading icon to icon server\n"); |
6879 | 6698 aim_bart_upload(od->sess, buf, st.st_size); |
5892 | 6699 } else |
8660 | 6700 gaim_debug_error("oscar", |
6039 | 6701 "Can't open buddy icon file!\n"); |
6702 g_free(buf); | |
6703 } else { | |
8660 | 6704 gaim_debug_error("oscar", |
6039 | 6705 "Can't stat buddy icon file!\n"); |
5892 | 6706 } |
6707 } | |
8363 | 6708 } else if (flags == 0x81) { |
6709 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
6710 if (iconfile == NULL) | |
6711 aim_ssi_delicon(od->sess); | |
6712 else | |
6713 aim_ssi_seticon(od->sess, md5, length); | |
6714 } | |
5892 | 6715 } break; |
6716 | |
6717 case 0x0002: { /* We just set an "available" message? */ | |
6718 } break; | |
6719 } | |
6720 | |
5842 | 6721 va_end(ap); |
5844 | 6722 |
6723 return 0; | |
5842 | 6724 } |
5892 | 6725 |
5575 | 6726 static void oscar_set_permit_deny(GaimConnection *gc) { |
6727 GaimAccount *account = gaim_connection_get_account(gc); | |
7283 | 6728 OscarData *od = (OscarData *)gc->proto_data; |
4230 | 6729 #ifdef NOSSI |
8143 | 6730 GSList *list; |
4230 | 6731 char buf[MAXMSGLEN]; |
6732 int at; | |
6733 | |
5575 | 6734 switch(account->perm_deny) { |
8175 | 6735 case GAIM_PRIVACY_ALLOW_ALL: |
5575 | 6736 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
4230 | 6737 break; |
8175 | 6738 case GAIM_PRIVACY_DENY_ALL: |
5575 | 6739 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
4230 | 6740 break; |
8175 | 6741 case GAIM_PRIVACY_ALLOW_USERS: |
5575 | 6742 list = account->permit; |
4230 | 6743 at = 0; |
6744 while (list) { | |
6745 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6746 list = list->next; | |
6747 } | |
6748 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
6749 break; | |
8175 | 6750 case GAIM_PRIVACY_DENY_USERS: |
5575 | 6751 list = account->deny; |
4230 | 6752 at = 0; |
6753 while (list) { | |
6754 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
6755 list = list->next; | |
6756 } | |
6757 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
6758 break; | |
6759 default: | |
6760 break; | |
2086 | 6761 } |
4230 | 6762 #else |
8175 | 6763 if (od->sess->ssi.received_data) { |
6764 switch (account->perm_deny) { | |
6765 case GAIM_PRIVACY_ALLOW_ALL: | |
6766 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6767 break; | |
6768 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
6769 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
6770 break; | |
6771 case GAIM_PRIVACY_ALLOW_USERS: | |
6772 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
6773 break; | |
6774 case GAIM_PRIVACY_DENY_ALL: | |
6775 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
6776 break; | |
6777 case GAIM_PRIVACY_DENY_USERS: | |
6778 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
6779 break; | |
6780 default: | |
6781 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
6782 break; | |
6783 } | |
6784 } | |
4230 | 6785 #endif |
2086 | 6786 } |
6787 | |
5575 | 6788 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
4269 | 6789 #ifdef NOSSI |
8143 | 6790 if (gc->account->perm_deny == 3) |
4269 | 6791 oscar_set_permit_deny(gc); |
6792 #else | |
7283 | 6793 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6794 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
4230 | 6795 if (od->sess->ssi.received_data) |
4889 | 6796 aim_ssi_addpermit(od->sess, who); |
4230 | 6797 #endif |
2086 | 6798 } |
6799 | |
5575 | 6800 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
4269 | 6801 #ifdef NOSSI |
8143 | 6802 if (gc->account->perm_deny == 4) |
4269 | 6803 oscar_set_permit_deny(gc); |
6804 #else | |
7283 | 6805 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6806 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
4230 | 6807 if (od->sess->ssi.received_data) |
4889 | 6808 aim_ssi_adddeny(od->sess, who); |
4230 | 6809 #endif |
2086 | 6810 } |
6811 | |
5575 | 6812 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
4269 | 6813 #ifdef NOSSI |
8143 | 6814 if (gc->account->perm_deny == 3) |
4269 | 6815 oscar_set_permit_deny(gc); |
6816 #else | |
7283 | 6817 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6818 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
4230 | 6819 if (od->sess->ssi.received_data) |
4889 | 6820 aim_ssi_delpermit(od->sess, who); |
4230 | 6821 #endif |
2086 | 6822 } |
6823 | |
5575 | 6824 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
4269 | 6825 #ifdef NOSSI |
8143 | 6826 if (gc->account->perm_deny == 4) |
4269 | 6827 oscar_set_permit_deny(gc); |
6828 #else | |
7283 | 6829 OscarData *od = (OscarData *)gc->proto_data; |
8660 | 6830 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
4230 | 6831 if (od->sess->ssi.received_data) |
4889 | 6832 aim_ssi_deldeny(od->sess, who); |
4230 | 6833 #endif |
2086 | 6834 } |
6835 | |
9975 | 6836 static GList * |
6837 oscar_status_types(GaimAccount *account) | |
2086 | 6838 { |
9975 | 6839 GList *status_types = NULL; |
6840 GaimStatusType *type; | |
6841 gboolean is_icq; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6842 |
9973 | 6843 g_return_val_if_fail(account != NULL, NULL); |
6844 | |
9975 | 6845 is_icq = aim_sn_is_icq(gaim_account_get_username(account)); |
6846 | |
9991 | 6847 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, |
6848 OSCAR_STATUS_ID_OFFLINE, | |
6849 _("Offline"), FALSE, FALSE, FALSE); | |
9976 | 6850 status_types = g_list_append(status_types, type); |
6851 | |
9991 | 6852 type = gaim_status_type_new_full(GAIM_STATUS_ONLINE, |
6853 OSCAR_STATUS_ID_ONLINE, | |
6854 _("Online"), FALSE, FALSE, FALSE); | |
9976 | 6855 status_types = g_list_append(status_types, type); |
6856 | |
9991 | 6857 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6858 OSCAR_STATUS_ID_AVAILABLE, | |
6859 _("Available"), TRUE, TRUE, FALSE); | |
9976 | 6860 status_types = g_list_append(status_types, type); |
6861 | |
9991 | 6862 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
6863 OSCAR_STATUS_ID_FREE4CHAT, | |
6864 _("Free For Chat"), TRUE, TRUE, FALSE); | |
9982 | 6865 status_types = g_list_append(status_types, type); |
6866 | |
9991 | 6867 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
6868 OSCAR_STATUS_ID_OCCUPIED, | |
6869 _("Occupied"), TRUE, TRUE, FALSE); | |
9976 | 6870 status_types = g_list_append(status_types, type); |
6871 | |
9991 | 6872 type = gaim_status_type_new_full(GAIM_STATUS_HIDDEN, |
6873 OSCAR_STATUS_ID_INVISIBLE, | |
6874 _("Invisible"), TRUE, TRUE, TRUE); | |
9982 | 6875 status_types = g_list_append(status_types, type); |
6876 | |
9991 | 6877 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, |
6878 OSCAR_STATUS_ID_AWAY, | |
6879 _("Away"), TRUE, TRUE, FALSE); | |
9976 | 6880 status_types = g_list_append(status_types, type); |
6881 | |
9991 | 6882 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6883 OSCAR_STATUS_ID_DND, | |
6884 _("Do Not Disturb"), TRUE, TRUE, FALSE); | |
9976 | 6885 status_types = g_list_append(status_types, type); |
6886 | |
9991 | 6887 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, |
6888 OSCAR_STATUS_ID_NA, | |
6889 _("Not Available"), TRUE, TRUE, FALSE); | |
9976 | 6890 status_types = g_list_append(status_types, type); |
9975 | 6891 |
6892 return status_types; | |
4333 | 6893 } |
6894 | |
7172 | 6895 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
8341 | 6896 GaimConnection *gc = data->gc; |
6897 OscarData *od = gc->proto_data; | |
7172 | 6898 GaimBuddy *b; |
6899 GaimGroup *g; | |
6900 | |
6901 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
6902 oscar_free_name_data(data); | |
6903 return; | |
6904 } | |
6905 | |
6906 if (!(g = gaim_find_buddys_group(b))) { | |
6907 oscar_free_name_data(data); | |
6908 return; | |
6909 } | |
6910 | |
6911 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
8341 | 6912 |
6913 if (!aim_sncmp(data->name, gc->account->username)) | |
6914 gaim_check_comment(od, text); | |
6915 | |
7172 | 6916 oscar_free_name_data(data); |
6917 } | |
6918 | |
9030 | 6919 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
6920 | |
6921 GaimBuddy *buddy; | |
6922 GaimConnection *gc; | |
6923 OscarData *od; | |
6924 struct name_data *data; | |
7172 | 6925 GaimGroup *g; |
6926 char *comment; | |
6927 gchar *comment_utf8; | |
9631 | 6928 gchar *title; |
7172 | 6929 |
9030 | 6930 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
6931 | |
6932 buddy = (GaimBuddy *) node; | |
6933 gc = gaim_account_get_connection(buddy->account); | |
6934 od = gc->proto_data; | |
6935 | |
6936 data = g_new(struct name_data, 1); | |
6937 | |
6938 if (!(g = gaim_find_buddys_group(buddy))) | |
7172 | 6939 return; |
9030 | 6940 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
7172 | 6941 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
6942 | |
6943 data->gc = gc; | |
9030 | 6944 data->name = g_strdup(buddy->name); |
7172 | 6945 data->nick = NULL; |
6946 | |
9631 | 6947 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
6948 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
8697 | 6949 comment_utf8, TRUE, FALSE, NULL, |
7172 | 6950 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
6951 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
6952 data); | |
9631 | 6953 g_free(title); |
7172 | 6954 |
6955 free(comment); | |
6956 g_free(comment_utf8); | |
6957 } | |
6958 | |
9030 | 6959 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
6960 | |
6961 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
7283 | 6962 OscarData *od = gc->proto_data; |
9030 | 6963 |
4333 | 6964 GList *m = NULL; |
9030 | 6965 GaimBlistNodeAction *act; |
6966 | |
6967 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
6968 oscar_buddycb_edit_comment, NULL); | |
6969 m = g_list_append(m, act); | |
7172 | 6970 |
4333 | 6971 if (od->icq) { |
4624 | 6972 #if 0 |
9030 | 6973 act = gaim_blist_node_action_new(_("Get Status Msg"), |
6974 oscar_get_icqstatusmsg, NULL); | |
6975 m = g_list_append(m, act); | |
4624 | 6976 #endif |
4333 | 6977 } else { |
7011 | 6978 aim_userinfo_t *userinfo; |
9030 | 6979 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
6980 | |
6981 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
6982 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
6983 | |
7011 | 6984 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
9030 | 6985 act = gaim_blist_node_action_new(_("Direct IM"), |
6986 oscar_ask_direct_im, NULL); | |
6987 m = g_list_append(m, act); | |
5917 | 6988 } |
9466 | 6989 #if 0 |
7011 | 6990 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
9030 | 6991 act = gaim_blist_node_action_new(_("Get File"), |
6992 oscar_ask_getfile, NULL); | |
6993 m = g_list_append(m, act); | |
5917 | 6994 } |
4826 | 6995 #endif |
4333 | 6996 } |
5131 | 6997 } |
5197 | 6998 |
5131 | 6999 if (od->sess->ssi.received_data) { |
9030 | 7000 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
7001 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
7002 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
7003 gaim_auth_sendrequest_menu, NULL); | |
7004 m = g_list_append(m, act); | |
4333 | 7005 } |
4916 | 7006 } |
7007 | |
4333 | 7008 return m; |
7009 } | |
7010 | |
9030 | 7011 |
7012 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
7013 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
7014 return oscar_buddy_menu((GaimBuddy *) node); | |
7015 } else { | |
7016 return NULL; | |
7017 } | |
7018 } | |
7019 | |
7020 | |
5575 | 7021 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
7283 | 7022 OscarData *od = gc->proto_data; |
5575 | 7023 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
4333 | 7024 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
7025 od->setnick = TRUE; | |
7026 od->newsn = g_strdup(nick); | |
7027 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7028 } else { | |
7029 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
7030 } | |
7031 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
7032 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
8152 | 7033 _("Screen name formatting can change only capitalization and whitespace.")); |
4333 | 7034 } |
7035 } | |
7036 | |
9015 | 7037 static void oscar_show_format_screenname(GaimPluginAction *action) |
4333 | 7038 { |
9015 | 7039 GaimConnection *gc = (GaimConnection *) action->context; |
8152 | 7040 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
8697 | 7041 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7042 _("OK"), G_CALLBACK(oscar_format_screenname), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7043 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7044 gc); |
4333 | 7045 } |
7046 | |
9015 | 7047 static void oscar_confirm_account(GaimPluginAction *action) |
4333 | 7048 { |
9015 | 7049 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7050 OscarData *od = gc->proto_data; |
4333 | 7051 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7052 | |
7053 if (conn) { | |
7054 aim_admin_reqconfirm(od->sess, conn); | |
7055 } else { | |
7056 od->conf = TRUE; | |
7057 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7058 } | |
7059 } | |
7060 | |
9015 | 7061 static void oscar_show_email(GaimPluginAction *action) |
4333 | 7062 { |
9015 | 7063 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7064 OscarData *od = gc->proto_data; |
4333 | 7065 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7066 | |
7067 if (conn) { | |
7068 aim_admin_getinfo(od->sess, conn, 0x11); | |
7069 } else { | |
7070 od->reqemail = TRUE; | |
7071 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7072 } | |
7073 } | |
7074 | |
5575 | 7075 static void oscar_change_email(GaimConnection *gc, const char *email) |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7076 { |
7283 | 7077 OscarData *od = gc->proto_data; |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7078 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
|
7079 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7080 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7081 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7082 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7083 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7084 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7085 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7086 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7087 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
7088 |
9015 | 7089 static void oscar_show_change_email(GaimPluginAction *action) |
4333 | 7090 { |
9015 | 7091 GaimConnection *gc = (GaimConnection *) action->context; |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
7092 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
8697 | 7093 FALSE, FALSE, NULL, |
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7094 _("OK"), G_CALLBACK(oscar_change_email), |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7095 _("Cancel"), NULL, |
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
7096 gc); |
4333 | 7097 } |
7098 | |
9015 | 7099 static void oscar_show_awaitingauth(GaimPluginAction *action) |
4333 | 7100 { |
9015 | 7101 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7102 OscarData *od = gc->proto_data; |
4333 | 7103 gchar *nombre, *text, *tmp; |
6695 | 7104 GaimBlistNode *gnode, *cnode, *bnode; |
4333 | 7105 int num=0; |
7106 | |
6873 | 7107 text = g_strdup(""); |
4333 | 7108 |
4785 | 7109 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
6695 | 7110 GaimGroup *group = (GaimGroup *)gnode; |
4785 | 7111 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
7112 continue; | |
6695 | 7113 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
7114 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 7115 continue; |
6695 | 7116 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
7117 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
7118 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
7119 continue; | |
7120 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
9620 | 7121 if (gaim_buddy_get_alias_only(buddy)) |
7122 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
6695 | 7123 else |
7124 nombre = g_strdup_printf(" %s", buddy->name); | |
6873 | 7125 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
6695 | 7126 g_free(text); |
7127 text = tmp; | |
7128 g_free(nombre); | |
7129 num++; | |
7130 } | |
4333 | 7131 } |
2979 | 7132 } |
4333 | 7133 } |
7134 | |
7135 if (!num) { | |
7136 g_free(text); | |
6873 | 7137 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
7138 } | |
7139 | |
7140 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
7141 "the following buddies"), _("You can re-request " | |
7142 "authorization from these buddies by " | |
7143 "right-clicking on them and selecting " | |
7144 "\"Re-request Authorization.\""), text, NULL, NULL); | |
4333 | 7145 g_free(text); |
2979 | 7146 } |
7147 | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7148 static void search_by_email_cb(GaimConnection *gc, const char *email) |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7149 { |
8950 | 7150 OscarData *od = (OscarData *)gc->proto_data; |
7151 | |
7152 aim_search_address(od->sess, od->conn, email); | |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7153 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7154 |
9015 | 7155 static void oscar_show_find_email(GaimPluginAction *action) |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7156 { |
9015 | 7157 GaimConnection *gc = (GaimConnection *) action->context; |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7158 gaim_request_input(gc, _("Find Buddy by E-mail"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7159 _("Search for a buddy by e-mail address"), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7160 _("Type the e-mail address of the buddy you are " |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7161 "searching for."), |
8697 | 7162 NULL, FALSE, FALSE, NULL, |
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7163 _("Search"), G_CALLBACK(search_by_email_cb), |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7164 _("Cancel"), NULL, gc); |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7165 } |
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
7166 |
9015 | 7167 static void oscar_show_set_info(GaimPluginAction *action) |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7168 { |
9015 | 7169 GaimConnection *gc = (GaimConnection *) action->context; |
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7170 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7171 } |
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
7172 |
9015 | 7173 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
8576 | 7174 { |
9015 | 7175 GaimConnection *gc = (GaimConnection *) action->context; |
9809 | 7176 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
8576 | 7177 } |
7178 | |
9015 | 7179 static void oscar_change_pass(GaimPluginAction *action) |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7180 { |
9015 | 7181 GaimConnection *gc = (GaimConnection *) action->context; |
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7182 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7183 } |
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
7184 |
9015 | 7185 static void oscar_show_chpassurl(GaimPluginAction *action) |
4333 | 7186 { |
9015 | 7187 GaimConnection *gc = (GaimConnection *) action->context; |
7283 | 7188 OscarData *od = gc->proto_data; |
5575 | 7189 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6400
diff
changeset
|
7190 gaim_notify_uri(gc, substituted); |
5517 | 7191 g_free(substituted); |
4333 | 7192 } |
7193 | |
9015 | 7194 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
7026 | 7195 { |
9015 | 7196 GaimConnection *gc = (GaimConnection *) action->context; |
7026 | 7197 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
7198 } | |
7199 | |
5842 | 7200 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
7201 { | |
7283 | 7202 OscarData *od = gc->proto_data; |
5844 | 7203 aim_session_t *sess = od->sess; |
5842 | 7204 FILE *file; |
7205 struct stat st; | |
5844 | 7206 |
6039 | 7207 if (iconfile == NULL) { |
8363 | 7208 aim_ssi_delicon(od->sess); |
6039 | 7209 } else if (!stat(iconfile, &st)) { |
5842 | 7210 char *buf = g_malloc(st.st_size); |
7211 file = fopen(iconfile, "rb"); | |
7212 if (file) { | |
6052 | 7213 md5_state_t *state; |
6039 | 7214 char md5[16]; |
9532 | 7215 /* XXX - Use g_file_get_contents()? */ |
5842 | 7216 int len = fread(buf, 1, st.st_size, file); |
6039 | 7217 fclose(file); |
6052 | 7218 state = g_malloc(sizeof(md5_state_t)); |
5842 | 7219 md5_init(state); |
7220 md5_append(state, buf, len); | |
7221 md5_finish(state, md5); | |
7222 g_free(state); | |
7223 aim_ssi_seticon(sess, md5, 16); | |
7224 } else | |
8660 | 7225 gaim_debug_error("oscar", |
5842 | 7226 "Can't open buddy icon file!\n"); |
7227 g_free(buf); | |
7228 } else | |
8660 | 7229 gaim_debug_error("oscar", |
5842 | 7230 "Can't stat buddy icon file!\n"); |
7231 } | |
7232 | |
7233 | |
9015 | 7234 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
2086 | 7235 { |
9015 | 7236 GaimConnection *gc = (GaimConnection *) context; |
7283 | 7237 OscarData *od = gc->proto_data; |
4333 | 7238 GList *m = NULL; |
9015 | 7239 GaimPluginAction *act; |
7240 | |
7241 act = gaim_plugin_action_new(_("Set User Info..."), | |
7242 oscar_show_set_info); | |
7243 m = g_list_append(m, act); | |
4333 | 7244 |
8576 | 7245 if (od->icq) { |
9015 | 7246 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
7247 oscar_show_set_info_icqurl); | |
7248 m = g_list_append(m, act); | |
8576 | 7249 } |
7250 | |
9015 | 7251 act = gaim_plugin_action_new(_("Change Password..."), |
7252 oscar_change_pass); | |
7253 m = g_list_append(m, act); | |
4617 | 7254 |
7255 if (od->sess->authinfo->chpassurl) { | |
9015 | 7256 act = gaim_plugin_action_new(_("Change Password (URL)"), |
7257 oscar_show_chpassurl); | |
7258 m = g_list_append(m, act); | |
7259 | |
7260 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
7261 oscar_show_imforwardingurl); | |
7262 m = g_list_append(m, act); | |
7026 | 7263 } |
7264 | |
5238 | 7265 if (!od->icq) { |
4617 | 7266 /* AIM actions */ |
7267 m = g_list_append(m, NULL); | |
4333 | 7268 |
9015 | 7269 act = gaim_plugin_action_new(_("Format Screen Name..."), |
7270 oscar_show_format_screenname); | |
7271 m = g_list_append(m, act); | |
7272 | |
7273 act = gaim_plugin_action_new(_("Confirm Account"), | |
7274 oscar_confirm_account); | |
7275 m = g_list_append(m, act); | |
7276 | |
7277 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
7278 oscar_show_email); | |
7279 m = g_list_append(m, act); | |
7280 | |
7281 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
7282 oscar_show_change_email); | |
7283 m = g_list_append(m, act); | |
2086 | 7284 } |
4333 | 7285 |
7286 m = g_list_append(m, NULL); | |
7287 | |
9015 | 7288 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
7289 oscar_show_awaitingauth); | |
7290 m = g_list_append(m, act); | |
4333 | 7291 |
2086 | 7292 m = g_list_append(m, NULL); |
4333 | 7293 |
9015 | 7294 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
7295 oscar_show_find_email); | |
7296 m = g_list_append(m, act); | |
4333 | 7297 |
8591 | 7298 #if 0 |
9015 | 7299 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
7300 show_find_info); | |
7301 m = g_list_append(m, act); | |
8591 | 7302 #endif |
2086 | 7303 |
7304 return m; | |
7305 } | |
7306 | |
5575 | 7307 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
2086 | 7308 { |
7283 | 7309 OscarData *od = gc->proto_data; |
4617 | 7310 |
7311 if (od->icq) { | |
7312 aim_icq_changepasswd(od->sess, new); | |
2086 | 7313 } else { |
4617 | 7314 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
7315 if (conn) { | |
7316 aim_admin_changepasswd(od->sess, conn, new, old); | |
7317 } else { | |
7318 od->chpass = TRUE; | |
7319 od->oldp = g_strdup(old); | |
7320 od->newp = g_strdup(new); | |
7321 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
7322 } | |
2086 | 7323 } |
7324 } | |
7325 | |
6059 | 7326 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7327 { |
7283 | 7328 OscarData *od = gc->proto_data; |
8971 | 7329 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
|
7330 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7331 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7332 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7333 |
8971 | 7334 oscar_direct_im_destroy(od, dim); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7335 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7336 |
9935 | 7337 static void |
7338 recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) | |
7339 { | |
7340 GaimConnection *gc = data; | |
7341 OscarData *od = gc->proto_data; | |
7342 aim_session_t *sess = od->sess; | |
7343 fu32_t presence; | |
7344 | |
7345 presence = aim_ssi_getpresence(sess->ssi.local); | |
7346 | |
7347 if (value) { | |
9992 | 7348 /* Based on the packet capture I thought it was the first one */ |
7349 /* Stu thinks it's the second one. */ | |
7350 /* presence |= 0x00400000; */ | |
9971 | 7351 presence &= ~0x00020000; |
9935 | 7352 aim_ssi_setpresence(sess, presence); |
7353 } else { | |
9992 | 7354 /* presence &= ~0x00400000; */ |
9971 | 7355 presence |= 0x00020000; |
9935 | 7356 aim_ssi_setpresence(sess, presence); |
7357 } | |
7358 } | |
7359 | |
7360 static GaimPluginPrefFrame * | |
9936 | 7361 get_plugin_pref_frame(GaimPlugin *plugin) |
7362 { | |
9935 | 7363 GaimPluginPrefFrame *frame; |
7364 GaimPluginPref *ppref; | |
7365 | |
7366 frame = gaim_plugin_pref_frame_new(); | |
7367 | |
7368 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); | |
7369 gaim_plugin_pref_frame_add(frame, ppref); | |
7370 | |
7371 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
7372 gaim_plugin_pref_frame_add(frame, ppref); | |
7373 | |
7374 return frame; | |
7375 } | |
7376 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7377 static GaimPluginProtocolInfo prpl_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7378 { |
9308 | 7379 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
9475 | 7380 NULL, /* user_splits */ |
7381 NULL, /* protocol_options */ | |
7382 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
7383 oscar_list_icon, /* list_icon */ | |
7384 oscar_list_emblems, /* list_emblems */ | |
7385 oscar_status_text, /* status_text */ | |
7386 oscar_tooltip_text, /* tooltip_text */ | |
9973 | 7387 oscar_status_types, /* status_types */ |
9475 | 7388 oscar_blist_node_menu, /* blist_node_menu */ |
7389 oscar_chat_info, /* chat_info */ | |
9754 | 7390 oscar_chat_info_defaults, /* chat_info_defaults */ |
9475 | 7391 oscar_login, /* login */ |
7392 oscar_close, /* close */ | |
7393 oscar_send_im, /* send_im */ | |
7394 oscar_set_info, /* set_info */ | |
7395 oscar_send_typing, /* send_typing */ | |
7396 oscar_get_info, /* get_info */ | |
9973 | 7397 oscar_set_status, /* set_status */ |
9475 | 7398 oscar_set_idle, /* set_idle */ |
7399 oscar_change_passwd, /* change_passwd */ | |
7400 oscar_add_buddy, /* add_buddy */ | |
7401 oscar_add_buddies, /* add_buddies */ | |
7402 oscar_remove_buddy, /* remove_buddy */ | |
7403 oscar_remove_buddies, /* remove_buddies */ | |
7404 oscar_add_permit, /* add_permit */ | |
7405 oscar_add_deny, /* add_deny */ | |
7406 oscar_rem_permit, /* rem_permit */ | |
7407 oscar_rem_deny, /* rem_deny */ | |
7408 oscar_set_permit_deny, /* set_permit_deny */ | |
7409 oscar_warn, /* warn */ | |
7410 oscar_join_chat, /* join_chat */ | |
7411 NULL, /* reject_chat */ | |
9973 | 7412 oscar_get_chat_name, /* get_chat_name */ |
9475 | 7413 oscar_chat_invite, /* chat_invite */ |
7414 oscar_chat_leave, /* chat_leave */ | |
7415 NULL, /* chat_whisper */ | |
7416 oscar_send_chat, /* chat_send */ | |
7417 oscar_keepalive, /* keepalive */ | |
7418 NULL, /* register_user */ | |
7419 NULL, /* get_cb_info */ | |
7420 NULL, /* get_cb_away */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7421 #ifndef NOSSI |
9475 | 7422 oscar_alias_buddy, /* alias_buddy */ |
7423 oscar_move_buddy, /* group_buddy */ | |
7424 oscar_rename_group, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7425 #else |
9475 | 7426 NULL, /* alias_buddy */ |
7427 NULL, /* group_buddy */ | |
7428 NULL, /* rename_group */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7429 #endif |
9475 | 7430 NULL, /* buddy_free */ |
7431 oscar_convo_closed, /* convo_closed */ | |
7432 NULL, /* normalize */ | |
7433 oscar_set_icon, /* set_buddy_icon */ | |
7434 NULL, /* remove_group */ | |
7435 NULL, /* get_cb_real_name */ | |
7436 NULL, /* set_chat_topic */ | |
7437 NULL, /* find_blist_chat */ | |
7438 NULL, /* roomlist_get_list */ | |
7439 NULL, /* roomlist_cancel */ | |
7440 NULL, /* roomlist_expand_category */ | |
7441 oscar_can_receive_file, /* can_receive_file */ | |
7442 oscar_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7443 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7444 |
9935 | 7445 static GaimPluginUiInfo prefs_info = { |
7446 get_plugin_pref_frame | |
7447 }; | |
7448 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7449 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7450 { |
9943 | 7451 GAIM_PLUGIN_MAGIC, |
7452 GAIM_MAJOR_VERSION, | |
7453 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7454 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7455 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7456 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7457 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7458 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7459 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7460 "prpl-oscar", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7461 "AIM/ICQ", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7462 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7463 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7464 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7465 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7466 N_("AIM/ICQ Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7467 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7468 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7469 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7470 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7471 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7472 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7473 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7474 NULL, /**< ui_info */ |
8993 | 7475 &prpl_info, /**< extra_info */ |
9935 | 7476 &prefs_info, /**< prefs_info */ |
9015 | 7477 oscar_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7478 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7479 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7480 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7481 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7482 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7483 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7484 |
9830 | 7485 option = gaim_account_option_string_new(_("Auth host"), "server", FAIM_LOGIN_SERVER); |
7486 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7487 | |
7488 option = gaim_account_option_int_new(_("Auth port"), "port", FAIM_LOGIN_PORT); | |
7489 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
7490 | |
7491 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
7492 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
|
7493 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7494 my_protocol = plugin; |
9935 | 7495 |
7496 gaim_prefs_add_none("/plugins/prpl/oscar"); | |
7497 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
9942 | 7498 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
2086 | 7499 } |
7500 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7501 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |