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