Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 4156:d833bacc054f
[gaim-migrate @ 4384]
including win32dep.h for snprintf
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 31 Dec 2002 02:53:41 +0000 |
parents | 3468d666d3cc |
children | 3f267c74e50a |
rev | line source |
---|---|
3453 | 1 |
2086 | 2 /* |
3 * gaim | |
4 * | |
5 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
25 #include <config.h> |
2086 | 26 #endif |
27 | |
3664 | 28 #include <sys/types.h> |
29 /*this must happen before sys/socket.h or freebsd won't compile*/ | |
30 | |
3630 | 31 #ifndef _WIN32 |
2086 | 32 #include <netdb.h> |
33 #include <netinet/in.h> | |
34 #include <arpa/inet.h> | |
3630 | 35 #include <sys/socket.h> |
36 #include <unistd.h> | |
37 #endif | |
38 | |
39 #include <errno.h> | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
40 #include <ctype.h> |
2086 | 41 #include <string.h> |
42 #include <stdlib.h> | |
43 #include <stdio.h> | |
44 #include <time.h> | |
45 #include <sys/stat.h> | |
3630 | 46 #include <signal.h> |
47 | |
2086 | 48 #include "multi.h" |
49 #include "prpl.h" | |
50 #include "gaim.h" | |
51 #include "aim.h" | |
52 #include "proxy.h" | |
53 | |
3630 | 54 #ifdef _WIN32 |
55 #include "win32dep.h" | |
56 #endif | |
57 | |
3490 | 58 #include "pixmaps/protocols/oscar/ab.xpm" |
59 #include "pixmaps/protocols/oscar/admin_icon.xpm" | |
60 #include "pixmaps/protocols/oscar/aol_icon.xpm" | |
61 #include "pixmaps/protocols/oscar/away_icon.xpm" | |
62 #include "pixmaps/protocols/oscar/dt_icon.xpm" | |
63 #include "pixmaps/protocols/oscar/free_icon.xpm" | |
64 #include "pixmaps/protocols/oscar/wireless_icon.xpm" | |
2086 | 65 |
3579 | 66 #include "pixmaps/protocols/icq/gnomeicu-online.xpm" |
67 #include "pixmaps/protocols/icq/gnomeicu-offline.xpm" | |
68 #include "pixmaps/protocols/icq/gnomeicu-away.xpm" | |
69 #include "pixmaps/protocols/icq/gnomeicu-dnd.xpm" | |
70 #include "pixmaps/protocols/icq/gnomeicu-na.xpm" | |
71 #include "pixmaps/protocols/icq/gnomeicu-occ.xpm" | |
72 #include "pixmaps/protocols/icq/gnomeicu-ffc.xpm" | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
73 |
2086 | 74 /* constants to identify proto_opts */ |
75 #define USEROPT_AUTH 0 | |
76 #define USEROPT_AUTHPORT 1 | |
77 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
78 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
79 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
80 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
81 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
82 #define UC_AB 0x20 |
3079 | 83 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
84 |
2086 | 85 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
86 | |
3630 | 87 /* For win32 compatability */ |
88 G_MODULE_IMPORT GSList *connections; | |
89 G_MODULE_IMPORT int report_idle; | |
90 | |
91 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | | |
92 AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE; | |
3458 | 93 |
94 /* Set AIM caps, because Gaim can still do them over ICQ and | |
95 * Winicq doesn't mind. */ | |
4154 | 96 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE; |
3595 | 97 /* static int caps_icq = AIM_CAPS_ICQ; */ |
98 /* What does AIM_CAPS_ICQ actually mean? -SE */ | |
3458 | 99 |
2308
a90be9567452
[gaim-migrate @ 2318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
100 static fu8_t gaim_features[] = {0x01, 0x01, 0x01, 0x02}; |
2086 | 101 |
102 struct oscar_data { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
103 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
104 aim_conn_t *conn; |
2086 | 105 |
106 guint cnpa; | |
107 guint paspa; | |
3694 | 108 guint emlpa; |
2086 | 109 |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
110 GSList *create_rooms; |
2086 | 111 |
112 gboolean conf; | |
113 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
114 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
115 char *email; |
2979 | 116 gboolean setnick; |
117 char *newsn; | |
2086 | 118 gboolean chpass; |
119 char *oldp; | |
120 char *newp; | |
121 | |
122 GSList *oscar_chats; | |
123 GSList *direct_ims; | |
3630 | 124 GSList *file_transfers; |
2086 | 125 GSList *hasicons; |
3600 | 126 GHashTable *supports_tn; |
2086 | 127 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
128 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
129 gboolean icq; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
130 GSList *evilhack; |
2993 | 131 |
132 struct { | |
133 guint maxbuddies; /* max users you can watch */ | |
134 guint maxwatchers; /* max users who can watch you */ | |
135 guint maxpermits; /* max users on permit list */ | |
136 guint maxdenies; /* max users on deny list */ | |
137 guint maxsiglen; /* max size (bytes) of profile */ | |
138 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
139 } rights; | |
2086 | 140 }; |
141 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
142 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
143 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
144 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
145 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
146 |
2086 | 147 struct chat_connection { |
148 char *name; | |
149 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
150 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
151 fu16_t instance; |
2086 | 152 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
|
153 aim_conn_t *conn; |
2086 | 154 int inpa; |
155 int id; | |
156 struct gaim_connection *gc; /* i hate this. */ | |
157 struct conversation *cnv; /* bah. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
158 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
159 int maxvis; |
2086 | 160 }; |
161 | |
162 struct direct_im { | |
163 struct gaim_connection *gc; | |
164 char name[80]; | |
165 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
166 aim_conn_t *conn; |
3008 | 167 gboolean connected; |
2086 | 168 }; |
169 | |
170 struct ask_direct { | |
171 struct gaim_connection *gc; | |
172 char *sn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
173 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
174 fu8_t cookie[8]; |
2086 | 175 }; |
176 | |
3630 | 177 struct oscar_file_transfer { |
178 enum { OFT_SENDFILE_IN, OFT_SENDFILE_OUT } type; | |
179 aim_conn_t *conn; | |
180 struct file_transfer *xfer; | |
181 char *sn; | |
182 char ip[64]; | |
183 fu16_t port; | |
184 fu8_t cookie[8]; | |
185 int totsize; | |
186 int filesdone; | |
187 int totfiles; | |
188 int watcher; | |
189 }; | |
190 | |
2086 | 191 struct icon_req { |
192 char *user; | |
193 time_t timestamp; | |
2196
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2194
diff
changeset
|
194 unsigned long length; |
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2172
diff
changeset
|
195 unsigned long checksum; |
2086 | 196 gboolean request; |
197 }; | |
198 | |
3453 | 199 struct channel4_data { |
3141 | 200 struct gaim_connection *gc; |
3453 | 201 gchar *uin; |
202 gchar *nick; | |
3141 | 203 }; |
204 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
205 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { |
2086 | 206 GSList *d = od->direct_ims; |
207 char *n = g_strdup(normalize(who)); | |
208 struct direct_im *m = NULL; | |
209 | |
210 while (d) { | |
211 m = (struct direct_im *)d->data; | |
212 if (!strcmp(n, normalize(m->name))) | |
213 break; | |
214 m = NULL; | |
215 d = d->next; | |
216 } | |
217 | |
218 g_free(n); | |
219 return m; | |
220 } | |
221 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
222 static char *extract_name(const char *name) { |
4121 | 223 char *tmp, *x; |
2086 | 224 int i, j; |
4120 | 225 |
226 if (!name) | |
4121 | 227 return NULL; |
228 | |
4120 | 229 x = strchr(name, '-'); |
4121 | 230 |
2086 | 231 if (!x) return NULL; |
232 x = strchr(++x, '-'); | |
233 if (!x) return NULL; | |
234 tmp = g_strdup(++x); | |
235 | |
236 for (i = 0, j = 0; x[i]; i++) { | |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
237 char hex[3]; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
238 if (x[i] != '%') { |
2086 | 239 tmp[j++] = x[i]; |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
240 continue; |
2086 | 241 } |
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
242 strncpy(hex, x + ++i, 2); hex[2] = 0; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
243 i++; |
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
244 tmp[j++] = strtol(hex, NULL, 16); |
2086 | 245 } |
246 | |
247 tmp[j] = 0; | |
248 return tmp; | |
249 } | |
250 | |
251 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { | |
252 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; | |
253 struct chat_connection *c = NULL; | |
254 | |
255 while (g) { | |
256 c = (struct chat_connection *)g->data; | |
257 if (c->id == id) | |
258 break; | |
259 g = g->next; | |
260 c = NULL; | |
261 } | |
262 | |
263 return c; | |
264 } | |
265 | |
266 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
267 aim_conn_t *conn) { |
2086 | 268 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
269 struct chat_connection *c = NULL; | |
270 | |
271 while (g) { | |
272 c = (struct chat_connection *)g->data; | |
273 if (c->conn == conn) | |
274 break; | |
275 g = g->next; | |
276 c = NULL; | |
277 } | |
278 | |
279 return c; | |
280 } | |
281 | |
3630 | 282 /* XXX there must be a better way than this.... -- wtm */ |
283 static struct oscar_file_transfer *find_oft_by_conn(struct gaim_connection *gc, | |
284 aim_conn_t *conn) { | |
285 GSList *g = ((struct oscar_data *)gc->proto_data)->file_transfers; | |
286 struct oscar_file_transfer *f = NULL; | |
287 | |
288 while (g) { | |
289 f = (struct oscar_file_transfer *)g->data; | |
290 if (f->conn == conn) | |
291 break; | |
292 g = g->next; | |
293 f = NULL; | |
294 } | |
295 | |
296 return f; | |
297 } | |
298 | |
299 static struct oscar_file_transfer *find_oft_by_xfer(struct gaim_connection *gc, | |
300 struct file_transfer *xfer) { | |
301 GSList *g = ((struct oscar_data *)gc->proto_data)->file_transfers; | |
302 struct oscar_file_transfer *f = NULL; | |
303 | |
304 while (g) { | |
305 f = (struct oscar_file_transfer *)g->data; | |
306 if (f->xfer == xfer) | |
307 break; | |
308 g = g->next; | |
309 f = NULL; | |
310 } | |
311 | |
312 return f; | |
313 } | |
314 | |
315 static struct oscar_file_transfer *find_oft_by_cookie(struct gaim_connection *gc, | |
316 const char *cookie) { | |
317 GSList *g = ((struct oscar_data *)gc->proto_data)->file_transfers; | |
318 struct oscar_file_transfer *f = NULL; | |
319 | |
320 while (g) { | |
321 f = (struct oscar_file_transfer *)g->data; | |
322 if (!strncmp(f->cookie, cookie, 8)) | |
323 break; | |
324 g = g->next; | |
325 f = NULL; | |
326 } | |
327 | |
328 return f; | |
329 } | |
330 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
331 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
332 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
333 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
334 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
335 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
336 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
337 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
338 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
339 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); |
3212 | 340 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
341 static int gaim_parse_user_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
342 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
343 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
344 static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
345 static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
346 static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
347 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
3694 | 348 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
349 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
350 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
351 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
352 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
353 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
354 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); |
3952 | 355 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
356 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); |
3952 | 357 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
358 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); |
3694 | 359 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
360 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); |
3595 | 361 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); |
2993 | 362 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
363 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
364 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
365 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
366 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
367 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
368 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
369 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
370 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); |
4151 | 371 static int gaim_icqsimpleinfo (aim_session_t *, aim_frame_t *, ...); |
372 static int gaim_icqallinfo (aim_session_t *, aim_frame_t *, ...); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
373 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); |
2991 | 374 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); |
375 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
376 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
377 static int gaim_directim_initiate(aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
378 static int gaim_directim_incoming(aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
379 static int gaim_directim_typing (aim_session_t *, aim_frame_t *, ...); |
2993 | 380 static int gaim_update_ui (aim_session_t *, aim_frame_t *, ...); |
2086 | 381 |
3630 | 382 static int oscar_file_transfer_do(aim_session_t *, aim_frame_t *, ...); |
383 static void oscar_file_transfer_disconnect(aim_session_t *, | |
384 aim_conn_t *); | |
3771 | 385 static void oscar_file_transfer_cancel(struct gaim_connection *, |
3630 | 386 struct file_transfer *); |
387 static int oscar_sendfile_request(aim_session_t *sess, | |
388 struct oscar_file_transfer *oft); | |
3752 | 389 static int oscar_sendfile_timeout(aim_session_t *sess, aim_frame_t *fr, ...); |
3630 | 390 |
4151 | 391 static fu32_t check_encoding(const char *utf8); |
392 static fu32_t parse_encoding(const char *enc); | |
393 | |
2086 | 394 static char *msgerrreason[] = { |
4056 | 395 N_("Invalid error"), |
396 N_("Invalid SNAC"), | |
397 N_("Rate to host"), | |
398 N_("Rate to client"), | |
399 N_("Not logged in"), | |
400 N_("Service unavailable"), | |
401 N_("Service not defined"), | |
402 N_("Obsolete SNAC"), | |
403 N_("Not supported by host"), | |
404 N_("Not supported by client"), | |
405 N_("Refused by client"), | |
406 N_("Reply too big"), | |
407 N_("Responses lost"), | |
408 N_("Request denied"), | |
409 N_("Busted SNAC payload"), | |
410 N_("Insufficient rights"), | |
411 N_("In local permit/deny"), | |
412 N_("Too evil (sender)"), | |
413 N_("Too evil (receiver)"), | |
414 N_("User temporarily unavailable"), | |
415 N_("No match"), | |
416 N_("List overflow"), | |
417 N_("Request ambiguous"), | |
418 N_("Queue full"), | |
419 N_("Not while on AOL") | |
2086 | 420 }; |
421 static int msgerrreasonlen = 25; | |
422 | |
3952 | 423 /* |
424 * This is called to clean up whenever a file transfer is no longer in progress, | |
425 * whether because it finished sucessfully, it was canceled, or there was an error. | |
426 */ | |
427 static void oscar_file_transfer_disconnect(aim_session_t *sess, aim_conn_t *conn) { | |
3630 | 428 struct gaim_connection *gc = sess->aux_data; |
429 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
430 struct oscar_file_transfer *oft = find_oft_by_conn(gc, | |
431 conn); | |
432 | |
433 od->file_transfers = g_slist_remove(od->file_transfers, oft); | |
434 | |
435 if (oft->watcher) { | |
436 gaim_input_remove(oft->watcher); | |
437 oft->watcher = 0; | |
438 } | |
439 | |
440 aim_conn_kill(sess, &conn); | |
441 | |
442 g_free(oft->sn); | |
443 g_free(oft); | |
444 } | |
445 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
446 static void gaim_directim_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
447 struct gaim_connection *gc = sess->aux_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
448 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
449 struct conversation *cnv; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
450 struct direct_im *dim; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
451 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
452 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
453 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
454 sn = g_strdup(aim_directim_getsn(conn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
455 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
456 debug_printf("%s disconnected Direct IM.\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
457 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
458 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
459 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
460 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
461 |
3008 | 462 if (dim->connected) |
463 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
464 else | |
465 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn); | |
466 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
467 if ((cnv = find_conversation(sn))) |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
468 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); |
2993 | 469 update_progress(cnv, 100); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
470 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
471 g_free(dim); /* I guess? I don't see it anywhere else... -- mid */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
472 g_free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
473 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
474 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
475 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
476 |
2086 | 477 static void oscar_callback(gpointer data, gint source, |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
478 GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
479 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
480 aim_session_t *sess = aim_conn_getsess(conn); |
2086 | 481 struct gaim_connection *gc = sess ? sess->aux_data : NULL; |
482 struct oscar_data *odata; | |
483 | |
484 if (!gc) { | |
485 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
486 debug_printf("oscar callback for closed connection (1).\n"); | |
487 return; | |
488 } | |
489 | |
490 odata = (struct oscar_data *)gc->proto_data; | |
491 | |
492 if (!g_slist_find(connections, gc)) { | |
493 /* oh boy. this is probably bad. i guess the only thing we | |
494 * can really do is return? */ | |
495 debug_printf("oscar callback for closed connection (2).\n"); | |
496 return; | |
497 } | |
498 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
499 if (condition & GAIM_INPUT_READ) { |
2086 | 500 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { |
501 debug_printf("got information on rendezvous\n"); | |
502 if (aim_handlerendconnect(odata->sess, conn) < 0) { | |
503 debug_printf(_("connection error (rend)\n")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
504 aim_conn_kill(odata->sess, &conn); |
2086 | 505 } |
506 } else { | |
507 if (aim_get_command(odata->sess, conn) >= 0) { | |
508 aim_rxdispatch(odata->sess); | |
509 if (odata->killme) | |
510 signoff(gc); | |
511 } else { | |
512 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
513 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { | |
514 debug_printf(_("major connection error\n")); | |
3074 | 515 hide_login_progress_error(gc, _("Disconnected.")); |
2086 | 516 signoff(gc); |
517 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
518 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
519 char buf[BUF_LONG]; | |
520 debug_printf("disconnected from chat room %s\n", c->name); | |
521 c->conn = NULL; | |
522 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
523 gaim_input_remove(c->inpa); |
2086 | 524 c->inpa = 0; |
525 c->fd = -1; | |
526 aim_conn_kill(odata->sess, &conn); | |
3574 | 527 snprintf(buf, sizeof(buf), _("You have been disconnected from chat room %s."), c->name); |
3427 | 528 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 529 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
530 if (odata->cnpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
531 gaim_input_remove(odata->cnpa); |
2086 | 532 odata->cnpa = 0; |
533 debug_printf("removing chatnav input watcher\n"); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
534 while (odata->create_rooms) { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
535 struct create_room *cr = odata->create_rooms->data; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
536 g_free(cr->name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
537 odata->create_rooms = |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
538 g_slist_remove(odata->create_rooms, cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
539 g_free(cr); |
3427 | 540 do_error_dialog(_("Chat is currently unavailable"), NULL, GAIM_ERROR); |
2086 | 541 } |
542 aim_conn_kill(odata->sess, &conn); | |
543 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
544 if (odata->paspa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
545 gaim_input_remove(odata->paspa); |
2086 | 546 odata->paspa = 0; |
547 debug_printf("removing authconn input watcher\n"); | |
548 aim_conn_kill(odata->sess, &conn); | |
3694 | 549 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
550 if (odata->emlpa > 0) | |
551 gaim_input_remove(odata->emlpa); | |
552 odata->emlpa = 0; | |
553 debug_printf("removing email input watcher\n"); | |
554 aim_conn_kill(odata->sess, &conn); | |
2086 | 555 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
556 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
557 gaim_directim_disconnect(odata->sess, conn); |
3630 | 558 else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) { |
559 struct oscar_file_transfer *oft = find_oft_by_conn(gc, conn); | |
560 if (oft) { | |
561 transfer_abort(oft->xfer, _("Buddy canceled transfer")); | |
562 } | |
563 oscar_file_transfer_disconnect(odata->sess, conn); | |
564 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
565 else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
566 debug_printf("No handler for rendezvous disconnect (%d).\n", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
567 source); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
568 } |
2086 | 569 aim_conn_kill(odata->sess, &conn); |
570 } else { | |
571 debug_printf("holy crap! generic connection error! %d\n", | |
572 conn->type); | |
573 aim_conn_kill(odata->sess, &conn); | |
574 } | |
575 } | |
576 } | |
577 } | |
578 } | |
579 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
580 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
2086 | 581 char *s = g_strdup_vprintf(format, va); |
582 char buf[256]; | |
583 char *t; | |
584 struct gaim_connection *gc = sess->aux_data; | |
585 | |
586 g_snprintf(buf, sizeof(buf), "%s %d: ", gc->username, level); | |
587 t = g_strconcat(buf, s, NULL); | |
588 debug_printf(t); | |
589 if (t[strlen(t)-1] != '\n') | |
590 debug_printf("\n"); | |
591 g_free(t); | |
592 g_free(s); | |
593 } | |
594 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
595 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 596 { |
597 struct gaim_connection *gc = data; | |
598 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
599 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
600 aim_conn_t *conn; |
2086 | 601 |
602 if (!g_slist_find(connections, gc)) { | |
603 close(source); | |
604 return; | |
605 } | |
606 | |
607 odata = gc->proto_data; | |
608 sess = odata->sess; | |
609 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
610 | |
611 if (source < 0) { | |
612 hide_login_progress(gc, _("Couldn't connect to host")); | |
613 signoff(gc); | |
614 return; | |
615 } | |
616 | |
617 aim_conn_completeconnect(sess, conn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
618 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, |
2086 | 619 oscar_callback, conn); |
620 debug_printf(_("Password sent, waiting for response\n")); | |
621 } | |
622 | |
623 static void oscar_login(struct aim_user *user) { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
624 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
625 aim_conn_t *conn; |
2086 | 626 char buf[256]; |
627 struct gaim_connection *gc = new_gaim_conn(user); | |
628 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); | |
629 | |
2589
4e149a0b9665
[gaim-migrate @ 2602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
630 if (isdigit(*user->username)) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
631 odata->icq = TRUE; |
2589
4e149a0b9665
[gaim-migrate @ 2602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
632 /* this is odd but it's necessary for a proper do_import and do_export */ |
4e149a0b9665
[gaim-migrate @ 2602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
633 gc->protocol = PROTO_ICQ; |
3064 | 634 gc->password[8] = 0; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
635 } else { |
2590
2dd86a1af92b
[gaim-migrate @ 2603]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2589
diff
changeset
|
636 gc->protocol = PROTO_TOC; |
2918
4df759d607f3
[gaim-migrate @ 2931]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2916
diff
changeset
|
637 gc->flags |= OPT_CONN_HTML; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
638 gc->flags |= OPT_CONN_AUTO_RESP; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
639 } |
3600 | 640 odata->supports_tn = g_hash_table_new(g_str_hash, g_str_equal); |
2086 | 641 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
642 sess = g_new0(aim_session_t, 1); |
2086 | 643 |
644 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
645 aim_setdebuggingcb(sess, oscar_debug); | |
646 | |
647 /* we need an immediate queue because we don't use a while-loop to | |
648 * see if things need to be sent. */ | |
649 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
650 odata->sess = sess; | |
651 sess->aux_data = gc; | |
652 | |
653 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
654 if (conn == NULL) { | |
655 debug_printf(_("internal connection error\n")); | |
656 hide_login_progress(gc, _("Unable to login to AIM")); | |
657 signoff(gc); | |
658 return; | |
659 } | |
660 | |
661 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | |
662 set_login_progress(gc, 2, buf); | |
663 | |
664 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); | |
665 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
666 | |
667 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
668 conn->fd = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? | |
669 user->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, | |
670 user->proto_opt[USEROPT_AUTHPORT][0] ? | |
671 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
672 oscar_login_connect, gc); | |
673 if (conn->fd < 0) { | |
674 hide_login_progress(gc, _("Couldn't connect to host")); | |
675 signoff(gc); | |
676 return; | |
677 } | |
678 aim_request_login(sess, conn, gc->username); | |
679 } | |
680 | |
681 static void oscar_close(struct gaim_connection *gc) { | |
682 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
683 | |
684 while (odata->oscar_chats) { | |
685 struct chat_connection *n = odata->oscar_chats->data; | |
686 if (n->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
687 gaim_input_remove(n->inpa); |
2086 | 688 g_free(n->name); |
689 g_free(n->show); | |
690 odata->oscar_chats = g_slist_remove(odata->oscar_chats, n); | |
691 g_free(n); | |
692 } | |
693 while (odata->direct_ims) { | |
694 struct direct_im *n = odata->direct_ims->data; | |
695 if (n->watcher > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
696 gaim_input_remove(n->watcher); |
2086 | 697 odata->direct_ims = g_slist_remove(odata->direct_ims, n); |
698 g_free(n); | |
699 } | |
3630 | 700 while (odata->file_transfers) { |
701 struct oscar_file_transfer *n = odata->file_transfers->data; | |
702 if (n->watcher > 0) | |
703 gaim_input_remove(n->watcher); | |
704 odata->file_transfers = g_slist_remove(odata->file_transfers, n); | |
705 g_free(n); | |
706 } | |
2086 | 707 while (odata->hasicons) { |
708 struct icon_req *n = odata->hasicons->data; | |
709 g_free(n->user); | |
710 odata->hasicons = g_slist_remove(odata->hasicons, n); | |
711 g_free(n); | |
712 } | |
3600 | 713 g_hash_table_destroy(odata->supports_tn); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
714 while (odata->evilhack) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
715 g_free(odata->evilhack->data); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
716 odata->evilhack = g_slist_remove(odata->evilhack, odata->evilhack->data); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
717 } |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
718 while (odata->create_rooms) { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
719 struct create_room *cr = odata->create_rooms->data; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
720 g_free(cr->name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
721 odata->create_rooms = g_slist_remove(odata->create_rooms, cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
722 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
723 } |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
724 if (odata->email) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
725 g_free(odata->email); |
2754
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
726 if (odata->newp) |
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
727 g_free(odata->newp); |
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
728 if (odata->oldp) |
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
729 g_free(odata->oldp); |
2086 | 730 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
731 gaim_input_remove(gc->inpa); |
2086 | 732 if (odata->cnpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
733 gaim_input_remove(odata->cnpa); |
2086 | 734 if (odata->paspa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
735 gaim_input_remove(odata->paspa); |
3694 | 736 if (odata->emlpa > 0) |
737 gaim_input_remove(odata->emlpa); | |
2086 | 738 aim_session_kill(odata->sess); |
739 g_free(odata->sess); | |
740 odata->sess = NULL; | |
741 g_free(gc->proto_data); | |
742 gc->proto_data = NULL; | |
743 debug_printf(_("Signed off.\n")); | |
744 } | |
745 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
746 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 747 struct gaim_connection *gc = data; |
748 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
749 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
750 aim_conn_t *bosconn; |
2086 | 751 |
752 if (!g_slist_find(connections, gc)) { | |
753 close(source); | |
754 return; | |
755 } | |
756 | |
757 odata = gc->proto_data; | |
758 sess = odata->sess; | |
759 bosconn = odata->conn; | |
760 | |
761 if (source < 0) { | |
762 hide_login_progress(gc, _("Could Not Connect")); | |
763 signoff(gc); | |
764 return; | |
765 } | |
766 | |
767 aim_conn_completeconnect(sess, bosconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
768 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, |
2086 | 769 oscar_callback, bosconn); |
770 set_login_progress(gc, 4, _("Connection established, cookie sent")); | |
771 } | |
772 | |
3630 | 773 static void oscar_ask_send_file(struct gaim_connection *gc, char *destsn) { |
774 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
3752 | 775 |
776 struct oscar_file_transfer *oft = g_new0(struct oscar_file_transfer, | |
777 1); | |
778 | |
779 oft->type = OFT_SENDFILE_OUT; | |
780 oft->sn = g_strdup(destsn); | |
781 | |
782 od->file_transfers = g_slist_append(od->file_transfers, oft); | |
783 | |
784 oft->xfer = transfer_out_add(gc, oft->sn); | |
3630 | 785 } |
786 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
787 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 788 va_list ap; |
2704 | 789 struct aim_authresp_info *info; |
2086 | 790 int i; char *host; int port; |
791 struct aim_user *user; | |
2704 | 792 aim_conn_t *bosconn; |
2086 | 793 |
794 struct gaim_connection *gc = sess->aux_data; | |
795 struct oscar_data *od = gc->proto_data; | |
796 user = gc->user; | |
797 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
798 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
799 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
800 va_start(ap, fr); |
2704 | 801 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 802 va_end(ap); |
803 | |
2704 | 804 debug_printf("inside auth_resp (Screen name: %s)\n", info->sn); |
805 | |
806 if (info->errorcode || !info->bosip || !info->cookie) { | |
4056 | 807 char buf[256]; |
2704 | 808 switch (info->errorcode) { |
2086 | 809 case 0x05: |
810 /* Incorrect nick/password */ | |
811 hide_login_progress(gc, _("Incorrect nickname or password.")); | |
812 plugin_event(event_error, (void *)980, 0, 0, 0); | |
813 break; | |
814 case 0x11: | |
815 /* Suspended account */ | |
816 hide_login_progress(gc, _("Your account is currently suspended.")); | |
817 break; | |
3498 | 818 case 0x14: |
819 /* service temporarily unavailable */ | |
820 hide_login_progress(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); | |
821 break; | |
2086 | 822 case 0x18: |
823 /* connecting too frequently */ | |
824 hide_login_progress(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.")); | |
825 plugin_event(event_error, (void *)983, 0, 0, 0); | |
826 break; | |
827 case 0x1c: | |
828 /* client too old */ | |
4056 | 829 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), WEBSITE); |
830 hide_login_progress(gc, buf); | |
2086 | 831 plugin_event(event_error, (void *)989, 0, 0, 0); |
832 break; | |
833 default: | |
834 hide_login_progress(gc, _("Authentication Failed")); | |
835 break; | |
836 } | |
2704 | 837 debug_printf("Login Error Code 0x%04x\n", info->errorcode); |
838 debug_printf("Error URL: %s\n", info->errorurl); | |
2086 | 839 od->killme = TRUE; |
840 return 1; | |
841 } | |
842 | |
843 | |
2704 | 844 debug_printf("Reg status: %d\n", info->regstatus); |
845 if (info->email) { | |
846 debug_printf("Email: %s\n", info->email); | |
2086 | 847 } else { |
848 debug_printf("Email is NULL\n"); | |
849 } | |
2704 | 850 debug_printf("BOSIP: %s\n", info->bosip); |
2086 | 851 debug_printf("Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
852 aim_conn_kill(sess, &fr->conn); |
2086 | 853 |
854 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
855 if (bosconn == NULL) { | |
856 hide_login_progress(gc, _("Internal Error")); | |
857 od->killme = TRUE; | |
858 return 0; | |
859 } | |
860 | |
2675 | 861 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 862 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
863 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
864 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 865 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 866 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
867 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
868 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
869 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
870 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
871 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 872 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 873 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
874 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
875 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
876 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
877 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 878 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
2086 | 879 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); |
880 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
881 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
|
882 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 883 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
884 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
885 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
886 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
887 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
888 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
|
889 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
|
890 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4151 | 891 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_SIMPLEINFO, gaim_icqsimpleinfo, 0); |
892 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALLINFO, gaim_icqallinfo, 0); | |
2991 | 893 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
894 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
895 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
3752 | 896 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_MSGTIMEOUT, oscar_sendfile_timeout, 0); |
2086 | 897 |
898 ((struct oscar_data *)gc->proto_data)->conn = bosconn; | |
2704 | 899 for (i = 0; i < (int)strlen(info->bosip); i++) { |
900 if (info->bosip[i] == ':') { | |
901 port = atoi(&(info->bosip[i+1])); | |
2086 | 902 break; |
903 } | |
904 } | |
2704 | 905 host = g_strndup(info->bosip, i); |
2086 | 906 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
907 bosconn->fd = proxy_connect(host, port, oscar_bos_connect, gc); | |
908 g_free(host); | |
909 if (bosconn->fd < 0) { | |
910 hide_login_progress(gc, _("Could Not Connect")); | |
911 od->killme = TRUE; | |
912 return 0; | |
913 } | |
2704 | 914 aim_sendcookie(sess, bosconn, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
915 gaim_input_remove(gc->inpa); |
2704 | 916 |
2086 | 917 return 1; |
918 } | |
919 | |
920 struct pieceofcrap { | |
921 struct gaim_connection *gc; | |
922 unsigned long offset; | |
923 unsigned long len; | |
924 char *modname; | |
925 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
926 aim_conn_t *conn; |
2086 | 927 unsigned int inpa; |
928 }; | |
929 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
930 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 931 { |
932 struct pieceofcrap *pos = data; | |
933 struct oscar_data *od = pos->gc->proto_data; | |
934 char in = '\0'; | |
935 int x = 0; | |
936 unsigned char m[17]; | |
937 | |
938 while (read(pos->fd, &in, 1) == 1) { | |
939 if (in == '\n') | |
940 x++; | |
941 else if (in != '\r') | |
942 x = 0; | |
943 if (x == 2) | |
944 break; | |
945 in = '\0'; | |
946 } | |
947 if (in != '\n') { | |
4056 | 948 char buf[256]; |
949 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
950 "this is fixed. Check %s for updates."), WEBSITE); | |
3427 | 951 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), |
4056 | 952 buf, GAIM_WARNING); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
953 gaim_input_remove(pos->inpa); |
2086 | 954 close(pos->fd); |
955 g_free(pos); | |
956 return; | |
957 } | |
958 read(pos->fd, m, 16); | |
959 m[16] = '\0'; | |
960 debug_printf("Sending hash: "); | |
961 for (x = 0; x < 16; x++) | |
962 debug_printf("%02x ", (unsigned char)m[x]); | |
963 debug_printf("\n"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
964 gaim_input_remove(pos->inpa); |
2086 | 965 close(pos->fd); |
966 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
967 g_free(pos); | |
968 } | |
969 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
970 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 971 struct pieceofcrap *pos = data; |
972 char buf[BUF_LONG]; | |
973 | |
974 if (source < 0) { | |
4056 | 975 char buf[256]; |
976 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
977 "this is fixed. Check %s for updates."), WEBSITE); | |
3427 | 978 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), |
4056 | 979 buf, GAIM_WARNING); |
2086 | 980 if (pos->modname) |
981 g_free(pos->modname); | |
982 g_free(pos); | |
983 return; | |
984 } | |
985 | |
986 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
987 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
988 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
989 write(pos->fd, buf, strlen(buf)); | |
990 if (pos->modname) | |
991 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
992 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 993 return; |
994 } | |
995 | |
996 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
997 #define AIM_MAX_FILE_SIZE 98304 | |
998 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
999 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1000 va_list ap; |
1001 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1002 fu32_t offset, len; |
2086 | 1003 char *modname; |
1004 int fd; | |
1005 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1006 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1007 offset = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1008 len = (fu32_t)va_arg(ap, unsigned long); |
2086 | 1009 modname = va_arg(ap, char *); |
1010 va_end(ap); | |
1011 | |
1012 debug_printf("offset: %d, len: %d, file: %s\n", offset, len, modname ? modname : "aim.exe"); | |
1013 if (len == 0) { | |
1014 debug_printf("len is 0, hashing NULL\n"); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1015 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 1016 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1017 return 1; | |
1018 } | |
1019 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
1020 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
1021 char *buf; | |
1022 int i = 8; | |
1023 if (modname) | |
1024 i += strlen(modname); | |
1025 buf = g_malloc(i); | |
1026 i = 0; | |
1027 if (modname) { | |
1028 memcpy(buf, modname, strlen(modname)); | |
1029 i += strlen(modname); | |
1030 } | |
1031 buf[i++] = offset & 0xff; | |
1032 buf[i++] = (offset >> 8) & 0xff; | |
1033 buf[i++] = (offset >> 16) & 0xff; | |
1034 buf[i++] = (offset >> 24) & 0xff; | |
1035 buf[i++] = len & 0xff; | |
1036 buf[i++] = (len >> 8) & 0xff; | |
1037 buf[i++] = (len >> 16) & 0xff; | |
1038 buf[i++] = (len >> 24) & 0xff; | |
1039 debug_printf("len + offset is invalid, hashing request\n"); | |
1040 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | |
1041 g_free(buf); | |
1042 return 1; | |
1043 } | |
1044 */ | |
1045 | |
1046 pos = g_new0(struct pieceofcrap, 1); | |
1047 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1048 pos->conn = fr->conn; |
2086 | 1049 |
1050 pos->offset = offset; | |
1051 pos->len = len; | |
1052 pos->modname = modname ? g_strdup(modname) : NULL; | |
1053 | |
1054 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos); | |
1055 if (fd < 0) { | |
4056 | 1056 char buf[256]; |
2086 | 1057 if (pos->modname) |
1058 g_free(pos->modname); | |
1059 g_free(pos); | |
4056 | 1060 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
1061 "this is fixed. Check %s for updates."), WEBSITE); | |
3427 | 1062 do_error_dialog(_("Gaim was Unable to get valid login hash."), |
4056 | 1063 buf, GAIM_WARNING); |
2086 | 1064 } |
1065 pos->fd = fd; | |
1066 | |
1067 return 1; | |
1068 } | |
1069 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1070 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1071 char *key; |
1072 va_list ap; | |
1073 struct gaim_connection *gc = sess->aux_data; | |
3458 | 1074 struct oscar_data *odata = gc->proto_data; |
2086 | 1075 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1076 va_start(ap, fr); |
2086 | 1077 key = va_arg(ap, char *); |
1078 va_end(ap); | |
1079 | |
3458 | 1080 if (odata->icq) { |
1081 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; | |
1082 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); | |
1083 } else { | |
1084 #if 0 | |
1085 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
1086 #endif | |
1087 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
1088 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); | |
1089 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1090 |
2086 | 1091 return 1; |
1092 } | |
1093 | |
2675 | 1094 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
2647 | 1095 struct gaim_connection *gc = sess->aux_data; |
1096 struct chat_connection *chatcon; | |
1097 static int id = 1; | |
1098 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1099 aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); |
2675 | 1100 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
1101 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
1102 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
1103 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
1104 | |
2672 | 1105 aim_clientready(sess, fr->conn); |
2675 | 1106 |
2647 | 1107 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
1108 chatcon->id = id; | |
1109 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
1110 | |
1111 return 1; | |
1112 } | |
1113 | |
2675 | 1114 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
1115 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1116 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 1117 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 1118 |
1119 aim_clientready(sess, fr->conn); | |
1120 | |
1121 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1122 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1123 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1124 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1125 |
3694 | 1126 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
1127 | |
1128 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1129 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
1130 | |
1131 aim_email_sendcookies(sess, fr->conn); | |
1132 aim_email_activate(sess, fr->conn); | |
1133 aim_clientready(sess, fr->conn); | |
1134 | |
1135 return 1; | |
1136 } | |
1137 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1138 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 1139 struct gaim_connection *gc = data; |
1140 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1141 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1142 aim_conn_t *tstconn; |
2086 | 1143 |
1144 if (!g_slist_find(connections, gc)) { | |
1145 close(source); | |
1146 return; | |
1147 } | |
1148 | |
1149 odata = gc->proto_data; | |
1150 sess = odata->sess; | |
1151 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); | |
1152 | |
1153 if (source < 0) { | |
1154 aim_conn_kill(sess, &tstconn); | |
1155 debug_printf("unable to connect to chatnav server\n"); | |
1156 return; | |
1157 } | |
1158 | |
1159 aim_conn_completeconnect(sess, tstconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1160 odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1161 oscar_callback, tstconn); |
2086 | 1162 debug_printf("chatnav: connected\n"); |
1163 } | |
1164 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1165 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1166 { |
1167 struct gaim_connection *gc = data; | |
1168 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1169 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1170 aim_conn_t *tstconn; |
2086 | 1171 |
1172 if (!g_slist_find(connections, gc)) { | |
1173 close(source); | |
1174 return; | |
1175 } | |
1176 | |
1177 odata = gc->proto_data; | |
1178 sess = odata->sess; | |
1179 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
1180 | |
1181 if (source < 0) { | |
1182 aim_conn_kill(sess, &tstconn); | |
1183 debug_printf("unable to connect to authorizer\n"); | |
1184 return; | |
1185 } | |
1186 | |
1187 aim_conn_completeconnect(sess, tstconn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1188 odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
2086 | 1189 oscar_callback, tstconn); |
1190 debug_printf("chatnav: connected\n"); | |
1191 } | |
1192 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1193 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1194 { |
1195 struct chat_connection *ccon = data; | |
1196 struct gaim_connection *gc = ccon->gc; | |
1197 struct oscar_data *odata; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1198 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1199 aim_conn_t *tstconn; |
2086 | 1200 |
1201 if (!g_slist_find(connections, gc)) { | |
1202 close(source); | |
1203 g_free(ccon->show); | |
1204 g_free(ccon->name); | |
1205 g_free(ccon); | |
1206 return; | |
1207 } | |
1208 | |
1209 odata = gc->proto_data; | |
1210 sess = odata->sess; | |
1211 tstconn = ccon->conn; | |
1212 | |
1213 if (source < 0) { | |
1214 aim_conn_kill(sess, &tstconn); | |
1215 g_free(ccon->show); | |
1216 g_free(ccon->name); | |
1217 g_free(ccon); | |
1218 return; | |
1219 } | |
1220 | |
1221 aim_conn_completeconnect(sess, ccon->conn); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1222 ccon->inpa = gaim_input_add(tstconn->fd, |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1223 GAIM_INPUT_READ, |
2086 | 1224 oscar_callback, tstconn); |
1225 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | |
1226 } | |
1227 | |
3694 | 1228 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
1229 struct gaim_connection *gc = data; | |
1230 struct oscar_data *odata; | |
1231 aim_session_t *sess; | |
1232 aim_conn_t *tstconn; | |
1233 | |
1234 if (!g_slist_find(connections, gc)) { | |
1235 close(source); | |
1236 return; | |
1237 } | |
1238 | |
1239 odata = gc->proto_data; | |
1240 sess = odata->sess; | |
1241 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); | |
1242 | |
1243 if (source < 0) { | |
1244 aim_conn_kill(sess, &tstconn); | |
1245 debug_printf("unable to connect to email server\n"); | |
1246 return; | |
1247 } | |
1248 | |
1249 aim_conn_completeconnect(sess, tstconn); | |
1250 odata->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
1251 debug_printf("email: connected\n"); | |
1252 } | |
1253 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1254 /* 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
|
1255 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1256 va_list ap; |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1257 struct aim_redirect_data *redir; |
2086 | 1258 struct gaim_connection *gc = sess->aux_data; |
1259 struct aim_user *user = gc->user; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1260 aim_conn_t *tstconn; |
2086 | 1261 int i; |
1262 char *host; | |
1263 int port; | |
1264 | |
1265 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
1266 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
1267 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1268 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1269 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1270 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1271 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1272 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1273 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1274 port = atoi(&(redir->ip[i+1])); |
2086 | 1275 break; |
1276 } | |
1277 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1278 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1279 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1280 switch(redir->group) { |
2086 | 1281 case 0x7: /* Authorizer */ |
1282 debug_printf("Reconnecting with authorizor...\n"); | |
1283 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1284 if (tstconn == NULL) { | |
1285 debug_printf("unable to reconnect with authorizer\n"); | |
1286 g_free(host); | |
1287 return 1; | |
1288 } | |
2675 | 1289 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 1290 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
1291 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
1292 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
1293 | |
1294 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1295 tstconn->fd = proxy_connect(host, port, oscar_auth_connect, gc); | |
1296 if (tstconn->fd < 0) { | |
1297 aim_conn_kill(sess, &tstconn); | |
1298 debug_printf("unable to reconnect with authorizer\n"); | |
1299 g_free(host); | |
1300 return 1; | |
1301 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1302 aim_sendcookie(sess, tstconn, redir->cookie); |
2086 | 1303 break; |
1304 case 0xd: /* ChatNav */ | |
1305 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1306 if (tstconn == NULL) { | |
1307 debug_printf("unable to connect to chatnav server\n"); | |
1308 g_free(host); | |
1309 return 1; | |
1310 } | |
2675 | 1311 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 1312 |
1313 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1314 tstconn->fd = proxy_connect(host, port, oscar_chatnav_connect, gc); | |
1315 if (tstconn->fd < 0) { | |
1316 aim_conn_kill(sess, &tstconn); | |
1317 debug_printf("unable to connect to chatnav server\n"); | |
1318 g_free(host); | |
1319 return 1; | |
1320 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1321 aim_sendcookie(sess, tstconn, redir->cookie); |
2086 | 1322 break; |
1323 case 0xe: /* Chat */ | |
1324 { | |
1325 struct chat_connection *ccon; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1326 |
2086 | 1327 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1328 if (tstconn == NULL) { | |
1329 debug_printf("unable to connect to chat server\n"); | |
1330 g_free(host); | |
1331 return 1; | |
1332 } | |
1333 | |
2675 | 1334 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
1335 | |
2086 | 1336 ccon = g_new0(struct chat_connection, 1); |
1337 ccon->conn = tstconn; | |
1338 ccon->gc = gc; | |
1339 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1340 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1341 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1342 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1343 ccon->show = extract_name(redir->chat.room); |
2086 | 1344 |
1345 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1346 ccon->conn->fd = proxy_connect(host, port, oscar_chat_connect, ccon); | |
1347 if (ccon->conn->fd < 0) { | |
1348 aim_conn_kill(sess, &tstconn); | |
1349 debug_printf("unable to connect to chat server\n"); | |
1350 g_free(host); | |
1351 g_free(ccon->show); | |
1352 g_free(ccon->name); | |
1353 g_free(ccon); | |
1354 return 1; | |
1355 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1356 aim_sendcookie(sess, tstconn, redir->cookie); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1357 debug_printf("Connected to chat room %s exchange %d\n", ccon->name, ccon->exchange); |
2086 | 1358 } |
1359 break; | |
3694 | 1360 |
1361 case 0x0018: { /* email */ | |
1362 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
1363 debug_printf("unable to connect to email server\n"); | |
1364 g_free(host); | |
1365 return 1; | |
1366 } | |
1367 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); | |
1368 | |
1369 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1370 tstconn->fd = proxy_connect(host, port, oscar_email_connect, gc); | |
1371 if (tstconn->fd < 0) { | |
1372 aim_conn_kill(sess, &tstconn); | |
1373 debug_printf("unable to connect to email server\n"); | |
1374 g_free(host); | |
1375 return 1; | |
1376 } | |
1377 aim_sendcookie(sess, tstconn, redir->cookie); | |
1378 } break; | |
1379 | |
2086 | 1380 default: /* huh? */ |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1381 debug_printf("got redirect for unknown service 0x%04x\n", redir->group); |
2086 | 1382 break; |
1383 } | |
1384 | |
1385 g_free(host); | |
1386 return 1; | |
1387 } | |
1388 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1389 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1390 struct gaim_connection *gc = sess->aux_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1391 struct oscar_data *od = gc->proto_data; |
2993 | 1392 aim_userinfo_t *info; |
1393 time_t time_idle = 0, signon = 0; | |
1394 int type = 0; | |
1395 int caps = 0; | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1396 char *tmp; |
2086 | 1397 |
1398 va_list ap; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1399 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1400 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1401 va_end(ap); |
1402 | |
2993 | 1403 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
1404 caps = info->capabilities; | |
3267 | 1405 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
1406 type |= UC_AB; | |
1407 | |
1408 if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) { | |
1409 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
1410 type |= UC_UNCONFIRMED; | |
1411 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
1412 type |= UC_ADMIN; | |
1413 if (info->flags & AIM_FLAG_AOL) | |
1414 type |= UC_AOL; | |
1415 if (info->flags & AIM_FLAG_FREE) | |
1416 type |= UC_NORMAL; | |
1417 if (info->flags & AIM_FLAG_AWAY) | |
1418 type |= UC_UNAVAILABLE; | |
1419 if (info->flags & AIM_FLAG_WIRELESS) | |
1420 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1421 } |
2993 | 1422 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 1423 type = (info->icqinfo.status << 16); |
3013 | 1424 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
1425 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 1426 type |= UC_UNAVAILABLE; |
3013 | 1427 } |
2993 | 1428 } |
1429 | |
1430 if (caps & AIM_CAPS_ICQ) | |
1431 caps ^= AIM_CAPS_ICQ; | |
1432 | |
1433 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 1434 time(&time_idle); |
1435 time_idle -= info->idletime*60; | |
2993 | 1436 } |
1437 | |
1438 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
1439 signon = time(NULL) - info->sessionlen; | |
2086 | 1440 |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1441 tmp = g_strdup(normalize(gc->username)); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1442 if (!strcmp(tmp, normalize(info->sn))) |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1443 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1444 g_free(tmp); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1445 |
2993 | 1446 serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon, |
2713
34ddcb44a4d2
[gaim-migrate @ 2726]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1447 time_idle, type, caps); |
2086 | 1448 |
1449 return 1; | |
1450 } | |
1451 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1452 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1453 aim_userinfo_t *info; |
2086 | 1454 va_list ap; |
1455 struct gaim_connection *gc = sess->aux_data; | |
1456 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1457 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1458 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1459 va_end(ap); |
1460 | |
1461 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0, 0); | |
1462 | |
1463 return 1; | |
1464 } | |
1465 | |
3730 | 1466 static void cancel_direct_im(struct ask_direct *d) { |
2086 | 1467 debug_printf("Freeing DirectIM prompts.\n"); |
1468 | |
1469 g_free(d->sn); | |
1470 g_free(d); | |
1471 } | |
1472 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1473 static void oscar_directim_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1474 struct direct_im *dim = data; |
1475 struct gaim_connection *gc = dim->gc; | |
1476 struct oscar_data *od = gc->proto_data; | |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
1477 struct conversation *cnv; |
2086 | 1478 char buf[256]; |
3008 | 1479 struct sockaddr name; |
1480 socklen_t name_len = 1; | |
1481 | |
2086 | 1482 if (!g_slist_find(connections, gc)) { |
1483 g_free(dim); | |
1484 return; | |
1485 } | |
1486 | |
1487 if (source < 0) { | |
1488 g_free(dim); | |
1489 return; | |
1490 } | |
1491 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1492 if (dim->conn->fd != source) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1493 dim->conn->fd = source; |
2086 | 1494 aim_conn_completeconnect(od->sess, dim->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1495 if (!(cnv = find_conversation(dim->name))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1496 cnv = new_conversation(dim->name); |
3008 | 1497 |
1498 /* This is the best way to see if we're connected or not */ | |
1499 if (getpeername(source, &name, &name_len) == 0) { | |
1500 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1501 dim->connected = TRUE; | |
1502 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); | |
1503 } | |
2086 | 1504 od->direct_ims = g_slist_append(od->direct_ims, dim); |
3008 | 1505 |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1506 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
3008 | 1507 oscar_callback, dim->conn); |
2086 | 1508 } |
1509 | |
3952 | 1510 /* |
1511 * This is called every time we are finished sending a file and the receiving buddy | |
1512 * has sent back an acknowledgement; we start the next file or tear down the | |
1513 * connection as appropriate. | |
1514 */ | |
3630 | 1515 static int oscar_sendfile_out_done(aim_session_t *sess, aim_frame_t *fr, ...) { |
1516 struct gaim_connection *gc = sess->aux_data; | |
1517 va_list ap; | |
1518 aim_conn_t *conn; | |
1519 const char *cook; | |
1520 struct oscar_file_transfer *oft; | |
1521 | |
1522 va_start(ap, fr); | |
1523 conn = va_arg(ap, aim_conn_t *); | |
1524 cook = va_arg(ap, const char *); | |
1525 va_end(ap); | |
1526 | |
1527 oft = find_oft_by_cookie(gc, cook); | |
1528 if (oft->filesdone == oft->totfiles) | |
1529 oscar_file_transfer_disconnect(sess, conn); | |
1530 else | |
1531 /* Send header for next file */ | |
1532 oscar_sendfile_request(sess, oft); | |
1533 | |
1534 return 0; | |
1535 } | |
1536 | |
1537 /* Called once for each file before sending the raw data. */ | |
1538 static int oscar_sendfile_request(aim_session_t *sess, | |
1539 struct oscar_file_transfer *oft) { | |
1540 char *name; | |
1541 int size; | |
1542 | |
1543 transfer_get_file_info(oft->xfer, &size, &name); | |
3952 | 1544 /* AAA convert the name to UCS-2 if necessary, and pass the encoding to the call below */ |
3630 | 1545 aim_oft_sendfile_request(sess, oft->conn, name, oft->filesdone, |
1546 oft->totfiles, size, oft->totsize); | |
1547 | |
1548 return 0; | |
1549 } | |
1550 | |
3952 | 1551 /* |
1552 * This is called when sending a file and a direct connection has been set up with | |
1553 * the buddy; we can now transmit the appropriate headers describing the transfer. | |
1554 */ | |
3630 | 1555 static int oscar_sendfile_accepted(aim_session_t *sess, aim_frame_t *fr, ...) { |
1556 struct gaim_connection *gc = sess->aux_data; | |
1557 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1558 struct oscar_file_transfer *oft; | |
1559 va_list ap; | |
1560 aim_conn_t *conn, *listenerconn; | |
3752 | 1561 |
3630 | 1562 va_start(ap, fr); |
1563 conn = va_arg(ap, aim_conn_t *); | |
1564 listenerconn = va_arg(ap, aim_conn_t *); | |
1565 va_end(ap); | |
1566 | |
1567 oft = find_oft_by_conn(gc, listenerconn); | |
1568 oft->conn = conn; | |
1569 /* Stop watching listener conn; watch transfer conn instead */ | |
1570 gaim_input_remove(oft->watcher); | |
1571 aim_conn_kill(sess, &listenerconn); | |
1572 | |
1573 aim_conn_addhandler(od->sess, oft->conn, AIM_CB_FAM_OFT, | |
3771 | 1574 AIM_CB_OFT_SENDFILEFILESEND, |
3630 | 1575 oscar_file_transfer_do, |
1576 0); | |
1577 aim_conn_addhandler(sess, conn, | |
1578 AIM_CB_FAM_OFT, | |
3771 | 1579 AIM_CB_OFT_SENDFILECOMPLETE, |
3630 | 1580 oscar_sendfile_out_done, |
1581 0); | |
1582 oft->watcher = gaim_input_add(oft->conn->fd, GAIM_INPUT_READ, | |
1583 oscar_callback, oft->conn); | |
1584 | |
1585 oscar_sendfile_request(sess, oft); | |
1586 | |
1587 return 0; | |
1588 } | |
1589 | |
3952 | 1590 /* |
1591 * This is called when we requested to send a file to a buddy, but he or she didn't | |
1592 * respond; we need to clean up. | |
1593 */ | |
3752 | 1594 static int oscar_sendfile_timeout(aim_session_t *sess, aim_frame_t *fr, ...) { |
1595 struct gaim_connection *gc = sess->aux_data; | |
1596 va_list ap; | |
1597 struct oscar_file_transfer *oft; | |
1598 char *cookie; | |
1599 aim_conn_t *bosconn; | |
1600 | |
1601 va_start(ap, fr); | |
1602 bosconn = va_arg(ap, aim_conn_t *); | |
1603 cookie = va_arg(ap, char *); | |
1604 va_end(ap); | |
1605 | |
1606 if ((oft = find_oft_by_cookie(gc, cookie))) { | |
3630 | 1607 aim_canceltransfer(sess, bosconn, oft->cookie, |
1608 oft->sn, AIM_CAPS_SENDFILE); | |
1609 | |
1610 transfer_abort(oft->xfer, _("Transfer timed out")); | |
1611 oscar_file_transfer_disconnect(sess, oft->conn); | |
1612 } | |
3752 | 1613 |
1614 return 1; /* success */ | |
3630 | 1615 } |
1616 | |
1617 /* Called once at the beginning of an outgoing transfer session. */ | |
3771 | 1618 static void oscar_file_transfer_out(struct gaim_connection *gc, |
3630 | 1619 struct file_transfer *xfer, const char *name, int totfiles, |
1620 int totsize) { | |
1621 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1622 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
1623 | |
1624 oft->xfer = xfer; | |
1625 oft->totsize = totsize; | |
1626 oft->totfiles = totfiles; | |
1627 oft->filesdone = 0; | |
1628 | |
1629 oft->conn = aim_sendfile_initiate(od->sess, oft->sn, | |
1630 name, totfiles, oft->totsize, oft->cookie); | |
1631 if (!oft->conn) { | |
1632 do_error_dialog(_("Couldn't open listener to send file"), | |
1633 _("File transfer aborted"), | |
1634 GAIM_ERROR); | |
1635 return; | |
1636 } | |
3752 | 1637 |
3630 | 1638 aim_conn_addhandler(od->sess, oft->conn, AIM_CB_FAM_OFT, |
3771 | 1639 AIM_CB_OFT_SENDFILEINITIATE, |
3630 | 1640 oscar_sendfile_accepted, |
1641 0); | |
1642 oft->watcher = gaim_input_add(oft->conn->fd, GAIM_INPUT_READ, | |
1643 oscar_callback, oft->conn); | |
1644 } | |
1645 | |
3952 | 1646 /* |
1647 * This is called after a chunk of data has been sent out or received; it is used | |
1648 * to update the checksum. | |
1649 */ | |
3771 | 1650 static void oscar_file_transfer_data_chunk(struct gaim_connection *gc, |
3630 | 1651 struct file_transfer *xfer, const char *buf, int len) |
1652 { | |
1653 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
1654 aim_session_t *sess = aim_conn_getsess(oft->conn); | |
1655 | |
1656 if (oft->type == OFT_SENDFILE_IN) | |
1657 aim_update_checksum(sess, oft->conn, buf, len); | |
1658 } | |
1659 | |
3952 | 1660 /* Called once at the beginning of an incoming transfer session. */ |
3771 | 1661 static void oscar_file_transfer_in(struct gaim_connection *gc, |
3630 | 1662 struct file_transfer *xfer, int offset) { |
1663 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1664 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
1665 | |
1666 oft->xfer = xfer; | |
1667 oft->conn = aim_accepttransfer(od->sess, od->conn, oft->sn, | |
1668 oft->cookie, oft->ip, | |
1669 oft->port, | |
1670 AIM_CAPS_SENDFILE); | |
1671 if (!oft->conn) { | |
3952 | 1672 /* XXX implement reverse connections for receiving from behind a firewall */ |
3630 | 1673 char *buf = g_strdup_printf("Couldn't connect to remote host"); |
1674 do_error_dialog(buf, NULL, GAIM_ERROR); | |
1675 g_free(buf); | |
1676 return; | |
1677 } | |
1678 | |
1679 aim_conn_addhandler(od->sess, oft->conn, AIM_CB_FAM_OFT, | |
3771 | 1680 AIM_CB_OFT_SENDFILEFILEREQ, oscar_file_transfer_do, |
3630 | 1681 0); |
1682 | |
1683 oft->watcher = gaim_input_add(oft->conn->fd, GAIM_INPUT_READ, | |
1684 oscar_callback, oft->conn); | |
1685 } | |
1686 | |
3952 | 1687 /* |
1688 * This is called when the user began a file transfer, but subsequently canceled. | |
1689 */ | |
1690 static void oscar_file_transfer_cancel(struct gaim_connection *gc, struct file_transfer *xfer) { | |
3630 | 1691 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
1692 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
1693 | |
1694 if (oft->type == OFT_SENDFILE_IN) | |
1695 aim_denytransfer(od->sess, oft->sn, oft->cookie, | |
1696 AIM_TRANSFER_DENY_DECLINE); | |
1697 | |
1698 od->file_transfers = g_slist_remove(od->file_transfers, oft); | |
1699 aim_conn_kill(od->sess, &oft->conn); | |
1700 g_free(oft->sn); | |
1701 g_free(oft); | |
1702 } | |
1703 | |
3730 | 1704 static int accept_direct_im(struct ask_direct *d) { |
2086 | 1705 struct gaim_connection *gc = d->gc; |
1706 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
1707 struct direct_im *dim; | |
2945 | 1708 char *host; int port = 4443; |
2086 | 1709 int i; |
1710 | |
1711 debug_printf("Accepted DirectIM.\n"); | |
1712 | |
1713 dim = find_direct_im(od, d->sn); | |
1714 if (dim) { | |
3730 | 1715 cancel_direct_im(d); /* 40 */ |
2086 | 1716 return TRUE; |
1717 } | |
1718 dim = g_new0(struct direct_im, 1); | |
1719 dim->gc = d->gc; | |
1720 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
1721 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1722 dim->conn = aim_directim_connect(od->sess, d->sn, NULL, d->cookie); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1723 if (!dim->conn) { |
2086 | 1724 g_free(dim); |
3730 | 1725 cancel_direct_im(d); |
2086 | 1726 return TRUE; |
1727 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1728 |
2086 | 1729 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
1730 gaim_directim_incoming, 0); | |
1731 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
1732 gaim_directim_typing, 0); | |
3033 | 1733 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
2993 | 1734 gaim_update_ui, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1735 for (i = 0; i < (int)strlen(d->ip); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1736 if (d->ip[i] == ':') { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1737 port = atoi(&(d->ip[i+1])); |
2086 | 1738 break; |
1739 } | |
1740 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1741 host = g_strndup(d->ip, i); |
2086 | 1742 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
1743 dim->conn->fd = proxy_connect(host, port, oscar_directim_callback, dim); | |
1744 g_free(host); | |
1745 if (dim->conn->fd < 0) { | |
1746 aim_conn_kill(od->sess, &dim->conn); | |
1747 g_free(dim); | |
3730 | 1748 cancel_direct_im(d); |
2086 | 1749 return TRUE; |
1750 } | |
1751 | |
3730 | 1752 cancel_direct_im(d); |
2086 | 1753 |
1754 return TRUE; | |
1755 } | |
1756 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1757 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
3642 | 1758 char *tmp; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1759 struct gaim_connection *gc = sess->aux_data; |
3600 | 1760 struct oscar_data *od = gc->proto_data; |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1761 int flags = 0; |
3659 | 1762 int convlen; |
1763 GError *err = NULL; | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1764 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1765 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1766 flags |= IM_FLAG_AWAY; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1767 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1768 if (args->icbmflags & AIM_IMFLAGS_HASICON) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1769 struct icon_req *ir = NULL; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1770 GSList *h = od->hasicons; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1771 char *who = normalize(userinfo->sn); |
4121 | 1772 |
1773 if (!args->iconlen || !args->iconsum || !args->iconstamp) | |
1774 return 1; | |
1775 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1776 debug_printf("%s has an icon\n", userinfo->sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1777 while (h) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1778 ir = h->data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1779 if (!strcmp(ir->user, who)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1780 break; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1781 h = h->next; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1782 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1783 if (!h) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1784 ir = g_new0(struct icon_req, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1785 ir->user = g_strdup(who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1786 od->hasicons = g_slist_append(od->hasicons, ir); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1787 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1788 if ((args->iconlen != ir->length) || |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1789 (args->iconsum != ir->checksum) || |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1790 (args->iconstamp != ir->timestamp)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1791 ir->request = TRUE; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1792 ir->length = args->iconlen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1793 ir->checksum = args->iconsum; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1794 ir->timestamp = args->iconstamp; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1795 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1796 |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1797 if (gc->user->iconfile[0] && (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1798 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1799 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1800 |
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1801 if (!stat(gc->user->iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1802 char *buf = g_malloc(st.st_size); |
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1803 file = fopen(gc->user->iconfile, "r"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1804 if (file) { |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1805 int len = fread(buf, 1, st.st_size, file); |
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1806 debug_printf("Sending buddy icon to %s (%d bytes, %d reported)\n", |
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1807 userinfo->sn, len, st.st_size); |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1808 aim_send_icon(sess, userinfo->sn, buf, st.st_size, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1809 st.st_mtime, aim_iconsum(buf, st.st_size)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1810 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1811 } else |
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1812 debug_printf("Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1813 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1814 } else |
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1815 debug_printf("Can't stat buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1816 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1817 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1818 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 1819 /* This message is marked as UNICODE, so we have to |
1820 * convert it to utf-8 before handing it to the gaim core. | |
1821 * This conversion should *never* fail, if it does it | |
1822 * means that either the incoming ICBM is corrupted or | |
1823 * there is something we don't understand about it. */ | |
1824 /* For the record, AIM Unicode is big-endian UCS-2 */ | |
4121 | 1825 |
1826 if (!args->msg || !args->msglen) | |
1827 return 1; | |
1828 | |
3659 | 1829 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
1830 if (err) { | |
1831 debug_printf("Unicode IM conversion: %s\n", err->message); | |
1832 tmp = strdup(_("(There was an error receiving this message)")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1833 } |
3722 | 1834 } else { |
3850 | 1835 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 1836 * unflagged messages, which are ASCII. That's OK because |
1837 * ASCII is a strict subset of ISO-8859-1; this should | |
1838 * help with compatibility with old, broken versions of | |
1839 * gaim (everything before 0.60) and other broken clients | |
1840 * that will happily send ISO-8859-1 without marking it as | |
1841 * such */ | |
3850 | 1842 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) { |
1843 debug_printf ("Received ISO-8859-1 IM\n"); | |
1844 } | |
4121 | 1845 |
1846 if (!args->msg || !args->msglen) | |
1847 return 1; | |
1848 | |
3659 | 1849 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
1850 if (err) { | |
1851 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); | |
1852 tmp = strdup(_("(There was an error receiving this message)")); | |
1853 } | |
3642 | 1854 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1855 |
3850 | 1856 if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) { |
1857 debug_printf ("Custom character set: %d %d\n", args->charset, args->charsubset); | |
1858 } | |
1859 | |
3595 | 1860 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) { |
3600 | 1861 char *who = normalize(userinfo->sn); |
1862 if (!g_hash_table_lookup(od->supports_tn, who)) | |
1863 g_hash_table_insert(od->supports_tn, who, who); | |
3595 | 1864 } |
1865 | |
3642 | 1866 //strip_linefeed(tmp); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
1867 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL), -1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1868 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1869 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1870 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1871 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1872 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1873 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1874 struct gaim_connection *gc = sess->aux_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1875 |
4121 | 1876 if (!args) |
1877 return 0; | |
1878 | |
2869 | 1879 debug_printf("rendezvous status %d (%s)\n", args->status, userinfo->sn); |
1880 | |
3630 | 1881 |
1882 if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
1883 struct oscar_file_transfer *oft; | |
4121 | 1884 if (!args->cookie) |
1885 return 1; | |
3630 | 1886 oft = find_oft_by_cookie(gc, args->cookie); |
1887 if (oft) { | |
1888 transfer_abort(oft->xfer, _("Buddy canceled transfer")); | |
1889 oscar_file_transfer_disconnect(sess, oft->conn); | |
1890 } | |
1891 return 0; | |
1892 } | |
1893 else if (args->status == AIM_RENDEZVOUS_ACCEPT) { | |
1894 /* The user accepted our transfer request, but we don't | |
1895 * really need to do anything yet. | |
1896 * -- wtm | |
1897 */ | |
1898 return 0; | |
1899 } | |
1900 else if (args->status != AIM_RENDEZVOUS_PROPOSE) { | |
3752 | 1901 debug_printf("unknown rendezvous status\n"); |
2869 | 1902 return 1; |
3630 | 1903 } |
2869 | 1904 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1905 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 1906 char *name; |
4120 | 1907 int *exch; |
4121 | 1908 GList *m = NULL; |
4120 | 1909 |
4121 | 1910 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
1911 return 1; | |
1912 name = extract_name(args->info.chat.roominfo.name); | |
4120 | 1913 exch = g_new0(int, 1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1914 m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1915 *exch = args->info.chat.roominfo.exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1916 m = g_list_append(m, exch); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1917 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1918 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1919 userinfo->sn, |
2869 | 1920 (char *)args->msg, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1921 m); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1922 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1923 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1924 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
3630 | 1925 struct oscar_file_transfer *oft; |
3752 | 1926 struct oscar_data *od = gc->proto_data; |
1927 | |
4121 | 1928 if (!args->cookie || !args->verifiedip || !args->port || |
1929 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
1930 !args->info.sendfile.totfiles || !args->msg || !args->reqclass) | |
1931 return 1; | |
3752 | 1932 if ((oft = find_oft_by_cookie(sess->aux_data, args->cookie))) |
1933 { | |
1934 /* This is a request for a reverse connection, | |
1935 * which is used by newer clients when for some | |
1936 * reason they are unable to connect to our listener | |
1937 * (e.g. they are behind a firewall). | |
1938 */ | |
1939 if (oft->type != OFT_SENDFILE_OUT) | |
1940 return -1; | |
1941 | |
1942 /* It seems that Trillian sends some weird | |
1943 * packets. Sanity check. | |
1944 */ | |
1945 if (!args->verifiedip) | |
1946 return -1; | |
1947 | |
1948 /* This connection isn't used for anything, since | |
1949 * we're using a reverse connection instead. | |
3630 | 1950 */ |
3752 | 1951 gaim_input_remove(oft->watcher); |
1952 aim_conn_kill(sess, &oft->conn); | |
1953 | |
1954 debug_printf("sendfile: doing reverse connection to %s:%d\n", args->verifiedip, args->port); | |
1955 | |
1956 oft->conn = aim_accepttransfer(sess, od->conn, | |
1957 userinfo->sn, | |
1958 args->cookie, args->verifiedip, | |
1959 args->port, | |
1960 AIM_CAPS_SENDFILE); | |
1961 | |
1962 /* XXX: this is a bit of a hack: ideally | |
1963 * we should wait on GAIM_INPUT_WRITE. -- wtm | |
1964 */ | |
1965 aim_conn_completeconnect(sess, oft->conn); | |
1966 | |
1967 oscar_sendfile_request(sess, oft); | |
1968 | |
1969 aim_conn_addhandler(sess, oft->conn, | |
1970 AIM_CB_FAM_OFT, | |
3771 | 1971 AIM_CB_OFT_SENDFILECOMPLETE, |
3752 | 1972 oscar_sendfile_out_done, |
1973 0); | |
1974 aim_conn_addhandler(sess, oft->conn, | |
1975 AIM_CB_FAM_OFT, | |
3771 | 1976 AIM_CB_OFT_SENDFILEFILESEND, |
3752 | 1977 oscar_file_transfer_do, |
1978 0); | |
1979 oft->watcher = gaim_input_add(oft->conn->fd, | |
1980 GAIM_INPUT_READ, oscar_callback, | |
1981 oft->conn); | |
1982 return 0; | |
3630 | 1983 } |
1984 | |
3952 | 1985 /* Someone wants to send a file (or files) to us */ |
3630 | 1986 debug_printf("%s (%s) requests to send a file to %s\n", |
1987 userinfo->sn, args->verifiedip, gc->username); | |
3752 | 1988 |
1989 oft = g_new0(struct oscar_file_transfer, 1); | |
3630 | 1990 |
1991 oft->type = OFT_SENDFILE_IN; | |
1992 oft->sn = g_strdup(userinfo->sn); | |
1993 strncpy(oft->ip, args->verifiedip, sizeof(oft->ip)); | |
1994 oft->port = args->port; | |
1995 memcpy(oft->cookie, args->cookie, 8); | |
1996 | |
3752 | 1997 od->file_transfers = g_slist_append(od->file_transfers, oft); |
3630 | 1998 |
1999 oft->xfer = transfer_in_add(gc, userinfo->sn, | |
2000 args->info.sendfile.filename, | |
2001 args->info.sendfile.totsize, | |
2002 args->info.sendfile.totfiles, | |
2003 args->msg); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2004 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2005 } else if (args->reqclass & AIM_CAPS_VOICE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2006 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2007 set_icon_data(gc, normalize(userinfo->sn), args->info.icon.icon, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2008 args->info.icon.length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2009 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2010 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2011 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2012 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2013 debug_printf("%s received direct im request from %s (%s)\n", |
2869 | 2014 gc->username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2015 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2016 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2017 d->sn = g_strdup(userinfo->sn); |
2869 | 2018 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2019 memcpy(d->cookie, args->cookie, 8); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2020 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2021 userinfo->sn, gc->username); |
3730 | 2022 do_ask_dialog(buf, _("This requires a direct connection between the two computers and is necessary for IM Images. Because your IP address will be revealed, this may be considered a privacy risk."), d, _("Connect"), accept_direct_im, _("Cancel"), cancel_direct_im); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2023 } else { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2024 debug_printf("Unknown reqclass %d\n", args->reqclass); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2025 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2026 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2027 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2028 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2029 |
3453 | 2030 /* |
2031 * Next 2 functions are for when other people ask you for authorization | |
2032 */ | |
3730 | 2033 static void gaim_icq_authgrant(struct channel4_data *data) { |
3453 | 2034 char message; |
3141 | 2035 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; |
2036 message = 0; | |
3453 | 2037 aim_send_im_ch4(od->sess, data->uin, AIM_ICQMSG_AUTHGRANTED, &message); |
2038 show_got_added(data->gc, NULL, data->uin, NULL, NULL); | |
2039 g_free(data->uin); | |
3730 | 2040 g_free(data); |
3141 | 2041 } |
2042 | |
3730 | 2043 static void gaim_icq_authdeny(struct channel4_data *data) { |
2044 gchar *message; | |
2045 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; | |
2046 message = g_strdup_printf("No reason given."); | |
2047 aim_send_im_ch4(od->sess, data->uin, AIM_ICQMSG_AUTHDENIED, message); | |
2048 g_free(data->uin); | |
2049 g_free(message); | |
3141 | 2050 g_free(data); |
2051 } | |
2052 | |
2053 /* | |
3453 | 2054 * Next 2 functions are for when someone sends you contacts |
2055 */ | |
3730 | 2056 static void gaim_icq_contactadd(struct channel4_data *data) { |
3453 | 2057 show_add_buddy(data->gc, data->uin, NULL, data->nick); |
3730 | 2058 free(data->uin); |
2059 free(data->nick); | |
2060 g_free(data); | |
3453 | 2061 } |
2062 | |
3730 | 2063 static void gaim_icq_contactdontadd(struct channel4_data *data) { |
3453 | 2064 free(data->uin); |
2065 free(data->nick); | |
2066 g_free(data); | |
2067 } | |
2068 | |
4075 | 2069 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) { |
3141 | 2070 struct gaim_connection *gc = sess->aux_data; |
4076 | 2071 gchar **msg1, **msg2; |
2072 GError *err = NULL; | |
2073 int i; | |
2074 | |
4121 | 2075 if (!args->type || !args->msg || !args->uin) |
2076 return 1; | |
2077 | |
4076 | 2078 debug_printf("Received a channel 4 message of type %d.\n", args->type); |
2079 | |
2080 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4151 | 2081 msg1 = g_strsplit(args->msg, "\177", 0); |
4076 | 2082 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* AAA */ |
2083 for (i=0; msg1[i]; i++) { | |
2084 strip_linefeed(msg1[i]); | |
2085 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); | |
2086 if (err) | |
2087 debug_printf("Error converting a string from ISO-8859-1 to UTF-8 in oscar ICBM channel 4 parsing\n"); | |
2088 } | |
2089 msg2[i] = NULL; | |
2090 | |
3952 | 2091 switch (args->type) { |
4075 | 2092 case 0x0001: { /* MacICQ message or basic offline message */ |
4076 | 2093 if (i >= 1) { |
2094 gchar *uin = g_strdup_printf("%lu", args->uin); | |
2095 if (t) { /* This is an offline message */ | |
2096 /* I think this timestamp is in UTC, or something */ | |
2097 serv_got_im(gc, uin, msg2[0], 0, t, -1); | |
2098 } else { /* This is a message from MacICQ/Miranda */ | |
2099 serv_got_im(gc, uin, msg2[0], 0, time(NULL), -1); | |
2100 } | |
2101 g_free(uin); | |
4075 | 2102 } |
3316 | 2103 } break; |
2104 | |
3453 | 2105 case 0x0004: { /* Someone sent you a URL */ |
4076 | 2106 if (i >= 2) { |
2107 gchar *uin = g_strdup_printf("%lu", args->uin); | |
2108 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); | |
3453 | 2109 serv_got_im(gc, uin, message, 0, time(NULL), -1); |
2110 g_free(uin); | |
2111 g_free(message); | |
2112 } | |
2113 } break; | |
2114 | |
3141 | 2115 case 0x0006: { /* Someone requested authorization */ |
4076 | 2116 if (i >= 6) { |
2117 struct channel4_data *data = g_new(struct channel4_data, 1); | |
2118 char *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason: %s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); | |
2119 debug_printf("Received an authorization request from UIN %lu\n", args->uin); | |
2120 data->gc = gc; | |
2121 data->uin = g_strdup_printf("%lu", args->uin); | |
2122 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_icq_authgrant, _("Deny"), gaim_icq_authdeny); | |
2123 g_free(dialog_msg); | |
2124 } | |
3141 | 2125 } break; |
2126 | |
2127 case 0x0007: { /* Someone has denied you authorization */ | |
4076 | 2128 if (i >= 1) { |
2129 char *dialog_msg = g_strdup_printf(_("The user %lu has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given.")); | |
2130 do_error_dialog(_("ICQ authorization denied."), dialog_msg, GAIM_ERROR); | |
2131 g_free(dialog_msg); | |
2132 } | |
3141 | 2133 } break; |
2134 | |
2135 case 0x0008: { /* Someone has granted you authorization */ | |
4076 | 2136 char *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin); |
3427 | 2137 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO); |
3141 | 2138 g_free(dialog_msg); |
2139 } break; | |
2140 | |
4076 | 2141 case 0x000d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
2142 if (i >= 6) { | |
2143 char *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); | |
2144 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO); | |
2145 g_free(dialog_msg); | |
2146 } | |
4075 | 2147 } break; |
2148 | |
2149 case 0x000e: { /* Someone has emailed you at your_uin@pager.icq.com */ | |
4076 | 2150 if (i >= 6) { |
2151 char *dialog_msg = g_strdup_printf(_("You have received an ICQ email\n\n1=%s\n2=%s\n3=%s\n4=%s\n5=%s\n6=%s\n"), msg2[0], msg2[1], msg2[2], msg2[3], msg2[4], msg2[5]); | |
2152 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO); | |
2153 g_free(dialog_msg); | |
2154 } | |
4075 | 2155 } break; |
2156 | |
3141 | 2157 case 0x0012: { |
2158 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ | |
2159 } break; | |
2160 | |
3453 | 2161 case 0x0013: { /* Someone has sent you some ICQ contacts */ |
2162 int i, num; | |
2163 gchar **text; | |
4151 | 2164 text = g_strsplit(args->msg, "\177", 0); |
3453 | 2165 if (text) { |
2166 num = 0; | |
2167 for (i=0; i<strlen(text[0]); i++) | |
2168 num = num*10 + text[0][i]-48; | |
2169 for (i=0; i<num; i++) { | |
2170 struct channel4_data *data = g_new(struct channel4_data, 1); | |
3730 | 2171 gchar *message = g_strdup_printf(_("ICQ user %lu has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]); |
3453 | 2172 data->gc = gc; |
2173 data->uin = g_strdup(text[i*2+2]); | |
2174 data->nick = g_strdup(text[i*2+1]); | |
4076 | 2175 do_ask_dialog(message, _("Do you want to add this contact to your Buddy List?"), data, _("Add"), gaim_icq_contactadd, _("Deny"), gaim_icq_contactdontadd); |
3453 | 2176 g_free(message); |
2177 } | |
2178 g_strfreev(text); | |
2179 } | |
2180 } break; | |
2181 | |
4075 | 2182 case 0x001a: { /* Someone has sent you a greeting card or requested contacts? */ |
3453 | 2183 /* This is boring and silly. */ |
2184 } break; | |
2185 | |
3141 | 2186 default: { |
2187 debug_printf("Received a channel 4 message of unknown type (type 0x%04d).\n", args->type); | |
2188 } break; | |
2189 } | |
2190 | |
4076 | 2191 g_strfreev(msg1); |
2192 g_strfreev(msg2); | |
2193 | |
3141 | 2194 return 1; |
2195 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2196 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2197 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2198 int channel, ret = 0; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2199 aim_userinfo_t *userinfo; |
2086 | 2200 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2201 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2202 va_start(ap, fr); |
2086 | 2203 channel = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2204 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2205 |
3141 | 2206 switch (channel) { |
2207 case 1: { /* standard message */ | |
2208 struct aim_incomingim_ch1_args *args; | |
2209 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2210 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2211 } break; | |
2212 | |
2213 case 2: { /* rendevous */ | |
2214 struct aim_incomingim_ch2_args *args; | |
2215 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2216 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2217 } break; | |
2218 | |
2219 case 4: { /* ICQ */ | |
2220 struct aim_incomingim_ch4_args *args; | |
2221 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2222 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2223 } break; |
2224 | |
2225 default: { | |
2226 debug_printf("ICBM received on unsupported channel (channel 0x%04d).", channel); | |
2227 } break; | |
2086 | 2228 } |
2229 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2230 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2231 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2232 return ret; |
2086 | 2233 } |
2234 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2235 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2236 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2237 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2238 aim_userinfo_t *userinfo; |
2086 | 2239 char buf[1024]; |
2240 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2241 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2242 chan = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2243 userinfo = va_arg(ap, aim_userinfo_t *); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2244 nummissed = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2245 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2246 va_end(ap); |
2247 | |
2248 switch(reason) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2249 case 0: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2250 /* Invalid (0) */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2251 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2252 sizeof(buf), |
2946 | 2253 nummissed == 1 ? |
2947 | 2254 _("You missed %d message from %s because it was invalid.") : |
2255 _("You missed %d messages from %s because they were invalid."), | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2256 nummissed, |
2947 | 2257 userinfo->sn); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2258 break; |
2086 | 2259 case 1: |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2260 /* Message too large */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2261 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2262 sizeof(buf), |
2943 | 2263 nummissed == 1 ? |
2264 _("You missed %d message from %s because it was too large.") : | |
2946 | 2265 _("You missed %d messages from %s because they were too large."), |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2266 nummissed, |
2943 | 2267 userinfo->sn); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2268 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2269 case 2: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2270 /* Rate exceeded */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2271 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2272 sizeof(buf), |
2943 | 2273 nummissed == 1 ? |
2274 _("You missed %d message from %s because the rate limit has been exceeded.") : | |
2275 _("You missed %d messages from %s because the rate limit has been exceeded."), | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2276 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2277 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2278 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2279 case 3: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2280 /* Evil Sender */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2281 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2282 sizeof(buf), |
2943 | 2283 nummissed == 1 ? |
4151 | 2284 _("You missed %d message from %s because he/she was too evil.") : |
2285 _("You missed %d messages from %s because he/she was too evil."), | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2286 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2287 userinfo->sn); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2288 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2289 case 4: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2290 /* Evil Receiver */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2291 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2292 sizeof(buf), |
2943 | 2293 nummissed == 1 ? |
2294 _("You missed %d message from %s because you are too evil.") : | |
2295 _("You missed %d messages from %s because you are too evil."), | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2296 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2297 userinfo->sn); |
2086 | 2298 break; |
2299 default: | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2300 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2301 sizeof(buf), |
2943 | 2302 nummissed == 1 ? |
4151 | 2303 _("You missed %d message from %s for an unknown reason.") : |
2304 _("You missed %d messages from %s for an unknown reason."), | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2305 nummissed, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2306 userinfo->sn); |
2086 | 2307 break; |
2308 } | |
3427 | 2309 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 2310 |
2311 return 1; | |
2312 } | |
2313 | |
3212 | 2314 static char *gaim_icq_status(int state) { |
2315 /* Make a cute little string that shows the status of the dude or dudet */ | |
2316 if (state & AIM_ICQ_STATE_CHAT) | |
2317 return g_strdup_printf("Free For Chat"); | |
2318 else if (state & AIM_ICQ_STATE_DND) | |
2319 return g_strdup_printf("Do Not Disturb"); | |
2320 else if (state & AIM_ICQ_STATE_OUT) | |
2321 return g_strdup_printf("Not Available"); | |
2322 else if (state & AIM_ICQ_STATE_BUSY) | |
2323 return g_strdup_printf("Occupied"); | |
2324 else if (state & AIM_ICQ_STATE_AWAY) | |
2325 return g_strdup_printf("Away"); | |
2326 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
2327 return g_strdup_printf("Web Aware"); | |
2328 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
2329 return g_strdup_printf("Invisible"); | |
2330 else | |
2331 return g_strdup_printf("Online"); | |
2332 } | |
2333 | |
4151 | 2334 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, int reason, const char *cookie) { |
3630 | 2335 struct gaim_connection *gc = sess->aux_data; |
2336 | |
2337 switch (reason) { | |
4151 | 2338 case 3: { /* Decline sendfile. */ |
2339 struct oscar_file_transfer *oft = find_oft_by_cookie(gc, cookie); | |
3630 | 2340 |
2341 if (oft) { | |
4151 | 2342 char *buf = g_strdup_printf(_("%s has declined to receive a file from %s.\n"), |
3630 | 2343 who, gc->username); |
2344 transfer_abort(oft->xfer, buf); | |
2345 g_free(buf); | |
2346 oscar_file_transfer_disconnect(sess, oft->conn); | |
2347 } | |
4151 | 2348 } break; |
2349 | |
2350 default: { | |
3630 | 2351 debug_printf("Received an unknown rendezvous client auto-response from %s. Type 0x%04x\n", who, reason); |
4151 | 2352 } |
3630 | 2353 |
2354 } | |
2355 | |
2356 return 0; | |
2357 } | |
2358 | |
4151 | 2359 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, int reason, int state, char *msg) { |
2360 struct gaim_connection *gc = sess->aux_data; | |
2361 | |
2362 switch(reason) { | |
2363 case 0x0003: { /* Reply from an ICQ status message request */ | |
2364 char *status_msg = gaim_icq_status(state); | |
2365 char *dialog_msg, **splitmsg; | |
2366 struct oscar_data *od = gc->proto_data; | |
2367 GSList *l = od->evilhack; | |
2368 gboolean evilhack = FALSE; | |
2369 | |
2370 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2371 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2372 | |
2373 /* If who is in od->evilhack, then we're just getting the away message, otherwise this | |
2374 * will just get appended to the info box (which is already showing). */ | |
2375 while (l) { | |
2376 char *x = l->data; | |
2377 if (!strcmp(x, normalize(who))) { | |
2378 evilhack = TRUE; | |
2379 g_free(x); | |
2380 od->evilhack = g_slist_remove(od->evilhack, x); | |
2381 break; | |
2382 } | |
2383 l = l->next; | |
2384 } | |
2385 | |
2386 if (evilhack) | |
2387 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<BR><HR>%s<BR>"), who, status_msg, g_strjoinv("<BR>", splitmsg)); | |
2388 else | |
2389 dialog_msg = g_strdup_printf(_("<B>Status:</B> %s<BR><HR>%s<BR>"), status_msg, g_strjoinv("<BR>", splitmsg)); | |
2390 g_show_info_text(gc, who, 2, dialog_msg, NULL); | |
2391 | |
2392 g_free(status_msg); | |
2393 g_free(dialog_msg); | |
2394 g_strfreev(splitmsg); | |
2395 } break; | |
2396 | |
2397 default: { | |
2398 debug_printf("Received an unknown client auto-response from %s. Type 0x%04x\n", who, reason); | |
2399 } break; | |
2400 } /* end of switch */ | |
2401 | |
2402 return 0; | |
2403 } | |
2404 | |
3212 | 2405 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
2406 va_list ap; | |
2407 fu16_t chan, reason; | |
2408 char *who; | |
2409 | |
2410 va_start(ap, fr); | |
2411 chan = (fu16_t)va_arg(ap, unsigned int); | |
2412 who = va_arg(ap, char *); | |
2413 reason = (fu16_t)va_arg(ap, unsigned int); | |
2414 | |
3952 | 2415 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 2416 char *cookie = va_arg(ap, char *); |
4151 | 2417 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 2418 } else if (chan == 0x0004) { /* ICQ message */ |
4151 | 2419 int state = 0; |
2420 char *msg = NULL; | |
2421 if (reason == 0x0003) { | |
2422 state = (int)va_arg(ap, fu32_t); | |
2423 msg = va_arg(ap, char *); | |
2424 } | |
2425 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
2426 } | |
3952 | 2427 |
3212 | 2428 va_end(ap); |
2429 | |
2430 return 1; | |
2431 } | |
2432 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2433 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2434 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2435 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2436 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2437 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2438 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2439 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2440 va_end(ap); |
2441 | |
2864
e22c09351e67
[gaim-migrate @ 2877]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
2442 debug_printf("snac threw error (reason 0x%04x: %s)\n", reason, |
2086 | 2443 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2444 | |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2445 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
4056 | 2446 reason < msgerrreasonlen ? gettext(msgerrreason[reason]) : _("Unknown error")); |
3427 | 2447 do_error_dialog(m, NULL, GAIM_ERROR); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2448 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2449 |
2086 | 2450 return 1; |
2451 } | |
2452 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2453 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2454 va_list ap; |
3752 | 2455 char *data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2456 fu16_t reason; |
2086 | 2457 char buf[1024]; |
3752 | 2458 struct gaim_connection *gc = sess->aux_data; |
2459 struct oscar_file_transfer *oft; | |
2460 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2461 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2462 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 2463 data = va_arg(ap, char *); |
2086 | 2464 va_end(ap); |
2465 | |
3752 | 2466 /* If this was a file transfer request, data is a cookie. */ |
2467 if ((oft = find_oft_by_cookie(gc, data))) { | |
3630 | 2468 transfer_abort(oft->xfer, |
4056 | 2469 (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason was given.")); |
3630 | 2470 |
2471 oscar_file_transfer_disconnect(sess, oft->conn); | |
2472 return 1; | |
2473 } | |
2474 | |
3752 | 2475 /* Data is assumed to be the destination sn. */ |
2476 snprintf(buf, sizeof(buf), _("Your message to %s did not get sent:"), data); | |
4056 | 2477 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason was given."), GAIM_ERROR); |
2086 | 2478 |
2479 return 1; | |
2480 } | |
2481 | |
3595 | 2482 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
2483 struct gaim_connection *gc = sess->aux_data; | |
2484 va_list ap; | |
2485 fu16_t type1, type2; | |
2486 char *sn; | |
2487 | |
2488 va_start(ap, fr); | |
2489 type1 = (fu16_t)va_arg(ap, unsigned int); | |
2490 sn = va_arg(ap, char *); | |
2491 type2 = (fu16_t)va_arg(ap, unsigned int); | |
2492 va_end(ap); | |
2493 | |
2494 debug_printf("Received an mtn from %s. Type1 is 0x%04d and type2 is 0x%04d.\n", sn, type1, type2); | |
2495 | |
2496 switch (type2) { | |
2497 case 0x0000: { /* Text has been cleared */ | |
2498 serv_got_typing_stopped(gc, sn); | |
2499 } break; | |
2500 | |
2501 case 0x0001: { /* Paused typing */ | |
3768 | 2502 serv_got_typing(gc, sn, 0, TYPED); |
3595 | 2503 } break; |
2504 | |
2505 case 0x0002: { /* Typing */ | |
3768 | 2506 serv_got_typing(gc, sn, 0, TYPING); |
3595 | 2507 } break; |
2508 | |
2509 default: { | |
2510 printf("Received unknown typing notification type.\n"); | |
2511 } break; | |
2512 } | |
2513 | |
2514 return 1; | |
2515 } | |
2516 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2517 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2518 va_list ap; |
2519 char *destn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2520 fu16_t reason; |
2086 | 2521 char buf[1024]; |
2522 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2523 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2524 reason = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2525 destn = va_arg(ap, char *); |
2526 va_end(ap); | |
2527 | |
3574 | 2528 snprintf(buf, sizeof(buf), _("User information for %s unavailable:"), destn); |
4056 | 2529 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason was given."), GAIM_ERROR); |
2086 | 2530 |
2531 return 1; | |
2532 } | |
2533 | |
2534 static char *images(int flags) { | |
2535 static char buf[1024]; | |
3101 | 2536 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
2679 | 2537 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
2086 | 2538 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
2539 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
3101 | 2540 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
2086 | 2541 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
3079 | 2542 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
2543 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
2086 | 2544 return buf; |
2545 } | |
2546 | |
3101 | 2547 |
2920 | 2548 /* XXX This is horribly copied from ../../buddy.c. */ |
2549 static char *caps_string(guint caps) | |
2550 { | |
2551 static char buf[512], *tmp; | |
2552 int count = 0, i = 0; | |
2553 guint bit = 1; | |
2554 while (bit <= 0x10000) { | |
2555 if (bit & caps) { | |
2556 switch (bit) { | |
2557 case 0x1: | |
2558 tmp = _("Buddy Icon"); | |
2559 break; | |
2560 case 0x2: | |
2561 tmp = _("Voice"); | |
2562 break; | |
2563 case 0x4: | |
2564 tmp = _("IM Image"); | |
2565 break; | |
2566 case 0x8: | |
2567 tmp = _("Chat"); | |
2568 break; | |
2569 case 0x10: | |
2570 tmp = _("Get File"); | |
2571 break; | |
2572 case 0x20: | |
2573 tmp = _("Send File"); | |
2574 break; | |
2575 case 0x40: | |
2576 case 0x200: | |
2577 tmp = _("Games"); | |
2578 break; | |
2579 case 0x80: | |
2580 tmp = _("Stocks"); | |
2581 break; | |
2582 case 0x100: | |
2583 tmp = _("Send Buddy List"); | |
2584 break; | |
2585 case 0x400: | |
2586 tmp = _("EveryBuddy Bug"); | |
2587 break; | |
2588 case 0x800: | |
2589 tmp = _("AP User"); | |
2590 break; | |
2591 case 0x1000: | |
2592 tmp = _("ICQ RTF"); | |
2593 break; | |
2594 case 0x2000: | |
2595 tmp = _("Nihilist"); | |
2596 break; | |
2597 case 0x4000: | |
2598 tmp = _("ICQ Server Relay"); | |
2599 break; | |
2600 case 0x8000: | |
2601 tmp = _("ICQ Unknown"); | |
2602 break; | |
2603 case 0x10000: | |
2604 tmp = _("Trillian Encryption"); | |
2605 break; | |
2606 default: | |
2607 tmp = NULL; | |
2608 break; | |
2609 } | |
2610 if (tmp) | |
2611 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
2612 tmp); | |
2613 count++; | |
2614 } | |
2615 bit <<= 1; | |
2616 } | |
2617 return buf; | |
2618 } | |
2619 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2620 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2621 aim_userinfo_t *info; |
4151 | 2622 char *text_enc = NULL, *text = NULL, *utf8 = NULL; |
2623 int text_len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2624 fu16_t infotype; |
4151 | 2625 fu32_t flags; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2626 char header[BUF_LONG]; |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
2627 char legend[BUF_LONG]; |
2086 | 2628 struct gaim_connection *gc = sess->aux_data; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2629 struct oscar_data *od = gc->proto_data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2630 GSList *l = od->evilhack; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2631 gboolean evilhack = FALSE; |
2086 | 2632 va_list ap; |
2993 | 2633 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; |
2086 | 2634 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2635 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2636 info = va_arg(ap, aim_userinfo_t *); |
2920 | 2637 infotype = (fu16_t)va_arg(ap, unsigned int); |
4151 | 2638 text_enc = va_arg(ap, char *); |
2639 text = va_arg(ap, char *); | |
2640 text_len = va_arg(ap, int); | |
2086 | 2641 va_end(ap); |
2642 | |
4151 | 2643 if (text_len > 0) { |
2644 flags = parse_encoding (text_enc); | |
2645 switch (flags) { | |
2646 case 0: | |
2647 utf8 = g_strdup(text); | |
2648 break; | |
2649 case AIM_IMFLAGS_UNICODE: | |
2650 utf8 = g_convert(text, text_len, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
2651 break; | |
2652 default: | |
4152 | 2653 utf8 = g_strdup(_("<I>Unable to display information because it was sent in an unknown encoding.</I>")); |
4151 | 2654 debug_printf("Encountered an unknown encoding parsing userinfo\n"); |
2655 } | |
2656 } | |
2657 | |
3101 | 2658 if (!od->icq) { |
2659 g_snprintf(legend, sizeof legend, | |
3952 | 2660 _("<BODY BGCOLOR=WHITE><hr><I>Legend:</I><br><br>" |
3101 | 2661 "<IMG SRC=\"free_icon.gif\"> : Normal AIM User<br>" |
2662 "<IMG SRC=\"aol_icon.gif\"> : AOL User <br>" | |
2663 "<IMG SRC=\"dt_icon.gif\"> : Trial AIM User <br>" | |
2664 "<IMG SRC=\"admin_icon.gif\"> : Administrator <br>" | |
2665 "<IMG SRC=\"ab_icon.gif\"> : ActiveBuddy Interactive Agent<br>" | |
2666 "<IMG SRC=\"wireless_icon.gif\"> : Wireless Device User<br>")); | |
3106 | 2667 } else { |
2668 legend[0] = 0; | |
3101 | 2669 } |
2670 | |
2993 | 2671 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
2672 onlinesince = g_strdup_printf("Online Since : <B>%s</B><BR>\n", | |
2673 asctime(localtime(&info->onlinesince))); | |
2674 } | |
2675 | |
2676 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
2677 membersince = g_strdup_printf("Member Since : <B>%s</B><BR>\n", | |
2678 asctime(localtime(&info->membersince))); | |
2679 } | |
2680 | |
2681 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2682 idle = g_strdup_printf("Idle : <B>%d minutes</B>", | |
2683 info->idletime); | |
2684 } else | |
2685 idle = g_strdup("Idle: <B>Active</B>"); | |
2686 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2687 g_snprintf(header, sizeof header, |
2086 | 2688 _("Username : <B>%s</B> %s <BR>\n" |
2993 | 2689 "Warning Level : <B>%d %%</B><BR>\n" |
2086 | 2690 "%s" |
2993 | 2691 "%s" |
2692 "%s<BR>\n" | |
3952 | 2693 "<HR>\n"), |
2086 | 2694 info->sn, images(info->flags), |
2695 info->warnlevel/10, | |
2993 | 2696 onlinesince ? onlinesince : "", |
2697 membersince ? membersince : "", | |
2698 idle ? idle : ""); | |
2699 | |
2700 g_free(onlinesince); | |
2701 g_free(membersince); | |
2702 g_free(idle); | |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
2703 |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2704 while (l) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2705 char *x = l->data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2706 if (!strcmp(x, normalize(info->sn))) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2707 evilhack = TRUE; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2708 g_free(x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2709 od->evilhack = g_slist_remove(od->evilhack, x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2710 break; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2711 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2712 l = l->next; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2713 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2714 |
2920 | 2715 if (infotype == AIM_GETINFO_AWAYMESSAGE) { |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2716 if (evilhack) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2717 g_show_info_text(gc, info->sn, 2, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2718 header, |
4151 | 2719 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
2720 _("<i>User has no away message</i>"), | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2721 legend, NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2722 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2723 g_show_info_text(gc, info->sn, 0, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2724 header, |
4151 | 2725 (utf8 && *utf8) ? away_subs(utf8, gc->username) : NULL, |
2726 (utf8 && *utf8) ? "<BR><HR>" : NULL, | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2727 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2728 } |
2920 | 2729 } else if (infotype == AIM_GETINFO_CAPABILITIES) { |
2730 g_show_info_text(gc, info->sn, 2, | |
2731 header, | |
2732 "<i>", _("Client Capabilities: "), | |
2733 caps_string(info->capabilities), | |
2734 "</i>", | |
2735 legend, | |
2736 NULL); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2737 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2738 g_show_info_text(gc, info->sn, 1, |
4151 | 2739 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
2740 _("<i>No Information Provided</i>"), | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2741 legend, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2742 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2743 } |
2086 | 2744 |
4151 | 2745 g_free(utf8); |
2746 | |
2086 | 2747 return 1; |
2748 } | |
2749 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2750 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2751 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2752 fu16_t id; |
2086 | 2753 va_list ap; |
2754 char buildbuf[150]; | |
2755 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2756 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2757 id = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2758 msg = va_arg(ap, char *); |
2759 va_end(ap); | |
2760 | |
2761 aim_getbuildstring(buildbuf, sizeof(buildbuf)); | |
2762 | |
2763 debug_printf("MOTD: %s (%d)\n", msg ? msg : "Unknown", id); | |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
2764 if (id < 4) |
3427 | 2765 do_error_dialog(_("Your AIM connection may be lost."), NULL, GAIM_WARNING); |
2086 | 2766 |
2767 return 1; | |
2768 } | |
2769 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2770 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2771 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2772 fu16_t type; |
2086 | 2773 struct gaim_connection *gc = sess->aux_data; |
2774 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
2775 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2776 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2777 type = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2778 |
2779 switch(type) { | |
2780 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2781 fu8_t maxrooms; |
2086 | 2782 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2783 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2784 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2785 maxrooms = (fu8_t)va_arg(ap, unsigned int); |
2086 | 2786 exchangecount = va_arg(ap, int); |
2787 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
2788 va_end(ap); | |
2789 | |
2790 debug_printf("chat info: Chat Rights:\n"); | |
2791 debug_printf("chat info: \tMax Concurrent Rooms: %d\n", maxrooms); | |
2792 debug_printf("chat info: \tExchange List: (%d total)\n", exchangecount); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2793 for (i = 0; i < exchangecount; i++) |
2931 | 2794 debug_printf("chat info: \t\t%d %s\n", exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2795 while (odata->create_rooms) { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2796 struct create_room *cr = odata->create_rooms->data; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2797 debug_printf("creating room %s\n", cr->name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2798 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2799 g_free(cr->name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2800 odata->create_rooms = g_slist_remove(odata->create_rooms, cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2801 g_free(cr); |
2086 | 2802 } |
2803 } | |
2804 break; | |
2805 case 0x0008: { | |
2806 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2807 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2808 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2809 fu32_t createtime; |
2086 | 2810 |
2811 fqcn = va_arg(ap, char *); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2812 instance = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2813 exchange = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2814 flags = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2815 createtime = va_arg(ap, fu32_t); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2816 maxmsglen = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2817 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2818 createperms = (fu8_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2819 unknown = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2820 name = va_arg(ap, char *); |
2821 ck = va_arg(ap, char *); | |
2822 va_end(ap); | |
2823 | |
2824 debug_printf("created room: %s %d %d %d %lu %d %d %d %d %s %s\n", | |
2825 fqcn, | |
2826 exchange, instance, flags, | |
2827 createtime, | |
2828 maxmsglen, maxoccupancy, createperms, unknown, | |
2829 name, ck); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2830 aim_chat_join(odata->sess, odata->conn, exchange, ck, instance); |
2086 | 2831 } |
2832 break; | |
2833 default: | |
2834 va_end(ap); | |
2835 debug_printf("chatnav info: unknown type (%04x)\n", type); | |
2836 break; | |
2837 } | |
2838 return 1; | |
2839 } | |
2840 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2841 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2842 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2843 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2844 aim_userinfo_t *info; |
2086 | 2845 struct gaim_connection *g = sess->aux_data; |
2846 | |
2847 struct chat_connection *c = NULL; | |
2848 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2849 va_start(ap, fr); |
2086 | 2850 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2851 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2852 va_end(ap); |
2853 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2854 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 2855 if (!c) |
2856 return 1; | |
2857 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2858 for (i = 0; i < count; i++) |
3708 | 2859 add_chat_buddy(c->cnv, info[i].sn, NULL); |
2086 | 2860 |
2861 return 1; | |
2862 } | |
2863 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2864 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2865 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2866 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2867 aim_userinfo_t *info; |
2086 | 2868 struct gaim_connection *g = sess->aux_data; |
2869 | |
2870 struct chat_connection *c = NULL; | |
2871 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2872 va_start(ap, fr); |
2086 | 2873 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2874 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2875 va_end(ap); |
2876 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2877 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 2878 if (!c) |
2879 return 1; | |
2880 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2881 for (i = 0; i < count; i++) |
2820
b917845dad3c
[gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2817
diff
changeset
|
2882 remove_chat_buddy(c->cnv, info[i].sn, NULL); |
2086 | 2883 |
2884 return 1; | |
2885 } | |
2886 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2887 static int gaim_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
|
2888 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2889 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2890 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2891 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2892 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2893 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2894 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2895 fu32_t creationtime; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2896 struct gaim_connection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2897 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
|
2898 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2899 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2900 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2901 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2902 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2903 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2904 roomdesc = va_arg(ap, char *); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2905 unknown_c9 = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2906 creationtime = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2907 maxmsglen = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2908 unknown_d2 = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2909 unknown_d5 = (fu16_t)va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2910 maxvisiblemsglen = (fu16_t)va_arg(ap, int); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2911 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2912 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2913 debug_printf("inside chat_info_update (maxmsglen = %d, maxvislen = %d)\n", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2914 maxmsglen, maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2915 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2916 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2917 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2918 |
2086 | 2919 return 1; |
2920 } | |
2921 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2922 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2923 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2924 aim_userinfo_t *info; |
2086 | 2925 char *msg; |
2926 struct gaim_connection *gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2927 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
2086 | 2928 char *tmp; |
2929 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2930 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2931 info = va_arg(ap, aim_userinfo_t *); |
2086 | 2932 msg = va_arg(ap, char *); |
2933 | |
2934 tmp = g_malloc(BUF_LONG); | |
2935 g_snprintf(tmp, BUF_LONG, "%s", msg); | |
2936 serv_got_chat_in(gc, ccon->id, info->sn, 0, tmp, time((time_t)NULL)); | |
2937 g_free(tmp); | |
2938 | |
2939 return 1; | |
2940 } | |
2941 | |
3694 | 2942 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
2943 va_list ap; | |
2944 struct gaim_connection *gc = sess->aux_data; | |
2945 struct aim_emailinfo *emailinfo; | |
3725 | 2946 int havenewmail; |
3694 | 2947 |
2948 va_start(ap, fr); | |
2949 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 2950 havenewmail = va_arg(ap, int); |
3694 | 2951 va_end(ap); |
2952 | |
3725 | 2953 if (emailinfo) { |
2954 debug_printf("Got email info. webmail address for screenname@%s is %s, new email: %hd, number new: %d, flag is %d, havenewmail is %d\n", emailinfo->domain, emailinfo->url, emailinfo->unread, emailinfo->nummsgs, emailinfo->flag, havenewmail); | |
2955 if (emailinfo->unread) { | |
2956 if (havenewmail) | |
2957 connection_has_mail(gc, emailinfo->nummsgs ? emailinfo->nummsgs : -1, NULL, NULL, emailinfo->url); | |
2958 } else | |
3694 | 2959 connection_has_mail(gc, 0, NULL, NULL, emailinfo->url); |
2960 } | |
2961 | |
2962 return 1; | |
2963 } | |
2964 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2965 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2966 * 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
|
2967 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2968 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2969 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2970 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2971 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2972 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2973 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2974 type = (fu16_t)va_arg(ap, unsigned int); |
2086 | 2975 sn = va_arg(ap, char *); |
2976 va_end(ap); | |
2977 | |
2978 debug_printf("Sent message to %s.\n", sn); | |
2979 | |
2980 return 1; | |
2981 } | |
2982 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2983 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
|
2984 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2985 "invalid", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2986 "change", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2987 "warning", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2988 "limit", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2989 "limit cleared", |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2990 }; |
2086 | 2991 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2992 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2993 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2994 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2995 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2996 code = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2997 rateclass= (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2998 windowsize = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2999 clear = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3000 alert = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3001 limit = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3002 disconnect = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3003 currentavg = (fu32_t)va_arg(ap, unsigned long); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3004 maxavg = (fu32_t)va_arg(ap, unsigned long); |
2086 | 3005 va_end(ap); |
3006 | |
3007 debug_printf("rate %s (paramid 0x%04lx): curavg = %ld, maxavg = %ld, alert at %ld, " | |
3008 "clear warning at %ld, limit at %ld, disconnect at %ld (window size = %ld)\n", | |
3009 (code < 5) ? codes[code] : codes[0], | |
3010 rateclass, | |
3011 currentavg, maxavg, | |
3012 alert, clear, | |
3013 limit, disconnect, | |
3014 windowsize); | |
3015 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3016 /* XXX fix these values */ |
2086 | 3017 if (code == AIM_RATE_CODE_CHANGE) { |
3018 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3019 aim_conn_setlatency(fr->conn, 0); |
2086 | 3020 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3021 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3022 } else if (code == AIM_RATE_CODE_LIMIT) { |
3427 | 3023 do_error_dialog(_("Rate limiting error."), |
3024 _("The last message was not sent because you are over the rate limit. " | |
3025 "Please wait 10 seconds and try again."), GAIM_ERROR); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3026 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3027 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3028 aim_conn_setlatency(fr->conn, 0); |
2086 | 3029 } |
3030 | |
3031 return 1; | |
3032 } | |
3033 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3034 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3035 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3036 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3037 aim_userinfo_t *userinfo; |
2086 | 3038 struct gaim_connection *gc = sess->aux_data; |
3039 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3040 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3041 newevil = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3042 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3043 va_end(ap); |
3044 | |
3045 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, newevil / 10); | |
3046 | |
3047 return 1; | |
3048 } | |
3049 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3050 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3051 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3052 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3053 struct gaim_connection *gc = sess->aux_data; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3054 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3055 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3056 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3057 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3058 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3059 gc->evil = info->warnlevel/10; |
2698
e80f4b4f840f
[gaim-migrate @ 2711]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2689
diff
changeset
|
3060 /* gc->correction_time = (info->onlinesince - gc->login_time); */ |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3061 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3062 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3063 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3064 |
2675 | 3065 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
3458 | 3066 struct gaim_connection *gc = sess->aux_data; |
3067 struct oscar_data *od = gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3068 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3069 aim_reqpersonalinfo(sess, fr->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3070 aim_bos_reqlocaterights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3071 aim_bos_reqbuddyrights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3072 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
3073 aim_reqicbmparams(sess); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3074 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3075 aim_bos_reqrights(sess, fr->conn); |
3458 | 3076 if (od->icq) { |
3077 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | |
3078 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | | |
3079 AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3080 } | |
2086 | 3081 |
3082 return 1; | |
3083 } | |
3084 | |
2675 | 3085 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
2647 | 3086 struct gaim_connection *gc = sess->aux_data; |
3087 struct oscar_data *od = gc->proto_data; | |
3088 | |
2672 | 3089 aim_clientready(sess, fr->conn); |
2675 | 3090 debug_printf("connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3091 |
2647 | 3092 if (od->chpass) { |
3093 debug_printf("changing password\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3094 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3095 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3096 od->oldp = NULL; |
2647 | 3097 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3098 od->newp = NULL; |
2647 | 3099 od->chpass = FALSE; |
3100 } | |
2979 | 3101 if (od->setnick) { |
3102 debug_printf("formatting screenname\n"); | |
3103 aim_admin_setnick(sess, fr->conn, od->newsn); | |
3104 g_free(od->newsn); | |
3105 od->newsn = NULL; | |
3106 od->setnick = FALSE; | |
3107 } | |
2647 | 3108 if (od->conf) { |
3109 debug_printf("confirming account\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3110 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3111 od->conf = FALSE; |
3112 } | |
3113 if (od->reqemail) { | |
3114 debug_printf("requesting email\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3115 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3116 od->reqemail = FALSE; |
3117 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3118 if (od->setemail) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3119 debug_printf("setting email\n"); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3120 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3121 g_free(od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3122 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3123 } |
2647 | 3124 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3125 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3126 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3127 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3128 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
|
3129 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3130 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3131 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3132 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3133 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3134 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3135 |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3136 /* evidently this crashes on solaris. i have no clue why |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3137 debug_printf("ICBM Parameters: maxchannel = %d, default flags = 0x%08lx, max msg len = %d, " |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3138 "max sender evil = %f, max receiver evil = %f, min msg interval = %ld\n", |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3139 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3140 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3141 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3142 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3143 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3144 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3145 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3146 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3147 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3148 |
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
3149 aim_seticbmparam(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3150 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3151 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3152 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3153 |
2993 | 3154 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3155 { | |
3156 va_list ap; | |
3157 fu16_t maxsiglen; | |
3158 struct gaim_connection *gc = sess->aux_data; | |
3159 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
4151 | 3160 char *unicode; |
3161 int unicode_len; | |
3162 fu32_t flags; | |
2993 | 3163 |
3164 va_start(ap, fr); | |
3165 maxsiglen = va_arg(ap, int); | |
3166 va_end(ap); | |
3167 | |
3168 debug_printf("locate rights: max sig len = %d\n", maxsiglen); | |
3169 | |
3170 odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint)maxsiglen; | |
3171 | |
3458 | 3172 if (odata->icq) |
4151 | 3173 aim_bos_setprofile(sess, fr->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
3174 else { | |
3175 flags = check_encoding (gc->user->user_info); | |
3176 | |
3177 if (flags == 0) { | |
3178 aim_bos_setprofile(sess, fr->conn, "us-ascii", gc->user->user_info, | |
3179 strlen(gc->user->user_info), NULL, NULL, 0, caps_aim); | |
3180 } else { | |
3181 unicode = g_convert (gc->user->user_info, strlen(gc->user->user_info), | |
3182 "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); | |
3183 aim_bos_setprofile(sess, fr->conn, "unicode-2-0", unicode, unicode_len, | |
3184 NULL, NULL, 0, caps_aim); | |
3185 g_free(unicode); | |
3186 } | |
3187 } | |
2993 | 3188 |
3189 return 1; | |
3190 } | |
3191 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3192 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
|
3193 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3194 fu16_t maxbuddies, maxwatchers; |
2993 | 3195 struct gaim_connection *gc = sess->aux_data; |
3196 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3197 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3198 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3199 maxbuddies = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3200 maxwatchers = (fu16_t)va_arg(ap, unsigned int); |
2086 | 3201 va_end(ap); |
3202 | |
3203 debug_printf("buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); | |
3204 | |
2993 | 3205 odata->rights.maxbuddies = (guint)maxbuddies; |
3206 odata->rights.maxwatchers = (guint)maxwatchers; | |
3207 | |
2086 | 3208 return 1; |
3209 } | |
3210 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3211 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3212 fu16_t maxpermits, maxdenies; |
2086 | 3213 va_list ap; |
2993 | 3214 struct gaim_connection *gc = sess->aux_data; |
3215 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
2086 | 3216 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3217 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3218 maxpermits = (fu16_t)va_arg(ap, unsigned int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3219 maxdenies = (fu16_t)va_arg(ap, unsigned int); |
2086 | 3220 va_end(ap); |
3221 | |
3222 debug_printf("BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); | |
3223 | |
2993 | 3224 odata->rights.maxpermits = (guint)maxpermits; |
3225 odata->rights.maxdenies = (guint)maxdenies; | |
3226 | |
3227 account_online(gc); | |
3228 serv_finish_login(gc); | |
3229 | |
3230 if (bud_list_cache_exists(gc)) | |
3231 do_import(gc, NULL); | |
3232 | |
3233 debug_printf("buddy list loaded\n"); | |
3234 | |
2672 | 3235 aim_clientready(sess, fr->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3236 |
3952 | 3237 /* XXX - Should call aim_bos_setidle with 0x0000 */ |
3238 | |
3239 /* XXX - Should only call reqofflinemsgs when using ICQ? */ | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3240 aim_icq_reqofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3241 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3242 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 3243 if (sess->authinfo->email) |
3244 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 3245 |
3109 | 3246 if (!odata->icq) { |
3247 debug_printf("ssi: requesting ssi list\n"); | |
3092 | 3248 aim_ssi_reqrights(sess, fr->conn); |
3109 | 3249 aim_ssi_reqdata(sess, fr->conn, sess->ssi.timestamp, sess->ssi.revision); |
3250 } | |
2991 | 3251 |
2086 | 3252 return 1; |
3253 } | |
3254 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3255 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
|
3256 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3257 struct aim_icq_offlinemsg *msg; |
4075 | 3258 struct aim_incomingim_ch4_args args; |
3259 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3260 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3261 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3262 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3263 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3264 |
4075 | 3265 debug_printf("Received offline message. Converting to channel 4 ICBM...\n"); |
3266 args.uin = msg->sender; | |
3267 args.type = msg->type; | |
4076 | 3268 args.msglen = msg->msglen; |
4075 | 3269 args.msg = msg->msg; |
3270 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); | |
3271 incomingim_chan4(sess, fr->conn, NULL, &args, t); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3272 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3273 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3274 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3275 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3276 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
|
3277 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3278 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3279 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3280 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3281 |
4151 | 3282 static int gaim_icqsimpleinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3283 { |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
3284 struct gaim_connection *gc = sess->aux_data; |
3212 | 3285 struct buddy *budlight; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3286 va_list ap; |
4151 | 3287 struct aim_icq_info *info; |
3288 gchar *buf, *tmp; | |
3289 gchar who[16]; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3290 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3291 va_start(ap, fr); |
4151 | 3292 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3293 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3294 |
4151 | 3295 g_snprintf(who, sizeof(who), "%lu", info->uin); |
3296 buf = g_strdup_printf("<b>UIN:</b> %s<br>", who); | |
3297 if (info->nick) { | |
3298 tmp = buf; | |
3299 buf = g_strconcat(tmp, "<b>Nick:</b> ", info->nick, "<br>\n", NULL); | |
3300 g_free(tmp); | |
3301 } | |
3302 if (info->first) { | |
3303 tmp = buf; | |
3304 buf = g_strconcat(tmp, "<b>First Name:</b> ", info->first, "<br>\n", NULL); | |
3305 g_free(tmp); | |
3306 } | |
3307 if (info->last) { | |
3308 tmp = buf; | |
3309 buf = g_strconcat(tmp, "<b>Last Name:</b> ", info->last, "<br>\n", NULL); | |
3310 g_free(tmp); | |
3311 } | |
3312 if (info->email) { | |
3313 tmp = buf; | |
3314 buf = g_strconcat(tmp, "<b>Email Address:</b> ", info->email, "<br>\n", NULL); | |
3315 g_free(tmp); | |
3316 } | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3317 |
3212 | 3318 /* If the contact is away, then we also want to get their status message |
3319 * and show it in the same window as info. g_show_info_text gets the status | |
3320 * message if the third arg is 0 (this seems really gross to me). The | |
3321 * parse-icq-status-message function knows if it is putting it's message in | |
3322 * an info window because the name will _not_ be in od->evilhack. For getting | |
3323 * only the away message the contact's UIN is put in od->evilhack. */ | |
3279 | 3324 if ((budlight = find_buddy(gc, who))) { |
3595 | 3325 if ((budlight->uc >> 16) & (AIM_ICQ_STATE_AWAY || AIM_ICQ_STATE_DND || AIM_ICQ_STATE_OUT || AIM_ICQ_STATE_BUSY || AIM_ICQ_STATE_CHAT)) { |
3270 | 3326 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) |
3327 g_show_info_text(gc, who, 0, buf, NULL); | |
3328 else { | |
3595 | 3329 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
3952 | 3330 g_show_info_text(gc, who, 2, buf, "<B>Status:</B> ", state_msg, "<BR>\n<HR><I>Remote client does not support sending status messages.</I><BR>\n", NULL); |
3270 | 3331 free(state_msg); |
3332 } | |
3333 } else { | |
3595 | 3334 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
3270 | 3335 g_show_info_text(gc, who, 2, buf, "<B>Status:</B> ", state_msg, NULL); |
3212 | 3336 free(state_msg); |
3337 } | |
3270 | 3338 } else |
3339 g_show_info_text(gc, who, 2, buf, NULL); | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3340 |
4151 | 3341 g_free(buf); |
3342 | |
3343 return 1; | |
3344 } | |
3345 | |
3346 static int gaim_icqallinfo(aim_session_t *sess, aim_frame_t *fr, ...) | |
3347 { | |
3348 struct gaim_connection *gc = sess->aux_data; | |
3349 va_list ap; | |
3350 struct aim_icq_info *info; | |
3351 gchar *buf, *tmp; | |
3352 gchar who[16]; | |
3353 | |
3354 va_start(ap, fr); | |
3355 info = va_arg(ap, struct aim_icq_info *); | |
3356 va_end(ap); | |
3357 | |
3358 g_snprintf(who, sizeof(who), "%lu", info->uin); | |
3359 buf = g_strdup_printf("<b>UIN:</b> %s<br>", who); | |
3360 if (info->nick) { | |
3361 tmp = buf; | |
3362 buf = g_strconcat(tmp, "<b>Nick:</b> ", info->nick, "<br>\n", NULL); | |
3363 g_free(tmp); | |
3364 } | |
3365 if (info->first) { | |
3366 tmp = buf; | |
3367 buf = g_strconcat(tmp, "<b>First Name:</b> ", info->first, "<br>\n", NULL); | |
3368 g_free(tmp); | |
3369 } | |
3370 if (info->last) { | |
3371 tmp = buf; | |
3372 buf = g_strconcat(tmp, "<b>Last Name:</b> ", info->last, "<br>\n", NULL); | |
3373 g_free(tmp); | |
3374 } | |
3375 if (info->email) { | |
3376 tmp = buf; | |
3377 buf = g_strconcat(tmp, "<b>Email Address:</b> ", info->email, "<br>\n", NULL); | |
3378 g_free(tmp); | |
3379 } | |
3380 if (info->personalwebpage) { | |
3381 tmp = buf; | |
3382 buf = g_strconcat(tmp, "<b>Personal Webpage:</b> ", info->personalwebpage, "<br>\n", NULL); | |
3383 g_free(tmp); | |
3384 } | |
3385 if (info->info) { | |
3386 tmp = buf; | |
3387 buf = g_strconcat(tmp, "<br><b>Additional Information:</b><br>", info->info, "<br><hr>\n", NULL); | |
3388 g_free(tmp); | |
3389 } | |
3390 if (info->homecity && info->homestate && info->homeaddr && info->homezip) { | |
3391 tmp = buf; | |
3392 buf = g_strconcat(tmp, "<br><b>Home Address:</b><br>\n", info->homeaddr, "<br>\n", info->homecity, ", ", info->homestate, " ", info->homezip, "<hr>\n", NULL); | |
3393 g_free(tmp); | |
3394 } | |
3395 | |
3396 g_show_info_text(gc, who, 2, buf, NULL); | |
3397 g_free(buf); | |
3398 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3399 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3400 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3401 |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3402 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
|
3403 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3404 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3405 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3406 va_list ap; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3407 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3408 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3409 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3410 url = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3411 wid = (fu16_t)va_arg(ap, int); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3412 hei = (fu16_t)va_arg(ap, int); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3413 delay = (fu16_t)va_arg(ap, int); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3414 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3415 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3416 serv_got_popup(msg, url, wid, hei); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3417 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3418 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3419 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3420 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3421 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3422 va_list ap; |
3423 char *address, *SNs; | |
3424 int i, num; | |
3425 char *buf; | |
3426 int at = 0, len; | |
3427 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3428 va_start(ap, fr); |
2086 | 3429 address = va_arg(ap, char *); |
3430 num = va_arg(ap, int); | |
3431 SNs = va_arg(ap, char *); | |
3432 va_end(ap); | |
3433 | |
3434 len = num * (MAXSNLEN + 1) + 1024; | |
3435 buf = g_malloc(len); | |
3436 at += g_snprintf(buf + at, len - at, "<B>%s has the following screen names:</B><BR>", address); | |
3437 for (i = 0; i < num; i++) | |
3438 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | |
3212 | 3439 g_show_info_text(NULL, NULL, 2, buf, NULL); |
2086 | 3440 g_free(buf); |
3441 | |
3442 return 1; | |
3443 } | |
3444 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3445 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3446 va_list ap; |
3447 char *address; | |
3448 char buf[BUF_LONG]; | |
3449 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3450 va_start(ap, fr); |
2086 | 3451 address = va_arg(ap, char *); |
3452 va_end(ap); | |
3453 | |
3454 g_snprintf(buf, sizeof(buf), "No results found for email address %s", address); | |
3427 | 3455 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 3456 |
3457 return 1; | |
3458 } | |
3459 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3460 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3461 fu16_t status; |
2086 | 3462 va_list ap; |
3463 char msg[256]; | |
3464 struct gaim_connection *gc = sess->aux_data; | |
3465 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3466 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3467 status = (fu16_t)va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 3468 va_end(ap); |
3469 | |
3470 debug_printf("account confirmation returned status 0x%04x (%s)\n", status, | |
3912 | 3471 status ? "unknown" : "email sent"); |
3472 if (!status) { | |
2086 | 3473 g_snprintf(msg, sizeof(msg), "You should receive an email asking to confirm %s.", |
3474 gc->username); | |
4056 | 3475 do_error_dialog(_("Account Confirmation Requested"), msg, GAIM_INFO); |
2086 | 3476 } |
3477 | |
3478 return 1; | |
3479 } | |
3480 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3481 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
3912 | 3482 struct gaim_connection *gc = sess->aux_data; |
2086 | 3483 va_list ap; |
3912 | 3484 fu16_t perms, err; |
3485 char *url, *sn, *email; | |
3486 int change; | |
2086 | 3487 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3488 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3489 change = va_arg(ap, int); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3490 perms = (fu16_t)va_arg(ap, unsigned int); |
3912 | 3491 err = (fu16_t)va_arg(ap, unsigned int); |
3492 url = va_arg(ap, char *); | |
3493 sn = va_arg(ap, char *); | |
3494 email = va_arg(ap, char *); | |
2086 | 3495 va_end(ap); |
3496 | |
3912 | 3497 debug_printf("account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
3498 change ? "change" : "request", perms, err, url, sn, email); | |
3499 | |
3500 if (err && url) { | |
3501 char *dialog_msg; | |
3502 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
3503 switch (err) { | |
3504 case 0x0001: { | |
3505 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
3506 } break; | |
3507 case 0x0006: { | |
3508 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
3509 } break; | |
3510 case 0x000b: { | |
3511 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
3512 } break; | |
3513 case 0x001d: { | |
3514 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); | |
3515 } break; | |
3516 case 0x0021: { | |
3517 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); | |
3518 } break; | |
3519 case 0x0023: { | |
3520 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
3521 } break; | |
3522 default: { | |
3523 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
3524 } break; | |
3525 } | |
3526 do_error_dialog(dialog_top, dialog_msg, GAIM_ERROR); | |
3527 g_free(dialog_top); | |
3528 g_free(dialog_msg); | |
3529 return 1; | |
3530 } | |
3531 | |
3532 if (sn) { | |
3533 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formated as follows:\n%s"), sn); | |
4056 | 3534 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
3912 | 3535 g_free(dialog_msg); |
3536 } | |
3537 | |
3538 if (email) { | |
3539 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), gc->username, email); | |
4056 | 3540 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
3912 | 3541 g_free(dialog_msg); |
2086 | 3542 } |
3543 | |
3544 return 1; | |
3545 } | |
3546 | |
3547 static void oscar_keepalive(struct gaim_connection *gc) { | |
3548 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
3549 aim_flap_nop(odata->sess, odata->conn); | |
3550 } | |
3551 | |
3001 | 3552 static int oscar_send_typing(struct gaim_connection *gc, char *name, int typing) { |
2993 | 3553 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
3554 struct direct_im *dim = find_direct_im(odata, name); | |
3595 | 3555 if (dim) |
3556 aim_send_typing(odata->sess, dim->conn, typing); | |
3557 else { | |
3600 | 3558 char *who = normalize(name); |
3559 if (g_hash_table_lookup(odata->supports_tn, who)) { | |
3596 | 3560 if (typing == TYPING) |
3595 | 3561 aim_mtn_send(odata->sess, 0x0001, name, 0x0002); |
3596 | 3562 else if (typing == TYPED) |
3563 aim_mtn_send(odata->sess, 0x0001, name, 0x0001); | |
3595 | 3564 else |
3565 aim_mtn_send(odata->sess, 0x0001, name, 0x0000); | |
3566 } | |
3567 } | |
2993 | 3568 return 0; |
3569 } | |
3048 | 3570 static void oscar_ask_direct_im(struct gaim_connection *gc, char *name); |
2993 | 3571 |
3033 | 3572 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) { |
2086 | 3573 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
3574 struct direct_im *dim = find_direct_im(odata, name); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3575 int ret = 0; |
3659 | 3576 GError *err = NULL; |
3458 | 3577 |
2086 | 3578 if (dim) { |
3009 | 3579 if (dim->connected) { /* If we're not connected yet, send through server */ |
3952 | 3580 /* AAA - The last parameter below is the encoding. Let Paco-Paco do something with it. */ |
3581 ret = aim_send_im_direct(odata->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0); | |
3009 | 3582 if (ret == 0) |
3583 return 1; | |
3584 else return ret; | |
3585 } | |
3008 | 3586 debug_printf("Direct IM pending, but not connected; sending through server\n"); |
3044 | 3587 } else if (len != -1) { |
3588 /* Trying to send an IM image outside of a direct connection. */ | |
3589 oscar_ask_direct_im(gc, name); | |
3590 return -ENOTCONN; | |
3591 } | |
3008 | 3592 if (imflags & IM_FLAG_AWAY) { |
3593 ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message); | |
2086 | 3594 } else { |
3008 | 3595 struct aim_sendimext_args args; |
3596 GSList *h = odata->hasicons; | |
3597 struct icon_req *ir = NULL; | |
3598 char *who = normalize(name); | |
3599 struct stat st; | |
4151 | 3600 int len; |
3008 | 3601 |
3602 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; | |
3603 if (odata->icq) | |
3604 args.flags |= AIM_IMFLAGS_OFFLINE; | |
3605 | |
3606 args.features = gaim_features; | |
3607 args.featureslen = sizeof(gaim_features); | |
3608 | |
3609 while (h) { | |
3610 ir = h->data; | |
3611 if (ir->request && !strcmp(who, ir->user)) | |
3612 break; | |
3613 h = h->next; | |
2086 | 3614 } |
3008 | 3615 if (h) { |
3616 ir->request = FALSE; | |
3617 args.flags |= AIM_IMFLAGS_BUDDYREQ; | |
3618 debug_printf("sending buddy icon request with message\n"); | |
3619 } | |
3620 | |
3621 if (gc->user->iconfile[0] && !stat(gc->user->iconfile, &st)) { | |
3622 FILE *file = fopen(gc->user->iconfile, "r"); | |
3623 if (file) { | |
3624 char *buf = g_malloc(st.st_size); | |
3625 fread(buf, 1, st.st_size, file); | |
3626 | |
3627 args.iconlen = st.st_size; | |
3628 args.iconsum = aim_iconsum(buf, st.st_size); | |
3629 args.iconstamp = st.st_mtime; | |
3630 | |
3631 args.flags |= AIM_IMFLAGS_HASICON; | |
3632 debug_printf("Claiming to have an icon.\n"); | |
3633 | |
3634 fclose(file); | |
3635 g_free(buf); | |
2086 | 3636 } |
3637 } | |
3008 | 3638 |
3639 args.destsn = name; | |
3642 | 3640 |
3641 len = strlen(message); | |
4151 | 3642 args.flags |= check_encoding(message); |
3642 | 3643 if (args.flags & AIM_IMFLAGS_UNICODE) { |
3850 | 3644 debug_printf ("Sending Unicode IM\n"); |
3659 | 3645 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3646 if (err) { | |
3647 debug_printf("Error converting a unicode message: %s\n", err->message); | |
3648 debug_printf("This really shouldn't happen!\n"); | |
3649 /* We really shouldn't try to send the | |
3650 * IM now, but I'm not sure what to do */ | |
3651 } | |
3850 | 3652 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
3653 debug_printf ("Sending ISO-8859-1 IM\n"); | |
3659 | 3654 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3655 if (err) { | |
3656 debug_printf("conversion error: %s\n", err->message); | |
3642 | 3657 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); |
3658 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; | |
3659 len = strlen(message); | |
3659 | 3660 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3661 if (err) { | |
3662 debug_printf ("Error in unicode fallback: %s\n", err->message); | |
3663 } | |
3642 | 3664 } |
3665 } else { | |
3666 args.msg = message; | |
3667 } | |
3668 args.msglen = len; | |
3008 | 3669 |
3670 ret = aim_send_im_ext(odata->sess, &args); | |
2086 | 3671 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3672 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3673 return 1; |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3674 return ret; |
2086 | 3675 } |
3676 | |
3677 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
3678 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3679 if (odata->icq) |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3680 aim_icq_getsimpleinfo(odata->sess, name); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3681 else |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3682 /* people want the away message on the top, so we get the away message |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3683 * first and then get the regular info, since it's too difficult to |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3684 * insert in the middle. i hate people. */ |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3685 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3686 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3687 |
3212 | 3688 static void oscar_get_away(struct gaim_connection *g, char *who) { |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3689 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
3212 | 3690 if (odata->icq) { |
3691 struct buddy *budlight = find_buddy(g, who); | |
3692 if (budlight) | |
3595 | 3693 if ((budlight->uc & 0xffff0000) >> 16) |
3212 | 3694 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) |
3595 | 3695 aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xffff0000) >> 16); |
3212 | 3696 else |
3697 debug_printf("Error: Remote client does not support retrieval of status messages.\n"); | |
3698 else | |
3699 debug_printf("Error: The user %s has no status message, therefore not requesting.\n", who); | |
3700 else | |
3701 debug_printf("Error: Could not find %s in local contact list, therefore unable to request status message.\n", who); | |
3702 } else | |
3703 aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_GENERALINFO); | |
2086 | 3704 } |
3705 | |
2920 | 3706 static void oscar_get_caps(struct gaim_connection *g, char *name) { |
3707 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
3708 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_CAPABILITIES); | |
3709 } | |
3710 | |
3466 | 3711 static void oscar_set_dir(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
3712 const char *maiden, const char *city, const char *state, const char *country, int web) { | |
2086 | 3713 /* FIXME : some of these things are wrong, but i'm lazy */ |
3714 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
3715 aim_setdirectoryinfo(odata->sess, odata->conn, first, middle, last, | |
3716 maiden, NULL, NULL, city, state, NULL, 0, web); | |
3717 } | |
3718 | |
3719 | |
3720 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
3721 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
3722 aim_bos_setidle(odata->sess, odata->conn, time); | |
3723 } | |
3724 | |
3725 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
3726 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
4151 | 3727 gchar *inforeal, *unicode; |
3728 fu32_t flags; | |
3729 int unicode_len; | |
2993 | 3730 |
3731 if (odata->rights.maxsiglen == 0) | |
3427 | 3732 do_error_dialog(_("Unable to set AIM profile."), |
3733 _("You have probably requested to set your profile before the login procedure completed. " | |
3734 "Your profile remains unset; try setting it again when you are fully connected."), GAIM_ERROR); | |
2993 | 3735 |
3736 if (strlen(info) > odata->rights.maxsiglen) { | |
3737 gchar *errstr; | |
3738 | |
3427 | 3739 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. " |
3740 "Gaim has truncated and set it."), odata->rights.maxsiglen); | |
3741 do_error_dialog("Profile too long.", errstr, GAIM_WARNING); | |
2993 | 3742 |
3743 g_free(errstr); | |
3744 } | |
3745 | |
3746 inforeal = g_strndup(info, odata->rights.maxsiglen); | |
3747 | |
3458 | 3748 if (odata->icq) |
4151 | 3749 aim_bos_setprofile(odata->sess, odata->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
3750 else { | |
3751 flags = check_encoding(inforeal); | |
3752 | |
3753 if (flags == 0) { | |
3754 aim_bos_setprofile(odata->sess, odata->conn, "us-ascii", inforeal, strlen (inforeal), | |
3755 NULL, NULL, 0, caps_aim); | |
3756 } else { | |
3757 unicode = g_convert (inforeal, strlen(inforeal), "UCS-2BE", "UTF-8", NULL, | |
3758 &unicode_len, NULL); | |
3759 aim_bos_setprofile(odata->sess, odata->conn, "unicode-2-0", unicode, unicode_len, | |
3760 NULL, NULL, 0, caps_aim); | |
3761 g_free(unicode); | |
3762 } | |
3763 } | |
2993 | 3764 g_free(inforeal); |
3765 | |
3766 return; | |
2086 | 3767 } |
3768 | |
2993 | 3769 static void oscar_set_away_aim(struct gaim_connection *gc, struct oscar_data *od, const char *message) |
3770 { | |
4151 | 3771 fu32_t flags; |
3772 char *unicode; | |
3773 int unicode_len; | |
2993 | 3774 |
3775 if (od->rights.maxawaymsglen == 0) | |
3427 | 3776 do_error_dialog(_("Unable to set AIM away message."), |
3777 _("You have probably requested to set your away message before the login procedure completed. " | |
3778 "You remain in a \"present\" state; try setting it again when you are fully connected."), GAIM_ERROR); | |
3779 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3780 if (gc->away) { |
2993 | 3781 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3782 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3783 } |
2993 | 3784 |
3785 if (!message) { | |
4151 | 3786 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, "", 0, caps_aim); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3787 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3788 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3789 |
2993 | 3790 if (strlen(message) > od->rights.maxawaymsglen) { |
3791 gchar *errstr; | |
3792 | |
3427 | 3793 errstr = g_strdup_printf(_("The away message length of %d bytes has been exceeded. " |
3794 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen); | |
3795 do_error_dialog("Away message too long.", errstr, GAIM_WARNING); | |
2993 | 3796 g_free(errstr); |
3797 } | |
3798 | |
3799 gc->away = g_strndup(message, od->rights.maxawaymsglen); | |
4151 | 3800 flags = check_encoding(message); |
3801 | |
3802 if (flags == 0) { | |
3803 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", gc->away, strlen(gc->away), | |
3804 caps_aim); | |
3805 } else { | |
3806 unicode = g_convert(message, strlen(message), "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); | |
3807 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", unicode, unicode_len, | |
3808 caps_aim); | |
3809 g_free(unicode); | |
3810 } | |
2993 | 3811 |
3812 return; | |
3813 } | |
3814 | |
3815 static void oscar_set_away_icq(struct gaim_connection *gc, struct oscar_data *od, const char *state, const char *message) | |
3816 { | |
3817 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3818 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3819 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3820 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3821 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3822 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3823 if (!strcmp(state, "Online")) |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2865
diff
changeset
|
3824 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3825 else if (!strcmp(state, "Away")) { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3826 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3827 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3828 } else if (!strcmp(state, "Do Not Disturb")) { |
3212 | 3829 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3830 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3831 } else if (!strcmp(state, "Not Available")) { |
3101 | 3832 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3833 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3834 } else if (!strcmp(state, "Occupied")) { |
3212 | 3835 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3836 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3837 } else if (!strcmp(state, "Free For Chat")) { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3838 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3839 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3840 } else if (!strcmp(state, "Invisible")) { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3841 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3842 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3843 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 3844 if (message) { |
3101 | 3845 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3846 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3847 } else { |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2865
diff
changeset
|
3848 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3849 } |
2086 | 3850 } |
2993 | 3851 |
3852 return; | |
3853 } | |
3854 | |
3855 static void oscar_set_away(struct gaim_connection *gc, char *state, char *message) | |
3856 { | |
3857 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
3858 | |
3859 if (od->icq) | |
3860 oscar_set_away_icq(gc, od, state, message); | |
3861 else | |
3862 oscar_set_away_aim(gc, od, message); | |
3863 | |
3864 return; | |
2086 | 3865 } |
3866 | |
3867 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { | |
3868 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
2113 | 3869 aim_send_warning(odata->sess, odata->conn, name, anon ? AIM_WARN_ANON : 0); |
2086 | 3870 } |
3871 | |
3466 | 3872 static void oscar_dir_search(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
3873 const char *maiden, const char *city, const char *state, const char *country, const char *email) { | |
2086 | 3874 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
3875 if (strlen(email)) | |
3876 aim_usersearch_address(odata->sess, odata->conn, email); | |
3877 } | |
3878 | |
3466 | 3879 static void oscar_add_buddy(struct gaim_connection *g, const char *name) { |
2086 | 3880 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
3092 | 3881 if (odata->icq) { |
3882 aim_add_buddy(odata->sess, odata->conn, name); | |
3883 } else { | |
3210 | 3884 if ((odata->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, name, 0x0000))) { |
2995 | 3885 debug_printf("ssi: adding buddy %s to group %s\n", name, find_group_by_buddy(g, name)->name); |
3886 aim_ssi_addbuddies(odata->sess, odata->conn, find_group_by_buddy(g, name)->name, &name, 1); | |
3092 | 3887 } |
2991 | 3888 } |
2086 | 3889 } |
3890 | |
3891 static void oscar_add_buddies(struct gaim_connection *g, GList *buddies) { | |
3892 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
3092 | 3893 if (odata->icq) { |
3894 char buf[MSG_LEN]; | |
3895 int n=0; | |
3896 while (buddies) { | |
3897 if (n > MSG_LEN - 18) { | |
3898 aim_bos_setbuddylist(odata->sess, odata->conn, buf); | |
3899 n = 0; | |
3900 } | |
3901 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); | |
3902 buddies = buddies->next; | |
3903 } | |
3904 aim_bos_setbuddylist(odata->sess, odata->conn, buf); | |
3905 } else { | |
3906 if (odata->sess->ssi.received_data) { | |
3907 int tmp; | |
3908 GSList *curgrp, *curbud; | |
3909 for (curgrp=g->groups; curgrp; curgrp=g_slist_next(curgrp)) { | |
2995 | 3910 tmp = 0; |
3911 for (curbud=((struct group*)curgrp->data)->members; curbud; curbud=curbud->next) | |
3210 | 3912 if (!aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) |
2995 | 3913 tmp++; |
3092 | 3914 if (tmp) { |
3915 char **sns = (char **)malloc(tmp*sizeof(char*)); | |
3916 tmp = 0; | |
3917 for (curbud=((struct group*)curgrp->data)->members; curbud; curbud=curbud->next) | |
3210 | 3918 if (!aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) { |
3092 | 3919 debug_printf("ssi: adding buddy %s to group %s\n", ((struct buddy*)curbud->data)->name, ((struct group*)curgrp->data)->name); |
3920 sns[tmp] = (char *)((struct buddy*)curbud->data)->name; | |
3921 tmp++; | |
3922 } | |
3595 | 3923 aim_ssi_addbuddies(odata->sess, odata->conn, ((struct group*)curgrp->data)->name, (const char**)sns, tmp); |
3092 | 3924 free(sns); |
2995 | 3925 } |
3092 | 3926 } |
2995 | 3927 } |
3928 } | |
3929 } | |
3930 | |
3867 | 3931 static void oscar_move_buddy(struct gaim_connection *g, const char *name, const char *old_group, const char *new_group) { |
3140 | 3932 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
3933 if (!odata->icq) | |
3934 if (odata->sess->ssi.received_data) { | |
3935 aim_ssi_movebuddy(odata->sess, odata->conn, old_group, new_group, name); | |
3936 debug_printf("ssi: moved buddy %s from group %s to group %s\n", name, old_group, new_group); | |
3937 } | |
3938 } | |
3939 | |
2995 | 3940 static void oscar_remove_buddy(struct gaim_connection *g, char *name, char *group) { |
3941 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
3092 | 3942 if (odata->icq) { |
3943 aim_remove_buddy(odata->sess, odata->conn, name); | |
3944 } else { | |
3945 if (odata->sess->ssi.received_data) { | |
3210 | 3946 struct aim_ssi_item *ssigroup; |
3947 while (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, name, 0x0000) && (ssigroup = aim_ssi_itemlist_findparent(odata->sess->ssi.items, name)) && !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)) | |
3092 | 3948 debug_printf("ssi: deleted buddy %s from group %s\n", name, group); |
3949 } | |
2995 | 3950 } |
3951 } | |
3952 | |
3867 | 3953 static void oscar_remove_buddies(struct gaim_connection *g, GList *buddies, const char *group) { |
2995 | 3954 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
3092 | 3955 if (odata->icq) { |
2995 | 3956 GList *cur; |
3957 for (cur=buddies; cur; cur=cur->next) | |
3092 | 3958 aim_remove_buddy(odata->sess, odata->conn, cur->data); |
3959 } else { | |
3960 if (odata->sess->ssi.received_data) { | |
3961 GList *cur; | |
3962 int tmp = 0; | |
2995 | 3963 for (cur=buddies; cur; cur=cur->next) |
3210 | 3964 if (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, cur->data, 0x0000)) |
2991 | 3965 tmp++; |
3092 | 3966 if (tmp) { |
3967 char **sns; | |
3968 sns = (char **)malloc(tmp*sizeof(char*)); | |
3969 tmp = 0; | |
3970 for (cur=buddies; cur; cur=cur->next) | |
3210 | 3971 if (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, cur->data, 0x0000)) { |
3092 | 3972 debug_printf("ssi: deleting buddy %s from group %s\n", cur->data, group); |
3973 sns[tmp] = cur->data; | |
3974 tmp++; | |
3975 } | |
3976 aim_ssi_delbuddies(odata->sess, odata->conn, group, sns, tmp); | |
3977 free(sns); | |
3978 } | |
2991 | 3979 } |
3980 } | |
3981 } | |
3982 | |
3867 | 3983 static void oscar_rename_group(struct gaim_connection *g, const char *old_group, const char *new_group, GList *members) { |
3348 | 3984 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
3985 if (!odata->icq) | |
3986 if (odata->sess->ssi.received_data) { | |
3987 if (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, new_group, 0x0001)) { | |
3988 oscar_remove_buddies(g, members, old_group); | |
3989 oscar_add_buddies(g, members); | |
3990 debug_printf("ssi: moved all buddies from group %s to %s\n", old_group, new_group); | |
3991 } else { | |
3992 aim_ssi_rename_group(odata->sess, odata->conn, old_group, new_group); | |
3993 debug_printf("ssi: renamed group %s to %s\n", old_group, new_group); | |
3994 } | |
3995 } | |
3996 } | |
3997 | |
2991 | 3998 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
3999 /* XXX - Fix parsing of the ssi rights packet and pass us the data | |
4000 fu16_t maxbuddies, maxgroups, maxpermits, maxdenies; | |
4001 va_list ap; | |
4002 | |
4003 va_start(ap, fr); | |
4004 maxbuddies = (fu16_t)va_arg(ap, unsigned int); | |
4005 maxgroupss = (fu16_t)va_arg(ap, unsigned int); | |
4006 maxpermits = (fu16_t)va_arg(ap, unsigned int); | |
4007 maxdenies = (fu16_t)va_arg(ap, unsigned int); | |
4008 va_end(ap); | |
4009 | |
4010 debug_printf("ssi rights: Max buddies = %d / Max groups = %d / Max permits = %d / Max denies = %d\n", maxbuddies, maxgroups, maxpermits, maxdenies); | |
4011 */ | |
4012 | |
4013 return 1; | |
4014 } | |
4015 | |
4016 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4017 struct gaim_connection *gc = sess->aux_data; | |
2995 | 4018 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
4019 struct aim_ssi_item *curitem; | |
2991 | 4020 int tmp; |
3466 | 4021 const char **sns; |
2991 | 4022 |
4023 debug_printf("ssi: syncing local list and server list\n"); | |
4024 | |
3109 | 4025 if (odata->icq) |
3092 | 4026 return 1; |
4027 | |
2991 | 4028 /* Activate SSI */ |
4029 debug_printf("ssi: activating server-stored buddy list\n"); | |
4030 aim_ssi_enable(sess, fr->conn); | |
4031 | |
4032 /* Clean the buddy list */ | |
3210 | 4033 aim_ssi_cleanlist(sess, fr->conn); |
2991 | 4034 |
4035 /* Add from server list to local list */ | |
4036 tmp = 0; | |
4037 for (curitem=sess->ssi.items; curitem; curitem=curitem->next) { | |
4038 switch (curitem->type) { | |
4039 case 0x0000: /* Buddy */ | |
4040 if ((curitem->name) && (!find_buddy(gc, curitem->name))) { | |
2995 | 4041 struct aim_ssi_item *curgroup = sess->ssi.items; |
2991 | 4042 while (curgroup) { |
4043 if ((curgroup->type == 0x0001) && (curgroup->gid == curitem->gid) && (curgroup->name)) { | |
2995 | 4044 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, curgroup->name); |
2991 | 4045 add_buddy(gc, curgroup->name, curitem->name, 0); |
4046 tmp++; | |
4047 } | |
4048 curgroup = curgroup->next; | |
4049 } | |
4050 } | |
4051 break; | |
4052 | |
2995 | 4053 case 0x0002: /* Permit buddy */ |
2991 | 4054 if (curitem->name) { |
4055 GSList *list; | |
4056 for (list=gc->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); | |
4057 if (!list) { | |
4058 char *name; | |
2995 | 4059 debug_printf("ssi: adding permit buddy %s to local list\n", curitem->name); |
2991 | 4060 name = g_strdup(normalize(curitem->name)); |
4061 gc->permit = g_slist_append(gc->permit, name); | |
4062 build_allow_list(); | |
4063 tmp++; | |
4064 } | |
4065 } | |
4066 break; | |
4067 | |
2995 | 4068 case 0x0003: /* Deny buddy */ |
2991 | 4069 if (curitem->name) { |
4070 GSList *list; | |
4071 for (list=gc->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); | |
4072 if (!list) { | |
4073 char *name; | |
2995 | 4074 debug_printf("ssi: adding deny buddy %s to local list\n", curitem->name); |
2991 | 4075 name = g_strdup(normalize(curitem->name)); |
4076 gc->deny = g_slist_append(gc->deny, name); | |
4077 build_block_list(); | |
4078 tmp++; | |
4079 } | |
4080 } | |
4081 break; | |
4082 | |
2995 | 4083 case 0x0004: /* Permit/deny setting */ |
2991 | 4084 if (curitem->data) { |
4085 fu8_t permdeny; | |
3210 | 4086 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != gc->permdeny)) { |
2991 | 4087 debug_printf("ssi: changing permdeny from %d to %d\n", gc->permdeny, permdeny); |
4088 gc->permdeny = permdeny; | |
2995 | 4089 tmp++; |
2991 | 4090 } |
4091 } | |
4092 break; | |
3109 | 4093 |
4094 case 0x0005: /* Presence setting */ | |
4095 /* We don't want to change Gaim's setting because it applies to all accounts */ | |
4096 break; | |
2991 | 4097 } /* End of switch on curitem->type */ |
4098 } /* End of for loop */ | |
4099 if (tmp) | |
4100 do_export(gc); | |
4101 | |
4102 /* Add from local list to server list */ | |
4103 if (gc) { | |
3017 | 4104 GSList *cur; |
4105 | |
2991 | 4106 /* Buddies */ |
3017 | 4107 cur = gc->groups; |
4108 while (cur) { | |
4109 GSList *curbud; | |
2991 | 4110 tmp = 0; |
3017 | 4111 for (curbud=((struct group*)cur->data)->members; curbud; curbud=curbud->next) |
3210 | 4112 if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) |
2991 | 4113 tmp++; |
4114 if (tmp) { | |
3466 | 4115 sns = malloc(tmp*sizeof(char*)); |
3017 | 4116 tmp = 0; |
4117 for (curbud=((struct group*)cur->data)->members; curbud; curbud=curbud->next) | |
3210 | 4118 if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) { |
3017 | 4119 debug_printf("ssi: adding buddy %s from local list to server list\n", ((struct buddy*)curbud->data)->name); |
4120 sns[tmp] = ((char *)((struct buddy*)curbud->data)->name); | |
4121 tmp++; | |
4122 } | |
4123 aim_ssi_addbuddies(sess, fr->conn, ((struct group*)cur->data)->name, sns, tmp); | |
2991 | 4124 free(sns); |
4125 } | |
3017 | 4126 cur = g_slist_next(cur); |
2991 | 4127 } |
4128 | |
4129 /* Permit list */ | |
4130 if (gc->permit) { | |
4131 tmp = 0; | |
3017 | 4132 for (cur=gc->permit; cur; cur=cur->next) |
3210 | 4133 if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0002)) |
2991 | 4134 tmp++; |
4135 if (tmp) { | |
3466 | 4136 sns = malloc(tmp*sizeof(char*)); |
3017 | 4137 tmp = 0; |
4138 for (cur=gc->permit; cur; cur=cur->next) | |
3210 | 4139 if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0002)) { |
3017 | 4140 debug_printf("ssi: adding permit %s from local list to server list\n", cur->data); |
4141 sns[tmp] = cur->data; | |
4142 tmp++; | |
4143 } | |
4144 aim_ssi_addpord(sess, fr->conn, sns, tmp, AIM_SSI_TYPE_PERMIT); | |
2991 | 4145 free(sns); |
4146 } | |
4147 } | |
4148 | |
4149 /* Deny list */ | |
4150 if (gc->deny) { | |
4151 tmp = 0; | |
3017 | 4152 for (cur=gc->deny; cur; cur=cur->next) |
3210 | 4153 if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0003)) |
2991 | 4154 tmp++; |
4155 if (tmp) { | |
3466 | 4156 sns = malloc(tmp*sizeof(char*)); |
3017 | 4157 tmp = 0; |
4158 for (cur=gc->deny; cur; cur=cur->next) | |
3210 | 4159 if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0003)) { |
3017 | 4160 debug_printf("ssi: adding deny %s from local list to server list\n", cur->data); |
4161 sns[tmp] = cur->data; | |
4162 tmp++; | |
4163 } | |
4164 aim_ssi_addpord(sess, fr->conn, sns, tmp, AIM_SSI_TYPE_DENY); | |
2991 | 4165 free(sns); |
4166 } | |
4167 } | |
3109 | 4168 |
4169 /* Presence settings (idle time visibility) */ | |
3210 | 4170 if ((tmp = aim_ssi_getpresence(sess->ssi.items)) != 0xFFFFFFFF) |
3109 | 4171 if (report_idle && !(tmp & 0x400)) |
4172 aim_ssi_setpresence(sess, fr->conn, tmp | 0x400); | |
3210 | 4173 |
4174 /* Check for maximum number of buddies */ | |
4175 for (cur=gc->groups, tmp=0; cur; cur=g_slist_next(cur)) { | |
3214 | 4176 struct group* gr = (struct group*)cur->data; |
4177 tmp = tmp + g_slist_length(gr->members); | |
4178 } | |
3210 | 4179 if (tmp > odata->rights.maxbuddies) { |
4180 char *dialog_msg = g_strdup_printf(_("The maximum number of buddies allowed in your buddy list is %d, and you have %d." | |
4181 " Until you are below the limit, some buddies will not show up as online."), | |
4182 odata->rights.maxbuddies, tmp); | |
3427 | 4183 do_error_dialog("Maximum buddy list length exceeded.", dialog_msg, GAIM_WARNING); |
3210 | 4184 g_free(dialog_msg); |
4185 } | |
3214 | 4186 |
3210 | 4187 } /* end if (gc) */ |
3092 | 4188 |
2991 | 4189 return 1; |
2086 | 4190 } |
4191 | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4192 static GList *oscar_chat_info(struct gaim_connection *gc) { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4193 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4194 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4195 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4196 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4197 pce->label = _("Join what group:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4198 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4199 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4200 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4201 pce->label = _("Exchange:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4202 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4203 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4204 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4205 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4206 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4207 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4208 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4209 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4210 static void oscar_join_chat(struct gaim_connection *g, GList *data) { |
2086 | 4211 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4212 aim_conn_t *cur; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4213 char *name; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4214 int *exchange; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4215 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4216 if (!data || !data->next) |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4217 return; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4218 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4219 name = data->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4220 exchange = data->next->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4221 |
2086 | 4222 debug_printf("Attempting to join chat room %s.\n", name); |
4223 if ((cur = aim_getconn_type(odata->sess, AIM_CONN_TYPE_CHATNAV))) { | |
4224 debug_printf("chatnav exists, creating room\n"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4225 aim_chatnav_createroom(odata->sess, cur, name, *exchange); |
2086 | 4226 } else { |
4227 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4228 struct create_room *cr = g_new0(struct create_room, 1); |
2086 | 4229 debug_printf("chatnav does not exist, opening chatnav\n"); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4230 cr->exchange = *exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4231 cr->name = g_strdup(name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4232 odata->create_rooms = g_slist_append(odata->create_rooms, cr); |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4233 aim_reqservice(odata->sess, odata->conn, AIM_CONN_TYPE_CHATNAV); |
2086 | 4234 } |
4235 } | |
4236 | |
3466 | 4237 static void oscar_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) { |
2086 | 4238 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
4239 struct chat_connection *ccon = find_oscar_chat(g, id); | |
4240 | |
4241 if (!ccon) | |
4242 return; | |
4243 | |
4244 aim_chat_invite(odata->sess, odata->conn, name, message ? message : "", | |
4245 ccon->exchange, ccon->name, 0x0); | |
4246 } | |
4247 | |
4248 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
4249 struct oscar_data *odata = g ? (struct oscar_data *)g->proto_data : NULL; | |
4250 GSList *bcs = g->buddy_chats; | |
4251 struct conversation *b = NULL; | |
4252 struct chat_connection *c = NULL; | |
4253 int count = 0; | |
4254 | |
4255 while (bcs) { | |
4256 count++; | |
4257 b = (struct conversation *)bcs->data; | |
4258 if (id == b->id) | |
4259 break; | |
4260 bcs = bcs->next; | |
4261 b = NULL; | |
4262 } | |
4263 | |
4264 if (!b) | |
4265 return; | |
4266 | |
4267 debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count); | |
4268 | |
4269 c = find_oscar_chat(g, b->id); | |
4270 if (c != NULL) { | |
4271 if (odata) | |
4272 odata->oscar_chats = g_slist_remove(odata->oscar_chats, c); | |
4273 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4274 gaim_input_remove(c->inpa); |
2086 | 4275 if (g && odata->sess) |
4276 aim_conn_kill(odata->sess, &c->conn); | |
4277 g_free(c->name); | |
4278 g_free(c->show); | |
4279 g_free(c); | |
4280 } | |
4281 /* we do this because with Oscar it doesn't tell us we left */ | |
4282 serv_got_chat_left(g, b->id); | |
4283 } | |
4284 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4285 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
2086 | 4286 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
4287 GSList *bcs = g->buddy_chats; | |
4288 struct conversation *b = NULL; | |
4289 struct chat_connection *c = NULL; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4290 char *buf, *buf2; |
2086 | 4291 int i, j; |
4292 | |
4293 while (bcs) { | |
4294 b = (struct conversation *)bcs->data; | |
4295 if (id == b->id) | |
4296 break; | |
4297 bcs = bcs->next; | |
4298 b = NULL; | |
4299 } | |
4300 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4301 return -EINVAL; |
2086 | 4302 |
4303 bcs = odata->oscar_chats; | |
4304 while (bcs) { | |
4305 c = (struct chat_connection *)bcs->data; | |
4306 if (b == c->cnv) | |
4307 break; | |
4308 bcs = bcs->next; | |
4309 c = NULL; | |
4310 } | |
4311 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4312 return -EINVAL; |
2086 | 4313 |
4314 buf = g_malloc(strlen(message) * 4 + 1); | |
4315 for (i = 0, j = 0; i < strlen(message); i++) { | |
4316 if (message[i] == '\n') { | |
4317 buf[j++] = '<'; | |
4318 buf[j++] = 'B'; | |
4319 buf[j++] = 'R'; | |
4320 buf[j++] = '>'; | |
4321 } else { | |
4322 buf[j++] = message[i]; | |
4323 } | |
4324 } | |
4325 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4326 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4327 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4328 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4329 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4330 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4331 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4332 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4333 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4334 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4335 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4336 |
2086 | 4337 aim_chat_send_im(odata->sess, c->conn, 0, buf, strlen(buf)); |
4338 g_free(buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4339 return 0; |
2086 | 4340 } |
4341 | |
4342 static char **oscar_list_icon(int uc) { | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4343 if (uc == 0) |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4344 return (char **)icon_online_xpm; |
3595 | 4345 if (uc & 0xffff0000) { |
4346 uc >>= 16; | |
3101 | 4347 if (uc & AIM_ICQ_STATE_INVISIBLE) |
4348 return icon_offline_xpm; | |
4349 if (uc & AIM_ICQ_STATE_CHAT) | |
4350 return icon_ffc_xpm; | |
3212 | 4351 if (uc & AIM_ICQ_STATE_DND) |
4352 return icon_dnd_xpm; | |
4353 if (uc & AIM_ICQ_STATE_OUT) | |
4354 return icon_na_xpm; | |
3101 | 4355 if (uc & AIM_ICQ_STATE_BUSY) |
4356 return icon_occ_xpm; | |
4357 if (uc & AIM_ICQ_STATE_AWAY) | |
4358 return icon_away_xpm; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4359 return icon_online_xpm; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4360 } |
3101 | 4361 if (uc & UC_UNAVAILABLE) |
4362 return (char **)away_icon_xpm; | |
3079 | 4363 if (uc & UC_WIRELESS) |
4364 return (char **)wireless_icon_xpm; | |
2689 | 4365 if (uc & UC_AB) |
2679 | 4366 return (char **)ab_xpm; |
2086 | 4367 if (uc & UC_AOL) |
4368 return (char **)aol_icon_xpm; | |
4369 if (uc & UC_ADMIN) | |
4370 return (char **)admin_icon_xpm; | |
4371 if (uc & UC_UNCONFIRMED) | |
4372 return (char **)dt_icon_xpm; | |
2297
a0f6ead876ca
[gaim-migrate @ 2307]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2288
diff
changeset
|
4373 if (uc & UC_NORMAL) |
a0f6ead876ca
[gaim-migrate @ 2307]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2288
diff
changeset
|
4374 return (char **)free_icon_xpm; |
2086 | 4375 return NULL; |
4376 } | |
4377 | |
3952 | 4378 /* |
4379 * This is called after the raw data for a file has been transferred (whether | |
4380 * we are sending or receiving), but there are other files remaining. | |
4381 */ | |
3771 | 4382 void oscar_file_transfer_nextfile(struct gaim_connection *gc, |
3630 | 4383 struct file_transfer *xfer) { |
4384 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
4385 aim_conn_t *conn = oft->conn; | |
4386 aim_session_t *sess = aim_conn_getsess(conn); | |
4387 | |
4388 oft->filesdone++; | |
4389 oft->watcher = gaim_input_add(conn->fd, GAIM_INPUT_READ, | |
4390 oscar_callback, conn); | |
4391 | |
4392 /* If this is an incoming sendfile transfer, we send an OK | |
4393 * message to the sender; if this is an outgoing sendfile, we | |
4394 * will get an OK from the receiver that will be handled in | |
4395 * oscar_sendfile_out_done(), so we don't need to do anything | |
4396 * yet. | |
4397 */ | |
4398 | |
4399 if (oft->type == OFT_SENDFILE_IN) | |
4400 aim_oft_end(sess, conn); | |
4401 } | |
4402 | |
3952 | 4403 /* |
4404 * This is called after the raw data for a file has been transferred (whether | |
4405 * we are sending or receiving), and it is the last file in the set, so we | |
4406 * can tear down the connection. | |
4407 */ | |
3771 | 4408 void oscar_file_transfer_done(struct gaim_connection *gc, |
3630 | 4409 struct file_transfer *xfer) { |
4410 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
4411 aim_conn_t *conn = oft->conn; | |
4412 aim_session_t *sess = aim_conn_getsess(conn); | |
4413 | |
4414 oft->filesdone++; | |
4415 if (oft->type == OFT_SENDFILE_IN) { | |
4416 aim_oft_end(sess, conn); | |
4417 oscar_file_transfer_disconnect(sess, conn); | |
4418 } | |
4419 else if (oft->type == OFT_SENDFILE_OUT) { | |
4420 /* Wait for response before closing connection. */ | |
4421 oft->watcher = gaim_input_add(conn->fd, GAIM_INPUT_READ, | |
4422 oscar_callback, conn); | |
4423 } | |
4424 } | |
4425 | |
3952 | 4426 /* |
4427 * This is called when there is raw data ready to be sent or received; all the | |
4428 * protocol details have been taken care of. | |
4429 */ | |
3630 | 4430 static int oscar_file_transfer_do(aim_session_t *sess, aim_frame_t *fr, ...) { |
4431 struct gaim_connection *gc = sess->aux_data; | |
4432 va_list ap; | |
4433 aim_conn_t *conn; | |
4434 struct oscar_file_transfer *oft; | |
3771 | 4435 struct aim_fileheader_t *fh; |
3752 | 4436 int err; |
3630 | 4437 |
4438 va_start(ap, fr); | |
4439 conn = va_arg(ap, aim_conn_t *); | |
3771 | 4440 fh = va_arg(ap, struct aim_fileheader_t *); |
4441 va_end(ap); | |
3630 | 4442 |
4443 oft = find_oft_by_conn(gc, conn); | |
4444 | |
4445 /* Don't use the regular input handler for the raw data. */ | |
4446 gaim_input_remove(oft->watcher); | |
4447 oft->watcher = 0; | |
4448 | |
4449 if (oft->type == OFT_SENDFILE_IN) { | |
3952 | 4450 /* AAA convert fh->name from UCS-2 to UTF-8 if (fh->nencode == 0x0002) */ |
4451 err = transfer_in_do(oft->xfer, conn->fd, fh->name, fh->size); | |
3630 | 4452 } |
4453 else { | |
3771 | 4454 err = transfer_out_do(oft->xfer, conn->fd, fh->nrecvd); |
3630 | 4455 } |
4456 | |
3752 | 4457 if (err) { |
4458 /* There was an error; cancel the transfer. */ | |
4459 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4460 aim_conn_t *bosconn = od->conn; | |
4461 aim_canceltransfer(sess, bosconn, oft->cookie, | |
4462 oft->sn, AIM_CAPS_SENDFILE); | |
4463 oscar_file_transfer_disconnect(sess, oft->conn); | |
4464 } | |
4465 | |
3630 | 4466 return 0; |
4467 } | |
4468 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4469 static int gaim_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4470 va_list ap; |
4471 struct gaim_connection *gc = sess->aux_data; | |
4472 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4473 aim_conn_t *newconn, *listenerconn; |
2235
5d8b6100a9cc
[gaim-migrate @ 2245]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
4474 struct conversation *cnv; |
2086 | 4475 struct direct_im *dim; |
4476 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4477 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4478 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4479 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4480 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4481 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 4482 va_end(ap); |
4483 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4484 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4485 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4486 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4487 sn = g_strdup(aim_directim_getsn(newconn)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4488 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4489 debug_printf("DirectIM: initiate success to %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4490 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4491 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4492 if (!(cnv = find_conversation(sn))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4493 cnv = new_conversation(sn); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4494 gaim_input_remove(dim->watcher); |
2086 | 4495 dim->conn = newconn; |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4496 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 4497 oscar_callback, dim->conn); |
3008 | 4498 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4499 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4500 g_free(sn); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
4501 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time(NULL), -1); |
2086 | 4502 |
4503 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
4504 gaim_directim_incoming, 0); | |
4505 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
4506 gaim_directim_typing, 0); | |
3033 | 4507 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
2993 | 4508 gaim_update_ui, 0); |
4509 return 1; | |
4510 } | |
4511 | |
4512 static int gaim_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4513 va_list ap; | |
4514 char *sn; | |
4515 double percent; | |
4516 struct gaim_connection *gc = sess->aux_data; | |
4517 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4518 struct conversation *c; | |
4519 struct direct_im *dim; | |
4520 | |
4521 va_start(ap, fr); | |
4522 sn = va_arg(ap, char *); | |
4523 percent = va_arg(ap, double); | |
4524 va_end(ap); | |
4525 | |
2994 | 4526 if (!(dim = find_direct_im(od, sn))) |
4527 return 1; | |
3059 | 4528 if (dim->watcher) { |
4529 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
4530 dim->watcher = 0; | |
4531 } | |
3044 | 4532 while (gtk_events_pending()) |
4533 gtk_main_iteration(); | |
4534 | |
2993 | 4535 if ((c = find_conversation(sn))) |
4536 update_progress(c, percent); | |
4537 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
4538 oscar_callback, dim->conn); | |
2086 | 4539 |
4540 return 1; | |
4541 } | |
4542 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4543 static int gaim_directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4544 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4545 char *msg, *sn; |
3952 | 4546 int len, encoding; |
2086 | 4547 struct gaim_connection *gc = sess->aux_data; |
4548 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4549 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4550 sn = va_arg(ap, char *); |
2086 | 4551 msg = va_arg(ap, char *); |
2993 | 4552 len = va_arg(ap, int); |
3952 | 4553 encoding = va_arg(ap, int); |
2086 | 4554 va_end(ap); |
4555 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4556 debug_printf("Got DirectIM message from %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4557 |
3952 | 4558 /* AAA - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
2993 | 4559 serv_got_im(gc, sn, msg, 0, time(NULL), len); |
2086 | 4560 |
4561 return 1; | |
4562 } | |
4563 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4564 static int gaim_directim_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4565 va_list ap; |
4566 char *sn; | |
2993 | 4567 int typing; |
4568 struct gaim_connection *gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4569 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4570 va_start(ap, fr); |
2086 | 4571 sn = va_arg(ap, char *); |
2993 | 4572 typing = va_arg(ap, int); |
2086 | 4573 va_end(ap); |
4574 | |
2993 | 4575 if (typing) { |
4576 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
4577 debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
3768 | 4578 serv_got_typing(gc,sn,0, TYPING); |
2993 | 4579 } else |
4580 serv_got_typing_stopped(gc,sn); | |
2086 | 4581 return 1; |
4582 } | |
4583 | |
4584 struct ask_do_dir_im { | |
4585 char *who; | |
4586 struct gaim_connection *gc; | |
4587 }; | |
4588 | |
3730 | 4589 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
2086 | 4590 g_free(data); |
4591 } | |
4592 | |
3730 | 4593 static void oscar_direct_im(struct ask_do_dir_im *data) { |
2086 | 4594 struct gaim_connection *gc = data->gc; |
4595 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4596 struct direct_im *dim; | |
4597 | |
4598 dim = find_direct_im(od, data->who); | |
4599 if (dim) { | |
3008 | 4600 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
4601 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
4602 gaim_input_remove(dim->watcher); | |
4603 g_free(dim); | |
4604 debug_printf("Gave up on old direct IM, trying again\n"); | |
4605 } else { | |
3427 | 4606 do_error_dialog("DirectIM already open.", NULL, GAIM_ERROR); |
3008 | 4607 return; |
4608 } | |
2086 | 4609 } |
4610 dim = g_new0(struct direct_im, 1); | |
4611 dim->gc = gc; | |
4612 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
4613 | |
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2713
diff
changeset
|
4614 dim->conn = aim_directim_initiate(od->sess, data->who); |
2086 | 4615 if (dim->conn != NULL) { |
4616 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4617 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 4618 oscar_callback, dim->conn); |
4619 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, | |
4620 gaim_directim_initiate, 0); | |
4621 } else { | |
3427 | 4622 do_error_dialog(_("Unable to open Direct IM"), NULL, GAIM_ERROR); |
2086 | 4623 g_free(dim); |
4624 } | |
4625 } | |
4626 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4627 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
2086 | 4628 char buf[BUF_LONG]; |
4629 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | |
4630 data->who = who; | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4631 data->gc = gc; |
3730 | 4632 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); |
4633 do_ask_dialog(buf, _("Because this reveals your IP address, it may be considered a privacy risk. Do you wish to continue?"), data, _("Connect"), oscar_direct_im, _("Cancel"), oscar_cancel_direct_im); | |
2086 | 4634 } |
4635 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4636 static void oscar_get_away_msg(struct gaim_connection *gc, char *who) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4637 struct oscar_data *od = gc->proto_data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4638 od->evilhack = g_slist_append(od->evilhack, g_strdup(normalize(who))); |
3212 | 4639 if (od->icq) { |
4640 struct buddy *budlight = find_buddy(gc, who); | |
4641 if (budlight) | |
3595 | 4642 if ((budlight->uc >> 16) & (AIM_ICQ_STATE_AWAY || AIM_ICQ_STATE_DND || AIM_ICQ_STATE_OUT || AIM_ICQ_STATE_BUSY || AIM_ICQ_STATE_CHAT)) |
3212 | 4643 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) |
3595 | 4644 aim_send_im_ch2_geticqmessage(od->sess, who, (budlight->uc & 0xffff0000) >> 16); |
3212 | 4645 else { |
3595 | 4646 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
3952 | 4647 char *dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<BR><HR><I>Remote client does not support sending status messages.</I><BR>"), who, state_msg); |
3212 | 4648 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
4649 free(state_msg); | |
4650 free(dialog_msg); | |
4651 } | |
4652 else { | |
3595 | 4653 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
3952 | 4654 char *dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<BR><HR><I>User has no status message.</I><BR>"), who, state_msg); |
3212 | 4655 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
4656 free(state_msg); | |
4657 free(dialog_msg); | |
4658 } | |
4659 else | |
3427 | 4660 do_error_dialog("Could not find contact in local list, therefore unable to request status message.\n", NULL, GAIM_ERROR); |
3212 | 4661 } else |
4662 oscar_get_info(gc, who); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4663 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4664 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4665 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4666 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4667 struct proto_buddy_menu *pbm; |
2086 | 4668 char *n = g_strdup(normalize(gc->username)); |
2833
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4669 struct oscar_data *odata = gc->proto_data; |
2086 | 4670 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4671 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4672 pbm->label = _("Get Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4673 pbm->callback = oscar_get_info; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4674 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4675 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4676 |
3212 | 4677 if (odata->icq) { |
4678 pbm = g_new0(struct proto_buddy_menu, 1); | |
4679 pbm->label = _("Get Status Msg"); | |
4680 pbm->callback = oscar_get_away_msg; | |
4681 pbm->gc = gc; | |
4682 m = g_list_append(m, pbm); | |
4683 } else { | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4684 pbm = g_new0(struct proto_buddy_menu, 1); |
2833
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4685 pbm->label = _("Get Away Msg"); |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4686 pbm->callback = oscar_get_away_msg; |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4687 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4688 m = g_list_append(m, pbm); |
2833
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4689 |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4690 if (strcmp(n, normalize(who))) { |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4691 pbm = g_new0(struct proto_buddy_menu, 1); |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4692 pbm->label = _("Direct IM"); |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4693 pbm->callback = oscar_ask_direct_im; |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4694 pbm->gc = gc; |
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4695 m = g_list_append(m, pbm); |
3752 | 4696 |
4697 pbm = g_new0(struct proto_buddy_menu, 1); | |
4698 pbm->label = _("Send File"); | |
4699 pbm->callback = oscar_ask_send_file; | |
4700 pbm->gc = gc; | |
4701 m = g_list_append(m, pbm); | |
2833
cdbe6e2f0ff2
[gaim-migrate @ 2846]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2822
diff
changeset
|
4702 } |
2086 | 4703 } |
2920 | 4704 |
4705 pbm = g_new0(struct proto_buddy_menu, 1); | |
4706 pbm->label = _("Get Capabilities"); | |
4707 pbm->callback = oscar_get_caps; | |
4708 pbm->gc = gc; | |
4709 m = g_list_append(m, pbm); | |
4710 | |
2086 | 4711 g_free(n); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4712 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4713 return m; |
2086 | 4714 } |
4715 | |
3456 | 4716 static GList *oscar_edit_buddy_menu(struct gaim_connection *gc, char *who) |
4717 { | |
4718 GList *m = NULL; | |
4719 struct proto_buddy_menu *pbm; | |
4720 struct oscar_data *odata = gc->proto_data; | |
4721 | |
4722 if (odata->icq) { | |
4723 pbm = g_new0(struct proto_buddy_menu, 1); | |
4724 pbm->label = _("Get Info"); | |
4725 pbm->callback = oscar_get_info; | |
4726 pbm->gc = gc; | |
4727 m = g_list_append(m, pbm); | |
4728 } | |
4729 | |
4730 return m; | |
4731 } | |
4732 | |
2086 | 4733 static void oscar_set_permit_deny(struct gaim_connection *gc) { |
4734 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
2995 | 4735 if (od->icq) { |
3783 | 4736 GSList *list, *g; |
2995 | 4737 char buf[MAXMSGLEN]; |
4738 int at; | |
4739 | |
4740 switch(gc->permdeny) { | |
4741 case 1: | |
4742 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username); | |
4743 break; | |
4744 case 2: | |
4745 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username); | |
4746 break; | |
4747 case 3: | |
4748 list = gc->permit; | |
4749 at = 0; | |
4750 while (list) { | |
4751 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
4752 list = list->next; | |
4753 } | |
4754 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
4755 break; | |
4756 case 4: | |
4757 list = gc->deny; | |
4758 at = 0; | |
4759 while (list) { | |
4760 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
4761 list = list->next; | |
4762 } | |
4763 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
4764 break; | |
3782 | 4765 case 5: |
3783 | 4766 g = gc->groups; |
4151 | 4767 at = 0; |
3782 | 4768 while (g) { |
4769 list = ((struct group *)g->data)->members; | |
4770 while (list) { | |
4151 | 4771 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", ((struct buddy *)list->data)->name); |
3782 | 4772 list = list->next; |
4773 } | |
4774 g = g->next; | |
4775 } | |
4776 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
4777 break; | |
4778 default: | |
2995 | 4779 break; |
2086 | 4780 } |
2995 | 4781 signoff_blocked(gc); |
4782 } else { | |
4783 if (od->sess->ssi.received_data) | |
3210 | 4784 aim_ssi_setpermdeny(od->sess, od->conn, gc->permdeny, 0xffffffff); |
2086 | 4785 } |
4786 } | |
4787 | |
4788 static void oscar_add_permit(struct gaim_connection *gc, char *who) { | |
2991 | 4789 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4790 if (od->icq) { |
4791 if (gc->permdeny != 3) return; | |
4792 oscar_set_permit_deny(gc); | |
4793 } else { | |
4794 debug_printf("ssi: About to add a permit\n"); | |
4795 if (od->sess->ssi.received_data) | |
3466 | 4796 aim_ssi_addpord(od->sess, od->conn, (const char **) &who, 1, AIM_SSI_TYPE_PERMIT); |
2995 | 4797 } |
2086 | 4798 } |
4799 | |
4800 static void oscar_add_deny(struct gaim_connection *gc, char *who) { | |
2991 | 4801 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4802 if (od->icq) { |
4803 if (gc->permdeny != 4) return; | |
4804 oscar_set_permit_deny(gc); | |
4805 } else { | |
4806 debug_printf("ssi: About to add a deny\n"); | |
4807 if (od->sess->ssi.received_data) | |
3466 | 4808 aim_ssi_addpord(od->sess, od->conn, (const char **) &who, 1, AIM_SSI_TYPE_DENY); |
2995 | 4809 } |
2086 | 4810 } |
4811 | |
4812 static void oscar_rem_permit(struct gaim_connection *gc, char *who) { | |
2991 | 4813 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4814 if (od->icq) { |
4815 if (gc->permdeny != 3) return; | |
4816 oscar_set_permit_deny(gc); | |
4817 } else { | |
4818 debug_printf("ssi: About to delete a permit\n"); | |
4819 if (od->sess->ssi.received_data) | |
3595 | 4820 aim_ssi_delpord(od->sess, od->conn, (const char **) &who, 1, AIM_SSI_TYPE_PERMIT); |
2995 | 4821 } |
2086 | 4822 } |
4823 | |
4824 static void oscar_rem_deny(struct gaim_connection *gc, char *who) { | |
2991 | 4825 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4826 if (od->icq) { |
4827 if (gc->permdeny != 4) return; | |
4828 oscar_set_permit_deny(gc); | |
4829 } else { | |
4830 debug_printf("ssi: About to delete a deny\n"); | |
4831 if (od->sess->ssi.received_data) | |
3595 | 4832 aim_ssi_delpord(od->sess, od->conn, (const char **) &who, 1, AIM_SSI_TYPE_DENY); |
2995 | 4833 } |
2086 | 4834 } |
4835 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4836 static GList *oscar_away_states(struct gaim_connection *gc) |
2086 | 4837 { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4838 struct oscar_data *od = gc->proto_data; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4839 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4840 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4841 if (!od->icq) |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4842 return g_list_append(m, GAIM_AWAY_CUSTOM); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4843 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4844 m = g_list_append(m, "Online"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4845 m = g_list_append(m, "Away"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4846 m = g_list_append(m, "Do Not Disturb"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4847 m = g_list_append(m, "Not Available"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4848 m = g_list_append(m, "Occupied"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4849 m = g_list_append(m, "Free For Chat"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4850 m = g_list_append(m, "Invisible"); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4851 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4852 return m; |
2086 | 4853 } |
4854 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4855 static void oscar_change_email(struct gaim_connection *gc, char *email) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4856 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4857 struct oscar_data *od = gc->proto_data; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4858 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
|
4859 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4860 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4861 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4862 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4863 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4864 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4865 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4866 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4867 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4868 |
2979 | 4869 static void oscar_format_screenname(struct gaim_connection *gc, char *nick) { |
4870 struct oscar_data *od = gc->proto_data; | |
3031 | 4871 if (!strcmp(normalize(nick), normalize(gc->username))) { |
2979 | 4872 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
4873 od->setnick = TRUE; | |
4874 od->newsn = g_strdup(nick); | |
4875 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
4876 } else { | |
4877 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
4878 } | |
4879 } else { | |
3427 | 4880 do_error_dialog("The new formatting is invalid.", |
4881 "Screenname formatting can change only capitalization and whitespace.", GAIM_ERROR); | |
2979 | 4882 } |
4883 } | |
4884 | |
2086 | 4885 static void oscar_do_action(struct gaim_connection *gc, char *act) |
4886 { | |
4887 struct oscar_data *od = gc->proto_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4888 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
2086 | 4889 |
4890 if (!strcmp(act, "Set User Info")) { | |
4891 show_set_info(gc); | |
4892 } else if (!strcmp(act, "Change Password")) { | |
4893 show_change_passwd(gc); | |
2979 | 4894 } else if (!strcmp(act, "Format Screenname")) { |
4895 do_prompt_dialog("New screenname formatting:", | |
4896 gc->displayname, gc, oscar_format_screenname, NULL); | |
2086 | 4897 } else if (!strcmp(act, "Confirm Account")) { |
4898 if (!conn) { | |
4899 od->conf = TRUE; | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4900 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
2086 | 4901 } else |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4902 aim_admin_reqconfirm(od->sess, conn); |
2086 | 4903 } else if (!strcmp(act, "Display Current Registered Address")) { |
4904 if (!conn) { | |
4905 od->reqemail = TRUE; | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4906 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
2086 | 4907 } else |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4908 aim_admin_getinfo(od->sess, conn, 0x11); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4909 } else if (!strcmp(act, "Change Current Registered Address")) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4910 do_prompt_dialog("Change Address To: ", NULL, gc, oscar_change_email, NULL); |
2086 | 4911 } else if (!strcmp(act, "Search for Buddy by Email")) { |
4912 show_find_email(gc); | |
4913 } | |
4914 } | |
4915 | |
4916 static GList *oscar_actions() | |
4917 { | |
4918 GList *m = NULL; | |
4919 | |
4920 m = g_list_append(m, "Set User Info"); | |
4921 m = g_list_append(m, NULL); | |
4922 m = g_list_append(m, "Change Password"); | |
2979 | 4923 m = g_list_append(m, "Format Screenname"); |
2086 | 4924 m = g_list_append(m, "Confirm Account"); |
4925 m = g_list_append(m, "Display Current Registered Address"); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4926 m = g_list_append(m, "Change Current Registered Address"); |
2086 | 4927 m = g_list_append(m, NULL); |
4928 m = g_list_append(m, "Search for Buddy by Email"); | |
4929 | |
4930 return m; | |
4931 } | |
4932 | |
3466 | 4933 static void oscar_change_passwd(struct gaim_connection *gc, const char *old, const char *new) |
2086 | 4934 { |
4935 struct oscar_data *od = gc->proto_data; | |
4936 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
4937 od->chpass = TRUE; | |
4938 od->oldp = g_strdup(old); | |
4939 od->newp = g_strdup(new); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4940 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
2086 | 4941 } else { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4942 aim_admin_changepasswd(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), |
2086 | 4943 new, old); |
4944 } | |
4945 } | |
4946 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4947 static void oscar_convo_closed(struct gaim_connection *gc, char *who) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4948 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4949 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4950 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4951 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4952 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4953 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4954 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4955 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4956 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4957 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4958 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4959 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4960 |
4151 | 4961 static fu32_t check_encoding(const char *utf8) |
4962 { | |
4963 int i = 0; | |
4964 fu32_t encodingflag = 0; | |
4965 | |
4966 /* Determine how we can send this message. Per the | |
4967 * warnings elsewhere in this file, these little | |
4968 * checks determine the simplest encoding we can use | |
4969 * for a given message send using it. */ | |
4970 while (utf8[i]) { | |
4971 if ((unsigned char)utf8[i] > 0x7f) { | |
4972 /* not ASCII! */ | |
4973 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
4974 break; | |
4975 } | |
4976 i++; | |
4977 } | |
4978 while (utf8[i]) { | |
4979 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
4980 * followed by 0xc0-0xc3 in the second */ | |
4981 if ((unsigned char)utf8[i] < 0x80) { | |
4982 i++; | |
4983 continue; | |
4984 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
4985 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
4986 i += 2; | |
4987 continue; | |
4988 } | |
4989 encodingflag = AIM_IMFLAGS_UNICODE; | |
4990 break; | |
4991 } | |
4992 | |
4993 return encodingflag; | |
4994 } | |
4995 | |
4996 static fu32_t parse_encoding(const char *enc) | |
4997 { | |
4998 char *charset; | |
4999 | |
5000 /* If anything goes wrong, fall back on ASCII and print a message */ | |
5001 charset = strstr(enc, "charset="); | |
5002 if (charset == NULL) { | |
5003 debug_printf("No charset specified for info, assuming ASCII\n"); | |
5004 return 0; | |
5005 } | |
5006 charset += 8; | |
5007 if (!strcmp(charset, "\"us-ascii\"")) { | |
5008 return 0; | |
5009 } else if (!strcmp(charset, "\"unicode-2-0\"")) { | |
5010 return AIM_IMFLAGS_UNICODE; | |
5011 } else { | |
5012 debug_printf("Unrecognized character set '%s', using ASCII\n", charset); | |
5013 return 0; | |
5014 } | |
5015 } | |
3035 | 5016 |
2086 | 5017 static struct prpl *my_protocol = NULL; |
5018 | |
3630 | 5019 G_MODULE_EXPORT void oscar_init(struct prpl *ret) { |
3572 | 5020 struct proto_user_opt *puo; |
2086 | 5021 ret->protocol = PROTO_OSCAR; |
3694 | 5022 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE; |
3858 | 5023 ret->name = g_strdup("AIM/ICQ"); |
2086 | 5024 ret->list_icon = oscar_list_icon; |
5025 ret->away_states = oscar_away_states; | |
5026 ret->actions = oscar_actions; | |
5027 ret->do_action = oscar_do_action; | |
5028 ret->buddy_menu = oscar_buddy_menu; | |
3456 | 5029 ret->edit_buddy_menu = oscar_edit_buddy_menu; |
2086 | 5030 ret->login = oscar_login; |
5031 ret->close = oscar_close; | |
5032 ret->send_im = oscar_send_im; | |
2993 | 5033 ret->send_typing = oscar_send_typing; |
2086 | 5034 ret->set_info = oscar_set_info; |
5035 ret->get_info = oscar_get_info; | |
5036 ret->set_away = oscar_set_away; | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5037 ret->get_away = oscar_get_away; |
2086 | 5038 ret->set_dir = oscar_set_dir; |
5039 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
5040 ret->dir_search = oscar_dir_search; | |
5041 ret->set_idle = oscar_set_idle; | |
5042 ret->change_passwd = oscar_change_passwd; | |
5043 ret->add_buddy = oscar_add_buddy; | |
5044 ret->add_buddies = oscar_add_buddies; | |
3140 | 5045 ret->group_buddy = oscar_move_buddy; |
3348 | 5046 ret->rename_group = oscar_rename_group; |
3771 | 5047 ret->file_transfer_cancel = oscar_file_transfer_cancel; |
5048 ret->file_transfer_in = oscar_file_transfer_in; | |
5049 ret->file_transfer_out = oscar_file_transfer_out; | |
5050 ret->file_transfer_data_chunk = oscar_file_transfer_data_chunk; | |
5051 ret->file_transfer_nextfile = oscar_file_transfer_nextfile; | |
5052 ret->file_transfer_done = oscar_file_transfer_done; | |
2086 | 5053 ret->remove_buddy = oscar_remove_buddy; |
2991 | 5054 ret->remove_buddies = oscar_remove_buddies; |
2086 | 5055 ret->add_permit = oscar_add_permit; |
5056 ret->add_deny = oscar_add_deny; | |
5057 ret->rem_permit = oscar_rem_permit; | |
5058 ret->rem_deny = oscar_rem_deny; | |
5059 ret->set_permit_deny = oscar_set_permit_deny; | |
5060 ret->warn = oscar_warn; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5061 ret->chat_info = oscar_chat_info; |
2086 | 5062 ret->join_chat = oscar_join_chat; |
5063 ret->chat_invite = oscar_chat_invite; | |
5064 ret->chat_leave = oscar_chat_leave; | |
5065 ret->chat_whisper = NULL; | |
5066 ret->chat_send = oscar_chat_send; | |
5067 ret->keepalive = oscar_keepalive; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5068 ret->convo_closed = oscar_convo_closed; |
2086 | 5069 |
3572 | 5070 puo = g_new0(struct proto_user_opt, 1); |
5071 puo->label = g_strdup("Auth Host:"); | |
5072 puo->def = g_strdup("login.oscar.aol.com"); | |
5073 puo->pos = USEROPT_AUTH; | |
5074 ret->user_opts = g_list_append(ret->user_opts, puo); | |
5075 | |
5076 puo = g_new0(struct proto_user_opt, 1); | |
5077 puo->label = g_strdup("Auth Port:"); | |
5078 puo->def = g_strdup("5190"); | |
5079 puo->pos = USEROPT_AUTHPORT; | |
5080 ret->user_opts = g_list_append(ret->user_opts, puo); | |
5081 | |
2086 | 5082 my_protocol = ret; |
5083 } | |
5084 | |
5085 #ifndef STATIC | |
5086 | |
3630 | 5087 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 5088 { |
3572 | 5089 oscar_init(prpl); |
5090 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 5091 } |
5092 | |
5093 #endif |