Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 4908:fd0a760786c5
[gaim-migrate @ 5242]
Someone remind me when I'm not busy to fix this the right way.
or someone else fix this the right way.
Oh, and I'm alive again.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 29 Mar 2003 05:03:45 +0000 |
parents | ad589b887af9 |
children | d9b6b5ae34e4 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
24 #include <config.h> |
2086 | 25 #endif |
26 | |
3664 | 27 #include <sys/types.h> |
4617 | 28 /* this must happen before sys/socket.h or freebsd won't compile */ |
3664 | 29 |
3630 | 30 #ifndef _WIN32 |
2086 | 31 #include <netdb.h> |
32 #include <netinet/in.h> | |
33 #include <arpa/inet.h> | |
3630 | 34 #include <sys/socket.h> |
35 #include <unistd.h> | |
36 #endif | |
37 | |
38 #include <errno.h> | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
39 #include <ctype.h> |
2086 | 40 #include <string.h> |
41 #include <stdlib.h> | |
42 #include <stdio.h> | |
43 #include <time.h> | |
44 #include <sys/stat.h> | |
3630 | 45 #include <signal.h> |
46 | |
4608 | 47 #include "gaim.h" |
2086 | 48 #include "multi.h" |
49 #include "prpl.h" | |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4366
diff
changeset
|
50 #include "core.h" |
4889 | 51 #include "proxy.h" |
2086 | 52 #include "aim.h" |
53 | |
3630 | 54 #ifdef _WIN32 |
55 #include "win32dep.h" | |
56 #endif | |
57 | |
2086 | 58 /* constants to identify proto_opts */ |
59 #define USEROPT_AUTH 0 | |
60 #define USEROPT_AUTHPORT 1 | |
61 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
62 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
63 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
64 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
65 #define UC_NORMAL 0x10 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
66 #define UC_AB 0x20 |
3079 | 67 #define UC_WIRELESS 0x40 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
68 |
2086 | 69 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
70 | |
4249 | 71 static struct prpl *my_protocol = NULL; |
72 | |
3630 | 73 /* For win32 compatability */ |
74 G_MODULE_IMPORT GSList *connections; | |
75 G_MODULE_IMPORT int report_idle; | |
76 | |
4811 | 77 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE; |
78 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE; | |
3458 | 79 |
4665 | 80 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
81 static fu8_t features_icq[] = {0x01, 0x06}; | |
2086 | 82 |
83 struct oscar_data { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
84 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
85 aim_conn_t *conn; |
2086 | 86 |
87 guint cnpa; | |
88 guint paspa; | |
3694 | 89 guint emlpa; |
4804 | 90 guint icopa; |
2086 | 91 |
4823 | 92 gboolean iconconnecting; |
93 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
94 GSList *create_rooms; |
2086 | 95 |
96 gboolean conf; | |
97 gboolean reqemail; | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
98 gboolean setemail; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
99 char *email; |
2979 | 100 gboolean setnick; |
101 char *newsn; | |
2086 | 102 gboolean chpass; |
103 char *oldp; | |
104 char *newp; | |
105 | |
106 GSList *oscar_chats; | |
107 GSList *direct_ims; | |
3630 | 108 GSList *file_transfers; |
4738 | 109 GHashTable *buddyinfo; |
4804 | 110 GSList *requesticon; |
2086 | 111 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
112 gboolean killme; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
113 gboolean icq; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
114 GSList *evilhack; |
4804 | 115 guint icontimer; |
2993 | 116 |
117 struct { | |
4230 | 118 guint maxwatchers; /* max users who can watch you */ |
2993 | 119 guint maxbuddies; /* max users you can watch */ |
4230 | 120 guint maxgroups; /* max groups in server list */ |
2993 | 121 guint maxpermits; /* max users on permit list */ |
122 guint maxdenies; /* max users on deny list */ | |
123 guint maxsiglen; /* max size (bytes) of profile */ | |
124 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
125 } rights; | |
2086 | 126 }; |
127 | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
128 struct create_room { |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
129 char *name; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
130 int exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
131 }; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
132 |
2086 | 133 struct chat_connection { |
134 char *name; | |
135 char *show; /* AOL did something funny to us */ | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
136 fu16_t exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
137 fu16_t instance; |
2086 | 138 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
|
139 aim_conn_t *conn; |
2086 | 140 int inpa; |
141 int id; | |
142 struct gaim_connection *gc; /* i hate this. */ | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
143 struct gaim_conversation *cnv; /* bah. */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
144 int maxlen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
145 int maxvis; |
2086 | 146 }; |
147 | |
148 struct direct_im { | |
149 struct gaim_connection *gc; | |
150 char name[80]; | |
151 int watcher; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 aim_conn_t *conn; |
3008 | 153 gboolean connected; |
2086 | 154 }; |
155 | |
156 struct ask_direct { | |
157 struct gaim_connection *gc; | |
158 char *sn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
159 char ip[64]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
160 fu8_t cookie[8]; |
2086 | 161 }; |
162 | |
4617 | 163 /* BBB */ |
164 struct oscar_xfer_data { | |
165 fu8_t cookie[8]; | |
4898 | 166 gchar *proxyip; |
4656 | 167 gchar *clientip; |
4898 | 168 gchar *verifiedip; |
4646 | 169 fu32_t modtime; |
170 fu32_t checksum; | |
3630 | 171 aim_conn_t *conn; |
4617 | 172 struct gaim_xfer *xfer; |
173 struct gaim_connection *gc; | |
3630 | 174 }; |
175 | |
4738 | 176 /* Various PRPL-specific buddy info that we want to keep track of */ |
177 struct buddyinfo { | |
178 time_t signon; | |
179 int caps; | |
180 gboolean typingnot; | |
181 | |
182 unsigned long ico_len; | |
183 unsigned long ico_csum; | |
184 time_t ico_time; | |
185 gboolean ico_need; | |
186 | |
187 unsigned long ico_me_len; | |
188 unsigned long ico_me_csum; | |
189 time_t ico_me_time; | |
190 gboolean ico_informed; | |
4804 | 191 |
4853 | 192 fu16_t iconcsumlen; |
193 fu8_t iconcsum[30]; | |
2086 | 194 }; |
195 | |
4230 | 196 struct name_data { |
3141 | 197 struct gaim_connection *gc; |
4230 | 198 gchar *name; |
3453 | 199 gchar *nick; |
3141 | 200 }; |
201 | |
4230 | 202 static void gaim_free_name_data(struct name_data *data) { |
203 g_free(data->name); | |
204 g_free(data->nick); | |
205 g_free(data); | |
206 } | |
207 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
208 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { |
2086 | 209 GSList *d = od->direct_ims; |
210 struct direct_im *m = NULL; | |
211 | |
212 while (d) { | |
213 m = (struct direct_im *)d->data; | |
4355 | 214 if (!aim_sncmp(who, m->name)) |
4269 | 215 return m; |
2086 | 216 d = d->next; |
217 } | |
218 | |
4269 | 219 return NULL; |
2086 | 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 | |
4656 | 282 /* All the libfaim->gaim callback functions */ |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
283 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
|
284 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
285 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
286 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
287 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
288 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
289 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
290 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
|
291 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); |
3212 | 292 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
|
293 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
|
294 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
295 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
296 static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
297 static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
298 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
|
299 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
3694 | 300 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
4804 | 301 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); |
302 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
303 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
304 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
305 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
306 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
307 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
308 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); |
4649 | 309 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); |
3952 | 310 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
311 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); |
3952 | 312 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
313 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); |
3694 | 314 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); |
4804 | 315 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
316 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); |
3595 | 317 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); |
2993 | 318 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
|
319 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
320 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
321 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
|
322 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
|
323 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
324 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
325 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
326 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); |
4759 | 327 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); |
4624 | 328 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
329 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); |
4230 | 330 #ifndef NOSSI |
4642 | 331 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); |
2991 | 332 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); |
333 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
4230 | 334 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); |
335 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); | |
336 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
337 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
338 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
339 #endif | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
340 |
4656 | 341 /* for DirectIM/image transfer */ |
4617 | 342 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); |
343 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
344 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
345 static int gaim_update_ui (aim_session_t *, aim_frame_t *, ...); | |
3630 | 346 |
4656 | 347 /* for file transfer */ |
348 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
349 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
350 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
351 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
352 | |
4804 | 353 /* for icons */ |
354 static gboolean gaim_icon_timerfunc(gpointer data); | |
355 | |
4151 | 356 static fu32_t check_encoding(const char *utf8); |
357 static fu32_t parse_encoding(const char *enc); | |
358 | |
2086 | 359 static char *msgerrreason[] = { |
4056 | 360 N_("Invalid error"), |
361 N_("Invalid SNAC"), | |
362 N_("Rate to host"), | |
363 N_("Rate to client"), | |
364 N_("Not logged in"), | |
365 N_("Service unavailable"), | |
366 N_("Service not defined"), | |
367 N_("Obsolete SNAC"), | |
368 N_("Not supported by host"), | |
369 N_("Not supported by client"), | |
370 N_("Refused by client"), | |
371 N_("Reply too big"), | |
372 N_("Responses lost"), | |
373 N_("Request denied"), | |
374 N_("Busted SNAC payload"), | |
375 N_("Insufficient rights"), | |
376 N_("In local permit/deny"), | |
377 N_("Too evil (sender)"), | |
378 N_("Too evil (receiver)"), | |
379 N_("User temporarily unavailable"), | |
380 N_("No match"), | |
381 N_("List overflow"), | |
382 N_("Request ambiguous"), | |
383 N_("Queue full"), | |
384 N_("Not while on AOL") | |
2086 | 385 }; |
386 static int msgerrreasonlen = 25; | |
387 | |
4617 | 388 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
389 struct gaim_connection *gc = sess->aux_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
390 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
391 struct gaim_conversation *cnv; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
392 struct direct_im *dim; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
393 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
394 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
395 |
4617 | 396 sn = g_strdup(aim_odc_getsn(conn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
397 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
398 debug_printf("%s disconnected Direct IM.\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
399 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
400 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
401 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
402 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
403 |
3008 | 404 if (dim->connected) |
405 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
406 else | |
407 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn); | |
408 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
409 if ((cnv = gaim_find_conversation(sn))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
410 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
411 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
412 gaim_conversation_update_progress(cnv, 100); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
413 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
414 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
|
415 g_free(sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
416 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
417 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
418 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
419 |
4617 | 420 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
421 aim_conn_t *conn = (aim_conn_t *)data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
422 aim_session_t *sess = aim_conn_getsess(conn); |
2086 | 423 struct gaim_connection *gc = sess ? sess->aux_data : NULL; |
4617 | 424 struct oscar_data *od; |
2086 | 425 |
426 if (!gc) { | |
427 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
428 debug_printf("oscar callback for closed connection (1).\n"); | |
429 return; | |
430 } | |
431 | |
4617 | 432 od = (struct oscar_data *)gc->proto_data; |
2086 | 433 |
434 if (!g_slist_find(connections, gc)) { | |
435 /* oh boy. this is probably bad. i guess the only thing we | |
436 * can really do is return? */ | |
437 debug_printf("oscar callback for closed connection (2).\n"); | |
438 return; | |
439 } | |
440 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
441 if (condition & GAIM_INPUT_READ) { |
4617 | 442 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
443 debug_printf("got information on rendezvous listener\n"); | |
444 if (aim_handlerendconnect(od->sess, conn) < 0) { | |
445 debug_printf("connection error (rendezvous listener)\n"); | |
446 aim_conn_kill(od->sess, &conn); | |
2086 | 447 } |
448 } else { | |
4617 | 449 if (aim_get_command(od->sess, conn) >= 0) { |
450 aim_rxdispatch(od->sess); | |
451 if (od->killme) | |
2086 | 452 signoff(gc); |
453 } else { | |
454 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
4617 | 455 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
4236 | 456 debug_printf("major connection error\n"); |
3074 | 457 hide_login_progress_error(gc, _("Disconnected.")); |
2086 | 458 signoff(gc); |
459 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
460 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
461 char buf[BUF_LONG]; | |
462 debug_printf("disconnected from chat room %s\n", c->name); | |
463 c->conn = NULL; | |
464 if (c->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
465 gaim_input_remove(c->inpa); |
2086 | 466 c->inpa = 0; |
467 c->fd = -1; | |
4617 | 468 aim_conn_kill(od->sess, &conn); |
3574 | 469 snprintf(buf, sizeof(buf), _("You have been disconnected from chat room %s."), c->name); |
3427 | 470 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 471 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
4617 | 472 if (od->cnpa > 0) |
473 gaim_input_remove(od->cnpa); | |
474 od->cnpa = 0; | |
2086 | 475 debug_printf("removing chatnav input watcher\n"); |
4617 | 476 while (od->create_rooms) { |
477 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
478 g_free(cr->name); |
4617 | 479 od->create_rooms = |
480 g_slist_remove(od->create_rooms, cr); | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
481 g_free(cr); |
3427 | 482 do_error_dialog(_("Chat is currently unavailable"), NULL, GAIM_ERROR); |
2086 | 483 } |
4617 | 484 aim_conn_kill(od->sess, &conn); |
2086 | 485 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
4617 | 486 if (od->paspa > 0) |
487 gaim_input_remove(od->paspa); | |
488 od->paspa = 0; | |
2086 | 489 debug_printf("removing authconn input watcher\n"); |
4617 | 490 aim_conn_kill(od->sess, &conn); |
3694 | 491 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
4617 | 492 if (od->emlpa > 0) |
493 gaim_input_remove(od->emlpa); | |
494 od->emlpa = 0; | |
3694 | 495 debug_printf("removing email input watcher\n"); |
4617 | 496 aim_conn_kill(od->sess, &conn); |
4804 | 497 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
498 if (od->icopa > 0) | |
499 gaim_input_remove(od->icopa); | |
500 od->icopa = 0; | |
501 debug_printf("removing icon input watcher\n"); | |
502 aim_conn_kill(od->sess, &conn); | |
2086 | 503 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
504 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
4617 | 505 gaim_odc_disconnect(od->sess, conn); |
506 aim_conn_kill(od->sess, &conn); | |
2086 | 507 } else { |
4194 | 508 debug_printf("holy crap! generic connection error! %hu\n", |
2086 | 509 conn->type); |
4617 | 510 aim_conn_kill(od->sess, &conn); |
2086 | 511 } |
512 } | |
513 } | |
514 } | |
515 } | |
516 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
517 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
2086 | 518 char *s = g_strdup_vprintf(format, va); |
519 char buf[256]; | |
520 char *t; | |
521 struct gaim_connection *gc = sess->aux_data; | |
522 | |
523 g_snprintf(buf, sizeof(buf), "%s %d: ", gc->username, level); | |
524 t = g_strconcat(buf, s, NULL); | |
525 debug_printf(t); | |
526 if (t[strlen(t)-1] != '\n') | |
527 debug_printf("\n"); | |
528 g_free(t); | |
529 g_free(s); | |
530 } | |
531 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
532 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 533 { |
534 struct gaim_connection *gc = data; | |
4617 | 535 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
536 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
537 aim_conn_t *conn; |
2086 | 538 |
539 if (!g_slist_find(connections, gc)) { | |
540 close(source); | |
541 return; | |
542 } | |
543 | |
4617 | 544 od = gc->proto_data; |
545 sess = od->sess; | |
2086 | 546 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 547 |
548 conn->fd = source; | |
2086 | 549 |
550 if (source < 0) { | |
551 hide_login_progress(gc, _("Couldn't connect to host")); | |
552 signoff(gc); | |
553 return; | |
554 } | |
555 | |
556 aim_conn_completeconnect(sess, conn); | |
4617 | 557 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
4236 | 558 debug_printf("Password sent, waiting for response\n"); |
2086 | 559 } |
560 | |
4491 | 561 static void oscar_login(struct gaim_account *account) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
562 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
563 aim_conn_t *conn; |
2086 | 564 char buf[256]; |
4491 | 565 struct gaim_connection *gc = new_gaim_conn(account); |
4617 | 566 struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); |
2086 | 567 |
4491 | 568 if (isdigit(*account->username)) { |
4617 | 569 od->icq = TRUE; |
3064 | 570 gc->password[8] = 0; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
571 } else { |
2918
4df759d607f3
[gaim-migrate @ 2931]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2916
diff
changeset
|
572 gc->flags |= OPT_CONN_HTML; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
573 gc->flags |= OPT_CONN_AUTO_RESP; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
574 } |
4738 | 575 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
2086 | 576 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
577 sess = g_new0(aim_session_t, 1); |
2086 | 578 |
579 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
580 aim_setdebuggingcb(sess, oscar_debug); | |
581 | |
582 /* we need an immediate queue because we don't use a while-loop to | |
583 * see if things need to be sent. */ | |
584 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
4617 | 585 od->sess = sess; |
2086 | 586 sess->aux_data = gc; |
587 | |
588 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
589 if (conn == NULL) { | |
4236 | 590 debug_printf("internal connection error\n"); |
2086 | 591 hide_login_progress(gc, _("Unable to login to AIM")); |
592 signoff(gc); | |
593 return; | |
594 } | |
595 | |
596 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | |
597 set_login_progress(gc, 2, buf); | |
598 | |
4649 | 599 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2086 | 600 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
601 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
602 | |
603 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 604 if (proxy_connect(account, account->proto_opt[USEROPT_AUTH][0] ? |
4491 | 605 account->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, |
606 account->proto_opt[USEROPT_AUTHPORT][0] ? | |
607 atoi(account->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
608 oscar_login_connect, gc) < 0) { | |
2086 | 609 hide_login_progress(gc, _("Couldn't connect to host")); |
610 signoff(gc); | |
611 return; | |
612 } | |
613 aim_request_login(sess, conn, gc->username); | |
614 } | |
615 | |
616 static void oscar_close(struct gaim_connection *gc) { | |
4617 | 617 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
618 | |
619 while (od->oscar_chats) { | |
620 struct chat_connection *n = od->oscar_chats->data; | |
2086 | 621 if (n->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
622 gaim_input_remove(n->inpa); |
2086 | 623 g_free(n->name); |
624 g_free(n->show); | |
4617 | 625 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
2086 | 626 g_free(n); |
627 } | |
4617 | 628 while (od->direct_ims) { |
629 struct direct_im *n = od->direct_ims->data; | |
2086 | 630 if (n->watcher > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
631 gaim_input_remove(n->watcher); |
4617 | 632 od->direct_ims = g_slist_remove(od->direct_ims, n); |
2086 | 633 g_free(n); |
634 } | |
4617 | 635 /* BBB */ |
636 while (od->file_transfers) { | |
637 struct gaim_xfer *xfer; | |
638 xfer = (struct gaim_xfer *)od->file_transfers->data; | |
639 gaim_xfer_destroy(xfer); | |
3630 | 640 } |
4804 | 641 while (od->requesticon) { |
642 char *sn = od->requesticon->data; | |
643 od->requesticon = g_slist_remove(od->requesticon, sn); | |
644 free(sn); | |
645 } | |
4738 | 646 g_hash_table_destroy(od->buddyinfo); |
4617 | 647 while (od->evilhack) { |
648 g_free(od->evilhack->data); | |
649 od->evilhack = g_slist_remove(od->evilhack, od->evilhack->data); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
650 } |
4617 | 651 while (od->create_rooms) { |
652 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
653 g_free(cr->name); |
4617 | 654 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
655 g_free(cr); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
656 } |
4617 | 657 if (od->email) |
658 g_free(od->email); | |
659 if (od->newp) | |
660 g_free(od->newp); | |
661 if (od->oldp) | |
662 g_free(od->oldp); | |
2086 | 663 if (gc->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
664 gaim_input_remove(gc->inpa); |
4617 | 665 if (od->cnpa > 0) |
666 gaim_input_remove(od->cnpa); | |
667 if (od->paspa > 0) | |
668 gaim_input_remove(od->paspa); | |
669 if (od->emlpa > 0) | |
670 gaim_input_remove(od->emlpa); | |
4804 | 671 if (od->icopa > 0) |
672 gaim_input_remove(od->icopa); | |
4832 | 673 if (od->icopa > 0) |
674 gaim_input_remove(od->icopa); | |
675 if (od->icontimer) | |
676 g_source_remove(od->icontimer); | |
4617 | 677 aim_session_kill(od->sess); |
678 g_free(od->sess); | |
679 od->sess = NULL; | |
2086 | 680 g_free(gc->proto_data); |
681 gc->proto_data = NULL; | |
4236 | 682 debug_printf("Signed off.\n"); |
2086 | 683 } |
684 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
685 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 686 struct gaim_connection *gc = data; |
4617 | 687 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
688 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
689 aim_conn_t *bosconn; |
2086 | 690 |
691 if (!g_slist_find(connections, gc)) { | |
692 close(source); | |
693 return; | |
694 } | |
695 | |
4617 | 696 od = gc->proto_data; |
697 sess = od->sess; | |
698 bosconn = od->conn; | |
4366 | 699 bosconn->fd = source; |
2086 | 700 |
701 if (source < 0) { | |
702 hide_login_progress(gc, _("Could Not Connect")); | |
703 signoff(gc); | |
704 return; | |
705 } | |
706 | |
707 aim_conn_completeconnect(sess, bosconn); | |
4617 | 708 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
2086 | 709 set_login_progress(gc, 4, _("Connection established, cookie sent")); |
710 } | |
711 | |
4617 | 712 /* BBB */ |
4656 | 713 /* |
714 * This little area in oscar.c is the nexus of file transfer code, | |
715 * so I wrote a little explanation of what happens. I am such a | |
716 * ninja. | |
717 * | |
718 * The series of events for a file send is: | |
719 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
720 * -User chooses a file and oscar_xfer_init is called. It establishs a | |
721 * listening socket, then asks the remote user to connect to us (and | |
722 * gives them the file name, port, IP, etc.) | |
723 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
724 * in oscar_sendfile_estblsh) | |
725 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
726 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
727 * connection. | |
728 * -We get drunk because file transfer kicks ass. | |
729 * | |
730 * The series of events for a file receive is: | |
731 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
732 * -Gaim user selects file to name and location to save file to and | |
733 * oscar_xfer_init is called | |
734 * -It connects to the remote user using the IP they gave us earlier | |
735 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
736 * them an AIM_CB_OFT_ACK. | |
737 * -They begin to send us lots of raw data. | |
738 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
739 * the connectionn. | |
740 */ | |
741 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
742 | |
743 /* XXX - This function is pretty ugly */ | |
744 static void | |
745 oscar_xfer_init(struct gaim_xfer *xfer) | |
746 { | |
747 struct gaim_connection *gc; | |
748 struct oscar_data *od; | |
749 struct oscar_xfer_data *xfer_data; | |
750 | |
751 debug_printf("in oscar_xfer_init\n"); | |
752 if (!(xfer_data = xfer->data)) | |
753 return; | |
754 if (!(gc = xfer_data->gc)) | |
755 return; | |
756 if (!(od = gc->proto_data)) | |
757 return; | |
758 | |
759 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
760 int i; | |
761 char ip[4]; | |
762 gchar **ipsplit; | |
763 | |
764 if (xfer->local_ip) { | |
765 ipsplit = g_strsplit(xfer->local_ip, ".", 4); | |
766 for (i=0; ipsplit[i]; i++) | |
767 ip[i] = atoi(ipsplit[i]); | |
768 g_strfreev(ipsplit); | |
769 } else { | |
770 memset(ip, 0x00, 4); | |
771 } | |
772 | |
773 xfer->filename = g_path_get_basename(xfer->local_filename); | |
774 xfer_data->checksum = aim_oft_checksum_file(xfer->local_filename); | |
775 | |
776 /* | |
777 * First try the port specified earlier (5190). If that fails, try a | |
778 * few random ports. Maybe we need a way to tell libfaim to listen | |
779 * for multiple connections on one listener socket. | |
780 */ | |
781 xfer_data->conn = aim_sendfile_listen(od->sess, xfer_data->cookie, ip, xfer->local_port); | |
782 for (i=0; (i<5 && !xfer_data->conn); i++) { | |
783 xfer->local_port = (rand() % (65535-1024)) + 1024; | |
784 xfer_data->conn = aim_sendfile_listen(od->sess, xfer_data->cookie, ip, xfer->local_port); | |
785 } | |
786 debug_printf("port is %d, ip is %hhd.%hhd.%hhd.%hhd\n", xfer->local_port, ip[0], ip[1], ip[2], ip[3]); | |
787 if (xfer_data->conn) { | |
788 xfer->watcher = gaim_input_add(xfer_data->conn->fd, GAIM_INPUT_READ, oscar_callback, xfer_data->conn); | |
789 aim_im_sendch2_sendfile_ask(od->sess, xfer_data->cookie, xfer->who, ip, xfer->local_port, xfer->filename, 1, xfer->size); | |
790 aim_conn_addhandler(od->sess, xfer_data->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
791 } else { | |
792 do_error_dialog(_("File Transfer Aborted"), _("Unable to establish listener socket."), GAIM_ERROR); | |
793 /* XXX - The below line causes a crash because the transfer is canceled before the "Ok" callback on the file selection thing exists, I think */ | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
794 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 795 } |
796 } else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
797 xfer_data->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
798 if (xfer_data->conn) { | |
799 xfer_data->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
800 aim_conn_addhandler(od->sess, xfer_data->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
801 xfer_data->conn->fd = xfer->fd = proxy_connect(gc->account, xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
802 if (xfer->fd == -1) { | |
803 do_error_dialog(_("File Transfer Aborted"), _("Unable to establish file descriptor."), GAIM_ERROR); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
804 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 805 } |
806 } else { | |
807 do_error_dialog(_("File Transfer Aborted"), _("Unable to create new connection."), GAIM_ERROR); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
808 /* gaim_xfer_cancel_remote(xfer); */ |
4656 | 809 /* Try a different port? Ask them to connect to us? */ |
810 } | |
811 | |
812 } | |
813 } | |
814 | |
815 static void | |
816 oscar_xfer_start(struct gaim_xfer *xfer) | |
817 { | |
818 /* struct gaim_connection *gc; | |
819 struct oscar_data *od; | |
820 struct oscar_xfer_data *xfer_data; | |
821 | |
822 if (!(xfer_data = xfer->data)) | |
823 return; | |
824 if (!(gc = xfer_data->gc)) | |
825 return; | |
826 if (!(od = gc->proto_data)) | |
827 return; | |
828 | |
829 od = xfer_data->od; | |
830 */ | |
831 debug_printf("AAA - in oscar_xfer_start\n"); | |
832 | |
833 /* I'm pretty sure we don't need to do jack here. Nor Jill. */ | |
834 } | |
835 | |
836 static void | |
837 oscar_xfer_end(struct gaim_xfer *xfer) | |
838 { | |
839 struct gaim_connection *gc; | |
840 struct oscar_data *od; | |
841 struct oscar_xfer_data *xfer_data; | |
842 | |
843 debug_printf("AAA - in oscar_xfer_end\n"); | |
844 if (!(xfer_data = xfer->data)) | |
845 return; | |
846 | |
847 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) | |
848 aim_oft_sendheader(xfer_data->conn->sessv, xfer_data->conn, AIM_CB_OFT_DONE, xfer_data->cookie, xfer->filename, 1, 1, xfer->size, xfer->size, xfer_data->modtime, xfer_data->checksum, 0x02, xfer->size, xfer_data->checksum); | |
849 | |
4898 | 850 g_free(xfer_data->proxyip); |
4656 | 851 g_free(xfer_data->clientip); |
4898 | 852 g_free(xfer_data->verifiedip); |
4656 | 853 |
854 if ((gc = xfer_data->gc)) { | |
855 if ((od = gc->proto_data)) | |
856 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
857 } | |
858 | |
859 g_free(xfer_data); | |
860 xfer->data = NULL; | |
861 } | |
862 | |
863 static void | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
864 oscar_xfer_cancel_send(struct gaim_xfer *xfer) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
865 { |
4763 | 866 struct gaim_connection *gc; |
867 struct oscar_data *od; | |
868 struct oscar_xfer_data *xfer_data; | |
869 aim_conn_t *conn; | |
870 | |
871 debug_printf("AAA - in oscar_xfer_cancel_send\n"); | |
872 if (!(xfer_data = xfer->data)) | |
873 return; | |
874 | |
875 if ((conn = xfer_data->conn)) { | |
876 aim_session_t *sess; | |
877 if ((sess = conn->sessv)) | |
878 if (xfer_data->cookie && xfer->who) | |
879 aim_im_sendch2_sendfile_cancel(sess, xfer_data->cookie, xfer->who, AIM_CAPS_SENDFILE); | |
880 } | |
881 | |
4898 | 882 g_free(xfer_data->proxyip); |
4763 | 883 g_free(xfer_data->clientip); |
4898 | 884 g_free(xfer_data->verifiedip); |
4763 | 885 |
886 if ((gc = xfer_data->gc)) | |
887 if ((od = gc->proto_data)) | |
888 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
889 | |
890 g_free(xfer_data); | |
891 xfer->data = NULL; | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
892 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
893 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
894 static void |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
895 oscar_xfer_cancel_recv(struct gaim_xfer *xfer) |
4656 | 896 { |
897 struct gaim_connection *gc; | |
898 struct oscar_data *od; | |
899 struct oscar_xfer_data *xfer_data; | |
900 aim_conn_t *conn; | |
901 | |
4763 | 902 debug_printf("AAA - in oscar_xfer_cancel_recv\n"); |
4656 | 903 if (!(xfer_data = xfer->data)) |
904 return; | |
905 | |
906 if ((conn = xfer_data->conn)) { | |
907 aim_session_t *sess; | |
908 if ((sess = conn->sessv)) | |
909 if (xfer_data->cookie && xfer->who) | |
910 aim_im_sendch2_sendfile_cancel(sess, xfer_data->cookie, xfer->who, AIM_CAPS_SENDFILE); | |
911 } | |
912 | |
4898 | 913 g_free(xfer_data->proxyip); |
4656 | 914 g_free(xfer_data->clientip); |
4898 | 915 g_free(xfer_data->verifiedip); |
4656 | 916 |
917 if ((gc = xfer_data->gc)) | |
918 if ((od = gc->proto_data)) | |
919 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
920 | |
921 g_free(xfer_data); | |
922 xfer->data = NULL; | |
923 } | |
924 | |
925 static void | |
926 oscar_xfer_ack(struct gaim_xfer *xfer, const char *buffer, size_t size) | |
927 { | |
928 struct oscar_xfer_data *xfer_data; | |
929 | |
930 if (!(xfer_data = xfer->data)) | |
931 return; | |
932 | |
933 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
934 /* | |
935 * If we're done sending, intercept the socket from the core ft code | |
936 * and wait for the other guy to send the "done" OFT packet. | |
937 */ | |
938 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
939 gaim_input_remove(xfer->watcher); | |
940 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, xfer_data->conn); | |
941 xfer->fd = 0; | |
942 gaim_xfer_set_completed(xfer, TRUE); | |
943 } | |
944 } else if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
945 /* Update our rolling checksum */ | |
946 /* xfer_data->checksum = aim_oft_checksum_chunk(buffer, size, xfer_data->checksum); */ | |
947 } | |
948 } | |
949 | |
950 static struct gaim_xfer * | |
951 oscar_find_xfer_by_cookie(GSList *fts, const char *ck) | |
952 { | |
953 struct gaim_xfer *xfer; | |
954 struct oscar_xfer_data *data; | |
955 | |
956 while (fts) { | |
957 xfer = fts->data; | |
958 data = xfer->data; | |
959 | |
960 if (data && !strcmp(data->cookie, ck)) | |
961 return xfer; | |
962 | |
963 fts = g_slist_next(fts); | |
964 } | |
965 | |
966 return NULL; | |
967 } | |
968 | |
969 static struct gaim_xfer * | |
970 oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) | |
971 { | |
972 struct gaim_xfer *xfer; | |
973 struct oscar_xfer_data *data; | |
974 | |
975 while (fts) { | |
976 xfer = fts->data; | |
977 data = xfer->data; | |
978 | |
979 if (data && (conn == data->conn)) | |
980 return xfer; | |
981 | |
982 fts = g_slist_next(fts); | |
983 } | |
984 | |
985 return NULL; | |
986 } | |
987 | |
4617 | 988 static void oscar_ask_sendfile(struct gaim_connection *gc, char *destsn) { |
3630 | 989 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
3752 | 990 |
4617 | 991 /* You want to send a file to someone else, you're so generous */ |
992 struct gaim_xfer *xfer; | |
993 struct oscar_xfer_data *xfer_data; | |
994 | |
995 /* Create the oscar-specific data */ | |
996 xfer_data = g_malloc0(sizeof(struct oscar_xfer_data)); | |
997 xfer_data->gc = gc; | |
998 | |
999 /* Build the file transfer handle */ | |
1000 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, destsn); | |
1001 xfer_data->xfer = xfer; | |
1002 xfer->data = xfer_data; | |
1003 | |
1004 /* Set the info about the incoming file */ | |
4650 | 1005 if (od && od->sess) { |
4617 | 1006 aim_conn_t *conn; |
4650 | 1007 if ((conn = aim_conn_findbygroup(od->sess, 0x0004))) |
1008 xfer->local_ip = gaim_getip_from_fd(conn->fd); | |
4617 | 1009 } |
1010 xfer->local_port = 5190; | |
1011 | |
1012 /* Setup our I/O op functions */ | |
1013 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
1014 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
1015 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1016 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1017 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4656 | 1018 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
4617 | 1019 |
1020 /* Keep track of this transfer for later */ | |
1021 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
1022 | |
1023 /* Now perform the request */ | |
1024 gaim_xfer_request(xfer); | |
3630 | 1025 } |
1026 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1027 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1028 va_list ap; |
2704 | 1029 struct aim_authresp_info *info; |
4452 | 1030 int i, rc; |
1031 char *host; int port; | |
4491 | 1032 struct gaim_account *account; |
2704 | 1033 aim_conn_t *bosconn; |
2086 | 1034 |
1035 struct gaim_connection *gc = sess->aux_data; | |
1036 struct oscar_data *od = gc->proto_data; | |
4491 | 1037 account = gc->account; |
1038 port = account->proto_opt[USEROPT_AUTHPORT][0] ? | |
1039 atoi(account->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
2086 | 1040 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1041 va_start(ap, fr); |
2704 | 1042 info = va_arg(ap, struct aim_authresp_info *); |
2086 | 1043 va_end(ap); |
1044 | |
2704 | 1045 debug_printf("inside auth_resp (Screen name: %s)\n", info->sn); |
1046 | |
4293 | 1047 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
4056 | 1048 char buf[256]; |
2704 | 1049 switch (info->errorcode) { |
2086 | 1050 case 0x05: |
1051 /* Incorrect nick/password */ | |
1052 hide_login_progress(gc, _("Incorrect nickname or password.")); | |
1053 break; | |
1054 case 0x11: | |
1055 /* Suspended account */ | |
1056 hide_login_progress(gc, _("Your account is currently suspended.")); | |
1057 break; | |
3498 | 1058 case 0x14: |
1059 /* service temporarily unavailable */ | |
1060 hide_login_progress(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); | |
1061 break; | |
2086 | 1062 case 0x18: |
1063 /* connecting too frequently */ | |
1064 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.")); | |
1065 break; | |
1066 case 0x1c: | |
1067 /* client too old */ | |
4056 | 1068 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), WEBSITE); |
1069 hide_login_progress(gc, buf); | |
2086 | 1070 break; |
1071 default: | |
1072 hide_login_progress(gc, _("Authentication Failed")); | |
1073 break; | |
1074 } | |
4194 | 1075 debug_printf("Login Error Code 0x%04hx\n", info->errorcode); |
2704 | 1076 debug_printf("Error URL: %s\n", info->errorurl); |
2086 | 1077 od->killme = TRUE; |
1078 return 1; | |
1079 } | |
1080 | |
1081 | |
4194 | 1082 debug_printf("Reg status: %hu\n", info->regstatus); |
2704 | 1083 if (info->email) { |
1084 debug_printf("Email: %s\n", info->email); | |
2086 | 1085 } else { |
1086 debug_printf("Email is NULL\n"); | |
1087 } | |
2704 | 1088 debug_printf("BOSIP: %s\n", info->bosip); |
2086 | 1089 debug_printf("Closing auth connection...\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1090 aim_conn_kill(sess, &fr->conn); |
2086 | 1091 |
1092 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
1093 if (bosconn == NULL) { | |
1094 hide_login_progress(gc, _("Internal Error")); | |
1095 od->killme = TRUE; | |
1096 return 0; | |
1097 } | |
1098 | |
4649 | 1099 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1100 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
2086 | 1101 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
1102 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
1103 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
2993 | 1104 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
2086 | 1105 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
1106 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
1107 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
1108 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
1109 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
1110 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
3212 | 1111 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
2086 | 1112 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
1113 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
1114 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
1115 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
1116 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
3595 | 1117 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
2086 | 1118 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); |
1119 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
1120 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
|
1121 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
2086 | 1122 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
1123 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
1124 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
1125 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
1126 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1127 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
|
1128 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
|
1129 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
4759 | 1130 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
4624 | 1131 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
4230 | 1132 #ifndef NOSSI |
4642 | 1133 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
2991 | 1134 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
1135 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
1136 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
4230 | 1137 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
1138 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); | |
1139 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
1140 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
1141 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
1142 #endif | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1143 |
2086 | 1144 ((struct oscar_data *)gc->proto_data)->conn = bosconn; |
2704 | 1145 for (i = 0; i < (int)strlen(info->bosip); i++) { |
1146 if (info->bosip[i] == ':') { | |
1147 port = atoi(&(info->bosip[i+1])); | |
2086 | 1148 break; |
1149 } | |
1150 } | |
2704 | 1151 host = g_strndup(info->bosip, i); |
2086 | 1152 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
4634 | 1153 rc = proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
2086 | 1154 g_free(host); |
4366 | 1155 if (rc < 0) { |
2086 | 1156 hide_login_progress(gc, _("Could Not Connect")); |
1157 od->killme = TRUE; | |
1158 return 0; | |
1159 } | |
4293 | 1160 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1161 gaim_input_remove(gc->inpa); |
2704 | 1162 |
2086 | 1163 return 1; |
1164 } | |
1165 | |
1166 struct pieceofcrap { | |
1167 struct gaim_connection *gc; | |
1168 unsigned long offset; | |
1169 unsigned long len; | |
1170 char *modname; | |
1171 int fd; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1172 aim_conn_t *conn; |
2086 | 1173 unsigned int inpa; |
1174 }; | |
1175 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1176 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
2086 | 1177 { |
1178 struct pieceofcrap *pos = data; | |
1179 struct oscar_data *od = pos->gc->proto_data; | |
1180 char in = '\0'; | |
1181 int x = 0; | |
1182 unsigned char m[17]; | |
1183 | |
1184 while (read(pos->fd, &in, 1) == 1) { | |
1185 if (in == '\n') | |
1186 x++; | |
1187 else if (in != '\r') | |
1188 x = 0; | |
1189 if (x == 2) | |
1190 break; | |
1191 in = '\0'; | |
1192 } | |
1193 if (in != '\n') { | |
4056 | 1194 char buf[256]; |
1195 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
1196 "this is fixed. Check %s for updates."), WEBSITE); | |
3427 | 1197 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), |
4056 | 1198 buf, GAIM_WARNING); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1199 gaim_input_remove(pos->inpa); |
2086 | 1200 close(pos->fd); |
1201 g_free(pos); | |
1202 return; | |
1203 } | |
1204 read(pos->fd, m, 16); | |
1205 m[16] = '\0'; | |
1206 debug_printf("Sending hash: "); | |
1207 for (x = 0; x < 16; x++) | |
4194 | 1208 debug_printf("%02hhx ", (unsigned char)m[x]); |
2086 | 1209 debug_printf("\n"); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1210 gaim_input_remove(pos->inpa); |
2086 | 1211 close(pos->fd); |
1212 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
1213 g_free(pos); | |
1214 } | |
1215 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1216 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 1217 struct pieceofcrap *pos = data; |
1218 char buf[BUF_LONG]; | |
1219 | |
4366 | 1220 pos->fd = source; |
1221 | |
2086 | 1222 if (source < 0) { |
4056 | 1223 char buf[256]; |
1224 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
1225 "this is fixed. Check %s for updates."), WEBSITE); | |
3427 | 1226 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), |
4056 | 1227 buf, GAIM_WARNING); |
2086 | 1228 if (pos->modname) |
1229 g_free(pos->modname); | |
1230 g_free(pos); | |
1231 return; | |
1232 } | |
1233 | |
1234 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
1235 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
1236 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
1237 write(pos->fd, buf, strlen(buf)); | |
1238 if (pos->modname) | |
1239 g_free(pos->modname); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1240 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
2086 | 1241 return; |
1242 } | |
1243 | |
1244 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
1245 #define AIM_MAX_FILE_SIZE 98304 | |
1246 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1247 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1248 va_list ap; |
1249 struct pieceofcrap *pos; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1250 fu32_t offset, len; |
2086 | 1251 char *modname; |
1252 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1253 va_start(ap, fr); |
4200 | 1254 offset = va_arg(ap, fu32_t); |
1255 len = va_arg(ap, fu32_t); | |
2086 | 1256 modname = va_arg(ap, char *); |
1257 va_end(ap); | |
1258 | |
4194 | 1259 debug_printf("offset: %lu, len: %lu, file: %s\n", offset, len, (modname ? modname : "aim.exe")); |
2086 | 1260 if (len == 0) { |
1261 debug_printf("len is 0, hashing NULL\n"); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1262 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
2086 | 1263 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
1264 return 1; | |
1265 } | |
1266 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
1267 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
1268 char *buf; | |
1269 int i = 8; | |
1270 if (modname) | |
1271 i += strlen(modname); | |
1272 buf = g_malloc(i); | |
1273 i = 0; | |
1274 if (modname) { | |
1275 memcpy(buf, modname, strlen(modname)); | |
1276 i += strlen(modname); | |
1277 } | |
1278 buf[i++] = offset & 0xff; | |
1279 buf[i++] = (offset >> 8) & 0xff; | |
1280 buf[i++] = (offset >> 16) & 0xff; | |
1281 buf[i++] = (offset >> 24) & 0xff; | |
1282 buf[i++] = len & 0xff; | |
1283 buf[i++] = (len >> 8) & 0xff; | |
1284 buf[i++] = (len >> 16) & 0xff; | |
1285 buf[i++] = (len >> 24) & 0xff; | |
1286 debug_printf("len + offset is invalid, hashing request\n"); | |
1287 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | |
1288 g_free(buf); | |
1289 return 1; | |
1290 } | |
1291 */ | |
1292 | |
1293 pos = g_new0(struct pieceofcrap, 1); | |
1294 pos->gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1295 pos->conn = fr->conn; |
2086 | 1296 |
1297 pos->offset = offset; | |
1298 pos->len = len; | |
1299 pos->modname = modname ? g_strdup(modname) : NULL; | |
1300 | |
4634 | 1301 if (proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
4056 | 1302 char buf[256]; |
2086 | 1303 if (pos->modname) |
1304 g_free(pos->modname); | |
1305 g_free(pos); | |
4056 | 1306 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
1307 "this is fixed. Check %s for updates."), WEBSITE); | |
4452 | 1308 do_error_dialog(_("Gaim was Unable to get a valid login hash."), |
4056 | 1309 buf, GAIM_WARNING); |
2086 | 1310 } |
1311 | |
1312 return 1; | |
1313 } | |
1314 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1315 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1316 char *key; |
1317 va_list ap; | |
1318 struct gaim_connection *gc = sess->aux_data; | |
4617 | 1319 struct oscar_data *od = gc->proto_data; |
2086 | 1320 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1321 va_start(ap, fr); |
2086 | 1322 key = va_arg(ap, char *); |
1323 va_end(ap); | |
1324 | |
4617 | 1325 if (od->icq) { |
3458 | 1326 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
1327 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); | |
1328 } else { | |
1329 #if 0 | |
1330 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
1331 #endif | |
1332 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
1333 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); | |
1334 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1335 |
2086 | 1336 return 1; |
1337 } | |
1338 | |
2675 | 1339 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
2647 | 1340 struct gaim_connection *gc = sess->aux_data; |
1341 struct chat_connection *chatcon; | |
1342 static int id = 1; | |
1343 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1344 aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); |
2675 | 1345 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
1346 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
1347 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
1348 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
1349 | |
2672 | 1350 aim_clientready(sess, fr->conn); |
2675 | 1351 |
2647 | 1352 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
1353 chatcon->id = id; | |
1354 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
1355 | |
1356 return 1; | |
1357 } | |
1358 | |
2675 | 1359 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
1360 | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1361 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
2647 | 1362 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
2675 | 1363 |
1364 aim_clientready(sess, fr->conn); | |
1365 | |
1366 aim_chatnav_reqrights(sess, fr->conn); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1367 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1368 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1369 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1370 |
3694 | 1371 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
1372 | |
1373 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1374 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
1375 | |
1376 aim_email_sendcookies(sess, fr->conn); | |
1377 aim_email_activate(sess, fr->conn); | |
1378 aim_clientready(sess, fr->conn); | |
1379 | |
1380 return 1; | |
1381 } | |
1382 | |
4804 | 1383 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
1384 struct gaim_connection *gc = sess->aux_data; | |
1385 struct oscar_data *od = gc->proto_data; | |
1386 | |
1387 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
1388 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
1389 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
1390 | |
1391 aim_clientready(sess, fr->conn); | |
1392 | |
4823 | 1393 od->iconconnecting = FALSE; |
1394 | |
4804 | 1395 if (od->icontimer) |
1396 g_source_remove(od->icontimer); | |
1397 od->icontimer = g_timeout_add(100, gaim_icon_timerfunc, gc); | |
1398 | |
1399 return 1; | |
1400 } | |
1401 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1402 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
2086 | 1403 struct gaim_connection *gc = data; |
4617 | 1404 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1405 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1406 aim_conn_t *tstconn; |
2086 | 1407 |
1408 if (!g_slist_find(connections, gc)) { | |
1409 close(source); | |
1410 return; | |
1411 } | |
1412 | |
4617 | 1413 od = gc->proto_data; |
1414 sess = od->sess; | |
2086 | 1415 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
4366 | 1416 tstconn->fd = source; |
2086 | 1417 |
1418 if (source < 0) { | |
1419 aim_conn_kill(sess, &tstconn); | |
1420 debug_printf("unable to connect to chatnav server\n"); | |
1421 return; | |
1422 } | |
1423 | |
1424 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1425 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2086 | 1426 debug_printf("chatnav: connected\n"); |
1427 } | |
1428 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1429 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1430 { |
1431 struct gaim_connection *gc = data; | |
4617 | 1432 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1433 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1434 aim_conn_t *tstconn; |
2086 | 1435 |
1436 if (!g_slist_find(connections, gc)) { | |
1437 close(source); | |
1438 return; | |
1439 } | |
1440 | |
4617 | 1441 od = gc->proto_data; |
1442 sess = od->sess; | |
2086 | 1443 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
4366 | 1444 tstconn->fd = source; |
2086 | 1445 |
1446 if (source < 0) { | |
1447 aim_conn_kill(sess, &tstconn); | |
1448 debug_printf("unable to connect to authorizer\n"); | |
1449 return; | |
1450 } | |
1451 | |
1452 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1453 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
2086 | 1454 debug_printf("chatnav: connected\n"); |
1455 } | |
1456 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1457 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1458 { |
1459 struct chat_connection *ccon = data; | |
1460 struct gaim_connection *gc = ccon->gc; | |
4617 | 1461 struct oscar_data *od; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1462 aim_session_t *sess; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1463 aim_conn_t *tstconn; |
2086 | 1464 |
1465 if (!g_slist_find(connections, gc)) { | |
1466 close(source); | |
1467 g_free(ccon->show); | |
1468 g_free(ccon->name); | |
1469 g_free(ccon); | |
1470 return; | |
1471 } | |
1472 | |
4617 | 1473 od = gc->proto_data; |
1474 sess = od->sess; | |
2086 | 1475 tstconn = ccon->conn; |
4366 | 1476 tstconn->fd = source; |
2086 | 1477 |
1478 if (source < 0) { | |
1479 aim_conn_kill(sess, &tstconn); | |
1480 g_free(ccon->show); | |
1481 g_free(ccon->name); | |
1482 g_free(ccon); | |
1483 return; | |
1484 } | |
1485 | |
1486 aim_conn_completeconnect(sess, ccon->conn); | |
4617 | 1487 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
1488 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
2086 | 1489 } |
1490 | |
3694 | 1491 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
1492 struct gaim_connection *gc = data; | |
4617 | 1493 struct oscar_data *od; |
3694 | 1494 aim_session_t *sess; |
1495 aim_conn_t *tstconn; | |
1496 | |
1497 if (!g_slist_find(connections, gc)) { | |
1498 close(source); | |
1499 return; | |
1500 } | |
1501 | |
4617 | 1502 od = gc->proto_data; |
1503 sess = od->sess; | |
3694 | 1504 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
4366 | 1505 tstconn->fd = source; |
3694 | 1506 |
1507 if (source < 0) { | |
1508 aim_conn_kill(sess, &tstconn); | |
1509 debug_printf("unable to connect to email server\n"); | |
1510 return; | |
1511 } | |
1512 | |
1513 aim_conn_completeconnect(sess, tstconn); | |
4617 | 1514 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
3694 | 1515 debug_printf("email: connected\n"); |
1516 } | |
1517 | |
4804 | 1518 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
1519 struct gaim_connection *gc = data; | |
1520 struct oscar_data *od; | |
1521 aim_session_t *sess; | |
1522 aim_conn_t *tstconn; | |
1523 | |
1524 if (!g_slist_find(connections, gc)) { | |
1525 close(source); | |
1526 return; | |
1527 } | |
1528 | |
1529 od = gc->proto_data; | |
1530 sess = od->sess; | |
1531 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
1532 tstconn->fd = source; | |
1533 | |
1534 if (source < 0) { | |
1535 aim_conn_kill(sess, &tstconn); | |
1536 debug_printf("unable to connect to icon server\n"); | |
1537 return; | |
1538 } | |
1539 | |
1540 aim_conn_completeconnect(sess, tstconn); | |
1541 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
1542 debug_printf("icon: connected\n"); | |
1543 } | |
1544 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1545 /* 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
|
1546 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1547 struct gaim_connection *gc = sess->aux_data; |
4491 | 1548 struct gaim_account *account = gc->account; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1549 aim_conn_t *tstconn; |
4452 | 1550 int i; |
2086 | 1551 char *host; |
1552 int port; | |
4821 | 1553 va_list ap; |
1554 struct aim_redirect_data *redir; | |
2086 | 1555 |
4491 | 1556 port = account->proto_opt[USEROPT_AUTHPORT][0] ? |
1557 atoi(account->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
2086 | 1558 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1559 va_start(ap, fr); |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1560 redir = va_arg(ap, struct aim_redirect_data *); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1561 va_end(ap); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1562 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1563 for (i = 0; i < (int)strlen(redir->ip); i++) { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1564 if (redir->ip[i] == ':') { |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1565 port = atoi(&(redir->ip[i+1])); |
2086 | 1566 break; |
1567 } | |
1568 } | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1569 host = g_strndup(redir->ip, i); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1570 |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1571 switch(redir->group) { |
2086 | 1572 case 0x7: /* Authorizer */ |
1573 debug_printf("Reconnecting with authorizor...\n"); | |
1574 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
1575 if (tstconn == NULL) { | |
1576 debug_printf("unable to reconnect with authorizer\n"); | |
1577 g_free(host); | |
1578 return 1; | |
1579 } | |
4649 | 1580 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1581 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
2086 | 1582 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
1583 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
1584 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
1585 | |
1586 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 1587 if (proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
2086 | 1588 aim_conn_kill(sess, &tstconn); |
1589 debug_printf("unable to reconnect with authorizer\n"); | |
1590 g_free(host); | |
1591 return 1; | |
1592 } | |
4293 | 1593 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1594 break; |
1595 | |
2086 | 1596 case 0xd: /* ChatNav */ |
1597 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
1598 if (tstconn == NULL) { | |
1599 debug_printf("unable to connect to chatnav server\n"); | |
1600 g_free(host); | |
1601 return 1; | |
1602 } | |
4649 | 1603 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1604 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
2086 | 1605 |
1606 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 1607 if (proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
2086 | 1608 aim_conn_kill(sess, &tstconn); |
1609 debug_printf("unable to connect to chatnav server\n"); | |
1610 g_free(host); | |
1611 return 1; | |
1612 } | |
4293 | 1613 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1614 break; |
1615 | |
1616 case 0xe: { /* Chat */ | |
2086 | 1617 struct chat_connection *ccon; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1618 |
2086 | 1619 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
1620 if (tstconn == NULL) { | |
1621 debug_printf("unable to connect to chat server\n"); | |
1622 g_free(host); | |
1623 return 1; | |
1624 } | |
1625 | |
4649 | 1626 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
2675 | 1627 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
1628 | |
2086 | 1629 ccon = g_new0(struct chat_connection, 1); |
1630 ccon->conn = tstconn; | |
1631 ccon->gc = gc; | |
1632 ccon->fd = -1; | |
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1633 ccon->name = g_strdup(redir->chat.room); |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1634 ccon->exchange = redir->chat.exchange; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1635 ccon->instance = redir->chat.instance; |
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1636 ccon->show = extract_name(redir->chat.room); |
4634 | 1637 |
2086 | 1638 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
4634 | 1639 if (proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
2086 | 1640 aim_conn_kill(sess, &tstconn); |
1641 debug_printf("unable to connect to chat server\n"); | |
1642 g_free(host); | |
1643 g_free(ccon->show); | |
1644 g_free(ccon->name); | |
1645 g_free(ccon); | |
1646 return 1; | |
1647 } | |
4293 | 1648 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
4194 | 1649 debug_printf("Connected to chat room %s exchange %hu\n", ccon->name, ccon->exchange); |
1650 } break; | |
3694 | 1651 |
4804 | 1652 case 0x0010: { /* icon */ |
1653 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
1654 debug_printf("unable to connect to icon server\n"); | |
1655 g_free(host); | |
1656 return 1; | |
1657 } | |
1658 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
1659 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
1660 | |
1661 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
1662 if (proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { | |
1663 aim_conn_kill(sess, &tstconn); | |
1664 debug_printf("unable to connect to icon server\n"); | |
1665 g_free(host); | |
1666 return 1; | |
1667 } | |
1668 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
1669 } break; | |
1670 | |
3694 | 1671 case 0x0018: { /* email */ |
1672 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
1673 debug_printf("unable to connect to email server\n"); | |
1674 g_free(host); | |
1675 return 1; | |
1676 } | |
4649 | 1677 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
3694 | 1678 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
1679 | |
1680 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
4634 | 1681 if (proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
3694 | 1682 aim_conn_kill(sess, &tstconn); |
1683 debug_printf("unable to connect to email server\n"); | |
1684 g_free(host); | |
1685 return 1; | |
1686 } | |
4293 | 1687 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
3694 | 1688 } break; |
1689 | |
2086 | 1690 default: /* huh? */ |
4194 | 1691 debug_printf("got redirect for unknown service 0x%04hx\n", redir->group); |
2086 | 1692 break; |
1693 } | |
1694 | |
1695 g_free(host); | |
1696 return 1; | |
1697 } | |
1698 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1699 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 1700 struct gaim_connection *gc = sess->aux_data; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1701 struct oscar_data *od = gc->proto_data; |
4738 | 1702 struct buddyinfo *bi; |
2993 | 1703 time_t time_idle = 0, signon = 0; |
1704 int type = 0; | |
1705 int caps = 0; | |
2086 | 1706 va_list ap; |
4738 | 1707 aim_userinfo_t *info; |
4194 | 1708 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1709 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1710 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1711 va_end(ap); |
1712 | |
2993 | 1713 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
1714 caps = info->capabilities; | |
3267 | 1715 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
1716 type |= UC_AB; | |
1717 | |
4766 | 1718 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
1719 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
1720 type |= UC_UNCONFIRMED; | |
1721 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
1722 type |= UC_ADMIN; | |
1723 if (info->flags & AIM_FLAG_AOL) | |
1724 type |= UC_AOL; | |
1725 if (info->flags & AIM_FLAG_FREE) | |
1726 type |= UC_NORMAL; | |
1727 if (info->flags & AIM_FLAG_AWAY) | |
1728 type |= UC_UNAVAILABLE; | |
1729 if (info->flags & AIM_FLAG_WIRELESS) | |
1730 type |= UC_WIRELESS; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1731 } |
2993 | 1732 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
3595 | 1733 type = (info->icqinfo.status << 16); |
3013 | 1734 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
1735 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
2993 | 1736 type |= UC_UNAVAILABLE; |
3013 | 1737 } |
2993 | 1738 } |
1739 | |
1740 if (caps & AIM_CAPS_ICQ) | |
1741 caps ^= AIM_CAPS_ICQ; | |
1742 | |
1743 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
2086 | 1744 time(&time_idle); |
1745 time_idle -= info->idletime*60; | |
2993 | 1746 } |
1747 | |
1748 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
1749 signon = time(NULL) - info->sessionlen; | |
2086 | 1750 |
4269 | 1751 if (!aim_sncmp(gc->username, info->sn)) |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1752 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1753 |
4738 | 1754 bi = g_hash_table_lookup(od->buddyinfo, normalize(info->sn)); |
1755 if (!bi) { | |
1756 bi = g_new0(struct buddyinfo, 1); | |
1757 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(info->sn)), bi); | |
1758 } | |
1759 bi->signon = info->onlinesince ? info->onlinesince : (info->sessionlen + time(NULL)); | |
4829 | 1760 if (caps) |
1761 bi->caps = caps; | |
4739 | 1762 bi->typingnot = FALSE; |
1763 bi->ico_informed = FALSE; | |
4732 | 1764 |
4804 | 1765 /* Server stored icon stuff */ |
4853 | 1766 if (info->iconcsumlen) { |
1767 char *b16, *saved_b16; | |
1768 struct buddy *b; | |
1769 | |
1770 memcpy(bi->iconcsum, info->iconcsum, info->iconcsumlen); | |
1771 bi->iconcsumlen = info->iconcsumlen; | |
1772 b16 = tobase16(bi->iconcsum, bi->iconcsumlen); | |
1773 b = gaim_find_buddy(gc->account, info->sn); | |
1774 saved_b16 = gaim_buddy_get_setting(b, "icon_checksum"); | |
1775 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { | |
1776 GSList *cur = od->requesticon; | |
1777 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
1778 cur = cur->next; | |
1779 if (!cur) { | |
1780 od->requesticon = g_slist_append(od->requesticon, strdup(normalize(info->sn))); | |
1781 if (od->icontimer) | |
1782 g_source_remove(od->icontimer); | |
1783 od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); | |
1784 } | |
1785 } | |
1786 free(saved_b16); | |
1787 free(b16); | |
1788 } | |
1789 | |
1790 serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon, time_idle, type); | |
2086 | 1791 |
1792 return 1; | |
1793 } | |
1794 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1795 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
4739 | 1796 struct gaim_connection *gc = sess->aux_data; |
2086 | 1797 va_list ap; |
4739 | 1798 aim_userinfo_t *info; |
2086 | 1799 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1800 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1801 info = va_arg(ap, aim_userinfo_t *); |
2086 | 1802 va_end(ap); |
1803 | |
4732 | 1804 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
2086 | 1805 |
1806 return 1; | |
1807 } | |
1808 | |
3730 | 1809 static void cancel_direct_im(struct ask_direct *d) { |
2086 | 1810 debug_printf("Freeing DirectIM prompts.\n"); |
1811 | |
1812 g_free(d->sn); | |
1813 g_free(d); | |
1814 } | |
1815 | |
4617 | 1816 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { |
2086 | 1817 struct direct_im *dim = data; |
1818 struct gaim_connection *gc = dim->gc; | |
1819 struct oscar_data *od = gc->proto_data; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1820 struct gaim_conversation *cnv; |
2086 | 1821 char buf[256]; |
3008 | 1822 struct sockaddr name; |
1823 socklen_t name_len = 1; | |
1824 | |
2086 | 1825 if (!g_slist_find(connections, gc)) { |
1826 g_free(dim); | |
1827 return; | |
1828 } | |
1829 | |
1830 if (source < 0) { | |
1831 g_free(dim); | |
1832 return; | |
1833 } | |
1834 | |
4366 | 1835 dim->conn->fd = source; |
2086 | 1836 aim_conn_completeconnect(od->sess, dim->conn); |
4491 | 1837 if (!(cnv = gaim_find_conversation(dim->name))) |
1838 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
3008 | 1839 |
1840 /* This is the best way to see if we're connected or not */ | |
1841 if (getpeername(source, &name, &name_len) == 0) { | |
1842 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
1843 dim->connected = TRUE; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1844 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
3008 | 1845 } |
2086 | 1846 od->direct_ims = g_slist_append(od->direct_ims, dim); |
3008 | 1847 |
4617 | 1848 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
2086 | 1849 } |
1850 | |
4617 | 1851 /* BBB */ |
3952 | 1852 /* |
4617 | 1853 * This is called after a remote AIM user has connected to us. We |
1854 * want to do some voodoo with the socket file descriptors, add a | |
1855 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
3952 | 1856 */ |
4656 | 1857 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
3630 | 1858 struct gaim_connection *gc = sess->aux_data; |
1859 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4617 | 1860 struct gaim_xfer *xfer; |
1861 struct oscar_xfer_data *xfer_data; | |
3630 | 1862 va_list ap; |
1863 aim_conn_t *conn, *listenerconn; | |
4656 | 1864 |
1865 debug_printf("AAA - in oscar_sendfile_estblsh\n"); | |
3630 | 1866 va_start(ap, fr); |
1867 conn = va_arg(ap, aim_conn_t *); | |
1868 listenerconn = va_arg(ap, aim_conn_t *); | |
1869 va_end(ap); | |
1870 | |
4617 | 1871 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
1872 return 1; | |
1873 | |
1874 if (!(xfer_data = xfer->data)) | |
1875 return 1; | |
1876 | |
3630 | 1877 /* Stop watching listener conn; watch transfer conn instead */ |
4617 | 1878 gaim_input_remove(xfer->watcher); |
3630 | 1879 aim_conn_kill(sess, &listenerconn); |
1880 | |
4617 | 1881 xfer_data->conn = conn; |
1882 xfer->fd = xfer_data->conn->fd; | |
1883 | |
1884 aim_conn_addhandler(sess, xfer_data->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
1885 aim_conn_addhandler(sess, xfer_data->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
1886 xfer->watcher = gaim_input_add(xfer_data->conn->fd, GAIM_INPUT_READ, oscar_callback, xfer_data->conn); | |
1887 | |
1888 /* Inform the other user that we are connected and ready to transfer */ | |
4646 | 1889 aim_oft_sendheader(sess, xfer_data->conn, AIM_CB_OFT_PROMPT, NULL, xfer->filename, 0, 1, xfer->size, xfer->size, time(NULL), xfer_data->checksum, 0x02, 0, 0); |
3630 | 1890 |
1891 return 0; | |
1892 } | |
1893 | |
3952 | 1894 /* |
4617 | 1895 * This is the gaim callback passed to proxy_connect when connecting to another AIM |
1896 * user in order to transfer a file. | |
3952 | 1897 */ |
4617 | 1898 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { |
1899 struct gaim_connection *gc; | |
1900 struct gaim_xfer *xfer; | |
1901 struct oscar_xfer_data *xfer_data; | |
4656 | 1902 |
1903 debug_printf("AAA - in oscar_sendfile_connected\n"); | |
4617 | 1904 if (!(xfer = data)) |
1905 return; | |
1906 if (!(xfer_data = xfer->data)) | |
1907 return; | |
1908 if (!(gc = xfer_data->gc)) | |
3630 | 1909 return; |
4617 | 1910 if (source < 0) |
1911 return; | |
1912 | |
1913 xfer->fd = source; | |
1914 xfer_data->conn->fd = source; | |
1915 | |
1916 aim_conn_completeconnect(xfer_data->conn->sessv, xfer_data->conn); | |
1917 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, xfer_data->conn); | |
1918 | |
1919 /* Inform the other user that we are connected and ready to transfer */ | |
1920 aim_im_sendch2_sendfile_accept(xfer_data->conn->sessv, xfer_data->cookie, xfer->who, AIM_CAPS_SENDFILE); | |
1921 | |
1922 return; | |
3630 | 1923 } |
1924 | |
3952 | 1925 /* |
4617 | 1926 * This is called when a buddy sends us some file info. This happens when they |
1927 * are sending a file to you, and you have just established a connection to them. | |
4650 | 1928 * You should send them the exact same info except use the real cookie. We also |
4617 | 1929 * get like totally ready to like, receive the file, kay? |
3952 | 1930 */ |
4617 | 1931 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
1932 struct gaim_connection *gc = sess->aux_data; | |
1933 struct oscar_data *od = gc->proto_data; | |
1934 struct gaim_xfer *xfer; | |
1935 struct oscar_xfer_data *xfer_data; | |
1936 va_list ap; | |
1937 aim_conn_t *conn; | |
1938 fu8_t *cookie; | |
1939 struct aim_fileheader_t *fh; | |
4656 | 1940 |
1941 debug_printf("AAA - in oscar_sendfile_prompt\n"); | |
4617 | 1942 va_start(ap, fr); |
1943 conn = va_arg(ap, aim_conn_t *); | |
1944 cookie = va_arg(ap, fu8_t *); | |
1945 fh = va_arg(ap, struct aim_fileheader_t *); | |
1946 va_end(ap); | |
1947 | |
1948 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
1949 return 1; | |
1950 | |
1951 if (!(xfer_data = xfer->data)) | |
1952 return 1; | |
1953 | |
1954 /* Jot down some data we'll need later */ | |
1955 xfer_data->modtime = fh->modtime; | |
1956 xfer_data->checksum = fh->checksum; | |
1957 | |
1958 /* We want to stop listening with a normal thingy */ | |
1959 gaim_input_remove(xfer->watcher); | |
1960 xfer->watcher = 0; | |
1961 | |
1962 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ | |
4646 | 1963 aim_oft_sendheader(xfer_data->conn->sessv, xfer_data->conn, AIM_CB_OFT_ACK, xfer_data->cookie, xfer->filename, 0, 1, xfer->size, xfer->size, fh->modtime, fh->checksum, 0x02, 0, 0); |
4617 | 1964 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
1965 | |
1966 return 0; | |
3630 | 1967 } |
1968 | |
3952 | 1969 /* |
4657 | 1970 * We are sending a file to someone else. They have just acknowledged our |
4617 | 1971 * prompt, so we want to start sending data like there's no tomorrow. |
3952 | 1972 */ |
4617 | 1973 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
1974 struct gaim_connection *gc = sess->aux_data; | |
1975 struct oscar_data *od = gc->proto_data; | |
1976 struct gaim_xfer *xfer; | |
1977 va_list ap; | |
1978 aim_conn_t *conn; | |
1979 fu8_t *cookie; | |
1980 struct aim_fileheader_t *fh; | |
4656 | 1981 |
1982 debug_printf("AAA - in oscar_sendfile_ack\n"); | |
4617 | 1983 va_start(ap, fr); |
1984 conn = va_arg(ap, aim_conn_t *); | |
1985 cookie = va_arg(ap, fu8_t *); | |
1986 fh = va_arg(ap, struct aim_fileheader_t *); | |
1987 va_end(ap); | |
1988 | |
1989 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
1990 return 1; | |
1991 | |
4656 | 1992 /* We want to stop listening with a normal thingy */ |
1993 gaim_input_remove(xfer->watcher); | |
1994 xfer->watcher = 0; | |
1995 | |
4617 | 1996 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
1997 | |
1998 return 0; | |
3630 | 1999 } |
4617 | 2000 |
2001 /* | |
2002 * We just sent a file to someone. They said they got it and everything, | |
2003 * so we can close our direct connection and what not. | |
2004 */ | |
2005 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
2006 struct gaim_connection *gc = sess->aux_data; | |
2007 struct oscar_data *od = gc->proto_data; | |
2008 struct gaim_xfer *xfer; | |
2009 va_list ap; | |
2010 aim_conn_t *conn; | |
2011 fu8_t *cookie; | |
2012 struct aim_fileheader_t *fh; | |
4656 | 2013 |
2014 debug_printf("AAA - in oscar_sendfile_done\n"); | |
4617 | 2015 va_start(ap, fr); |
2016 conn = va_arg(ap, aim_conn_t *); | |
2017 cookie = va_arg(ap, fu8_t *); | |
2018 fh = va_arg(ap, struct aim_fileheader_t *); | |
2019 va_end(ap); | |
2020 | |
2021 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
2022 return 1; | |
2023 | |
4656 | 2024 xfer->fd = conn->fd; |
4617 | 2025 gaim_xfer_end(xfer); |
2026 | |
2027 return 0; | |
2028 } | |
3630 | 2029 |
4244 | 2030 static void accept_direct_im(struct ask_direct *d) { |
2086 | 2031 struct gaim_connection *gc = d->gc; |
4244 | 2032 struct oscar_data *od; |
2086 | 2033 struct direct_im *dim; |
2945 | 2034 char *host; int port = 4443; |
4366 | 2035 int i, rc; |
2086 | 2036 |
4244 | 2037 if (!g_slist_find(connections, gc)) { |
2038 cancel_direct_im(d); | |
2039 return; | |
2040 } | |
2041 | |
2042 od = (struct oscar_data *)gc->proto_data; | |
2086 | 2043 debug_printf("Accepted DirectIM.\n"); |
2044 | |
2045 dim = find_direct_im(od, d->sn); | |
2046 if (dim) { | |
3730 | 2047 cancel_direct_im(d); /* 40 */ |
4244 | 2048 return; |
2086 | 2049 } |
2050 dim = g_new0(struct direct_im, 1); | |
2051 dim->gc = d->gc; | |
2052 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
2053 | |
4617 | 2054 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2055 if (!dim->conn) { |
2086 | 2056 g_free(dim); |
3730 | 2057 cancel_direct_im(d); |
4244 | 2058 return; |
2086 | 2059 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2060 |
2086 | 2061 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
4617 | 2062 gaim_odc_incoming, 0); |
2086 | 2063 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, |
4617 | 2064 gaim_odc_typing, 0); |
3033 | 2065 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
2993 | 2066 gaim_update_ui, 0); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2067 for (i = 0; i < (int)strlen(d->ip); i++) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2068 if (d->ip[i] == ':') { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2069 port = atoi(&(d->ip[i+1])); |
2086 | 2070 break; |
2071 } | |
2072 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2073 host = g_strndup(d->ip, i); |
2086 | 2074 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
4634 | 2075 rc = proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
2086 | 2076 g_free(host); |
4366 | 2077 if (rc < 0) { |
2086 | 2078 aim_conn_kill(od->sess, &dim->conn); |
2079 g_free(dim); | |
3730 | 2080 cancel_direct_im(d); |
4244 | 2081 return; |
2086 | 2082 } |
2083 | |
3730 | 2084 cancel_direct_im(d); |
2086 | 2085 |
4244 | 2086 return; |
2086 | 2087 } |
2088 | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2089 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2090 struct gaim_connection *gc = sess->aux_data; |
3600 | 2091 struct oscar_data *od = gc->proto_data; |
4738 | 2092 char *tmp; |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2093 int flags = 0; |
3659 | 2094 int convlen; |
2095 GError *err = NULL; | |
4738 | 2096 struct buddyinfo *bi; |
2097 | |
2098 bi = g_hash_table_lookup(od->buddyinfo, normalize(userinfo->sn)); | |
2099 if (!bi) { | |
2100 bi = g_new0(struct buddyinfo, 1); | |
2101 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(userinfo->sn)), bi); | |
2102 } | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2103 |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2104 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
2105 flags |= IM_FLAG_AWAY; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2106 |
4738 | 2107 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
2108 bi->typingnot = TRUE; | |
2109 else | |
2110 bi->typingnot = FALSE; | |
2111 | |
4380 | 2112 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2113 debug_printf("%s has an icon\n", userinfo->sn); |
4738 | 2114 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
2115 bi->ico_need = TRUE; | |
2116 bi->ico_len = args->iconlen; | |
2117 bi->ico_csum = args->iconsum; | |
2118 bi->ico_time = args->iconstamp; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2119 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2120 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2121 |
4491 | 2122 if (gc->account->iconfile[0] && (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2123 FILE *file; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2124 struct stat st; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2125 |
4491 | 2126 if (!stat(gc->account->iconfile, &st)) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2127 char *buf = g_malloc(st.st_size); |
4491 | 2128 file = fopen(gc->account->iconfile, "rb"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2129 if (file) { |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2130 int len = fread(buf, 1, st.st_size, file); |
4194 | 2131 debug_printf("Sending buddy icon to %s (%d bytes, %lu reported)\n", |
4617 | 2132 userinfo->sn, len, st.st_size); |
2133 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, | |
2134 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2135 fclose(file); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2136 } else |
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2137 debug_printf("Can't open buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2138 g_free(buf); |
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2139 } else |
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
2140 debug_printf("Can't stat buddy icon file!\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2141 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2142 |
4662 | 2143 debug_printf("Character set is %hu %hu\n", args->charset, args->charsubset); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2144 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
3722 | 2145 /* This message is marked as UNICODE, so we have to |
2146 * convert it to utf-8 before handing it to the gaim core. | |
2147 * This conversion should *never* fail, if it does it | |
2148 * means that either the incoming ICBM is corrupted or | |
4662 | 2149 * there is something we don't understand about it. |
2150 * For the record, AIM Unicode is big-endian UCS-2 */ | |
2151 | |
2152 debug_printf("Received UNICODE IM\n"); | |
4121 | 2153 |
2154 if (!args->msg || !args->msglen) | |
2155 return 1; | |
4641 | 2156 |
3659 | 2157 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
2158 if (err) { | |
2159 debug_printf("Unicode IM conversion: %s\n", err->message); | |
2160 tmp = strdup(_("(There was an error receiving this message)")); | |
4800 | 2161 g_error_free(err); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2162 } |
3722 | 2163 } else { |
3850 | 2164 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 2165 * unflagged messages, which are ASCII. That's OK because |
2166 * ASCII is a strict subset of ISO-8859-1; this should | |
2167 * help with compatibility with old, broken versions of | |
2168 * gaim (everything before 0.60) and other broken clients | |
2169 * that will happily send ISO-8859-1 without marking it as | |
2170 * such */ | |
4662 | 2171 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
4194 | 2172 debug_printf("Received ISO-8859-1 IM\n"); |
4121 | 2173 |
2174 if (!args->msg || !args->msglen) | |
2175 return 1; | |
2176 | |
3659 | 2177 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
2178 if (err) { | |
2179 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); | |
2180 tmp = strdup(_("(There was an error receiving this message)")); | |
4800 | 2181 g_error_free(err); |
3659 | 2182 } |
3642 | 2183 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2184 |
4333 | 2185 /* strip_linefeed(tmp); */ |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
2186 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
|
2187 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2188 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2189 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2190 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2191 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2192 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
|
2193 struct gaim_connection *gc = sess->aux_data; |
4617 | 2194 struct oscar_data *od = gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2195 |
4121 | 2196 if (!args) |
2197 return 0; | |
4194 | 2198 |
4617 | 2199 debug_printf("rendezvous with %s, status is %hu\n", userinfo->sn, args->status); |
2869 | 2200 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2201 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 2202 char *name; |
4120 | 2203 int *exch; |
4121 | 2204 GList *m = NULL; |
4120 | 2205 |
4121 | 2206 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
2207 return 1; | |
2208 name = extract_name(args->info.chat.roominfo.name); | |
4120 | 2209 exch = g_new0(int, 1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2210 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
|
2211 *exch = args->info.chat.roominfo.exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2212 m = g_list_append(m, exch); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2213 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2214 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2215 userinfo->sn, |
2869 | 2216 (char *)args->msg, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2217 m); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2218 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2219 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2220 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 2221 /* BBB */ |
2222 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
2223 /* Someone wants to send a file (or files) to us */ | |
2224 struct gaim_xfer *xfer; | |
2225 struct oscar_xfer_data *xfer_data; | |
2226 | |
2227 if (!args->cookie || !args->verifiedip || !args->port || | |
2228 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 2229 !args->info.sendfile.totfiles || !args->reqclass) { |
2230 debug_printf("%s tried to send you a file with incomplete information.\n", userinfo->sn); | |
4617 | 2231 return 1; |
4656 | 2232 } |
4617 | 2233 |
2234 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
2235 /* last char of the ft req is a star, they are sending us a | |
2236 * directory -- remove the star and trailing slash so we dont save | |
2237 * directories that look like 'dirname\*' -- arl */ | |
2238 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
2239 if (tmp && (tmp[1] == '*')) { | |
2240 tmp[0] = '\0'; | |
2241 } | |
2242 } | |
2243 | |
2244 /* Setup the oscar-specific transfer xfer_data */ | |
2245 xfer_data = g_malloc0(sizeof(struct oscar_xfer_data)); | |
2246 xfer_data->gc = gc; | |
2247 memcpy(xfer_data->cookie, args->cookie, 8); | |
2248 | |
2249 /* Build the file transfer handle */ | |
2250 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
2251 xfer_data->xfer = xfer; | |
2252 xfer->data = xfer_data; | |
2253 | |
2254 /* Set the info about the incoming file */ | |
2255 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); | |
2256 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
2257 xfer->remote_port = args->port; | |
4650 | 2258 xfer->remote_ip = g_strdup(args->verifiedip); |
4898 | 2259 if (args->proxyip) |
2260 xfer_data->proxyip = g_strdup(args->proxyip); | |
4650 | 2261 if (args->clientip) |
2262 xfer_data->clientip = g_strdup(args->clientip); | |
4898 | 2263 if (args->verifiedip) |
2264 xfer_data->verifiedip = g_strdup(args->verifiedip); | |
4617 | 2265 |
2266 /* Setup our I/O op functions */ | |
2267 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
2268 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
2269 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2270 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2271 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4617 | 2272 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
2273 | |
2274 /* | |
2275 * XXX - Should do something with args->msg, args->encoding, and args->language | |
2276 * probably make it apply to all ch2 messages. | |
3752 | 2277 */ |
4617 | 2278 |
2279 /* Keep track of this transfer for later */ | |
2280 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2281 | |
2282 /* Now perform the request */ | |
2283 gaim_xfer_request(xfer); | |
2284 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
2285 /* The other user wants to cancel a file transfer */ | |
2286 struct gaim_xfer *xfer; | |
2287 debug_printf("AAA - File transfer canceled by remote user\n"); | |
2288 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2289 gaim_xfer_cancel_remote(xfer); |
4617 | 2290 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
2291 /* | |
2292 * This gets sent by the receiver of a file | |
2293 * as they connect directly to us. If we don't | |
2294 * get this, then maybe a third party connected | |
2295 * to us, and we shouldn't send them anything. | |
2296 */ | |
2297 } else { | |
2298 debug_printf("unknown rendezvous status!\n"); | |
3630 | 2299 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2300 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2301 } else if (args->reqclass & AIM_CAPS_VOICE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2302 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
4799 | 2303 set_icon_data(gc, userinfo->sn, args->info.icon.icon, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2304 args->info.icon.length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2305 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2306 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2307 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2308 |
4212 | 2309 if (!args->verifiedip) { |
4650 | 2310 debug_printf("directim kill blocked (%s)\n", userinfo->sn); |
2311 return 1; | |
4212 | 2312 } |
2313 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2314 debug_printf("%s received direct im request from %s (%s)\n", |
2869 | 2315 gc->username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2316 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2317 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2318 d->sn = g_strdup(userinfo->sn); |
2869 | 2319 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2320 memcpy(d->cookie, args->cookie, 8); |
4650 | 2321 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, gc->username); |
4249 | 2322 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, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2323 } else { |
4194 | 2324 debug_printf("Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2325 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2326 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2327 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2328 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2329 |
3453 | 2330 /* |
4230 | 2331 * Authorization Functions |
2332 * Most of these are callbacks from dialogs. They're used by both | |
2333 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 2334 */ |
4269 | 2335 /* When you ask other people for authorization */ |
4337 | 2336 static void gaim_auth_request(struct name_data *data, char *msg) { |
4230 | 2337 struct gaim_connection *gc = data->gc; |
4244 | 2338 |
2339 if (g_slist_find(connections, gc)) { | |
2340 struct oscar_data *od = gc->proto_data; | |
4687 | 2341 struct buddy *buddy = gaim_find_buddy(gc->account, data->name); |
2342 struct group *group = gaim_find_buddys_group(buddy); | |
4244 | 2343 if (buddy && group) { |
2344 debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name); | |
4889 | 2345 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 2346 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
4889 | 2347 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
4244 | 2348 } |
4230 | 2349 } |
4337 | 2350 } |
2351 | |
2352 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
2353 do_prompt_dialog(_("Authorization Request Message:"), _("Please authorize me!"), data, gaim_auth_request, gaim_free_name_data); | |
4230 | 2354 } |
2355 | |
2356 static void gaim_auth_dontrequest(struct name_data *data) { | |
4244 | 2357 struct gaim_connection *gc = data->gc; |
2358 | |
2359 if (g_slist_find(connections, gc)) { | |
2360 /* struct oscar_data *od = gc->proto_data; */ | |
2361 /* XXX - Take the buddy out of our buddy list */ | |
2362 } | |
2363 | |
4230 | 2364 gaim_free_name_data(data); |
2365 } | |
2366 | |
4269 | 2367 static void gaim_auth_sendrequest(struct gaim_connection *gc, char *name) { |
2368 struct name_data *data = g_new(struct name_data, 1); | |
2369 struct buddy *buddy; | |
2370 gchar *dialog_msg, *nombre; | |
2371 | |
4687 | 2372 buddy = gaim_find_buddy(gc->account, name); |
2373 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
2374 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
4269 | 2375 else |
4830 | 2376 nombre = NULL; |
2377 | |
2378 dialog_msg = g_strdup_printf(_("The user %s requires authorization before being added to a buddy list. Do you want to send an authorization request?"), (nombre ? nombre : name)); | |
4269 | 2379 data->gc = gc; |
2380 data->name = g_strdup(name); | |
2381 data->nick = NULL; | |
4337 | 2382 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request_msgprompt, _("Cancel"), gaim_auth_dontrequest, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
4269 | 2383 |
2384 g_free(dialog_msg); | |
2385 g_free(nombre); | |
2386 } | |
2387 | |
4230 | 2388 /* When other people ask you for authorization */ |
2389 static void gaim_auth_grant(struct name_data *data) { | |
2390 struct gaim_connection *gc = data->gc; | |
4244 | 2391 |
2392 if (g_slist_find(connections, gc)) { | |
2393 struct oscar_data *od = gc->proto_data; | |
4236 | 2394 #ifdef NOSSI |
4244 | 2395 struct buddy *buddy; |
2396 gchar message; | |
2397 message = 0; | |
4687 | 2398 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 2399 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
4687 | 2400 show_got_added(gc, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 2401 #else |
4889 | 2402 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
4230 | 2403 #endif |
4244 | 2404 } |
2405 | |
4230 | 2406 gaim_free_name_data(data); |
3141 | 2407 } |
2408 | |
4230 | 2409 /* When other people ask you for authorization */ |
4337 | 2410 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
4230 | 2411 struct gaim_connection *gc = data->gc; |
4244 | 2412 |
2413 if (g_slist_find(connections, gc)) { | |
2414 struct oscar_data *od = gc->proto_data; | |
4230 | 2415 #ifdef NOSSI |
4617 | 2416 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 2417 #else |
4889 | 2418 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 2419 #endif |
4244 | 2420 } |
4337 | 2421 } |
2422 | |
2423 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
2424 do_prompt_dialog(_("Authorization Denied Message:"), _("No reason given."), data, gaim_auth_dontgrant, gaim_free_name_data); | |
3141 | 2425 } |
2426 | |
4230 | 2427 /* When someone sends you contacts */ |
2428 static void gaim_icq_contactadd(struct name_data *data) { | |
2429 struct gaim_connection *gc = data->gc; | |
4244 | 2430 |
2431 if (g_slist_find(connections, gc)) { | |
2432 show_add_buddy(gc, data->name, NULL, data->nick); | |
2433 } | |
2434 | |
4230 | 2435 gaim_free_name_data(data); |
3453 | 2436 } |
2437 | |
4075 | 2438 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 | 2439 struct gaim_connection *gc = sess->aux_data; |
4076 | 2440 gchar **msg1, **msg2; |
2441 GError *err = NULL; | |
2442 int i; | |
2443 | |
4121 | 2444 if (!args->type || !args->msg || !args->uin) |
2445 return 1; | |
4194 | 2446 |
2447 debug_printf("Received a channel 4 message of type 0x%02hhx.\n", args->type); | |
4076 | 2448 |
2449 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 2450 msg1 = g_strsplit(args->msg, "\376", 0); |
4194 | 2451 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* XXX - 10 is a guess */ |
4076 | 2452 for (i=0; msg1[i]; i++) { |
2453 strip_linefeed(msg1[i]); | |
2454 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); | |
4800 | 2455 if (err) { |
4076 | 2456 debug_printf("Error converting a string from ISO-8859-1 to UTF-8 in oscar ICBM channel 4 parsing\n"); |
4800 | 2457 g_error_free(err); |
2458 } | |
4076 | 2459 } |
2460 msg2[i] = NULL; | |
2461 | |
3952 | 2462 switch (args->type) { |
4173 | 2463 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 2464 if (i >= 1) { |
2465 gchar *uin = g_strdup_printf("%lu", args->uin); | |
2466 if (t) { /* This is an offline message */ | |
2467 /* I think this timestamp is in UTC, or something */ | |
2468 serv_got_im(gc, uin, msg2[0], 0, t, -1); | |
2469 } else { /* This is a message from MacICQ/Miranda */ | |
2470 serv_got_im(gc, uin, msg2[0], 0, time(NULL), -1); | |
2471 } | |
2472 g_free(uin); | |
4075 | 2473 } |
3316 | 2474 } break; |
2475 | |
4173 | 2476 case 0x04: { /* Someone sent you a URL */ |
4076 | 2477 if (i >= 2) { |
2478 gchar *uin = g_strdup_printf("%lu", args->uin); | |
2479 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); | |
3453 | 2480 serv_got_im(gc, uin, message, 0, time(NULL), -1); |
2481 g_free(uin); | |
2482 g_free(message); | |
2483 } | |
2484 } break; | |
2485 | |
4173 | 2486 case 0x06: { /* Someone requested authorization */ |
4076 | 2487 if (i >= 6) { |
4230 | 2488 struct name_data *data = g_new(struct name_data, 1); |
4337 | 2489 gchar *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
4076 | 2490 debug_printf("Received an authorization request from UIN %lu\n", args->uin); |
2491 data->gc = gc; | |
4230 | 2492 data->name = g_strdup_printf("%lu", args->uin); |
2493 data->nick = NULL; | |
4337 | 2494 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
4076 | 2495 g_free(dialog_msg); |
2496 } | |
3141 | 2497 } break; |
2498 | |
4173 | 2499 case 0x07: { /* Someone has denied you authorization */ |
4076 | 2500 if (i >= 1) { |
4194 | 2501 gchar *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.")); |
4230 | 2502 do_error_dialog(_("ICQ authorization denied."), dialog_msg, GAIM_INFO); |
4076 | 2503 g_free(dialog_msg); |
2504 } | |
3141 | 2505 } break; |
2506 | |
4173 | 2507 case 0x08: { /* Someone has granted you authorization */ |
4194 | 2508 gchar *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin); |
3427 | 2509 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO); |
3141 | 2510 g_free(dialog_msg); |
2511 } break; | |
2512 | |
4333 | 2513 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
2514 if (i >= 5) { | |
2515 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); | |
2516 do_error_dialog("ICQ Server Message", dialog_msg, GAIM_INFO); | |
2517 g_free(dialog_msg); | |
2518 } | |
2519 } break; | |
2520 | |
4173 | 2521 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 2522 if (i >= 6) { |
4194 | 2523 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); |
4076 | 2524 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO); |
2525 g_free(dialog_msg); | |
2526 } | |
4075 | 2527 } break; |
2528 | |
4173 | 2529 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 2530 if (i >= 6) { |
4308 | 2531 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ email from %s [%s]\n\nMessage is:\n%s"), msg2[0], msg2[3], msg2[5]); |
4076 | 2532 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO); |
2533 g_free(dialog_msg); | |
2534 } | |
4075 | 2535 } break; |
2536 | |
4173 | 2537 case 0x12: { |
3141 | 2538 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
4173 | 2539 /* Someone added you to their contact list? */ |
3141 | 2540 } break; |
2541 | |
4173 | 2542 case 0x13: { /* Someone has sent you some ICQ contacts */ |
3453 | 2543 int i, num; |
2544 gchar **text; | |
4173 | 2545 text = g_strsplit(args->msg, "\376", 0); |
3453 | 2546 if (text) { |
2547 num = 0; | |
2548 for (i=0; i<strlen(text[0]); i++) | |
2549 num = num*10 + text[0][i]-48; | |
2550 for (i=0; i<num; i++) { | |
4230 | 2551 struct name_data *data = g_new(struct name_data, 1); |
3730 | 2552 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 | 2553 data->gc = gc; |
4790 | 2554 data->name = g_strdup(text[i*2+1]); |
2555 data->nick = g_strdup(text[i*2+2]); | |
4249 | 2556 do_ask_dialog(message, _("Do you want to add this contact to your Buddy List?"), data, _("Add"), gaim_icq_contactadd, _("Decline"), gaim_free_name_data, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
3453 | 2557 g_free(message); |
2558 } | |
2559 g_strfreev(text); | |
2560 } | |
2561 } break; | |
2562 | |
4173 | 2563 case 0x1a: { /* Someone has sent you a greeting card or requested contacts? */ |
3453 | 2564 /* This is boring and silly. */ |
2565 } break; | |
2566 | |
3141 | 2567 default: { |
4194 | 2568 debug_printf("Received a channel 4 message of unknown type (type 0x%02hhx).\n", args->type); |
3141 | 2569 } break; |
2570 } | |
2571 | |
4076 | 2572 g_strfreev(msg1); |
2573 g_strfreev(msg2); | |
2574 | |
3141 | 2575 return 1; |
2576 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2577 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2578 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 2579 fu16_t channel; |
2580 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2581 aim_userinfo_t *userinfo; |
2086 | 2582 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2583 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2584 va_start(ap, fr); |
4200 | 2585 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2586 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2587 |
3141 | 2588 switch (channel) { |
2589 case 1: { /* standard message */ | |
2590 struct aim_incomingim_ch1_args *args; | |
2591 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2592 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2593 } break; | |
2594 | |
2595 case 2: { /* rendevous */ | |
2596 struct aim_incomingim_ch2_args *args; | |
2597 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2598 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2599 } break; | |
2600 | |
2601 case 4: { /* ICQ */ | |
2602 struct aim_incomingim_ch4_args *args; | |
2603 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2604 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2605 } break; |
2606 | |
2607 default: { | |
4194 | 2608 debug_printf("ICBM received on unsupported channel (channel 0x%04hx).", channel); |
3141 | 2609 } break; |
2086 | 2610 } |
2611 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2612 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2613 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2614 return ret; |
2086 | 2615 } |
2616 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2617 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2618 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2619 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2620 aim_userinfo_t *userinfo; |
2086 | 2621 char buf[1024]; |
2622 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2623 va_start(ap, fr); |
4200 | 2624 chan = (fu16_t)va_arg(ap, unsigned int); |
2625 userinfo = va_arg(ap, aim_userinfo_t *); | |
2626 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
2627 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 2628 va_end(ap); |
2629 | |
2630 switch(reason) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2631 case 0: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2632 /* Invalid (0) */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2633 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2634 sizeof(buf), |
4276 | 2635 ngettext( |
2636 "You missed %hu message from %s because it was invalid.", | |
2637 "You missed %hu messages from %s because they were invalid.", | |
2638 nummissed), | |
4282 | 2639 nummissed, |
2640 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2641 break; |
2086 | 2642 case 1: |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2643 /* Message too large */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2644 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2645 sizeof(buf), |
4276 | 2646 ngettext( |
2647 "You missed %hu message from %s because it was too large.", | |
2648 "You missed %hu messages from %s because they were too large.", | |
2649 nummissed), | |
4282 | 2650 nummissed, |
2651 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2652 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2653 case 2: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2654 /* Rate exceeded */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2655 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2656 sizeof(buf), |
4276 | 2657 ngettext( |
2658 "You missed %hu message from %s because the rate limit has been exceeded.", | |
2659 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
2660 nummissed), | |
4282 | 2661 nummissed, |
2662 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2663 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2664 case 3: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2665 /* Evil Sender */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2666 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2667 sizeof(buf), |
4276 | 2668 ngettext( |
2669 "You missed %hu message from %s because he/she was too evil.", | |
2670 "You missed %hu messages from %s because he/she was too evil.", | |
2671 nummissed), | |
4282 | 2672 nummissed, |
2673 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2674 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2675 case 4: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2676 /* Evil Receiver */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2677 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2678 sizeof(buf), |
4276 | 2679 ngettext( |
2680 "You missed %hu message from %s because you are too evil.", | |
2681 "You missed %hu messages from %s because you are too evil.", | |
2682 nummissed), | |
4282 | 2683 nummissed, |
2684 userinfo->sn); | |
2086 | 2685 break; |
2686 default: | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2687 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2688 sizeof(buf), |
4276 | 2689 ngettext( |
2690 "You missed %hu message from %s for an unknown reason.", | |
2691 "You missed %hu messages from %s for an unknown reason.", | |
2692 nummissed), | |
4282 | 2693 nummissed, |
2694 userinfo->sn); | |
2086 | 2695 break; |
2696 } | |
3427 | 2697 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 2698 |
2699 return 1; | |
2700 } | |
2701 | |
3212 | 2702 static char *gaim_icq_status(int state) { |
2703 /* Make a cute little string that shows the status of the dude or dudet */ | |
2704 if (state & AIM_ICQ_STATE_CHAT) | |
4342 | 2705 return g_strdup_printf(_("Free For Chat")); |
3212 | 2706 else if (state & AIM_ICQ_STATE_DND) |
4342 | 2707 return g_strdup_printf(_("Do Not Disturb")); |
3212 | 2708 else if (state & AIM_ICQ_STATE_OUT) |
4342 | 2709 return g_strdup_printf(_("Not Available")); |
3212 | 2710 else if (state & AIM_ICQ_STATE_BUSY) |
4342 | 2711 return g_strdup_printf(_("Occupied")); |
3212 | 2712 else if (state & AIM_ICQ_STATE_AWAY) |
4342 | 2713 return g_strdup_printf(_("Away")); |
3212 | 2714 else if (state & AIM_ICQ_STATE_WEBAWARE) |
4342 | 2715 return g_strdup_printf(_("Web Aware")); |
3212 | 2716 else if (state & AIM_ICQ_STATE_INVISIBLE) |
4342 | 2717 return g_strdup_printf(_("Invisible")); |
3212 | 2718 else |
4342 | 2719 return g_strdup_printf(_("Online")); |
3212 | 2720 } |
2721 | |
4194 | 2722 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
3630 | 2723 struct gaim_connection *gc = sess->aux_data; |
4617 | 2724 struct oscar_data *od = gc->proto_data; |
2725 | |
2726 /* BBB */ | |
3630 | 2727 switch (reason) { |
4151 | 2728 case 3: { /* Decline sendfile. */ |
4617 | 2729 struct gaim_xfer *xfer; |
2730 debug_printf("AAA - Other user declined file transfer\n"); | |
2731 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2732 gaim_xfer_cancel_remote(xfer); |
4151 | 2733 } break; |
2734 | |
2735 default: { | |
4194 | 2736 debug_printf("Received an unknown rendezvous client auto-response from %s. Type 0x%04hx\n", who, reason); |
4151 | 2737 } |
3630 | 2738 |
2739 } | |
2740 | |
2741 return 0; | |
2742 } | |
2743 | |
4194 | 2744 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
4151 | 2745 struct gaim_connection *gc = sess->aux_data; |
2746 | |
2747 switch(reason) { | |
2748 case 0x0003: { /* Reply from an ICQ status message request */ | |
2749 char *status_msg = gaim_icq_status(state); | |
2750 char *dialog_msg, **splitmsg; | |
2751 struct oscar_data *od = gc->proto_data; | |
2752 GSList *l = od->evilhack; | |
2753 gboolean evilhack = FALSE; | |
2754 | |
2755 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2756 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2757 | |
2758 /* If who is in od->evilhack, then we're just getting the away message, otherwise this | |
2759 * will just get appended to the info box (which is already showing). */ | |
2760 while (l) { | |
2761 char *x = l->data; | |
2762 if (!strcmp(x, normalize(who))) { | |
2763 evilhack = TRUE; | |
2764 g_free(x); | |
2765 od->evilhack = g_slist_remove(od->evilhack, x); | |
2766 break; | |
2767 } | |
2768 l = l->next; | |
2769 } | |
2770 | |
2771 if (evilhack) | |
4344 | 2772 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
4151 | 2773 else |
4344 | 2774 dialog_msg = g_strdup_printf(_("<B>Status:</B> %s<HR>%s"), status_msg, g_strjoinv("<BR>", splitmsg)); |
4151 | 2775 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
2776 | |
2777 g_free(status_msg); | |
2778 g_free(dialog_msg); | |
2779 g_strfreev(splitmsg); | |
2780 } break; | |
2781 | |
2782 default: { | |
4194 | 2783 debug_printf("Received an unknown client auto-response from %s. Type 0x%04hx\n", who, reason); |
4151 | 2784 } break; |
2785 } /* end of switch */ | |
2786 | |
2787 return 0; | |
2788 } | |
2789 | |
3212 | 2790 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
2791 va_list ap; | |
2792 fu16_t chan, reason; | |
2793 char *who; | |
2794 | |
2795 va_start(ap, fr); | |
4200 | 2796 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2797 who = va_arg(ap, char *); |
4200 | 2798 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2799 |
3952 | 2800 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 2801 char *cookie = va_arg(ap, char *); |
4151 | 2802 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 2803 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 2804 fu32_t state = 0; |
4151 | 2805 char *msg = NULL; |
2806 if (reason == 0x0003) { | |
4200 | 2807 state = va_arg(ap, fu32_t); |
4151 | 2808 msg = va_arg(ap, char *); |
2809 } | |
2810 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
2811 } | |
3952 | 2812 |
3212 | 2813 va_end(ap); |
2814 | |
2815 return 1; | |
2816 } | |
2817 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2818 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2819 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2820 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2821 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2822 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2823 va_start(ap, fr); |
4199 | 2824 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 2825 va_end(ap); |
2826 | |
4194 | 2827 debug_printf("snac threw error (reason 0x%04hx: %s)\n", reason, |
2086 | 2828 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2829 | |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2830 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
4056 | 2831 reason < msgerrreasonlen ? gettext(msgerrreason[reason]) : _("Unknown error")); |
3427 | 2832 do_error_dialog(m, NULL, GAIM_ERROR); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2833 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2834 |
2086 | 2835 return 1; |
2836 } | |
2837 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2838 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4617 | 2839 #if 0 |
3752 | 2840 struct gaim_connection *gc = sess->aux_data; |
4617 | 2841 struct oscar_data *od = gc->proto_data; |
2842 struct gaim_xfer *xfer; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2843 #endif |
4617 | 2844 va_list ap; |
2845 fu16_t reason; | |
2846 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2847 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2848 va_start(ap, fr); |
4617 | 2849 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 2850 data = va_arg(ap, char *); |
2086 | 2851 va_end(ap); |
2852 | |
4617 | 2853 debug_printf("Message error with data %s and reason %hu\n", data, reason); |
2854 | |
2855 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2856 #if 0 |
4617 | 2857 /* If this was a file transfer request, data is a cookie */ |
2858 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, data))) { | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2859 gaim_xfer_cancel_remote(xfer); |
3630 | 2860 return 1; |
2861 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2862 #endif |
3630 | 2863 |
4617 | 2864 /* Data is assumed to be the destination sn */ |
2865 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
4342 | 2866 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
4617 | 2867 g_free(buf); |
2086 | 2868 |
2869 return 1; | |
2870 } | |
2871 | |
3595 | 2872 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
2873 struct gaim_connection *gc = sess->aux_data; | |
2874 va_list ap; | |
2875 fu16_t type1, type2; | |
2876 char *sn; | |
2877 | |
2878 va_start(ap, fr); | |
4199 | 2879 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2880 sn = va_arg(ap, char *); |
4199 | 2881 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2882 va_end(ap); |
2883 | |
2884 switch (type2) { | |
2885 case 0x0000: { /* Text has been cleared */ | |
2886 serv_got_typing_stopped(gc, sn); | |
2887 } break; | |
2888 | |
2889 case 0x0001: { /* Paused typing */ | |
3768 | 2890 serv_got_typing(gc, sn, 0, TYPED); |
3595 | 2891 } break; |
2892 | |
2893 case 0x0002: { /* Typing */ | |
3768 | 2894 serv_got_typing(gc, sn, 0, TYPING); |
3595 | 2895 } break; |
2896 | |
2897 default: { | |
4624 | 2898 printf("Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); |
3595 | 2899 } break; |
2900 } | |
2901 | |
2902 return 1; | |
2903 } | |
2904 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2905 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2906 va_list ap; |
2907 char *destn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2908 fu16_t reason; |
2086 | 2909 char buf[1024]; |
2910 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2911 va_start(ap, fr); |
4199 | 2912 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 2913 destn = va_arg(ap, char *); |
2914 va_end(ap); | |
2915 | |
3574 | 2916 snprintf(buf, sizeof(buf), _("User information for %s unavailable:"), destn); |
4342 | 2917 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
2086 | 2918 |
2919 return 1; | |
2920 } | |
2921 | |
4853 | 2922 /* CCC */ |
2086 | 2923 static char *images(int flags) { |
2924 static char buf[1024]; | |
3101 | 2925 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
2679 | 2926 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
2086 | 2927 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
2928 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
3101 | 2929 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
2086 | 2930 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
3079 | 2931 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
2932 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
2086 | 2933 return buf; |
2934 } | |
2935 | |
3101 | 2936 |
2920 | 2937 static char *caps_string(guint caps) |
2938 { | |
2939 static char buf[512], *tmp; | |
2940 int count = 0, i = 0; | |
2941 guint bit = 1; | |
4742 | 2942 |
2943 if (!caps) { | |
4744 | 2944 return NULL; |
4743 | 2945 } else while (bit <= 0x20000) { |
2920 | 2946 if (bit & caps) { |
2947 switch (bit) { | |
2948 case 0x1: | |
2949 tmp = _("Buddy Icon"); | |
2950 break; | |
2951 case 0x2: | |
2952 tmp = _("Voice"); | |
2953 break; | |
2954 case 0x4: | |
4898 | 2955 tmp = _("Direct IM"); |
2920 | 2956 break; |
2957 case 0x8: | |
2958 tmp = _("Chat"); | |
2959 break; | |
2960 case 0x10: | |
2961 tmp = _("Get File"); | |
2962 break; | |
2963 case 0x20: | |
2964 tmp = _("Send File"); | |
2965 break; | |
2966 case 0x40: | |
2967 case 0x200: | |
2968 tmp = _("Games"); | |
2969 break; | |
2970 case 0x80: | |
4898 | 2971 tmp = _("Add-Ins"); |
2920 | 2972 break; |
2973 case 0x100: | |
2974 tmp = _("Send Buddy List"); | |
2975 break; | |
2976 case 0x400: | |
2977 tmp = _("EveryBuddy Bug"); | |
2978 break; | |
2979 case 0x800: | |
2980 tmp = _("AP User"); | |
2981 break; | |
2982 case 0x1000: | |
2983 tmp = _("ICQ RTF"); | |
2984 break; | |
2985 case 0x2000: | |
2986 tmp = _("Nihilist"); | |
2987 break; | |
2988 case 0x4000: | |
2989 tmp = _("ICQ Server Relay"); | |
2990 break; | |
2991 case 0x8000: | |
2992 tmp = _("ICQ Unknown"); | |
2993 break; | |
2994 case 0x10000: | |
2995 tmp = _("Trillian Encryption"); | |
2996 break; | |
4742 | 2997 case 0x20000: |
2998 tmp = _("ICQ UTF8"); | |
2999 break; | |
2920 | 3000 default: |
3001 tmp = NULL; | |
3002 break; | |
3003 } | |
3004 if (tmp) | |
3005 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
3006 tmp); | |
3007 count++; | |
3008 } | |
3009 bit <<= 1; | |
3010 } | |
4744 | 3011 return buf; |
2920 | 3012 } |
3013 | |
4732 | 3014 static char *oscar_tooltip_text(struct buddy *b) { |
4738 | 3015 struct gaim_connection *gc = b->account->gc; |
3016 struct oscar_data *od = gc->proto_data; | |
3017 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name)); | |
3018 | |
4744 | 3019 if (bi) { |
4825 | 3020 gchar *yay; |
4744 | 3021 char *caps = caps_string(bi->caps); |
4842 | 3022 char *tstr = sec_to_text(time(NULL) - bi->signon + |
3023 (gc->login_time_official ? gc->login_time_official - gc->login_time : 0)); | |
4825 | 3024 yay = g_strdup_printf(_("<b>Logged In:</b> %s%s%s"), tstr, |
4744 | 3025 caps ? _("\n<b>Capabilities:</b> ") : "", caps ? caps : ""); |
4825 | 3026 free(tstr); |
4898 | 3027 |
3028 if (isdigit(b->name[0])) { | |
3029 char *tmp, *status = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
3030 tmp = yay; | |
3031 yay = g_strconcat(tmp, _("\n<b>Status:</b> "), status, NULL); | |
3032 g_free(tmp); | |
3033 g_free(status); | |
3034 } | |
4825 | 3035 return yay; |
4744 | 3036 } else { |
4738 | 3037 return NULL; |
4744 | 3038 } |
4732 | 3039 } |
3040 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3041 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
4791 | 3042 struct gaim_connection *gc = sess->aux_data; |
3043 struct oscar_data *od = gc->proto_data; | |
3044 char header[BUF_LONG]; | |
3045 GSList *l = od->evilhack; | |
3046 gboolean evilhack = FALSE; | |
3047 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; | |
3048 fu32_t flags; | |
3049 va_list ap; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3050 aim_userinfo_t *info; |
4791 | 3051 fu16_t infotype; |
4151 | 3052 char *text_enc = NULL, *text = NULL, *utf8 = NULL; |
3053 int text_len; | |
2086 | 3054 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3055 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3056 info = va_arg(ap, aim_userinfo_t *); |
4199 | 3057 infotype = (fu16_t) va_arg(ap, unsigned int); |
4151 | 3058 text_enc = va_arg(ap, char *); |
3059 text = va_arg(ap, char *); | |
3060 text_len = va_arg(ap, int); | |
2086 | 3061 va_end(ap); |
3062 | |
4151 | 3063 if (text_len > 0) { |
3064 flags = parse_encoding (text_enc); | |
3065 switch (flags) { | |
3066 case 0: | |
4159 | 3067 utf8 = g_strndup(text, text_len); |
4151 | 3068 break; |
4166 | 3069 case AIM_IMFLAGS_ISO_8859_1: |
3070 utf8 = g_convert(text, text_len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
3071 break; | |
4151 | 3072 case AIM_IMFLAGS_UNICODE: |
3073 utf8 = g_convert(text, text_len, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
3074 break; | |
3075 default: | |
4791 | 3076 utf8 = g_strdup(_("<i>Unable to display information because it was sent in an unknown encoding.</i>")); |
4194 | 3077 debug_printf("Encountered an unknown encoding while parsing userinfo\n"); |
4151 | 3078 } |
3079 } | |
3080 | |
2993 | 3081 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
4834 | 3082 onlinesince = g_strdup_printf(_("Online Since : <b>%s</b><br>\n"), |
2993 | 3083 asctime(localtime(&info->onlinesince))); |
3084 } | |
3085 | |
3086 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
4834 | 3087 membersince = g_strdup_printf(_("Member Since : <b>%s</b><br>\n"), |
2993 | 3088 asctime(localtime(&info->membersince))); |
3089 } | |
3090 | |
3091 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
4426 | 3092 gchar *itime = sec_to_text(info->idletime*60); |
4834 | 3093 idle = g_strdup_printf(_("Idle : <b>%s</b>"), itime); |
4426 | 3094 g_free(itime); |
2993 | 3095 } else |
4834 | 3096 idle = g_strdup(_("Idle: <b>Active</b>")); |
2993 | 3097 |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3098 g_snprintf(header, sizeof header, |
4791 | 3099 _("Username : <b>%s</b> %s <br>\n" |
3100 "Warning Level : <b>%d %%</b><br>\n" | |
2086 | 3101 "%s" |
2993 | 3102 "%s" |
4344 | 3103 "%s\n" |
4791 | 3104 "<hr>\n"), |
2086 | 3105 info->sn, images(info->flags), |
3106 info->warnlevel/10, | |
2993 | 3107 onlinesince ? onlinesince : "", |
3108 membersince ? membersince : "", | |
3109 idle ? idle : ""); | |
3110 | |
3111 g_free(onlinesince); | |
3112 g_free(membersince); | |
3113 g_free(idle); | |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
3114 |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3115 while (l) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3116 char *x = l->data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3117 if (!strcmp(x, normalize(info->sn))) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3118 evilhack = TRUE; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3119 g_free(x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3120 od->evilhack = g_slist_remove(od->evilhack, x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3121 break; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3122 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3123 l = l->next; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3124 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3125 |
2920 | 3126 if (infotype == AIM_GETINFO_AWAYMESSAGE) { |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3127 if (evilhack) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3128 g_show_info_text(gc, info->sn, 2, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3129 header, |
4151 | 3130 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
4207 | 3131 _("<i>User has no away message</i>"), NULL); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3132 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3133 g_show_info_text(gc, info->sn, 0, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3134 header, |
4151 | 3135 (utf8 && *utf8) ? away_subs(utf8, gc->username) : NULL, |
4791 | 3136 (utf8 && *utf8) ? "<hr>" : NULL, |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3137 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3138 } |
2920 | 3139 } else if (infotype == AIM_GETINFO_CAPABILITIES) { |
3140 g_show_info_text(gc, info->sn, 2, | |
3141 header, | |
3142 "<i>", _("Client Capabilities: "), | |
3143 caps_string(info->capabilities), | |
3144 "</i>", | |
3145 NULL); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3146 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3147 g_show_info_text(gc, info->sn, 1, |
4151 | 3148 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
3149 _("<i>No Information Provided</i>"), | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3150 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3151 } |
2086 | 3152 |
4151 | 3153 g_free(utf8); |
3154 | |
2086 | 3155 return 1; |
3156 } | |
3157 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3158 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3159 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3160 fu16_t id; |
2086 | 3161 va_list ap; |
3162 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3163 va_start(ap, fr); |
4199 | 3164 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3165 msg = va_arg(ap, char *); |
3166 va_end(ap); | |
3167 | |
4194 | 3168 debug_printf("MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
3169 if (id < 4) |
3427 | 3170 do_error_dialog(_("Your AIM connection may be lost."), NULL, GAIM_WARNING); |
2086 | 3171 |
3172 return 1; | |
3173 } | |
3174 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3175 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3176 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3177 fu16_t type; |
2086 | 3178 struct gaim_connection *gc = sess->aux_data; |
4617 | 3179 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3180 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3181 va_start(ap, fr); |
4199 | 3182 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3183 |
3184 switch(type) { | |
3185 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3186 fu8_t maxrooms; |
2086 | 3187 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3188 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3189 |
4199 | 3190 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 3191 exchangecount = va_arg(ap, int); |
3192 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
3193 | |
3194 debug_printf("chat info: Chat Rights:\n"); | |
4194 | 3195 debug_printf("chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
2086 | 3196 debug_printf("chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3197 for (i = 0; i < exchangecount; i++) |
4194 | 3198 debug_printf("chat info: \t\t%hu %s\n", exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 3199 while (od->create_rooms) { |
3200 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3201 debug_printf("creating room %s\n", cr->name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3202 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3203 g_free(cr->name); |
4617 | 3204 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3205 g_free(cr); |
2086 | 3206 } |
3207 } | |
3208 break; | |
3209 case 0x0008: { | |
3210 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3211 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3212 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3213 fu32_t createtime; |
2086 | 3214 |
3215 fqcn = va_arg(ap, char *); | |
4200 | 3216 instance = (fu16_t)va_arg(ap, unsigned int); |
3217 exchange = (fu16_t)va_arg(ap, unsigned int); | |
3218 flags = (fu16_t)va_arg(ap, unsigned int); | |
3219 createtime = va_arg(ap, fu32_t); | |
3220 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3221 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
3222 createperms = (fu8_t)va_arg(ap, unsigned int); | |
3223 unknown = (fu16_t)va_arg(ap, unsigned int); | |
3224 name = va_arg(ap, char *); | |
3225 ck = va_arg(ap, char *); | |
4194 | 3226 |
3227 debug_printf("created room: %s %hu %hu %hu %lu %hu %hu %hhu %hu %s %s\n", | |
2086 | 3228 fqcn, |
3229 exchange, instance, flags, | |
3230 createtime, | |
3231 maxmsglen, maxoccupancy, createperms, unknown, | |
3232 name, ck); | |
4617 | 3233 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 3234 } |
3235 break; | |
3236 default: | |
4194 | 3237 debug_printf("chatnav info: unknown type (%04hx)\n", type); |
2086 | 3238 break; |
3239 } | |
4194 | 3240 |
3241 va_end(ap); | |
3242 | |
2086 | 3243 return 1; |
3244 } | |
3245 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3246 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3247 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3248 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3249 aim_userinfo_t *info; |
2086 | 3250 struct gaim_connection *g = sess->aux_data; |
3251 | |
3252 struct chat_connection *c = NULL; | |
3253 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3254 va_start(ap, fr); |
2086 | 3255 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3256 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3257 va_end(ap); |
3258 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3259 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3260 if (!c) |
3261 return 1; | |
3262 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3263 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3264 gaim_chat_add_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3265 |
3266 return 1; | |
3267 } | |
3268 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3269 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3270 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3271 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3272 aim_userinfo_t *info; |
2086 | 3273 struct gaim_connection *g = sess->aux_data; |
3274 | |
3275 struct chat_connection *c = NULL; | |
3276 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3277 va_start(ap, fr); |
2086 | 3278 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3279 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3280 va_end(ap); |
3281 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3282 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3283 if (!c) |
3284 return 1; | |
3285 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3286 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3287 gaim_chat_remove_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3288 |
3289 return 1; | |
3290 } | |
3291 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3292 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
|
3293 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3294 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3295 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3296 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3297 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3298 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3299 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3300 fu32_t creationtime; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3301 struct gaim_connection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3302 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
|
3303 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3304 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3305 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3306 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3307 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3308 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3309 roomdesc = va_arg(ap, char *); |
4200 | 3310 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
3311 creationtime = va_arg(ap, fu32_t); | |
3312 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3313 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
3314 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
3315 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3316 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3317 |
4194 | 3318 debug_printf("inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3319 maxmsglen, maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3320 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3321 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3322 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3323 |
2086 | 3324 return 1; |
3325 } | |
3326 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3327 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
4269 | 3328 struct gaim_connection *gc = sess->aux_data; |
2086 | 3329 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3330 aim_userinfo_t *info; |
2086 | 3331 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3332 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
2086 | 3333 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3334 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3335 info = va_arg(ap, aim_userinfo_t *); |
4194 | 3336 msg = va_arg(ap, char *); |
3337 va_end(ap); | |
2086 | 3338 |
4269 | 3339 serv_got_chat_in(gc, ccon->id, info->sn, 0, msg, time((time_t)NULL)); |
2086 | 3340 |
3341 return 1; | |
3342 } | |
3343 | |
3694 | 3344 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
3345 va_list ap; | |
3346 struct gaim_connection *gc = sess->aux_data; | |
3347 struct aim_emailinfo *emailinfo; | |
3725 | 3348 int havenewmail; |
3694 | 3349 |
3350 va_start(ap, fr); | |
3351 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 3352 havenewmail = va_arg(ap, int); |
3694 | 3353 va_end(ap); |
3354 | |
3725 | 3355 if (emailinfo) { |
3356 if (emailinfo->unread) { | |
3357 if (havenewmail) | |
3358 connection_has_mail(gc, emailinfo->nummsgs ? emailinfo->nummsgs : -1, NULL, NULL, emailinfo->url); | |
3359 } else | |
3694 | 3360 connection_has_mail(gc, 0, NULL, NULL, emailinfo->url); |
3361 } | |
3362 | |
3363 return 1; | |
3364 } | |
3365 | |
4804 | 3366 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
3367 struct gaim_connection *gc = sess->aux_data; | |
3368 struct oscar_data *od = gc->proto_data; | |
3369 char *sn; | |
3370 | |
3371 sn = od->requesticon->data; | |
3372 debug_printf("removing %s from hash table\n", sn); | |
3373 od->requesticon = g_slist_remove(od->requesticon, sn); | |
3374 free(sn); | |
3375 | |
3376 if (od->icontimer) | |
3377 g_source_remove(od->icontimer); | |
3378 od->icontimer = g_timeout_add(500, gaim_icon_timerfunc, gc); | |
3379 | |
3380 return 1; | |
3381 } | |
3382 | |
3383 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
3384 struct gaim_connection *gc = sess->aux_data; | |
3385 struct oscar_data *od = gc->proto_data; | |
3386 GSList *cur; | |
3387 va_list ap; | |
3388 char *sn; | |
4853 | 3389 fu8_t *iconcsum, *icon; |
3390 fu16_t iconcsumlen, iconlen; | |
4804 | 3391 |
3392 va_start(ap, fr); | |
3393 sn = va_arg(ap, char *); | |
4853 | 3394 iconcsum = va_arg(ap, fu8_t *); |
3395 iconcsumlen = va_arg(ap, int); | |
4804 | 3396 icon = va_arg(ap, fu8_t *); |
3397 iconlen = va_arg(ap, int); | |
3398 va_end(ap); | |
3399 | |
4853 | 3400 if (iconlen > 0) { |
3401 char *b16; | |
3402 struct buddy *b; | |
4804 | 3403 set_icon_data(gc, sn, icon, iconlen); |
4853 | 3404 b16 = tobase16(iconcsum, iconcsumlen); |
3405 b = gaim_find_buddy(gc->account, sn); | |
3406 gaim_buddy_set_setting(b, "icon_checksum", b16); | |
4870 | 3407 gaim_blist_save(); |
4853 | 3408 free(b16); |
3409 } | |
4804 | 3410 |
3411 cur = od->requesticon; | |
3412 while (cur) { | |
3413 char *cursn = cur->data; | |
3414 if (!aim_sncmp(cursn, sn)) { | |
3415 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
3416 free(cursn); | |
3417 cur = od->requesticon; | |
3418 } else | |
3419 cur = cur->next; | |
3420 } | |
3421 | |
3422 if (od->icontimer) | |
3423 g_source_remove(od->icontimer); | |
3424 od->icontimer = g_timeout_add(250, gaim_icon_timerfunc, gc); | |
3425 | |
3426 return 1; | |
3427 } | |
3428 | |
3429 static gboolean gaim_icon_timerfunc(gpointer data) { | |
3430 struct gaim_connection *gc = data; | |
3431 struct oscar_data *od = gc->proto_data; | |
3432 struct buddyinfo *bi; | |
3433 aim_conn_t *conn; | |
3434 | |
3435 if (!od->requesticon) { | |
3436 debug_printf("no more icons to request\n"); | |
3437 return FALSE; | |
3438 } | |
3439 | |
3440 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
4823 | 3441 if (!conn && !od->iconconnecting) { |
4804 | 3442 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); |
4823 | 3443 od->iconconnecting = TRUE; |
4804 | 3444 return FALSE; |
3445 } | |
3446 | |
3447 bi = g_hash_table_lookup(od->buddyinfo, (char *)od->requesticon->data); | |
4853 | 3448 if (bi && (bi->iconcsumlen > 0)) { |
4889 | 3449 aim_icon_request(od->sess, od->requesticon->data, bi->iconcsum, bi->iconcsumlen); |
4804 | 3450 return FALSE; |
3451 } else { | |
3452 char *sn = od->requesticon->data; | |
3453 od->requesticon = g_slist_remove(od->requesticon, sn); | |
3454 free(sn); | |
3455 } | |
3456 | |
3457 return TRUE; | |
3458 } | |
3459 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3460 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3461 * 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
|
3462 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3463 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3464 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3465 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3466 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3467 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3468 va_start(ap, fr); |
4199 | 3469 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3470 sn = va_arg(ap, char *); |
3471 va_end(ap); | |
3472 | |
3473 debug_printf("Sent message to %s.\n", sn); | |
3474 | |
3475 return 1; | |
3476 } | |
3477 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3478 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
|
3479 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3480 "invalid", |
4194 | 3481 "change", |
3482 "warning", | |
3483 "limit", | |
3484 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3485 }; |
2086 | 3486 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3487 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3488 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3489 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3490 va_start(ap, fr); |
4200 | 3491 code = (fu16_t)va_arg(ap, unsigned int); |
3492 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
3493 windowsize = va_arg(ap, fu32_t); | |
3494 clear = va_arg(ap, fu32_t); | |
3495 alert = va_arg(ap, fu32_t); | |
3496 limit = va_arg(ap, fu32_t); | |
3497 disconnect = va_arg(ap, fu32_t); | |
3498 currentavg = va_arg(ap, fu32_t); | |
3499 maxavg = va_arg(ap, fu32_t); | |
2086 | 3500 va_end(ap); |
3501 | |
4194 | 3502 debug_printf("rate %s (param ID 0x%04hx): curavg = %lu, maxavg = %lu, alert at %lu, " |
3503 "clear warning at %lu, limit at %lu, disconnect at %lu (window size = %lu)\n", | |
2086 | 3504 (code < 5) ? codes[code] : codes[0], |
3505 rateclass, | |
3506 currentavg, maxavg, | |
3507 alert, clear, | |
3508 limit, disconnect, | |
3509 windowsize); | |
3510 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3511 /* XXX fix these values */ |
2086 | 3512 if (code == AIM_RATE_CODE_CHANGE) { |
3513 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3514 aim_conn_setlatency(fr->conn, 0); |
2086 | 3515 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3516 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3517 } else if (code == AIM_RATE_CODE_LIMIT) { |
3427 | 3518 do_error_dialog(_("Rate limiting error."), |
3519 _("The last message was not sent because you are over the rate limit. " | |
3520 "Please wait 10 seconds and try again."), GAIM_ERROR); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3521 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3522 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3523 aim_conn_setlatency(fr->conn, 0); |
2086 | 3524 } |
3525 | |
3526 return 1; | |
3527 } | |
3528 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3529 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3530 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3531 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3532 aim_userinfo_t *userinfo; |
2086 | 3533 struct gaim_connection *gc = sess->aux_data; |
3534 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3535 va_start(ap, fr); |
4199 | 3536 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3537 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3538 va_end(ap); |
3539 | |
3540 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, newevil / 10); | |
3541 | |
3542 return 1; | |
3543 } | |
3544 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3545 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
|
3546 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3547 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3548 struct gaim_connection *gc = sess->aux_data; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3549 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3550 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3551 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3552 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3553 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3554 gc->evil = info->warnlevel/10; |
4841 | 3555 |
3556 if (info->onlinesince) | |
3557 gc->login_time_official = info->onlinesince; | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3558 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3559 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3560 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3561 |
4649 | 3562 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
3563 struct gaim_connection *gc = sess->aux_data; | |
4666 | 3564 struct oscar_data *od = gc->proto_data; |
4649 | 3565 va_list ap; |
3566 fu16_t code; | |
3567 char *msg; | |
3568 | |
3569 va_start(ap, fr); | |
3570 code = (fu16_t)va_arg(ap, int); | |
3571 msg = va_arg(ap, char *); | |
3572 va_end(ap); | |
3573 | |
3574 debug_printf("Disconnected. Code is 0x%04x and msg is %s\n", code, msg); | |
3575 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { | |
4651 | 3576 if (code == 0x0001) { |
4652 | 3577 hide_login_progress_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 3578 } else { |
4652 | 3579 hide_login_progress_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 3580 } |
4666 | 3581 od->killme = TRUE; |
4649 | 3582 } |
3583 | |
3584 return 1; | |
3585 } | |
3586 | |
2675 | 3587 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3588 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3589 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 3590 |
3591 #ifndef NOSSI | |
3592 debug_printf("ssi: requesting ssi list\n"); | |
4889 | 3593 aim_ssi_reqrights(sess); |
3594 aim_ssi_reqdata(sess, sess->ssi.timestamp, sess->ssi.numitems); | |
4230 | 3595 #endif |
3596 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3597 aim_bos_reqlocaterights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3598 aim_bos_reqbuddyrights(sess, fr->conn); |
4617 | 3599 aim_im_reqparams(sess); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3600 aim_bos_reqrights(sess, fr->conn); |
4230 | 3601 |
3602 #ifdef NOSSI | |
3603 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | |
3604 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3605 #endif | |
2086 | 3606 |
3607 return 1; | |
3608 } | |
3609 | |
2675 | 3610 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
2647 | 3611 struct gaim_connection *gc = sess->aux_data; |
3612 struct oscar_data *od = gc->proto_data; | |
3613 | |
2672 | 3614 aim_clientready(sess, fr->conn); |
2675 | 3615 debug_printf("connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3616 |
2647 | 3617 if (od->chpass) { |
3618 debug_printf("changing password\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3619 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3620 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3621 od->oldp = NULL; |
2647 | 3622 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3623 od->newp = NULL; |
2647 | 3624 od->chpass = FALSE; |
3625 } | |
2979 | 3626 if (od->setnick) { |
3627 debug_printf("formatting screenname\n"); | |
3628 aim_admin_setnick(sess, fr->conn, od->newsn); | |
3629 g_free(od->newsn); | |
3630 od->newsn = NULL; | |
3631 od->setnick = FALSE; | |
3632 } | |
2647 | 3633 if (od->conf) { |
3634 debug_printf("confirming account\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3635 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3636 od->conf = FALSE; |
3637 } | |
3638 if (od->reqemail) { | |
3639 debug_printf("requesting email\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3640 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3641 od->reqemail = FALSE; |
3642 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3643 if (od->setemail) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3644 debug_printf("setting email\n"); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3645 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3646 g_free(od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3647 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3648 } |
2647 | 3649 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3650 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3651 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3652 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3653 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
|
3654 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3655 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3656 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3657 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3658 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3659 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3660 |
4194 | 3661 /* XXX - evidently this crashes on solaris. i have no clue why |
3662 debug_printf("ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " | |
3663 "max sender evil = %f, max receiver evil = %f, min msg interval = %lu\n", | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3664 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3665 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3666 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3667 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3668 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3669 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3670 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3671 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3672 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3673 |
4617 | 3674 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3675 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3676 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3677 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3678 |
2993 | 3679 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3680 { | |
3681 va_list ap; | |
3682 fu16_t maxsiglen; | |
3683 struct gaim_connection *gc = sess->aux_data; | |
4617 | 3684 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4151 | 3685 char *unicode; |
3686 int unicode_len; | |
3687 fu32_t flags; | |
2993 | 3688 |
3689 va_start(ap, fr); | |
4199 | 3690 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 3691 va_end(ap); |
3692 | |
3693 debug_printf("locate rights: max sig len = %d\n", maxsiglen); | |
3694 | |
4617 | 3695 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3696 | |
3697 if (od->icq) | |
4151 | 3698 aim_bos_setprofile(sess, fr->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
3699 else { | |
4491 | 3700 flags = check_encoding (gc->account->user_info); |
4151 | 3701 |
3702 if (flags == 0) { | |
4600 | 3703 aim_bos_setprofile(sess, fr->conn, "us-ascii", gc->account->user_info, |
4491 | 3704 strlen(gc->account->user_info), NULL, NULL, 0, caps_aim); |
4151 | 3705 } else { |
4491 | 3706 unicode = g_convert (gc->account->user_info, strlen(gc->account->user_info), |
4151 | 3707 "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); |
3708 aim_bos_setprofile(sess, fr->conn, "unicode-2-0", unicode, unicode_len, | |
3709 NULL, NULL, 0, caps_aim); | |
3710 g_free(unicode); | |
3711 } | |
3712 } | |
2993 | 3713 |
3714 return 1; | |
3715 } | |
3716 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3717 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
|
3718 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3719 fu16_t maxbuddies, maxwatchers; |
2993 | 3720 struct gaim_connection *gc = sess->aux_data; |
4617 | 3721 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3722 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3723 va_start(ap, fr); |
4199 | 3724 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
3725 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3726 va_end(ap); |
3727 | |
4194 | 3728 debug_printf("buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 3729 |
4617 | 3730 od->rights.maxbuddies = (guint)maxbuddies; |
3731 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 3732 |
2086 | 3733 return 1; |
3734 } | |
3735 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3736 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
|
3737 fu16_t maxpermits, maxdenies; |
2086 | 3738 va_list ap; |
2993 | 3739 struct gaim_connection *gc = sess->aux_data; |
4617 | 3740 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3741 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3742 va_start(ap, fr); |
4199 | 3743 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
3744 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3745 va_end(ap); |
3746 | |
4194 | 3747 debug_printf("BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 3748 |
4617 | 3749 od->rights.maxpermits = (guint)maxpermits; |
3750 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 3751 |
3752 account_online(gc); | |
3753 serv_finish_login(gc); | |
3754 | |
3755 debug_printf("buddy list loaded\n"); | |
3756 | |
2672 | 3757 aim_clientready(sess, fr->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3758 |
4617 | 3759 /* XXX - Should call aim_bos_setidle with 0x0000 */ |
3760 | |
4664 | 3761 if (od->icq) { |
3762 aim_icq_reqofflinemsgs(sess); | |
3763 aim_icq_hideip(sess); | |
3764 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3765 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3766 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 3767 if (sess->authinfo->email) |
3768 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 3769 |
3770 return 1; | |
3771 } | |
3772 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3773 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
|
3774 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3775 struct aim_icq_offlinemsg *msg; |
4075 | 3776 struct aim_incomingim_ch4_args args; |
3777 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3778 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3779 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3780 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3781 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3782 |
4075 | 3783 debug_printf("Received offline message. Converting to channel 4 ICBM...\n"); |
3784 args.uin = msg->sender; | |
3785 args.type = msg->type; | |
4173 | 3786 args.flags = msg->flags; |
4076 | 3787 args.msglen = msg->msglen; |
4075 | 3788 args.msg = msg->msg; |
3789 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); | |
3790 incomingim_chan4(sess, fr->conn, NULL, &args, t); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3791 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3792 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3793 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3794 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3795 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
|
3796 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3797 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3798 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3799 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3800 |
4624 | 3801 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3802 { |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
3803 struct gaim_connection *gc = sess->aux_data; |
4819 | 3804 gchar *buf, *tmp, *utf8; |
4624 | 3805 gchar who[16]; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3806 va_list ap; |
4151 | 3807 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3808 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3809 va_start(ap, fr); |
4151 | 3810 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3811 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3812 |
4664 | 3813 if (!info->uin) |
3814 return 0; | |
3815 | |
4151 | 3816 g_snprintf(who, sizeof(who), "%lu", info->uin); |
4820 | 3817 buf = g_strdup_printf("<b>%s</b> %s", _("UIN:"), who); |
4819 | 3818 if (info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) { |
3819 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
3820 } | |
3821 if (info->first && info->first[0] && (utf8 = gaim_try_conv_to_utf8(info->first))) { | |
3822 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
3823 } | |
3824 if (info->last && info->last[0] && (utf8 = gaim_try_conv_to_utf8(info->last))) { | |
3825 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
3826 } | |
3827 if (info->email && info->email[0] && (utf8 = gaim_try_conv_to_utf8(info->email))) { | |
3828 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address:"), "</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
4625 | 3829 } |
3830 if (info->numaddresses && info->email2) { | |
3831 int i; | |
3832 for (i = 0; i < info->numaddresses; i++) { | |
4819 | 3833 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_try_conv_to_utf8(info->email2[i]))) { |
3834 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address:"), "</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
4643 | 3835 } |
4625 | 3836 } |
4624 | 3837 } |
4819 | 3838 if (info->mobile && info->mobile[0] && (utf8 = gaim_try_conv_to_utf8(info->mobile))) { |
3839 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4625 | 3840 } |
3841 if (info->gender) { | |
4819 | 3842 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender:"), "</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); |
4151 | 3843 } |
4624 | 3844 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 3845 char date[30]; |
3846 struct tm tm; | |
3847 tm.tm_mday = (int)info->birthday; | |
3848 tm.tm_mon = (int)info->birthmonth-1; | |
3849 tm.tm_year = (int)info->birthyear-1900; | |
4628 | 3850 strftime(date, sizeof(date), "%x", &tm); |
4819 | 3851 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday:"), "</b> ", date, NULL); g_free(tmp); |
4151 | 3852 } |
4624 | 3853 if (info->age) { |
3854 char age[5]; | |
3855 snprintf(age, sizeof(age), "%hhd", info->age); | |
4819 | 3856 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age:"), "</b> ", age, NULL); g_free(tmp); |
3857 } | |
3858 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->personalwebpage))) { | |
3859 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Personal Web Page:"), "</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
3860 } | |
3861 if (info->info && info->info[0] && (utf8 = gaim_try_conv_to_utf8(info->info))) { | |
3862 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information:"), "</b><br>", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3863 } |
3864 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | |
4641 | 3865 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
4819 | 3866 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Home Address:"), "</b>", NULL); g_free(tmp); |
3867 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->homeaddr))) { | |
3868 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3869 } |
4819 | 3870 if (info->homecity && info->homecity[0] && (utf8 = gaim_try_conv_to_utf8(info->homecity))) { |
3871 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3872 } |
4819 | 3873 if (info->homestate && info->homestate[0] && (utf8 = gaim_try_conv_to_utf8(info->homestate))) { |
3874 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3875 } |
4819 | 3876 if (info->homezip && info->homezip[0] && (utf8 = gaim_try_conv_to_utf8(info->homezip))) { |
3877 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3878 } |
3879 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3880 } |
4641 | 3881 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
4819 | 3882 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Address:"), "</b>", NULL); g_free(tmp); |
3883 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->workaddr))) { | |
3884 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3885 } |
4819 | 3886 if (info->workcity && info->workcity[0] && (utf8 = gaim_try_conv_to_utf8(info->workcity))) { |
3887 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3888 } |
4819 | 3889 if (info->workstate && info->workstate[0] && (utf8 = gaim_try_conv_to_utf8(info->workstate))) { |
3890 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3891 } |
4819 | 3892 if (info->workzip && info->workzip[0] && (utf8 = gaim_try_conv_to_utf8(info->workzip))) { |
3893 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3894 } |
3895 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
3896 } | |
4641 | 3897 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
4819 | 3898 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Information:"), "</b>", NULL); g_free(tmp); |
3899 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_try_conv_to_utf8(info->workcompany))) { | |
3900 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3901 } |
4819 | 3902 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_try_conv_to_utf8(info->workdivision))) { |
3903 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3904 } |
4819 | 3905 if (info->workposition && info->workposition[0] && (utf8 = gaim_try_conv_to_utf8(info->workposition))) { |
3906 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4624 | 3907 } |
4819 | 3908 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->workwebpage))) { |
3909 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Web Page:"), "</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | |
4624 | 3910 } |
3911 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3912 } |
3913 | |
3914 g_show_info_text(gc, who, 2, buf, NULL); | |
3915 g_free(buf); | |
3916 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3917 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3918 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3919 |
4759 | 3920 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
3921 { | |
3922 struct gaim_connection *gc = sess->aux_data; | |
4820 | 3923 gchar who[16], *utf8; |
4759 | 3924 struct buddy *b; |
3925 va_list ap; | |
3926 struct aim_icq_info *info; | |
3927 | |
3928 va_start(ap, fr); | |
3929 info = va_arg(ap, struct aim_icq_info *); | |
3930 va_end(ap); | |
3931 | |
4822 | 3932 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) { |
4759 | 3933 g_snprintf(who, sizeof(who), "%lu", info->uin); |
4820 | 3934 serv_got_alias(gc, who, utf8); |
4759 | 3935 if ((b = gaim_find_buddy(gc->account, who))) { |
4820 | 3936 gaim_buddy_set_setting(b, "servernick", utf8); |
4759 | 3937 gaim_blist_save(); |
3938 } | |
4820 | 3939 g_free(utf8); |
4759 | 3940 } |
3941 | |
3942 return 1; | |
3943 } | |
3944 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3945 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
|
3946 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3947 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3948 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3949 va_list ap; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3950 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3951 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3952 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3953 url = va_arg(ap, char *); |
4199 | 3954 wid = (fu16_t) va_arg(ap, int); |
3955 hei = (fu16_t) va_arg(ap, int); | |
3956 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3957 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3958 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3959 serv_got_popup(msg, url, wid, hei); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3960 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3961 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3962 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3963 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3964 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3965 va_list ap; |
3966 char *address, *SNs; | |
3967 int i, num; | |
3968 char *buf; | |
3969 int at = 0, len; | |
3970 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3971 va_start(ap, fr); |
2086 | 3972 address = va_arg(ap, char *); |
3973 num = va_arg(ap, int); | |
3974 SNs = va_arg(ap, char *); | |
3975 va_end(ap); | |
3976 | |
3977 len = num * (MAXSNLEN + 1) + 1024; | |
3978 buf = g_malloc(len); | |
3979 at += g_snprintf(buf + at, len - at, "<B>%s has the following screen names:</B><BR>", address); | |
3980 for (i = 0; i < num; i++) | |
3981 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | |
3212 | 3982 g_show_info_text(NULL, NULL, 2, buf, NULL); |
2086 | 3983 g_free(buf); |
3984 | |
3985 return 1; | |
3986 } | |
3987 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3988 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3989 va_list ap; |
3990 char *address; | |
3991 char buf[BUF_LONG]; | |
3992 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3993 va_start(ap, fr); |
2086 | 3994 address = va_arg(ap, char *); |
3995 va_end(ap); | |
3996 | |
3997 g_snprintf(buf, sizeof(buf), "No results found for email address %s", address); | |
3427 | 3998 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 3999 |
4000 return 1; | |
4001 } | |
4002 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4003 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
|
4004 fu16_t status; |
2086 | 4005 va_list ap; |
4006 char msg[256]; | |
4007 struct gaim_connection *gc = sess->aux_data; | |
4008 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4009 va_start(ap, fr); |
4199 | 4010 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 4011 va_end(ap); |
4012 | |
4013 debug_printf("account confirmation returned status 0x%04x (%s)\n", status, | |
3912 | 4014 status ? "unknown" : "email sent"); |
4015 if (!status) { | |
2086 | 4016 g_snprintf(msg, sizeof(msg), "You should receive an email asking to confirm %s.", |
4017 gc->username); | |
4056 | 4018 do_error_dialog(_("Account Confirmation Requested"), msg, GAIM_INFO); |
2086 | 4019 } |
4020 | |
4021 return 1; | |
4022 } | |
4023 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4024 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
3912 | 4025 struct gaim_connection *gc = sess->aux_data; |
2086 | 4026 va_list ap; |
3912 | 4027 fu16_t perms, err; |
4028 char *url, *sn, *email; | |
4029 int change; | |
2086 | 4030 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4031 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4032 change = va_arg(ap, int); |
4199 | 4033 perms = (fu16_t) va_arg(ap, unsigned int); |
4034 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 4035 url = va_arg(ap, char *); |
4036 sn = va_arg(ap, char *); | |
4037 email = va_arg(ap, char *); | |
2086 | 4038 va_end(ap); |
4039 | |
3912 | 4040 debug_printf("account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
4041 change ? "change" : "request", perms, err, url, sn, email); | |
4042 | |
4043 if (err && url) { | |
4044 char *dialog_msg; | |
4045 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
4046 switch (err) { | |
4047 case 0x0001: { | |
4048 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
4049 } break; | |
4050 case 0x0006: { | |
4051 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
4052 } break; | |
4053 case 0x000b: { | |
4054 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
4055 } break; | |
4056 case 0x001d: { | |
4057 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); | |
4058 } break; | |
4059 case 0x0021: { | |
4060 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); | |
4061 } break; | |
4062 case 0x0023: { | |
4063 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
4064 } break; | |
4065 default: { | |
4066 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
4067 } break; | |
4068 } | |
4069 do_error_dialog(dialog_top, dialog_msg, GAIM_ERROR); | |
4070 g_free(dialog_top); | |
4071 g_free(dialog_msg); | |
4072 return 1; | |
4073 } | |
4074 | |
4075 if (sn) { | |
4585 | 4076 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formatted as follows:\n%s"), sn); |
4056 | 4077 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
3912 | 4078 g_free(dialog_msg); |
4079 } | |
4080 | |
4081 if (email) { | |
4082 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), gc->username, email); | |
4056 | 4083 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
3912 | 4084 g_free(dialog_msg); |
2086 | 4085 } |
4086 | |
4087 return 1; | |
4088 } | |
4089 | |
4090 static void oscar_keepalive(struct gaim_connection *gc) { | |
4617 | 4091 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4092 aim_flap_nop(od->sess, od->conn); | |
2086 | 4093 } |
4094 | |
3001 | 4095 static int oscar_send_typing(struct gaim_connection *gc, char *name, int typing) { |
4617 | 4096 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4097 struct direct_im *dim = find_direct_im(od, name); | |
3595 | 4098 if (dim) |
4870 | 4099 if (typing == TYPING) |
4100 aim_odc_send_typing(od->sess, dim->conn, 0x0002); | |
4101 else if (typing == TYPED) | |
4102 aim_odc_send_typing(od->sess, dim->conn, 0x0001); | |
4103 else | |
4104 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
3595 | 4105 else { |
4738 | 4106 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); |
4107 if (bi && bi->typingnot) { | |
3596 | 4108 if (typing == TYPING) |
4617 | 4109 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
3596 | 4110 else if (typing == TYPED) |
4617 | 4111 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
3595 | 4112 else |
4617 | 4113 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); |
3595 | 4114 } |
4115 } | |
2993 | 4116 return 0; |
4117 } | |
3048 | 4118 static void oscar_ask_direct_im(struct gaim_connection *gc, char *name); |
2993 | 4119 |
3033 | 4120 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) { |
4617 | 4121 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4122 struct direct_im *dim = find_direct_im(od, name); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4123 int ret = 0; |
3659 | 4124 GError *err = NULL; |
3458 | 4125 |
4838 | 4126 if (dim && dim->connected) { |
4127 /* If we're directly connected, send a direct IM */ | |
4128 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
4870 | 4129 if (imflags & IM_FLAG_AWAY) |
4130 ret = aim_odc_send_im(od->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0, 1); | |
4131 else | |
4132 ret = aim_odc_send_im(od->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0, 0); | |
3044 | 4133 } else if (len != -1) { |
4134 /* Trying to send an IM image outside of a direct connection. */ | |
4135 oscar_ask_direct_im(gc, name); | |
4838 | 4136 ret = -ENOTCONN; |
2086 | 4137 } else { |
4738 | 4138 struct buddyinfo *bi; |
3008 | 4139 struct aim_sendimext_args args; |
4140 struct stat st; | |
4151 | 4141 int len; |
4269 | 4142 |
4738 | 4143 bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); |
4144 if (!bi) { | |
4145 bi = g_new0(struct buddyinfo, 1); | |
4146 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(name)), bi); | |
4147 } | |
4148 | |
3008 | 4149 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 4150 if (od->icq) { |
4151 args.features = features_icq; | |
4152 args.featureslen = sizeof(features_icq); | |
3008 | 4153 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 4154 } else { |
4155 args.features = features_aim; | |
4156 args.featureslen = sizeof(features_aim); | |
4157 } | |
4269 | 4158 |
4838 | 4159 if (imflags & IM_FLAG_AWAY) |
4160 args.flags |= AIM_IMFLAGS_AWAY; | |
4161 | |
4738 | 4162 if (bi->ico_need) { |
4163 debug_printf("Sending buddy icon request with message\n"); | |
3008 | 4164 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 4165 bi->ico_need = FALSE; |
3008 | 4166 } |
4269 | 4167 |
4491 | 4168 if (gc->account->iconfile[0] && !stat(gc->account->iconfile, &st)) { |
4169 FILE *file = fopen(gc->account->iconfile, "r"); | |
3008 | 4170 if (file) { |
4171 char *buf = g_malloc(st.st_size); | |
4172 fread(buf, 1, st.st_size, file); | |
4269 | 4173 |
3008 | 4174 args.iconlen = st.st_size; |
4617 | 4175 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 4176 args.iconstamp = st.st_mtime; |
4177 | |
4738 | 4178 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) |
4179 bi->ico_informed = FALSE; | |
4180 | |
4181 if (!bi->ico_informed) { | |
4182 debug_printf("Claiming to have a buddy icon\n"); | |
4183 args.flags |= AIM_IMFLAGS_HASICON; | |
4184 bi->ico_me_len = args.iconlen; | |
4185 bi->ico_me_csum = args.iconsum; | |
4186 bi->ico_me_time = args.iconstamp; | |
4187 bi->ico_informed = TRUE; | |
4188 } | |
4189 | |
3008 | 4190 fclose(file); |
4191 g_free(buf); | |
2086 | 4192 } |
4193 } | |
4269 | 4194 |
3008 | 4195 args.destsn = name; |
4269 | 4196 |
3642 | 4197 len = strlen(message); |
4151 | 4198 args.flags |= check_encoding(message); |
3642 | 4199 if (args.flags & AIM_IMFLAGS_UNICODE) { |
4194 | 4200 debug_printf("Sending Unicode IM\n"); |
4662 | 4201 args.charset = 0x0002; |
4665 | 4202 args.charsubset = 0x0000; |
3659 | 4203 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
4204 if (err) { | |
4205 debug_printf("Error converting a unicode message: %s\n", err->message); | |
4206 debug_printf("This really shouldn't happen!\n"); | |
4207 /* We really shouldn't try to send the | |
4208 * IM now, but I'm not sure what to do */ | |
4800 | 4209 g_error_free(err); |
3659 | 4210 } |
3850 | 4211 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
4194 | 4212 debug_printf("Sending ISO-8859-1 IM\n"); |
4662 | 4213 args.charset = 0x0003; |
4665 | 4214 args.charsubset = 0x0000; |
3659 | 4215 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
4216 if (err) { | |
4217 debug_printf("conversion error: %s\n", err->message); | |
3642 | 4218 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); |
4219 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; | |
4220 len = strlen(message); | |
4800 | 4221 g_error_free(err); |
3659 | 4222 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
4223 if (err) { | |
4194 | 4224 debug_printf("Error in unicode fallback: %s\n", err->message); |
4800 | 4225 g_error_free(err); |
3659 | 4226 } |
3642 | 4227 } |
4228 } else { | |
4662 | 4229 args.charset = 0x0000; |
4230 args.charsubset = 0x0000; | |
3642 | 4231 args.msg = message; |
4232 } | |
4233 args.msglen = len; | |
4269 | 4234 |
4617 | 4235 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 4236 } |
4838 | 4237 |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4238 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4239 return 1; |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
4240 return ret; |
2086 | 4241 } |
4242 | |
4243 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
4617 | 4244 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4245 if (od->icq) | |
4624 | 4246 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4247 else |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4248 /* 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
|
4249 * 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
|
4250 * insert in the middle. i hate people. */ |
4617 | 4251 aim_getinfo(od->sess, od->conn, name, AIM_GETINFO_AWAYMESSAGE); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4252 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4253 |
3212 | 4254 static void oscar_get_away(struct gaim_connection *g, char *who) { |
4617 | 4255 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4256 if (od->icq) { | |
4687 | 4257 struct buddy *budlight = gaim_find_buddy(g->account, who); |
3212 | 4258 if (budlight) |
3595 | 4259 if ((budlight->uc & 0xffff0000) >> 16) |
4687 | 4260 aim_im_sendch2_geticqaway(od->sess, who, (budlight->uc & 0xffff0000) >> 16); |
3212 | 4261 else |
4262 debug_printf("Error: The user %s has no status message, therefore not requesting.\n", who); | |
4263 else | |
4264 debug_printf("Error: Could not find %s in local contact list, therefore unable to request status message.\n", who); | |
4265 } else | |
4617 | 4266 aim_getinfo(od->sess, od->conn, who, AIM_GETINFO_GENERALINFO); |
2086 | 4267 } |
4268 | |
3466 | 4269 static void oscar_set_dir(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
4270 const char *maiden, const char *city, const char *state, const char *country, int web) { | |
4617 | 4271 /* XXX - some of these things are wrong, but i'm lazy */ |
4272 struct oscar_data *od = (struct oscar_data *)g->proto_data; | |
4273 aim_setdirectoryinfo(od->sess, od->conn, first, middle, last, | |
2086 | 4274 maiden, NULL, NULL, city, state, NULL, 0, web); |
4275 } | |
4276 | |
4277 | |
4278 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
4617 | 4279 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4280 aim_bos_setidle(od->sess, od->conn, time); | |
2086 | 4281 } |
4282 | |
4283 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
4617 | 4284 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4151 | 4285 gchar *inforeal, *unicode; |
4286 fu32_t flags; | |
4287 int unicode_len; | |
2993 | 4288 |
4617 | 4289 if (od->rights.maxsiglen == 0) |
3427 | 4290 do_error_dialog(_("Unable to set AIM profile."), |
4291 _("You have probably requested to set your profile before the login procedure completed. " | |
4292 "Your profile remains unset; try setting it again when you are fully connected."), GAIM_ERROR); | |
2993 | 4293 |
4617 | 4294 if (strlen(info) > od->rights.maxsiglen) { |
2993 | 4295 gchar *errstr; |
4296 | |
3427 | 4297 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. " |
4617 | 4298 "Gaim has truncated and set it."), od->rights.maxsiglen); |
3427 | 4299 do_error_dialog("Profile too long.", errstr, GAIM_WARNING); |
2993 | 4300 |
4301 g_free(errstr); | |
4302 } | |
4303 | |
4617 | 4304 inforeal = g_strndup(info, od->rights.maxsiglen); |
4305 | |
4306 if (od->icq) | |
4307 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); | |
4151 | 4308 else { |
4309 flags = check_encoding(inforeal); | |
4310 | |
4311 if (flags == 0) { | |
4617 | 4312 aim_bos_setprofile(od->sess, od->conn, "us-ascii", inforeal, strlen (inforeal), |
4151 | 4313 NULL, NULL, 0, caps_aim); |
4314 } else { | |
4315 unicode = g_convert (inforeal, strlen(inforeal), "UCS-2BE", "UTF-8", NULL, | |
4316 &unicode_len, NULL); | |
4617 | 4317 aim_bos_setprofile(od->sess, od->conn, "unicode-2-0", unicode, unicode_len, |
4151 | 4318 NULL, NULL, 0, caps_aim); |
4319 g_free(unicode); | |
4320 } | |
4321 } | |
2993 | 4322 g_free(inforeal); |
4323 | |
4324 return; | |
2086 | 4325 } |
4326 | |
2993 | 4327 static void oscar_set_away_aim(struct gaim_connection *gc, struct oscar_data *od, const char *message) |
4328 { | |
4151 | 4329 fu32_t flags; |
4330 char *unicode; | |
4331 int unicode_len; | |
2993 | 4332 |
4333 if (od->rights.maxawaymsglen == 0) | |
3427 | 4334 do_error_dialog(_("Unable to set AIM away message."), |
4335 _("You have probably requested to set your away message before the login procedure completed. " | |
4336 "You remain in a \"present\" state; try setting it again when you are fully connected."), GAIM_ERROR); | |
4337 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4338 if (gc->away) { |
2993 | 4339 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4340 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4341 } |
2993 | 4342 |
4343 if (!message) { | |
4151 | 4344 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
|
4345 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4346 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4347 |
2993 | 4348 if (strlen(message) > od->rights.maxawaymsglen) { |
4349 gchar *errstr; | |
4350 | |
3427 | 4351 errstr = g_strdup_printf(_("The away message length of %d bytes has been exceeded. " |
4352 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen); | |
4353 do_error_dialog("Away message too long.", errstr, GAIM_WARNING); | |
2993 | 4354 g_free(errstr); |
4355 } | |
4356 | |
4357 gc->away = g_strndup(message, od->rights.maxawaymsglen); | |
4151 | 4358 flags = check_encoding(message); |
4359 | |
4360 if (flags == 0) { | |
4361 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", gc->away, strlen(gc->away), | |
4362 caps_aim); | |
4363 } else { | |
4364 unicode = g_convert(message, strlen(message), "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); | |
4365 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", unicode, unicode_len, | |
4366 caps_aim); | |
4367 g_free(unicode); | |
4368 } | |
2993 | 4369 |
4370 return; | |
4371 } | |
4372 | |
4373 static void oscar_set_away_icq(struct gaim_connection *gc, struct oscar_data *od, const char *state, const char *message) | |
4374 { | |
4375 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4376 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4377 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4378 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4379 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4380 |
4342 | 4381 if (strcmp(state, _("Invisible"))) { |
4491 | 4382 if (aim_ssi_getpermdeny(od->sess->ssi.local) != gc->account->permdeny) |
4889 | 4383 aim_ssi_setpermdeny(od->sess, gc->account->permdeny, 0xffffffff); |
4491 | 4384 gc->account->permdeny = 4; |
4342 | 4385 } else { |
4386 if (aim_ssi_getpermdeny(od->sess->ssi.local) != 0x03) | |
4889 | 4387 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); |
4491 | 4388 gc->account->permdeny = 3; |
4342 | 4389 } |
4390 | |
4391 if (!strcmp(state, _("Online"))) | |
4901 | 4392 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
4342 | 4393 else if (!strcmp(state, _("Away"))) { |
4901 | 4394 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4395 gc->away = g_strdup(""); |
4342 | 4396 } else if (!strcmp(state, _("Do Not Disturb"))) { |
4901 | 4397 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4398 gc->away = g_strdup(""); |
4342 | 4399 } else if (!strcmp(state, _("Not Available"))) { |
4901 | 4400 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4401 gc->away = g_strdup(""); |
4342 | 4402 } else if (!strcmp(state, _("Occupied"))) { |
4901 | 4403 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4404 gc->away = g_strdup(""); |
4342 | 4405 } else if (!strcmp(state, _("Free For Chat"))) { |
4901 | 4406 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4407 gc->away = g_strdup(""); |
4342 | 4408 } else if (!strcmp(state, _("Invisible"))) { |
4901 | 4409 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4410 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4411 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 4412 if (message) { |
4901 | 4413 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4414 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4415 } else { |
4901 | 4416 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4417 } |
2086 | 4418 } |
2993 | 4419 |
4420 return; | |
4421 } | |
4422 | |
4423 static void oscar_set_away(struct gaim_connection *gc, char *state, char *message) | |
4424 { | |
4425 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4426 | |
4427 if (od->icq) | |
4428 oscar_set_away_icq(gc, od, state, message); | |
4429 else | |
4430 oscar_set_away_aim(gc, od, message); | |
4431 | |
4432 return; | |
2086 | 4433 } |
4434 | |
4230 | 4435 static void oscar_warn(struct gaim_connection *gc, char *name, int anon) { |
4617 | 4436 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4437 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); | |
2086 | 4438 } |
4439 | |
4230 | 4440 static void oscar_dir_search(struct gaim_connection *gc, const char *first, const char *middle, const char *last, |
3466 | 4441 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
4617 | 4442 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 4443 if (strlen(email)) |
4617 | 4444 aim_usersearch_address(od->sess, od->conn, email); |
2086 | 4445 } |
4446 | |
4230 | 4447 static void oscar_add_buddy(struct gaim_connection *gc, const char *name) { |
4448 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4449 #ifdef NOSSI | |
4450 aim_add_buddy(od->sess, od->conn, name); | |
4451 #else | |
4452 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
4687 | 4453 struct buddy *buddy = gaim_find_buddy(gc->account, name); |
4454 struct group *group = gaim_find_buddys_group(buddy); | |
4230 | 4455 if (buddy && group) { |
4456 debug_printf("ssi: adding buddy %s to group %s\n", name, group->name); | |
4889 | 4457 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4458 } |
4459 } | |
4460 #endif | |
4759 | 4461 if (od->icq) |
4462 aim_icq_getalias(od->sess, name); | |
4230 | 4463 } |
4464 | |
4465 static void oscar_add_buddies(struct gaim_connection *gc, GList *buddies) { | |
4466 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4467 #ifdef NOSSI | |
4468 char buf[MSG_LEN]; | |
4469 int n=0; | |
4470 while (buddies) { | |
4471 if (n > MSG_LEN - 18) { | |
4472 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4473 n = 0; | |
3092 | 4474 } |
4230 | 4475 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); |
4476 buddies = buddies->next; | |
4477 } | |
4478 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4479 #else | |
4480 if (od->sess->ssi.received_data) { | |
4481 while (buddies) { | |
4687 | 4482 struct buddy *buddy = gaim_find_buddy(gc->account, (const char *)buddies->data); |
4483 struct group *group = gaim_find_buddys_group(buddy); | |
4230 | 4484 if (buddy && group) { |
4485 debug_printf("ssi: adding buddy %s to group %s\n", (const char *)buddies->data, group->name); | |
4889 | 4486 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4487 } |
4488 buddies = buddies->next; | |
4489 } | |
4490 } | |
4491 #endif | |
4492 } | |
4493 | |
4494 static void oscar_remove_buddy(struct gaim_connection *gc, char *name, char *group) { | |
4495 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4496 #ifdef NOSSI | |
4497 aim_remove_buddy(od->sess, od->conn, name); | |
4498 #else | |
4499 if (od->sess->ssi.received_data) { | |
4500 debug_printf("ssi: deleting buddy %s from group %s\n", name, group); | |
4889 | 4501 aim_ssi_delbuddy(od->sess, name, group); |
4230 | 4502 } |
4503 #endif | |
4504 } | |
4505 | |
4506 static void oscar_remove_buddies(struct gaim_connection *gc, GList *buddies, const char *group) { | |
4507 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4508 #ifdef NOSSI | |
4509 GList *cur; | |
4510 for (cur=buddies; cur; cur=cur->next) | |
4511 aim_remove_buddy(od->sess, od->conn, cur->data); | |
4512 #else | |
4513 if (od->sess->ssi.received_data) { | |
3092 | 4514 while (buddies) { |
4230 | 4515 debug_printf("ssi: deleting buddy %s from group %s\n", (char *)buddies->data, group); |
4889 | 4516 aim_ssi_delbuddy(od->sess, buddies->data, group); |
3092 | 4517 buddies = buddies->next; |
4518 } | |
4230 | 4519 } |
4520 #endif | |
4521 } | |
4522 | |
4523 #ifndef NOSSI | |
4269 | 4524 static void oscar_move_buddy(struct gaim_connection *gc, const char *name, const char *old_group, const char *new_group) { |
4525 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4303 | 4526 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
4269 | 4527 debug_printf("ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4889 | 4528 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
4269 | 4529 } |
4530 } | |
4531 | |
4532 static void oscar_alias_buddy(struct gaim_connection *gc, const char *name, const char *alias) { | |
4533 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4534 if (od->sess->ssi.received_data) { | |
4535 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
4536 if (gname) { | |
4537 debug_printf("ssi: changing the alias for buddy %s to %s\n", name, alias); | |
4889 | 4538 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
4269 | 4539 } |
4540 } | |
4541 } | |
4542 | |
4230 | 4543 static void oscar_rename_group(struct gaim_connection *g, const char *old_group, const char *new_group, GList *members) { |
4544 struct oscar_data *od = (struct oscar_data *)g->proto_data; | |
4545 | |
4546 if (od->sess->ssi.received_data) { | |
4547 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
4548 oscar_remove_buddies(g, members, old_group); | |
4549 oscar_add_buddies(g, members); | |
4550 debug_printf("ssi: moved all buddies from group %s to %s\n", old_group, new_group); | |
4551 } else { | |
4889 | 4552 aim_ssi_rename_group(od->sess, old_group, new_group); |
4230 | 4553 debug_printf("ssi: renamed group %s to %s\n", old_group, new_group); |
2995 | 4554 } |
4555 } | |
4556 } | |
4557 | |
4642 | 4558 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4559 struct gaim_connection *gc = sess->aux_data; | |
4560 struct oscar_data *od = gc->proto_data; | |
4561 va_list ap; | |
4562 fu16_t reason; | |
4563 | |
4564 va_start(ap, fr); | |
4565 reason = (fu16_t)va_arg(ap, unsigned int); | |
4566 va_end(ap); | |
4567 | |
4568 debug_printf("ssi: SNAC error %hu\n", reason); | |
4569 | |
4570 if (reason == 0x0005) { | |
4571 do_error_dialog(_("Unable To Retrive Buddy List"), _("Gaim was temporarily unable to retrive your buddy list from the AIM servers. Your buddy list is not lost, and will probably become available in a few hours."), GAIM_ERROR); | |
4572 } | |
4573 | |
4574 /* Activate SSI */ | |
4575 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4576 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
4577 debug_printf("ssi: activating server-stored buddy list\n"); | |
4578 aim_ssi_enable(od->sess); | |
4579 | |
4580 return 1; | |
4581 } | |
4582 | |
2991 | 4583 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
4230 | 4584 struct gaim_connection *gc = sess->aux_data; |
4585 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4586 int numtypes, i; | |
4587 fu16_t *maxitems; | |
2991 | 4588 va_list ap; |
4589 | |
4590 va_start(ap, fr); | |
4230 | 4591 numtypes = va_arg(ap, int); |
4592 maxitems = va_arg(ap, fu16_t *); | |
2991 | 4593 va_end(ap); |
4594 | |
4230 | 4595 debug_printf("ssi rights:"); |
4596 for (i=0; i<numtypes; i++) | |
4617 | 4597 debug_printf(" max type 0x%04x=%hd,", i, maxitems[i]); |
4317 | 4598 debug_printf("\n"); |
4230 | 4599 |
4600 if (numtypes >= 0) | |
4601 od->rights.maxbuddies = maxitems[0]; | |
4602 if (numtypes >= 1) | |
4603 od->rights.maxgroups = maxitems[1]; | |
4604 if (numtypes >= 2) | |
4605 od->rights.maxpermits = maxitems[2]; | |
4606 if (numtypes >= 3) | |
4607 od->rights.maxdenies = maxitems[3]; | |
2991 | 4608 |
4609 return 1; | |
4610 } | |
4611 | |
4612 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4613 struct gaim_connection *gc = sess->aux_data; | |
4230 | 4614 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4615 struct aim_ssi_item *curitem; |
2991 | 4616 int tmp; |
4778 | 4617 gboolean export = FALSE; |
4617 | 4618 /* XXX - use these? |
4230 | 4619 va_list ap; |
4620 | |
4621 va_start(ap, fr); | |
4622 fmtver = (fu16_t)va_arg(ap, int); | |
4623 numitems = (fu16_t)va_arg(ap, int); | |
4624 items = va_arg(ap, struct aim_ssi_item); | |
4625 timestamp = va_arg(ap, fu32_t); | |
4626 va_end(ap); */ | |
2991 | 4627 |
4628 debug_printf("ssi: syncing local list and server list\n"); | |
4629 | |
4630 /* Clean the buddy list */ | |
4889 | 4631 aim_ssi_cleanlist(sess); |
2991 | 4632 |
4633 /* Add from server list to local list */ | |
4230 | 4634 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
2991 | 4635 switch (curitem->type) { |
4230 | 4636 case 0x0000: { /* Buddy */ |
4251 | 4637 if (curitem->name) { |
4292 | 4638 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
4458 | 4639 char *gname_utf8 = gaim_try_conv_to_utf8(gname); |
4282 | 4640 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
4458 | 4641 char *alias_utf8 = gaim_try_conv_to_utf8(alias); |
4687 | 4642 struct buddy *buddy = gaim_find_buddy(gc->account, curitem->name); |
4458 | 4643 /* Should gname be freed here? -- elb */ |
4754 | 4644 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 4645 free(alias); |
4282 | 4646 if (buddy) { |
4292 | 4647 /* Get server stored alias */ |
4705 | 4648 if (alias_utf8) { |
4649 g_free(buddy->alias); | |
4650 buddy->alias = g_strdup(alias_utf8); | |
4651 } | |
4282 | 4652 } else { |
4687 | 4653 struct group *g; |
4654 buddy = gaim_buddy_new(gc->account, curitem->name, alias_utf8); | |
4655 | |
4754 | 4656 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 4657 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 4658 gaim_blist_add_group(g, NULL); |
4659 } | |
4687 | 4660 |
4251 | 4661 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); |
4687 | 4662 gaim_blist_add_buddy(buddy, g, NULL); |
4778 | 4663 export = TRUE; |
4251 | 4664 } |
4458 | 4665 free(gname_utf8); |
4666 free(alias_utf8); | |
2991 | 4667 } |
4230 | 4668 } break; |
4669 | |
4670 case 0x0001: { /* Group */ | |
4282 | 4671 /* Shouldn't add empty groups */ |
4230 | 4672 } break; |
4673 | |
4674 case 0x0002: { /* Permit buddy */ | |
2991 | 4675 if (curitem->name) { |
4230 | 4676 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 4677 GSList *list; |
4491 | 4678 for (list=gc->account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4679 if (!list) { |
2995 | 4680 debug_printf("ssi: adding permit buddy %s to local list\n", curitem->name); |
4491 | 4681 gaim_privacy_permit_add(gc->account, curitem->name); |
2991 | 4682 build_allow_list(); |
4778 | 4683 export = TRUE; |
2991 | 4684 } |
4685 } | |
4230 | 4686 } break; |
4687 | |
4688 case 0x0003: { /* Deny buddy */ | |
2991 | 4689 if (curitem->name) { |
4690 GSList *list; | |
4491 | 4691 for (list=gc->account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4692 if (!list) { |
2995 | 4693 debug_printf("ssi: adding deny buddy %s to local list\n", curitem->name); |
4491 | 4694 gaim_privacy_deny_add(gc->account, curitem->name); |
2991 | 4695 build_block_list(); |
4778 | 4696 export = TRUE; |
2991 | 4697 } |
4698 } | |
4230 | 4699 } break; |
4700 | |
4701 case 0x0004: { /* Permit/deny setting */ | |
2991 | 4702 if (curitem->data) { |
4703 fu8_t permdeny; | |
4491 | 4704 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != gc->account->permdeny)) { |
4705 debug_printf("ssi: changing permdeny from %d to %hhu\n", gc->account->permdeny, permdeny); | |
4706 gc->account->permdeny = permdeny; | |
4707 if (od->icq && gc->account->permdeny == 0x03) { | |
4342 | 4708 serv_set_away(gc, "Invisible", ""); |
4709 } | |
4778 | 4710 export = TRUE; |
2991 | 4711 } |
4712 } | |
4230 | 4713 } break; |
4714 | |
4715 case 0x0005: { /* Presence setting */ | |
3109 | 4716 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 4717 } break; |
2991 | 4718 } /* End of switch on curitem->type */ |
4719 } /* End of for loop */ | |
4230 | 4720 |
4721 /* If changes were made, then flush buddy list to file */ | |
4778 | 4722 if (export) |
4349 | 4723 gaim_blist_save(); |
2991 | 4724 |
4759 | 4725 { /* Add from local list to server list */ |
4726 GaimBlistNode *gnode, *bnode; | |
4727 struct group *group; | |
4728 struct buddy *buddy; | |
4729 struct gaim_buddy_list *blist; | |
3017 | 4730 GSList *cur; |
4731 | |
2991 | 4732 /* Buddies */ |
4759 | 4733 if ((blist = gaim_get_blist())) |
4734 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
4735 group = (struct group *)gnode; | |
4736 for (bnode = gnode->child; bnode; bnode = bnode->next) { | |
4737 buddy = (struct buddy *)bnode; | |
4738 if (buddy->account == gc->account) { | |
4739 gchar *servernick = gaim_buddy_get_setting(buddy, "servernick"); | |
4740 if (servernick) { | |
4741 serv_got_alias(gc, buddy->name, servernick); | |
4742 g_free(servernick); | |
4743 } | |
4744 if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { | |
4745 /* Store local alias on server */ | |
4746 char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); | |
4783 | 4747 if (!alias && buddy->alias && strlen(buddy->alias)) |
4889 | 4748 aim_ssi_aliasbuddy(sess, group->name, buddy->name, buddy->alias); |
4759 | 4749 free(alias); |
4750 } else { | |
4751 debug_printf("ssi: adding buddy %s from local list to server list\n", buddy->name); | |
4889 | 4752 aim_ssi_addbuddy(sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4759 | 4753 } |
4349 | 4754 } |
4230 | 4755 } |
4292 | 4756 } |
2991 | 4757 /* Permit list */ |
4491 | 4758 if (gc->account->permit) { |
4759 for (cur=gc->account->permit; cur; cur=cur->next) | |
4230 | 4760 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
4761 debug_printf("ssi: adding permit %s from local list to server list\n", (char *)cur->data); | |
4889 | 4762 aim_ssi_addpermit(sess, cur->data); |
4230 | 4763 } |
2991 | 4764 } |
4765 | |
4766 /* Deny list */ | |
4491 | 4767 if (gc->account->deny) { |
4768 for (cur=gc->account->deny; cur; cur=cur->next) | |
4230 | 4769 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
4770 debug_printf("ssi: adding deny %s from local list to server list\n", (char *)cur->data); | |
4889 | 4771 aim_ssi_adddeny(sess, cur->data); |
4230 | 4772 } |
2991 | 4773 } |
3109 | 4774 /* Presence settings (idle time visibility) */ |
4230 | 4775 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) |
3109 | 4776 if (report_idle && !(tmp & 0x400)) |
4889 | 4777 aim_ssi_setpresence(sess, tmp | 0x400); |
4778 | 4778 } /* end adding buddies from local list to server list */ |
4779 | |
4780 { /* Check for maximum number of buddies */ | |
4785 | 4781 GaimBlistNode *gnode,*bnode; |
4782 tmp = 0; | |
4783 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
4784 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 continue; | |
4786 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
4787 struct buddy *b = (struct buddy *)bnode; | |
4788 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
4789 continue; | |
4491 | 4790 if(b->account == gc->account) |
4349 | 4791 tmp++; |
4792 } | |
3214 | 4793 } |
4770 | 4794 |
4230 | 4795 if (tmp > od->rights.maxbuddies) { |
3210 | 4796 char *dialog_msg = g_strdup_printf(_("The maximum number of buddies allowed in your buddy list is %d, and you have %d." |
4797 " Until you are below the limit, some buddies will not show up as online."), | |
4230 | 4798 od->rights.maxbuddies, tmp); |
4642 | 4799 do_error_dialog(_("Maximum buddy list length exceeded."), dialog_msg, GAIM_WARNING); |
3210 | 4800 g_free(dialog_msg); |
4801 } | |
4778 | 4802 } |
4785 | 4803 |
4901 | 4804 /* Set our ICQ status */ |
4805 if (od->icq && !gc->away) { | |
4806 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); | |
4807 } | |
4808 | |
4342 | 4809 /* Activate SSI */ |
4810 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4811 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
4812 debug_printf("ssi: activating server-stored buddy list\n"); | |
4642 | 4813 aim_ssi_enable(sess); |
4342 | 4814 |
2991 | 4815 return 1; |
2086 | 4816 } |
4230 | 4817 |
4818 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4819 struct gaim_connection *gc = sess->aux_data; | |
4820 va_list ap; | |
4821 struct aim_ssi_tmp *retval; | |
4822 | |
4823 va_start(ap, fr); | |
4824 retval = va_arg(ap, struct aim_ssi_tmp *); | |
4825 va_end(ap); | |
4826 | |
4827 while (retval) { | |
4848 | 4828 debug_printf("ssi: status is 0x%04hx for a 0x%04hx action with name %s\n", retval->ack, retval->action, retval->item ? (retval->item->name ? retval->item->name : "no name") : "no item"); |
4230 | 4829 |
4830 if (retval->ack != 0xffff) | |
4831 switch (retval->ack) { | |
4832 case 0x0000: { /* added successfully */ | |
4833 } break; | |
4834 | |
4829 | 4835 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
4836 gchar *buf; | |
4837 buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)"))); | |
4838 /* do_error_dialog(_("Unable To Add"), buf, GAIM_ERROR); */ | |
4839 g_free(buf); | |
4840 } | |
4841 | |
4230 | 4842 case 0x000e: { /* contact requires authorization */ |
4828 | 4843 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
4269 | 4844 gaim_auth_sendrequest(gc, retval->name); |
4230 | 4845 } break; |
4846 | |
4847 default: { /* La la la */ | |
4848 debug_printf("ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); | |
4849 /* Should remove buddy from local list and give an error message? */ | |
4850 } break; | |
4851 } | |
4852 | |
4853 retval = retval->next; | |
4854 } | |
4855 | |
4856 return 1; | |
4857 } | |
4858 | |
4859 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4860 struct gaim_connection *gc = sess->aux_data; | |
4861 va_list ap; | |
4862 char *sn, *msg; | |
4236 | 4863 gchar *dialog_msg, *nombre; |
4230 | 4864 struct name_data *data; |
4236 | 4865 struct buddy *buddy; |
4230 | 4866 |
4867 va_start(ap, fr); | |
4868 sn = va_arg(ap, char *); | |
4869 msg = va_arg(ap, char *); | |
4870 va_end(ap); | |
4871 | |
4872 debug_printf("ssi: %s has given you permission to add him to your buddy list\n", sn); | |
4873 | |
4687 | 4874 buddy = gaim_find_buddy(gc->account, sn); |
4875 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4876 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4877 else |
4878 nombre = g_strdup(sn); | |
4879 | |
4880 dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list. Do you want to add them?"), nombre); | |
4230 | 4881 data = g_new(struct name_data, 1); |
4882 data->gc = gc; | |
4883 data->name = g_strdup(sn); | |
4884 data->nick = NULL; | |
4249 | 4885 do_ask_dialog(_("Authorization Given"), dialog_msg, data, _("Yes"), gaim_icq_contactadd, _("No"), gaim_free_name_data, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
4236 | 4886 |
4230 | 4887 g_free(dialog_msg); |
4236 | 4888 g_free(nombre); |
4230 | 4889 |
4890 return 1; | |
4891 } | |
4892 | |
4893 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4894 struct gaim_connection *gc = sess->aux_data; | |
4895 va_list ap; | |
4896 char *sn, *msg; | |
4236 | 4897 gchar *dialog_msg, *nombre; |
4230 | 4898 struct name_data *data; |
4236 | 4899 struct buddy *buddy; |
4230 | 4900 |
4901 va_start(ap, fr); | |
4902 sn = va_arg(ap, char *); | |
4903 msg = va_arg(ap, char *); | |
4904 va_end(ap); | |
4905 | |
4906 debug_printf("ssi: received authorization request from %s\n", sn); | |
4907 | |
4687 | 4908 buddy = gaim_find_buddy(gc->account, sn); |
4909 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4910 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4911 else |
4912 nombre = g_strdup(sn); | |
4913 | |
4337 | 4914 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
4230 | 4915 data = g_new(struct name_data, 1); |
4916 data->gc = gc; | |
4917 data->name = g_strdup(sn); | |
4918 data->nick = NULL; | |
4337 | 4919 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
4236 | 4920 |
4230 | 4921 g_free(dialog_msg); |
4236 | 4922 g_free(nombre); |
4230 | 4923 |
4924 return 1; | |
4925 } | |
4926 | |
4927 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4236 | 4928 struct gaim_connection *gc = sess->aux_data; |
4230 | 4929 va_list ap; |
4930 char *sn, *msg; | |
4236 | 4931 gchar *dialog_msg, *nombre; |
4230 | 4932 fu8_t reply; |
4236 | 4933 struct buddy *buddy; |
4230 | 4934 |
4935 va_start(ap, fr); | |
4936 sn = va_arg(ap, char *); | |
4937 reply = (fu8_t)va_arg(ap, int); | |
4938 msg = va_arg(ap, char *); | |
4939 va_end(ap); | |
4940 | |
4236 | 4941 debug_printf("ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4942 | |
4687 | 4943 buddy = gaim_find_buddy(gc->account, sn); |
4944 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4945 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4946 else |
4947 nombre = g_strdup(sn); | |
4948 | |
4230 | 4949 if (reply) { |
4950 /* Granted */ | |
4236 | 4951 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your contact list."), nombre); |
4230 | 4952 do_error_dialog(_("Authorization Granted"), dialog_msg, GAIM_INFO); |
4953 } else { | |
4954 /* Denied */ | |
4236 | 4955 dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your contact list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
4230 | 4956 do_error_dialog(_("Authorization Denied"), dialog_msg, GAIM_INFO); |
4957 } | |
4958 g_free(dialog_msg); | |
4236 | 4959 g_free(nombre); |
4230 | 4960 |
4961 return 1; | |
4962 } | |
4963 | |
4964 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4965 struct gaim_connection *gc = sess->aux_data; | |
4966 va_list ap; | |
4967 char *sn; | |
4236 | 4968 struct buddy *buddy; |
4230 | 4969 |
4970 va_start(ap, fr); | |
4971 sn = va_arg(ap, char *); | |
4972 va_end(ap); | |
4973 | |
4687 | 4974 buddy = gaim_find_buddy(gc->account, sn); |
4230 | 4975 debug_printf("ssi: %s added you to their buddy list\n", sn); |
4687 | 4976 show_got_added(gc, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 4977 |
4978 return 1; | |
4979 } | |
4269 | 4980 #endif |
2086 | 4981 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4982 static GList *oscar_chat_info(struct gaim_connection *gc) { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4983 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4984 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4985 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4986 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4987 pce->label = _("Join what group:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4988 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4989 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4990 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4991 pce->label = _("Exchange:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4992 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4993 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4994 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4995 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4996 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4997 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4998 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4999 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5000 static void oscar_join_chat(struct gaim_connection *g, GList *data) { |
4617 | 5001 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5002 aim_conn_t *cur; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5003 char *name; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5004 int *exchange; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5005 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5006 if (!data || !data->next) |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5007 return; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5008 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5009 name = data->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5010 exchange = data->next->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5011 |
2086 | 5012 debug_printf("Attempting to join chat room %s.\n", name); |
4617 | 5013 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
2086 | 5014 debug_printf("chatnav exists, creating room\n"); |
4617 | 5015 aim_chatnav_createroom(od->sess, cur, name, *exchange); |
2086 | 5016 } else { |
5017 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5018 struct create_room *cr = g_new0(struct create_room, 1); |
2086 | 5019 debug_printf("chatnav does not exist, opening chatnav\n"); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5020 cr->exchange = *exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5021 cr->name = g_strdup(name); |
4617 | 5022 od->create_rooms = g_slist_append(od->create_rooms, cr); |
5023 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 5024 } |
5025 } | |
5026 | |
3466 | 5027 static void oscar_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) { |
4617 | 5028 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 5029 struct chat_connection *ccon = find_oscar_chat(g, id); |
5030 | |
5031 if (!ccon) | |
5032 return; | |
5033 | |
4617 | 5034 aim_chat_invite(od->sess, od->conn, name, message ? message : "", |
2086 | 5035 ccon->exchange, ccon->name, 0x0); |
5036 } | |
5037 | |
5038 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
4617 | 5039 struct oscar_data *od = g ? (struct oscar_data *)g->proto_data : NULL; |
2086 | 5040 GSList *bcs = g->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5041 struct gaim_conversation *b = NULL; |
2086 | 5042 struct chat_connection *c = NULL; |
5043 int count = 0; | |
5044 | |
5045 while (bcs) { | |
5046 count++; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5047 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5048 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 5049 break; |
5050 bcs = bcs->next; | |
5051 b = NULL; | |
5052 } | |
5053 | |
5054 if (!b) | |
5055 return; | |
5056 | |
5057 debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count); | |
5058 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5059 c = find_oscar_chat(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 5060 if (c != NULL) { |
4617 | 5061 if (od) |
5062 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 5063 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5064 gaim_input_remove(c->inpa); |
4617 | 5065 if (g && od->sess) |
5066 aim_conn_kill(od->sess, &c->conn); | |
2086 | 5067 g_free(c->name); |
5068 g_free(c->show); | |
5069 g_free(c); | |
5070 } | |
5071 /* we do this because with Oscar it doesn't tell us we left */ | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5072 serv_got_chat_left(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 5073 } |
5074 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5075 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
4617 | 5076 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 5077 GSList *bcs = g->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5078 struct gaim_conversation *b = NULL; |
2086 | 5079 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5080 char *buf, *buf2; |
2086 | 5081 int i, j; |
5082 | |
5083 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5084 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5085 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 5086 break; |
5087 bcs = bcs->next; | |
5088 b = NULL; | |
5089 } | |
5090 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5091 return -EINVAL; |
2086 | 5092 |
4617 | 5093 bcs = od->oscar_chats; |
2086 | 5094 while (bcs) { |
5095 c = (struct chat_connection *)bcs->data; | |
5096 if (b == c->cnv) | |
5097 break; | |
5098 bcs = bcs->next; | |
5099 c = NULL; | |
5100 } | |
5101 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5102 return -EINVAL; |
2086 | 5103 |
5104 buf = g_malloc(strlen(message) * 4 + 1); | |
5105 for (i = 0, j = 0; i < strlen(message); i++) { | |
5106 if (message[i] == '\n') { | |
5107 buf[j++] = '<'; | |
5108 buf[j++] = 'B'; | |
5109 buf[j++] = 'R'; | |
5110 buf[j++] = '>'; | |
5111 } else { | |
5112 buf[j++] = message[i]; | |
5113 } | |
5114 } | |
5115 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5116 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5117 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5118 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5119 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5120 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5121 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5122 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5123 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5124 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5125 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5126 |
4617 | 5127 aim_chat_send_im(od->sess, c->conn, 0, buf, strlen(buf)); |
2086 | 5128 g_free(buf); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5129 return 0; |
2086 | 5130 } |
5131 | |
4687 | 5132 static const char *oscar_list_icon(struct gaim_account *a, struct buddy *b) { |
4766 | 5133 if (!b || (b && b->name && b->name[0] == '+')) { |
4687 | 5134 if (isdigit(a->username[0])) |
5135 return "icq"; | |
5136 else | |
5137 return "aim"; | |
5138 } | |
5139 | |
5140 if (isdigit(b->name[0])) | |
5141 return "icq"; | |
5142 return "aim"; | |
5143 } | |
5144 | |
4690 | 5145 static void oscar_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 5146 { |
5147 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
5148 int i = 0; | |
5149 | |
4766 | 5150 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
5151 /* int uc = b->uc >> 16; | |
5152 if (uc & AIM_ICQ_STATE_INVISIBLE) | |
5153 emblems[i++] = "icq_invisible"; | |
5154 else if (uc & AIM_ICQ_STATE_CHAT) | |
5155 emblems[i++] = "icq_chat"; | |
5156 else if (uc & AIM_ICQ_STATE_DND) | |
5157 emblems[i++] = "icq_dnd"; | |
5158 else if (uc & AIM_ICQ_STATE_OUT) | |
5159 emblems[i++] = "icq_out"; | |
5160 else if (uc & AIM_ICQ_STATE_BUSY) | |
5161 emblems[i++] = "icq_busy"; | |
5162 else if (uc & AIM_ICQ_STATE_AWAY) | |
5163 emblems[i++] = "icq_away"; | |
5164 */ | |
5165 if (b->uc & UC_UNAVAILABLE) | |
5166 emblems[i++] = "away"; | |
5167 } else { | |
5168 if (b->uc & UC_UNAVAILABLE) | |
5169 emblems[i++] = "away"; | |
5170 } | |
4687 | 5171 if (b->uc & UC_WIRELESS) |
5172 emblems[i++] = "wireless"; | |
5173 if (b->uc & UC_AOL) | |
5174 emblems[i++] = "aol"; | |
5175 if (b->uc & UC_ADMIN) | |
5176 emblems[i++] = "admin"; | |
5177 if (b->uc & UC_AB && i < 4) | |
5178 emblems[i++] = "activebuddy"; | |
4766 | 5179 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
5180 emblems[i++] = "unconfirmed"; */ | |
4687 | 5181 *se = emblems[0]; |
5182 *sw = emblems[1]; | |
5183 *nw = emblems[2]; | |
5184 *ne = emblems[3]; | |
5185 } | |
5186 | |
3952 | 5187 /* |
4617 | 5188 * We have just established a socket with the other dude, so set up some handlers. |
3952 | 5189 */ |
4617 | 5190 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5191 struct gaim_connection *gc = sess->aux_data; |
5192 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5193 struct gaim_conversation *cnv; |
2086 | 5194 struct direct_im *dim; |
5195 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5196 char *sn; |
4617 | 5197 va_list ap; |
5198 aim_conn_t *newconn, *listenerconn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5199 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5200 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5201 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5202 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 5203 va_end(ap); |
5204 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5205 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5206 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5207 |
4617 | 5208 sn = g_strdup(aim_odc_getsn(newconn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5209 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5210 debug_printf("DirectIM: initiate success to %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5211 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5212 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5213 if (!(cnv = gaim_find_conversation(sn))) |
4491 | 5214 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5215 gaim_input_remove(dim->watcher); |
2086 | 5216 dim->conn = newconn; |
4617 | 5217 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
3008 | 5218 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5219 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5220 g_free(sn); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5221 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
2086 | 5222 |
4617 | 5223 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
5224 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
5225 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_update_ui, 0); | |
5226 | |
2993 | 5227 return 1; |
5228 } | |
5229 | |
5230 static int gaim_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
5231 va_list ap; | |
5232 char *sn; | |
5233 double percent; | |
5234 struct gaim_connection *gc = sess->aux_data; | |
5235 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5236 struct gaim_conversation *c; |
2993 | 5237 struct direct_im *dim; |
5238 | |
5239 va_start(ap, fr); | |
5240 sn = va_arg(ap, char *); | |
5241 percent = va_arg(ap, double); | |
5242 va_end(ap); | |
5243 | |
2994 | 5244 if (!(dim = find_direct_im(od, sn))) |
5245 return 1; | |
3059 | 5246 if (dim->watcher) { |
5247 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
5248 dim->watcher = 0; | |
5249 } | |
3044 | 5250 while (gtk_events_pending()) |
5251 gtk_main_iteration(); | |
5252 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5253 if ((c = gaim_find_conversation(sn))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5254 gaim_conversation_update_progress(c, percent); |
2993 | 5255 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
5256 oscar_callback, dim->conn); | |
2086 | 5257 |
5258 return 1; | |
5259 } | |
5260 | |
4617 | 5261 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
4870 | 5262 struct gaim_connection *gc = sess->aux_data; |
5263 int imflags = 0; | |
2086 | 5264 va_list ap; |
4870 | 5265 char *sn, *msg; |
5266 int len, encoding, isawaymsg; | |
2086 | 5267 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5268 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5269 sn = va_arg(ap, char *); |
2086 | 5270 msg = va_arg(ap, char *); |
2993 | 5271 len = va_arg(ap, int); |
3952 | 5272 encoding = va_arg(ap, int); |
4870 | 5273 isawaymsg = va_arg(ap, int); |
2086 | 5274 va_end(ap); |
5275 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5276 debug_printf("Got DirectIM message from %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5277 |
4870 | 5278 if (isawaymsg) |
5279 imflags |= IM_FLAG_AWAY; | |
5280 | |
4617 | 5281 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
4870 | 5282 serv_got_im(gc, sn, msg, imflags, time(NULL), len); |
2086 | 5283 |
5284 return 1; | |
5285 } | |
5286 | |
4617 | 5287 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5288 va_list ap; |
5289 char *sn; | |
2993 | 5290 int typing; |
5291 struct gaim_connection *gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5292 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5293 va_start(ap, fr); |
2086 | 5294 sn = va_arg(ap, char *); |
2993 | 5295 typing = va_arg(ap, int); |
2086 | 5296 va_end(ap); |
5297 | |
4870 | 5298 if (typing == 0x0002) { |
2993 | 5299 /* I had to leave this. It's just too funny. It reminds me of my sister. */ |
5300 debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
4342 | 5301 serv_got_typing(gc, sn, 0, TYPING); |
4870 | 5302 } else if (typing == 0x0001) |
5303 serv_got_typing(gc, sn, 0, TYPED); | |
5304 else | |
4342 | 5305 serv_got_typing_stopped(gc, sn); |
2086 | 5306 return 1; |
5307 } | |
5308 | |
5309 struct ask_do_dir_im { | |
5310 char *who; | |
5311 struct gaim_connection *gc; | |
5312 }; | |
5313 | |
3730 | 5314 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
2086 | 5315 g_free(data); |
5316 } | |
5317 | |
3730 | 5318 static void oscar_direct_im(struct ask_do_dir_im *data) { |
2086 | 5319 struct gaim_connection *gc = data->gc; |
4244 | 5320 struct oscar_data *od; |
2086 | 5321 struct direct_im *dim; |
5322 | |
4244 | 5323 if (!g_slist_find(connections, gc)) { |
5324 g_free(data); | |
5325 return; | |
5326 } | |
5327 | |
5328 od = (struct oscar_data *)gc->proto_data; | |
5329 | |
2086 | 5330 dim = find_direct_im(od, data->who); |
5331 if (dim) { | |
3008 | 5332 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
5333 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
5334 gaim_input_remove(dim->watcher); | |
5335 g_free(dim); | |
5336 debug_printf("Gave up on old direct IM, trying again\n"); | |
5337 } else { | |
3427 | 5338 do_error_dialog("DirectIM already open.", NULL, GAIM_ERROR); |
4244 | 5339 g_free(data); |
3008 | 5340 return; |
5341 } | |
2086 | 5342 } |
5343 dim = g_new0(struct direct_im, 1); | |
5344 dim->gc = gc; | |
5345 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
5346 | |
4617 | 5347 dim->conn = aim_odc_initiate(od->sess, data->who); |
2086 | 5348 if (dim->conn != NULL) { |
5349 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5350 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 5351 oscar_callback, dim->conn); |
4617 | 5352 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
5353 gaim_odc_initiate, 0); | |
2086 | 5354 } else { |
3427 | 5355 do_error_dialog(_("Unable to open Direct IM"), NULL, GAIM_ERROR); |
2086 | 5356 g_free(dim); |
5357 } | |
4244 | 5358 |
5359 g_free(data); | |
2086 | 5360 } |
5361 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
5362 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
2086 | 5363 char buf[BUF_LONG]; |
5364 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | |
5365 data->who = who; | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
5366 data->gc = gc; |
3730 | 5367 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); |
4249 | 5368 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, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
2086 | 5369 } |
5370 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5371 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
|
5372 struct oscar_data *od = gc->proto_data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5373 od->evilhack = g_slist_append(od->evilhack, g_strdup(normalize(who))); |
3212 | 5374 if (od->icq) { |
4687 | 5375 struct buddy *budlight = gaim_find_buddy(gc->account, who); |
3212 | 5376 if (budlight) |
4687 | 5377 if ((budlight->uc >> 16) & (AIM_ICQ_STATE_AWAY || AIM_ICQ_STATE_DND || AIM_ICQ_STATE_OUT || AIM_ICQ_STATE_BUSY || AIM_ICQ_STATE_CHAT)) { |
3595 | 5378 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
4344 | 5379 char *dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR><I>Remote client does not support sending status messages.</I><BR>"), who, state_msg); |
3212 | 5380 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
5381 free(state_msg); | |
5382 free(dialog_msg); | |
5383 } | |
5384 else { | |
3595 | 5385 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
4344 | 5386 char *dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR><I>User has no status message.</I><BR>"), who, state_msg); |
3212 | 5387 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
5388 free(state_msg); | |
5389 free(dialog_msg); | |
5390 } | |
5391 else | |
3427 | 5392 do_error_dialog("Could not find contact in local list, therefore unable to request status message.\n", NULL, GAIM_ERROR); |
3212 | 5393 } else |
5394 oscar_get_info(gc, who); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5395 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5396 |
2086 | 5397 static void oscar_set_permit_deny(struct gaim_connection *gc) { |
5398 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4230 | 5399 #ifdef NOSSI |
4770 | 5400 GSList *list, *g = gaim_blist_groups(), *g1; |
4230 | 5401 char buf[MAXMSGLEN]; |
5402 int at; | |
5403 | |
4491 | 5404 switch(gc->account->permdeny) { |
4687 | 5405 case 1: |
4230 | 5406 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username); |
5407 break; | |
5408 case 2: | |
5409 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username); | |
5410 break; | |
5411 case 3: | |
4642 | 5412 list = gc->account->permit; |
4230 | 5413 at = 0; |
5414 while (list) { | |
5415 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5416 list = list->next; | |
5417 } | |
5418 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
5419 break; | |
5420 case 4: | |
4642 | 5421 list = gc->account->deny; |
4230 | 5422 at = 0; |
5423 while (list) { | |
5424 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5425 list = list->next; | |
5426 } | |
5427 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
5428 break; | |
5429 case 5: | |
4770 | 5430 g1 = g; |
4230 | 5431 at = 0; |
4770 | 5432 while (g1) { |
5433 list = gaim_blist_members((struct group *)g->data); | |
5434 GSList list1 = list; | |
5435 while (list1) { | |
5436 struct buddy *b = list1->data; | |
4491 | 5437 if(b->account == gc->account) |
4349 | 5438 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", b->name); |
4770 | 5439 list1 = list1->next; |
2995 | 5440 } |
4770 | 5441 g_slist_free(list); |
5442 g1 = g1->next; | |
4349 | 5443 } |
4770 | 5444 g_slist_free(g); |
4230 | 5445 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); |
5446 break; | |
5447 default: | |
5448 break; | |
2086 | 5449 } |
4230 | 5450 signoff_blocked(gc); |
5451 #else | |
5452 if (od->sess->ssi.received_data) | |
4889 | 5453 aim_ssi_setpermdeny(od->sess, gc->account->permdeny, 0xffffffff); |
4230 | 5454 #endif |
2086 | 5455 } |
5456 | |
4349 | 5457 static void oscar_add_permit(struct gaim_connection *gc, const char *who) { |
4269 | 5458 #ifdef NOSSI |
4491 | 5459 if (gc->account->permdeny == 3) |
4269 | 5460 oscar_set_permit_deny(gc); |
5461 #else | |
2991 | 5462 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5463 debug_printf("ssi: About to add a permit\n"); |
5464 if (od->sess->ssi.received_data) | |
4889 | 5465 aim_ssi_addpermit(od->sess, who); |
4230 | 5466 #endif |
2086 | 5467 } |
5468 | |
4349 | 5469 static void oscar_add_deny(struct gaim_connection *gc, const char *who) { |
4269 | 5470 #ifdef NOSSI |
4491 | 5471 if (gc->account->permdeny == 4) |
4269 | 5472 oscar_set_permit_deny(gc); |
5473 #else | |
2991 | 5474 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5475 debug_printf("ssi: About to add a deny\n"); |
5476 if (od->sess->ssi.received_data) | |
4889 | 5477 aim_ssi_adddeny(od->sess, who); |
4230 | 5478 #endif |
2086 | 5479 } |
5480 | |
4349 | 5481 static void oscar_rem_permit(struct gaim_connection *gc, const char *who) { |
4269 | 5482 #ifdef NOSSI |
4491 | 5483 if (gc->account->permdeny == 3) |
4269 | 5484 oscar_set_permit_deny(gc); |
5485 #else | |
2991 | 5486 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5487 debug_printf("ssi: About to delete a permit\n"); |
5488 if (od->sess->ssi.received_data) | |
4889 | 5489 aim_ssi_delpermit(od->sess, who); |
4230 | 5490 #endif |
2086 | 5491 } |
5492 | |
4349 | 5493 static void oscar_rem_deny(struct gaim_connection *gc, const char *who) { |
4269 | 5494 #ifdef NOSSI |
4491 | 5495 if (gc->account->permdeny == 4) |
4269 | 5496 oscar_set_permit_deny(gc); |
5497 #else | |
2991 | 5498 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5499 debug_printf("ssi: About to delete a deny\n"); |
5500 if (od->sess->ssi.received_data) | |
4889 | 5501 aim_ssi_deldeny(od->sess, who); |
4230 | 5502 #endif |
2086 | 5503 } |
5504 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5505 static GList *oscar_away_states(struct gaim_connection *gc) |
2086 | 5506 { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5507 struct oscar_data *od = gc->proto_data; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5508 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5509 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5510 if (!od->icq) |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5511 return g_list_append(m, GAIM_AWAY_CUSTOM); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5512 |
4333 | 5513 m = g_list_append(m, _("Online")); |
5514 m = g_list_append(m, _("Away")); | |
5515 m = g_list_append(m, _("Do Not Disturb")); | |
5516 m = g_list_append(m, _("Not Available")); | |
5517 m = g_list_append(m, _("Occupied")); | |
5518 m = g_list_append(m, _("Free For Chat")); | |
5519 m = g_list_append(m, _("Invisible")); | |
5520 | |
5521 return m; | |
5522 } | |
5523 | |
5524 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { | |
5525 struct oscar_data *od = gc->proto_data; | |
5526 GList *m = NULL; | |
5527 struct proto_buddy_menu *pbm; | |
5528 | |
5529 if (od->icq) { | |
4624 | 5530 #if 0 |
4333 | 5531 pbm = g_new0(struct proto_buddy_menu, 1); |
5532 pbm->label = _("Get Status Msg"); | |
5533 pbm->callback = oscar_get_away_msg; | |
5534 pbm->gc = gc; | |
5535 m = g_list_append(m, pbm); | |
4624 | 5536 #endif |
4333 | 5537 } else { |
4687 | 5538 struct buddy *b = gaim_find_buddy(gc->account, who); |
4356 | 5539 |
5540 if (!b || (b->uc & UC_UNAVAILABLE)) { | |
5541 pbm = g_new0(struct proto_buddy_menu, 1); | |
5542 pbm->label = _("Get Away Msg"); | |
5543 pbm->callback = oscar_get_away_msg; | |
5544 pbm->gc = gc; | |
5545 m = g_list_append(m, pbm); | |
5546 } | |
4333 | 5547 |
5548 if (aim_sncmp(gc->username, who)) { | |
5549 pbm = g_new0(struct proto_buddy_menu, 1); | |
5550 pbm->label = _("Direct IM"); | |
5551 pbm->callback = oscar_ask_direct_im; | |
5552 pbm->gc = gc; | |
5553 m = g_list_append(m, pbm); | |
4650 | 5554 |
4333 | 5555 pbm = g_new0(struct proto_buddy_menu, 1); |
5556 pbm->label = _("Send File"); | |
4617 | 5557 pbm->callback = oscar_ask_sendfile; |
4333 | 5558 pbm->gc = gc; |
5559 m = g_list_append(m, pbm); | |
4826 | 5560 |
5561 #if 0 | |
5562 pbm = g_new0(struct proto_buddy_menu, 1); | |
5563 pbm->label = _("Get File"); | |
5564 pbm->callback = oscar_ask_getfile; | |
5565 pbm->gc = gc; | |
5566 m = g_list_append(m, pbm); | |
5567 #endif | |
4333 | 5568 } |
5569 } | |
5570 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5571 return m; |
2086 | 5572 } |
5573 | |
4333 | 5574 static GList *oscar_edit_buddy_menu(struct gaim_connection *gc, char *who) |
5575 { | |
5576 struct oscar_data *od = gc->proto_data; | |
5577 GList *m = NULL; | |
5578 struct proto_buddy_menu *pbm; | |
5579 | |
5580 if (od->icq) { | |
5581 pbm = g_new0(struct proto_buddy_menu, 1); | |
5582 pbm->label = _("Get Info"); | |
5583 pbm->callback = oscar_get_info; | |
5584 pbm->gc = gc; | |
5585 m = g_list_append(m, pbm); | |
5586 } | |
5587 | |
5588 if (od->sess->ssi.received_data) { | |
5589 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
5590 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
5591 pbm = g_new0(struct proto_buddy_menu, 1); | |
5592 pbm->label = _("Re-request Authorization"); | |
5593 pbm->callback = gaim_auth_sendrequest; | |
5594 pbm->gc = gc; | |
5595 m = g_list_append(m, pbm); | |
5596 } | |
5597 } | |
5598 | |
5599 return m; | |
5600 } | |
5601 | |
5602 static void oscar_format_screenname(struct gaim_connection *gc, char *nick) { | |
5603 struct oscar_data *od = gc->proto_data; | |
5604 if (!aim_sncmp(gc->username, nick)) { | |
5605 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
5606 od->setnick = TRUE; | |
5607 od->newsn = g_strdup(nick); | |
5608 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5609 } else { | |
5610 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
5611 } | |
5612 } else { | |
5613 do_error_dialog(_("The new formatting is invalid."), | |
5614 _("Screenname formatting can change only capitalization and whitespace."), GAIM_ERROR); | |
5615 } | |
5616 } | |
5617 | |
5618 static void oscar_show_format_screenname(struct gaim_connection *gc) | |
5619 { | |
5620 do_prompt_dialog(_("New screenname formatting:"), gc->displayname, gc, oscar_format_screenname, NULL); | |
5621 } | |
5622 | |
5623 static void oscar_confirm_account(struct gaim_connection *gc) | |
5624 { | |
5625 struct oscar_data *od = gc->proto_data; | |
5626 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
5627 | |
5628 if (conn) { | |
5629 aim_admin_reqconfirm(od->sess, conn); | |
5630 } else { | |
5631 od->conf = TRUE; | |
5632 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5633 } | |
5634 } | |
5635 | |
5636 static void oscar_show_email(struct gaim_connection *gc) | |
5637 { | |
5638 struct oscar_data *od = gc->proto_data; | |
5639 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
5640 | |
5641 if (conn) { | |
5642 aim_admin_getinfo(od->sess, conn, 0x11); | |
5643 } else { | |
5644 od->reqemail = TRUE; | |
5645 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5646 } | |
5647 } | |
5648 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5649 static void oscar_change_email(struct gaim_connection *gc, char *email) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5650 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5651 struct oscar_data *od = gc->proto_data; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5652 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
|
5653 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5654 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5655 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5656 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5657 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5658 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5659 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5660 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5661 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5662 |
4333 | 5663 static void oscar_show_change_email(struct gaim_connection *gc) |
5664 { | |
5665 do_prompt_dialog(_("Change Address To: "), NULL, gc, oscar_change_email, NULL); | |
5666 } | |
5667 | |
5668 static void oscar_show_awaitingauth(struct gaim_connection *gc) | |
5669 { | |
2979 | 5670 struct oscar_data *od = gc->proto_data; |
4333 | 5671 gchar *nombre, *text, *tmp; |
4785 | 5672 GaimBlistNode *gnode,*bnode; |
4333 | 5673 int num=0; |
5674 | |
5675 text = g_strdup(_("You are awaiting authorization from the following buddies:<BR>")); | |
5676 | |
4785 | 5677 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
5678 struct group *group = (struct group *)gnode; | |
5679 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
5680 continue; | |
5681 for (bnode = gnode->child; bnode; bnode = bnode->next) { | |
5682 struct buddy *buddy = (struct buddy *)bnode; | |
5683 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
5684 continue; | |
4491 | 5685 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { |
4687 | 5686 if (gaim_get_buddy_alias_only(buddy)) |
5687 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
4333 | 5688 else |
4337 | 5689 nombre = g_strdup_printf(" %s", buddy->name); |
4333 | 5690 tmp = g_strdup_printf("%s<BR>%s", text, nombre); |
5691 g_free(text); | |
5692 text = tmp; | |
5693 g_free(nombre); | |
5694 num++; | |
5695 } | |
2979 | 5696 } |
4333 | 5697 } |
5698 | |
5699 if (!num) { | |
5700 tmp = g_strdup_printf("%s<BR>%s", text, _("<i>you are not waiting for authorization</i>")); | |
5701 g_free(text); | |
5702 text = tmp; | |
2979 | 5703 } |
4333 | 5704 |
5705 tmp = g_strdup_printf(_("%s<BR><BR>You can re-request authorization from these buddies by right-clicking on them in the \"Edit Buddies\" pane and selecting \"Re-request authorization.\""), text); | |
5706 g_free(text); | |
5707 text = tmp; | |
5708 g_show_info_text(gc, gc->username, 2, text, NULL); | |
5709 g_free(text); | |
2979 | 5710 } |
5711 | |
4333 | 5712 static void oscar_show_chpassurl(struct gaim_connection *gc) |
5713 { | |
5714 struct oscar_data *od = gc->proto_data; | |
5715 open_url(NULL, od->sess->authinfo->chpassurl); | |
5716 } | |
5717 | |
5718 static GList *oscar_actions(struct gaim_connection *gc) | |
2086 | 5719 { |
5720 struct oscar_data *od = gc->proto_data; | |
4333 | 5721 struct proto_actions_menu *pam; |
5722 GList *m = NULL; | |
5723 | |
5724 pam = g_new0(struct proto_actions_menu, 1); | |
5725 pam->label = _("Set User Info"); | |
5726 pam->callback = show_set_info; | |
5727 pam->gc = gc; | |
5728 m = g_list_append(m, pam); | |
5729 | |
4617 | 5730 if ((od->sess->authinfo->regstatus == 0x0003) || (od->icq)) { |
4333 | 5731 pam = g_new0(struct proto_actions_menu, 1); |
5732 pam->label = _("Change Password"); | |
5733 pam->callback = show_change_passwd; | |
5734 pam->gc = gc; | |
5735 m = g_list_append(m, pam); | |
4617 | 5736 } |
5737 | |
5738 if (od->sess->authinfo->chpassurl) { | |
5739 pam = g_new0(struct proto_actions_menu, 1); | |
5740 pam->label = _("Change Password (URL)"); | |
5741 pam->callback = oscar_show_chpassurl; | |
5742 pam->gc = gc; | |
5743 m = g_list_append(m, pam); | |
5744 } | |
5745 | |
5746 if (od->sess->authinfo->regstatus == 0x0003) { | |
5747 /* AIM actions */ | |
5748 m = g_list_append(m, NULL); | |
4333 | 5749 |
5750 pam = g_new0(struct proto_actions_menu, 1); | |
5751 pam->label = _("Format Screenname"); | |
5752 pam->callback = oscar_show_format_screenname; | |
5753 pam->gc = gc; | |
5754 m = g_list_append(m, pam); | |
5755 | |
5756 pam = g_new0(struct proto_actions_menu, 1); | |
5757 pam->label = _("Confirm Account"); | |
5758 pam->callback = oscar_confirm_account; | |
5759 pam->gc = gc; | |
5760 m = g_list_append(m, pam); | |
5761 | |
5762 pam = g_new0(struct proto_actions_menu, 1); | |
5763 pam->label = _("Display Current Registered Address"); | |
5764 pam->callback = oscar_show_email; | |
5765 pam->gc = gc; | |
5766 m = g_list_append(m, pam); | |
5767 | |
5768 pam = g_new0(struct proto_actions_menu, 1); | |
5769 pam->label = _("Change Current Registered Address"); | |
5770 pam->callback = oscar_show_change_email; | |
5771 pam->gc = gc; | |
5772 m = g_list_append(m, pam); | |
2086 | 5773 } |
4333 | 5774 |
5775 m = g_list_append(m, NULL); | |
5776 | |
5777 pam = g_new0(struct proto_actions_menu, 1); | |
5778 pam->label = _("Show Buddies Awaiting Authorization"); | |
5779 pam->callback = oscar_show_awaitingauth; | |
5780 pam->gc = gc; | |
5781 m = g_list_append(m, pam); | |
5782 | |
2086 | 5783 m = g_list_append(m, NULL); |
4333 | 5784 |
5785 pam = g_new0(struct proto_actions_menu, 1); | |
5786 pam->label = _("Search for Buddy by Email"); | |
5787 pam->callback = show_find_email; | |
5788 pam->gc = gc; | |
5789 m = g_list_append(m, pam); | |
5790 | |
4336 | 5791 /* pam = g_new0(struct proto_actions_menu, 1); |
4333 | 5792 pam->label = _("Search for Buddy by Information"); |
5793 pam->callback = show_find_info; | |
5794 pam->gc = gc; | |
4336 | 5795 m = g_list_append(m, pam); */ |
2086 | 5796 |
5797 return m; | |
5798 } | |
5799 | |
3466 | 5800 static void oscar_change_passwd(struct gaim_connection *gc, const char *old, const char *new) |
2086 | 5801 { |
5802 struct oscar_data *od = gc->proto_data; | |
4617 | 5803 |
5804 if (od->icq) { | |
5805 aim_icq_changepasswd(od->sess, new); | |
2086 | 5806 } else { |
4617 | 5807 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
5808 if (conn) { | |
5809 aim_admin_changepasswd(od->sess, conn, new, old); | |
5810 } else { | |
5811 od->chpass = TRUE; | |
5812 od->oldp = g_strdup(old); | |
5813 od->newp = g_strdup(new); | |
5814 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5815 } | |
2086 | 5816 } |
5817 } | |
5818 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5819 static void oscar_convo_closed(struct gaim_connection *gc, char *who) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5820 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5821 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5822 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5823 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5824 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5825 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5826 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5827 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5828 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5829 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5830 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5831 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5832 |
4151 | 5833 static fu32_t check_encoding(const char *utf8) |
5834 { | |
5835 int i = 0; | |
5836 fu32_t encodingflag = 0; | |
5837 | |
5838 /* Determine how we can send this message. Per the | |
5839 * warnings elsewhere in this file, these little | |
5840 * checks determine the simplest encoding we can use | |
5841 * for a given message send using it. */ | |
5842 while (utf8[i]) { | |
5843 if ((unsigned char)utf8[i] > 0x7f) { | |
5844 /* not ASCII! */ | |
5845 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
5846 break; | |
5847 } | |
5848 i++; | |
5849 } | |
5850 while (utf8[i]) { | |
5851 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
5852 * followed by 0xc0-0xc3 in the second */ | |
5853 if ((unsigned char)utf8[i] < 0x80) { | |
5854 i++; | |
5855 continue; | |
5856 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
5857 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
5858 i += 2; | |
5859 continue; | |
5860 } | |
5861 encodingflag = AIM_IMFLAGS_UNICODE; | |
5862 break; | |
5863 } | |
5864 | |
5865 return encodingflag; | |
5866 } | |
5867 | |
5868 static fu32_t parse_encoding(const char *enc) | |
5869 { | |
5870 char *charset; | |
5871 | |
5872 /* If anything goes wrong, fall back on ASCII and print a message */ | |
4643 | 5873 if (enc == NULL) { |
5874 debug_printf("Encoding was null, that's odd\n"); | |
5875 return 0; | |
5876 } | |
4151 | 5877 charset = strstr(enc, "charset="); |
5878 if (charset == NULL) { | |
5879 debug_printf("No charset specified for info, assuming ASCII\n"); | |
5880 return 0; | |
5881 } | |
5882 charset += 8; | |
4600 | 5883 if (!strcmp(charset, "\"us-ascii\"") || !strcmp(charset, "\"utf-8\"")) { |
5884 /* UTF-8 is our native charset, ASCII is a proper subset */ | |
4151 | 5885 return 0; |
4166 | 5886 } else if (!strcmp(charset, "\"iso-8859-1\"")) { |
5887 return AIM_IMFLAGS_ISO_8859_1; | |
4151 | 5888 } else if (!strcmp(charset, "\"unicode-2-0\"")) { |
5889 return AIM_IMFLAGS_UNICODE; | |
5890 } else { | |
5891 debug_printf("Unrecognized character set '%s', using ASCII\n", charset); | |
5892 return 0; | |
5893 } | |
5894 } | |
3035 | 5895 |
3630 | 5896 G_MODULE_EXPORT void oscar_init(struct prpl *ret) { |
3572 | 5897 struct proto_user_opt *puo; |
2086 | 5898 ret->protocol = PROTO_OSCAR; |
3694 | 5899 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE; |
3858 | 5900 ret->name = g_strdup("AIM/ICQ"); |
2086 | 5901 ret->list_icon = oscar_list_icon; |
4687 | 5902 ret->list_emblems = oscar_list_emblems; |
2086 | 5903 ret->away_states = oscar_away_states; |
5904 ret->actions = oscar_actions; | |
5905 ret->buddy_menu = oscar_buddy_menu; | |
3456 | 5906 ret->edit_buddy_menu = oscar_edit_buddy_menu; |
2086 | 5907 ret->login = oscar_login; |
5908 ret->close = oscar_close; | |
5909 ret->send_im = oscar_send_im; | |
2993 | 5910 ret->send_typing = oscar_send_typing; |
2086 | 5911 ret->set_info = oscar_set_info; |
5912 ret->get_info = oscar_get_info; | |
5913 ret->set_away = oscar_set_away; | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5914 ret->get_away = oscar_get_away; |
2086 | 5915 ret->set_dir = oscar_set_dir; |
5916 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
5917 ret->dir_search = oscar_dir_search; | |
5918 ret->set_idle = oscar_set_idle; | |
5919 ret->change_passwd = oscar_change_passwd; | |
5920 ret->add_buddy = oscar_add_buddy; | |
5921 ret->add_buddies = oscar_add_buddies; | |
4269 | 5922 ret->remove_buddy = oscar_remove_buddy; |
5923 ret->remove_buddies = oscar_remove_buddies; | |
4230 | 5924 #ifndef NOSSI |
3140 | 5925 ret->group_buddy = oscar_move_buddy; |
4269 | 5926 ret->alias_buddy = oscar_alias_buddy; |
3348 | 5927 ret->rename_group = oscar_rename_group; |
4230 | 5928 #endif |
4269 | 5929 ret->add_permit = oscar_add_permit; |
5930 ret->add_deny = oscar_add_deny; | |
5931 ret->rem_permit = oscar_rem_permit; | |
5932 ret->rem_deny = oscar_rem_deny; | |
5933 ret->set_permit_deny = oscar_set_permit_deny; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5934 |
2086 | 5935 ret->warn = oscar_warn; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5936 ret->chat_info = oscar_chat_info; |
2086 | 5937 ret->join_chat = oscar_join_chat; |
5938 ret->chat_invite = oscar_chat_invite; | |
5939 ret->chat_leave = oscar_chat_leave; | |
5940 ret->chat_whisper = NULL; | |
5941 ret->chat_send = oscar_chat_send; | |
5942 ret->keepalive = oscar_keepalive; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5943 ret->convo_closed = oscar_convo_closed; |
4732 | 5944 ret->tooltip_text = oscar_tooltip_text; |
2086 | 5945 |
3572 | 5946 puo = g_new0(struct proto_user_opt, 1); |
5947 puo->label = g_strdup("Auth Host:"); | |
5948 puo->def = g_strdup("login.oscar.aol.com"); | |
5949 puo->pos = USEROPT_AUTH; | |
5950 ret->user_opts = g_list_append(ret->user_opts, puo); | |
5951 | |
5952 puo = g_new0(struct proto_user_opt, 1); | |
5953 puo->label = g_strdup("Auth Port:"); | |
5954 puo->def = g_strdup("5190"); | |
5955 puo->pos = USEROPT_AUTHPORT; | |
5956 ret->user_opts = g_list_append(ret->user_opts, puo); | |
5957 | |
2086 | 5958 my_protocol = ret; |
5959 } | |
5960 | |
5961 #ifndef STATIC | |
5962 | |
3630 | 5963 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 5964 { |
3572 | 5965 oscar_init(prpl); |
5966 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 5967 } |
5968 | |
5969 #endif |