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