Mercurial > pidgin.yaz
annotate src/protocols/oscar/oscar.c @ 4780:5d4243c013a2
[gaim-migrate @ 5100]
Mom! Sean's making me uneasy! Make him stop!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 14 Mar 2003 23:46:32 +0000 |
parents | 443aade63ef8 |
children | fd69b80cb349 |
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)")); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2038 } |
3722 | 2039 } else { |
3850 | 2040 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
3722 | 2041 * unflagged messages, which are ASCII. That's OK because |
2042 * ASCII is a strict subset of ISO-8859-1; this should | |
2043 * help with compatibility with old, broken versions of | |
2044 * gaim (everything before 0.60) and other broken clients | |
2045 * that will happily send ISO-8859-1 without marking it as | |
2046 * such */ | |
4662 | 2047 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
4194 | 2048 debug_printf("Received ISO-8859-1 IM\n"); |
4121 | 2049 |
2050 if (!args->msg || !args->msglen) | |
2051 return 1; | |
2052 | |
3659 | 2053 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
2054 if (err) { | |
2055 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); | |
2056 tmp = strdup(_("(There was an error receiving this message)")); | |
2057 } | |
3642 | 2058 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2059 |
4333 | 2060 /* strip_linefeed(tmp); */ |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
2061 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
|
2062 g_free(tmp); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2063 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2064 return 1; |
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 |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2067 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
|
2068 struct gaim_connection *gc = sess->aux_data; |
4617 | 2069 struct oscar_data *od = gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2070 |
4121 | 2071 if (!args) |
2072 return 0; | |
4194 | 2073 |
4617 | 2074 debug_printf("rendezvous with %s, status is %hu\n", userinfo->sn, args->status); |
2869 | 2075 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2076 if (args->reqclass & AIM_CAPS_CHAT) { |
4121 | 2077 char *name; |
4120 | 2078 int *exch; |
4121 | 2079 GList *m = NULL; |
4120 | 2080 |
4121 | 2081 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
2082 return 1; | |
2083 name = extract_name(args->info.chat.roominfo.name); | |
4120 | 2084 exch = g_new0(int, 1); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2085 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
|
2086 *exch = args->info.chat.roominfo.exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2087 m = g_list_append(m, exch); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2088 serv_got_chat_invite(gc, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2089 name ? name : args->info.chat.roominfo.name, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2090 userinfo->sn, |
2869 | 2091 (char *)args->msg, |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2092 m); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2093 if (name) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2094 g_free(name); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2095 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
4617 | 2096 /* BBB */ |
2097 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
2098 /* Someone wants to send a file (or files) to us */ | |
2099 struct gaim_xfer *xfer; | |
2100 struct oscar_xfer_data *xfer_data; | |
2101 | |
2102 if (!args->cookie || !args->verifiedip || !args->port || | |
2103 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
4656 | 2104 !args->info.sendfile.totfiles || !args->reqclass) { |
2105 debug_printf("%s tried to send you a file with incomplete information.\n", userinfo->sn); | |
4617 | 2106 return 1; |
4656 | 2107 } |
4617 | 2108 |
2109 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
2110 /* last char of the ft req is a star, they are sending us a | |
2111 * directory -- remove the star and trailing slash so we dont save | |
2112 * directories that look like 'dirname\*' -- arl */ | |
2113 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
2114 if (tmp && (tmp[1] == '*')) { | |
2115 tmp[0] = '\0'; | |
2116 } | |
2117 } | |
2118 | |
2119 /* Setup the oscar-specific transfer xfer_data */ | |
2120 xfer_data = g_malloc0(sizeof(struct oscar_xfer_data)); | |
2121 xfer_data->gc = gc; | |
2122 memcpy(xfer_data->cookie, args->cookie, 8); | |
2123 | |
2124 /* Build the file transfer handle */ | |
2125 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
2126 xfer_data->xfer = xfer; | |
2127 xfer->data = xfer_data; | |
2128 | |
2129 /* Set the info about the incoming file */ | |
2130 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); | |
2131 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
2132 xfer->remote_port = args->port; | |
4650 | 2133 xfer->remote_ip = g_strdup(args->verifiedip); |
2134 if (args->clientip) | |
2135 xfer_data->clientip = g_strdup(args->clientip); | |
2136 if (args->clientip2) | |
2137 xfer_data->clientip2 = g_strdup(args->clientip2); | |
4617 | 2138 |
2139 /* Setup our I/O op functions */ | |
2140 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init); | |
2141 gaim_xfer_set_start_fnc(xfer, oscar_xfer_start); | |
2142 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2143 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2144 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
4617 | 2145 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack); |
2146 | |
2147 /* | |
2148 * XXX - Should do something with args->msg, args->encoding, and args->language | |
2149 * probably make it apply to all ch2 messages. | |
3752 | 2150 */ |
4617 | 2151 |
2152 /* Keep track of this transfer for later */ | |
2153 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
2154 | |
2155 /* Now perform the request */ | |
2156 gaim_xfer_request(xfer); | |
2157 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
2158 /* The other user wants to cancel a file transfer */ | |
2159 struct gaim_xfer *xfer; | |
2160 debug_printf("AAA - File transfer canceled by remote user\n"); | |
2161 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
|
2162 gaim_xfer_cancel_remote(xfer); |
4617 | 2163 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
2164 /* | |
2165 * This gets sent by the receiver of a file | |
2166 * as they connect directly to us. If we don't | |
2167 * get this, then maybe a third party connected | |
2168 * to us, and we shouldn't send them anything. | |
2169 */ | |
2170 } else { | |
2171 debug_printf("unknown rendezvous status!\n"); | |
3630 | 2172 } |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2173 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2174 } else if (args->reqclass & AIM_CAPS_VOICE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2175 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2176 set_icon_data(gc, normalize(userinfo->sn), args->info.icon.icon, |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2177 args->info.icon.length); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2178 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2179 struct ask_direct *d = g_new0(struct ask_direct, 1); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2180 char buf[256]; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2181 |
4212 | 2182 if (!args->verifiedip) { |
4650 | 2183 debug_printf("directim kill blocked (%s)\n", userinfo->sn); |
2184 return 1; | |
4212 | 2185 } |
2186 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2187 debug_printf("%s received direct im request from %s (%s)\n", |
2869 | 2188 gc->username, userinfo->sn, args->verifiedip); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2189 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2190 d->gc = gc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2191 d->sn = g_strdup(userinfo->sn); |
2869 | 2192 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2193 memcpy(d->cookie, args->cookie, 8); |
4650 | 2194 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, gc->username); |
4249 | 2195 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
|
2196 } else { |
4194 | 2197 debug_printf("Unknown reqclass %hu\n", args->reqclass); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2198 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2199 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2200 return 1; |
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 |
3453 | 2203 /* |
4230 | 2204 * Authorization Functions |
2205 * Most of these are callbacks from dialogs. They're used by both | |
2206 * methods of authorization (SSI and old-school channel 4 ICBM) | |
3453 | 2207 */ |
4269 | 2208 /* When you ask other people for authorization */ |
4337 | 2209 static void gaim_auth_request(struct name_data *data, char *msg) { |
4230 | 2210 struct gaim_connection *gc = data->gc; |
4244 | 2211 |
2212 if (g_slist_find(connections, gc)) { | |
2213 struct oscar_data *od = gc->proto_data; | |
4687 | 2214 struct buddy *buddy = gaim_find_buddy(gc->account, data->name); |
2215 struct group *group = gaim_find_buddys_group(buddy); | |
4244 | 2216 if (buddy && group) { |
2217 debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name); | |
4337 | 2218 aim_ssi_sendauthrequest(od->sess, od->conn, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
4269 | 2219 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
4687 | 2220 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
4244 | 2221 } |
4230 | 2222 } |
4337 | 2223 } |
2224 | |
2225 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
2226 do_prompt_dialog(_("Authorization Request Message:"), _("Please authorize me!"), data, gaim_auth_request, gaim_free_name_data); | |
4230 | 2227 } |
2228 | |
2229 static void gaim_auth_dontrequest(struct name_data *data) { | |
4244 | 2230 struct gaim_connection *gc = data->gc; |
2231 | |
2232 if (g_slist_find(connections, gc)) { | |
2233 /* struct oscar_data *od = gc->proto_data; */ | |
2234 /* XXX - Take the buddy out of our buddy list */ | |
2235 } | |
2236 | |
4230 | 2237 gaim_free_name_data(data); |
2238 } | |
2239 | |
4269 | 2240 static void gaim_auth_sendrequest(struct gaim_connection *gc, char *name) { |
2241 struct name_data *data = g_new(struct name_data, 1); | |
2242 struct buddy *buddy; | |
2243 gchar *dialog_msg, *nombre; | |
2244 | |
4687 | 2245 buddy = gaim_find_buddy(gc->account, name); |
2246 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
2247 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
4269 | 2248 else |
2249 nombre = g_strdup(name); | |
2250 | |
2251 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); | |
2252 data->gc = gc; | |
2253 data->name = g_strdup(name); | |
2254 data->nick = NULL; | |
4337 | 2255 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 | 2256 |
2257 g_free(dialog_msg); | |
2258 g_free(nombre); | |
2259 } | |
2260 | |
4230 | 2261 /* When other people ask you for authorization */ |
2262 static void gaim_auth_grant(struct name_data *data) { | |
2263 struct gaim_connection *gc = data->gc; | |
4244 | 2264 |
2265 if (g_slist_find(connections, gc)) { | |
2266 struct oscar_data *od = gc->proto_data; | |
4236 | 2267 #ifdef NOSSI |
4244 | 2268 struct buddy *buddy; |
2269 gchar message; | |
2270 message = 0; | |
4687 | 2271 buddy = gaim_find_buddy(gc->account, data->name); |
4617 | 2272 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
4687 | 2273 show_got_added(gc, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 2274 #else |
4244 | 2275 aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x01, NULL); |
4230 | 2276 #endif |
4244 | 2277 } |
2278 | |
4230 | 2279 gaim_free_name_data(data); |
3141 | 2280 } |
2281 | |
4230 | 2282 /* When other people ask you for authorization */ |
4337 | 2283 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
4230 | 2284 struct gaim_connection *gc = data->gc; |
4244 | 2285 |
2286 if (g_slist_find(connections, gc)) { | |
2287 struct oscar_data *od = gc->proto_data; | |
4230 | 2288 #ifdef NOSSI |
4617 | 2289 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
4230 | 2290 #else |
4337 | 2291 aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x00, msg ? msg : _("No reason given.")); |
4230 | 2292 #endif |
4244 | 2293 } |
4337 | 2294 } |
2295 | |
2296 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
2297 do_prompt_dialog(_("Authorization Denied Message:"), _("No reason given."), data, gaim_auth_dontgrant, gaim_free_name_data); | |
3141 | 2298 } |
2299 | |
4230 | 2300 /* When someone sends you contacts */ |
2301 static void gaim_icq_contactadd(struct name_data *data) { | |
2302 struct gaim_connection *gc = data->gc; | |
4244 | 2303 |
2304 if (g_slist_find(connections, gc)) { | |
2305 show_add_buddy(gc, data->name, NULL, data->nick); | |
2306 } | |
2307 | |
4230 | 2308 gaim_free_name_data(data); |
3453 | 2309 } |
2310 | |
4075 | 2311 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 | 2312 struct gaim_connection *gc = sess->aux_data; |
4076 | 2313 gchar **msg1, **msg2; |
2314 GError *err = NULL; | |
2315 int i; | |
2316 | |
4121 | 2317 if (!args->type || !args->msg || !args->uin) |
2318 return 1; | |
4194 | 2319 |
2320 debug_printf("Received a channel 4 message of type 0x%02hhx.\n", args->type); | |
4076 | 2321 |
2322 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
4173 | 2323 msg1 = g_strsplit(args->msg, "\376", 0); |
4194 | 2324 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* XXX - 10 is a guess */ |
4076 | 2325 for (i=0; msg1[i]; i++) { |
2326 strip_linefeed(msg1[i]); | |
2327 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); | |
2328 if (err) | |
2329 debug_printf("Error converting a string from ISO-8859-1 to UTF-8 in oscar ICBM channel 4 parsing\n"); | |
2330 } | |
2331 msg2[i] = NULL; | |
2332 | |
3952 | 2333 switch (args->type) { |
4173 | 2334 case 0x01: { /* MacICQ message or basic offline message */ |
4076 | 2335 if (i >= 1) { |
2336 gchar *uin = g_strdup_printf("%lu", args->uin); | |
2337 if (t) { /* This is an offline message */ | |
2338 /* I think this timestamp is in UTC, or something */ | |
2339 serv_got_im(gc, uin, msg2[0], 0, t, -1); | |
2340 } else { /* This is a message from MacICQ/Miranda */ | |
2341 serv_got_im(gc, uin, msg2[0], 0, time(NULL), -1); | |
2342 } | |
2343 g_free(uin); | |
4075 | 2344 } |
3316 | 2345 } break; |
2346 | |
4173 | 2347 case 0x04: { /* Someone sent you a URL */ |
4076 | 2348 if (i >= 2) { |
2349 gchar *uin = g_strdup_printf("%lu", args->uin); | |
2350 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); | |
3453 | 2351 serv_got_im(gc, uin, message, 0, time(NULL), -1); |
2352 g_free(uin); | |
2353 g_free(message); | |
2354 } | |
2355 } break; | |
2356 | |
4173 | 2357 case 0x06: { /* Someone requested authorization */ |
4076 | 2358 if (i >= 6) { |
4230 | 2359 struct name_data *data = g_new(struct name_data, 1); |
4337 | 2360 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 | 2361 debug_printf("Received an authorization request from UIN %lu\n", args->uin); |
2362 data->gc = gc; | |
4230 | 2363 data->name = g_strdup_printf("%lu", args->uin); |
2364 data->nick = NULL; | |
4337 | 2365 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 | 2366 g_free(dialog_msg); |
2367 } | |
3141 | 2368 } break; |
2369 | |
4173 | 2370 case 0x07: { /* Someone has denied you authorization */ |
4076 | 2371 if (i >= 1) { |
4194 | 2372 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 | 2373 do_error_dialog(_("ICQ authorization denied."), dialog_msg, GAIM_INFO); |
4076 | 2374 g_free(dialog_msg); |
2375 } | |
3141 | 2376 } break; |
2377 | |
4173 | 2378 case 0x08: { /* Someone has granted you authorization */ |
4194 | 2379 gchar *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin); |
3427 | 2380 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO); |
3141 | 2381 g_free(dialog_msg); |
2382 } break; | |
2383 | |
4333 | 2384 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
2385 if (i >= 5) { | |
2386 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); | |
2387 do_error_dialog("ICQ Server Message", dialog_msg, GAIM_INFO); | |
2388 g_free(dialog_msg); | |
2389 } | |
2390 } break; | |
2391 | |
4173 | 2392 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
4076 | 2393 if (i >= 6) { |
4194 | 2394 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 | 2395 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO); |
2396 g_free(dialog_msg); | |
2397 } | |
4075 | 2398 } break; |
2399 | |
4173 | 2400 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
4076 | 2401 if (i >= 6) { |
4308 | 2402 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 | 2403 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO); |
2404 g_free(dialog_msg); | |
2405 } | |
4075 | 2406 } break; |
2407 | |
4173 | 2408 case 0x12: { |
3141 | 2409 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
4173 | 2410 /* Someone added you to their contact list? */ |
3141 | 2411 } break; |
2412 | |
4173 | 2413 case 0x13: { /* Someone has sent you some ICQ contacts */ |
3453 | 2414 int i, num; |
2415 gchar **text; | |
4173 | 2416 text = g_strsplit(args->msg, "\376", 0); |
3453 | 2417 if (text) { |
2418 num = 0; | |
2419 for (i=0; i<strlen(text[0]); i++) | |
2420 num = num*10 + text[0][i]-48; | |
2421 for (i=0; i<num; i++) { | |
4230 | 2422 struct name_data *data = g_new(struct name_data, 1); |
3730 | 2423 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 | 2424 data->gc = gc; |
4230 | 2425 data->name = g_strdup(text[i*2+2]); |
3453 | 2426 data->nick = g_strdup(text[i*2+1]); |
4249 | 2427 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 | 2428 g_free(message); |
2429 } | |
2430 g_strfreev(text); | |
2431 } | |
2432 } break; | |
2433 | |
4173 | 2434 case 0x1a: { /* Someone has sent you a greeting card or requested contacts? */ |
3453 | 2435 /* This is boring and silly. */ |
2436 } break; | |
2437 | |
3141 | 2438 default: { |
4194 | 2439 debug_printf("Received a channel 4 message of unknown type (type 0x%02hhx).\n", args->type); |
3141 | 2440 } break; |
2441 } | |
2442 | |
4076 | 2443 g_strfreev(msg1); |
2444 g_strfreev(msg2); | |
2445 | |
3141 | 2446 return 1; |
2447 } | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2448 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2449 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
4200 | 2450 fu16_t channel; |
2451 int ret = 0; | |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2452 aim_userinfo_t *userinfo; |
2086 | 2453 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2454 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2455 va_start(ap, fr); |
4200 | 2456 channel = (fu16_t)va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2457 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 2458 |
3141 | 2459 switch (channel) { |
2460 case 1: { /* standard message */ | |
2461 struct aim_incomingim_ch1_args *args; | |
2462 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
2463 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
2464 } break; | |
2465 | |
2466 case 2: { /* rendevous */ | |
2467 struct aim_incomingim_ch2_args *args; | |
2468 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
2469 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
2470 } break; | |
2471 | |
2472 case 4: { /* ICQ */ | |
2473 struct aim_incomingim_ch4_args *args; | |
2474 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
4075 | 2475 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
3141 | 2476 } break; |
2477 | |
2478 default: { | |
4194 | 2479 debug_printf("ICBM received on unsupported channel (channel 0x%04hx).", channel); |
3141 | 2480 } break; |
2086 | 2481 } |
2482 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2483 va_end(ap); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2484 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2485 return ret; |
2086 | 2486 } |
2487 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2488 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2489 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2490 fu16_t chan, nummissed, reason; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2491 aim_userinfo_t *userinfo; |
2086 | 2492 char buf[1024]; |
2493 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2494 va_start(ap, fr); |
4200 | 2495 chan = (fu16_t)va_arg(ap, unsigned int); |
2496 userinfo = va_arg(ap, aim_userinfo_t *); | |
2497 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
2498 reason = (fu16_t)va_arg(ap, unsigned int); | |
2086 | 2499 va_end(ap); |
2500 | |
2501 switch(reason) { | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2502 case 0: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2503 /* Invalid (0) */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2504 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2505 sizeof(buf), |
4276 | 2506 ngettext( |
2507 "You missed %hu message from %s because it was invalid.", | |
2508 "You missed %hu messages from %s because they were invalid.", | |
2509 nummissed), | |
4282 | 2510 nummissed, |
2511 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2512 break; |
2086 | 2513 case 1: |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2514 /* Message too large */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2515 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2516 sizeof(buf), |
4276 | 2517 ngettext( |
2518 "You missed %hu message from %s because it was too large.", | |
2519 "You missed %hu messages from %s because they were too large.", | |
2520 nummissed), | |
4282 | 2521 nummissed, |
2522 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2523 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2524 case 2: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2525 /* Rate exceeded */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2526 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2527 sizeof(buf), |
4276 | 2528 ngettext( |
2529 "You missed %hu message from %s because the rate limit has been exceeded.", | |
2530 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
2531 nummissed), | |
4282 | 2532 nummissed, |
2533 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2534 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2535 case 3: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2536 /* Evil Sender */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2537 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2538 sizeof(buf), |
4276 | 2539 ngettext( |
2540 "You missed %hu message from %s because he/she was too evil.", | |
2541 "You missed %hu messages from %s because he/she was too evil.", | |
2542 nummissed), | |
4282 | 2543 nummissed, |
2544 userinfo->sn); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2545 break; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2546 case 4: |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2547 /* Evil Receiver */ |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2548 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2549 sizeof(buf), |
4276 | 2550 ngettext( |
2551 "You missed %hu message from %s because you are too evil.", | |
2552 "You missed %hu messages from %s because you are too evil.", | |
2553 nummissed), | |
4282 | 2554 nummissed, |
2555 userinfo->sn); | |
2086 | 2556 break; |
2557 default: | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2558 g_snprintf(buf, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2559 sizeof(buf), |
4276 | 2560 ngettext( |
2561 "You missed %hu message from %s for an unknown reason.", | |
2562 "You missed %hu messages from %s for an unknown reason.", | |
2563 nummissed), | |
4282 | 2564 nummissed, |
2565 userinfo->sn); | |
2086 | 2566 break; |
2567 } | |
3427 | 2568 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 2569 |
2570 return 1; | |
2571 } | |
2572 | |
3212 | 2573 static char *gaim_icq_status(int state) { |
2574 /* Make a cute little string that shows the status of the dude or dudet */ | |
2575 if (state & AIM_ICQ_STATE_CHAT) | |
4342 | 2576 return g_strdup_printf(_("Free For Chat")); |
3212 | 2577 else if (state & AIM_ICQ_STATE_DND) |
4342 | 2578 return g_strdup_printf(_("Do Not Disturb")); |
3212 | 2579 else if (state & AIM_ICQ_STATE_OUT) |
4342 | 2580 return g_strdup_printf(_("Not Available")); |
3212 | 2581 else if (state & AIM_ICQ_STATE_BUSY) |
4342 | 2582 return g_strdup_printf(_("Occupied")); |
3212 | 2583 else if (state & AIM_ICQ_STATE_AWAY) |
4342 | 2584 return g_strdup_printf(_("Away")); |
3212 | 2585 else if (state & AIM_ICQ_STATE_WEBAWARE) |
4342 | 2586 return g_strdup_printf(_("Web Aware")); |
3212 | 2587 else if (state & AIM_ICQ_STATE_INVISIBLE) |
4342 | 2588 return g_strdup_printf(_("Invisible")); |
3212 | 2589 else |
4342 | 2590 return g_strdup_printf(_("Online")); |
3212 | 2591 } |
2592 | |
4194 | 2593 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
3630 | 2594 struct gaim_connection *gc = sess->aux_data; |
4617 | 2595 struct oscar_data *od = gc->proto_data; |
2596 | |
2597 /* BBB */ | |
3630 | 2598 switch (reason) { |
4151 | 2599 case 3: { /* Decline sendfile. */ |
4617 | 2600 struct gaim_xfer *xfer; |
2601 debug_printf("AAA - Other user declined file transfer\n"); | |
2602 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
|
2603 gaim_xfer_cancel_remote(xfer); |
4151 | 2604 } break; |
2605 | |
2606 default: { | |
4194 | 2607 debug_printf("Received an unknown rendezvous client auto-response from %s. Type 0x%04hx\n", who, reason); |
4151 | 2608 } |
3630 | 2609 |
2610 } | |
2611 | |
2612 return 0; | |
2613 } | |
2614 | |
4194 | 2615 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
4151 | 2616 struct gaim_connection *gc = sess->aux_data; |
2617 | |
2618 switch(reason) { | |
2619 case 0x0003: { /* Reply from an ICQ status message request */ | |
2620 char *status_msg = gaim_icq_status(state); | |
2621 char *dialog_msg, **splitmsg; | |
2622 struct oscar_data *od = gc->proto_data; | |
2623 GSList *l = od->evilhack; | |
2624 gboolean evilhack = FALSE; | |
2625 | |
2626 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
2627 splitmsg = g_strsplit(msg, "\r\n", 0); | |
2628 | |
2629 /* If who is in od->evilhack, then we're just getting the away message, otherwise this | |
2630 * will just get appended to the info box (which is already showing). */ | |
2631 while (l) { | |
2632 char *x = l->data; | |
2633 if (!strcmp(x, normalize(who))) { | |
2634 evilhack = TRUE; | |
2635 g_free(x); | |
2636 od->evilhack = g_slist_remove(od->evilhack, x); | |
2637 break; | |
2638 } | |
2639 l = l->next; | |
2640 } | |
2641 | |
2642 if (evilhack) | |
4344 | 2643 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
4151 | 2644 else |
4344 | 2645 dialog_msg = g_strdup_printf(_("<B>Status:</B> %s<HR>%s"), status_msg, g_strjoinv("<BR>", splitmsg)); |
4151 | 2646 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
2647 | |
2648 g_free(status_msg); | |
2649 g_free(dialog_msg); | |
2650 g_strfreev(splitmsg); | |
2651 } break; | |
2652 | |
2653 default: { | |
4194 | 2654 debug_printf("Received an unknown client auto-response from %s. Type 0x%04hx\n", who, reason); |
4151 | 2655 } break; |
2656 } /* end of switch */ | |
2657 | |
2658 return 0; | |
2659 } | |
2660 | |
3212 | 2661 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
2662 va_list ap; | |
2663 fu16_t chan, reason; | |
2664 char *who; | |
2665 | |
2666 va_start(ap, fr); | |
4200 | 2667 chan = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2668 who = va_arg(ap, char *); |
4200 | 2669 reason = (fu16_t)va_arg(ap, unsigned int); |
3212 | 2670 |
3952 | 2671 if (chan == 0x0002) { /* File transfer declined */ |
3630 | 2672 char *cookie = va_arg(ap, char *); |
4151 | 2673 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
3952 | 2674 } else if (chan == 0x0004) { /* ICQ message */ |
4200 | 2675 fu32_t state = 0; |
4151 | 2676 char *msg = NULL; |
2677 if (reason == 0x0003) { | |
4200 | 2678 state = va_arg(ap, fu32_t); |
4151 | 2679 msg = va_arg(ap, char *); |
2680 } | |
2681 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
2682 } | |
3952 | 2683 |
3212 | 2684 va_end(ap); |
2685 | |
2686 return 1; | |
2687 } | |
2688 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2689 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2690 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2691 fu16_t reason; |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2692 char *m; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2693 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2694 va_start(ap, fr); |
4199 | 2695 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 2696 va_end(ap); |
2697 | |
4194 | 2698 debug_printf("snac threw error (reason 0x%04hx: %s)\n", reason, |
2086 | 2699 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
2700 | |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2701 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
4056 | 2702 reason < msgerrreasonlen ? gettext(msgerrreason[reason]) : _("Unknown error")); |
3427 | 2703 do_error_dialog(m, NULL, GAIM_ERROR); |
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2704 g_free(m); |
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2705 |
2086 | 2706 return 1; |
2707 } | |
2708 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2709 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4617 | 2710 #if 0 |
3752 | 2711 struct gaim_connection *gc = sess->aux_data; |
4617 | 2712 struct oscar_data *od = gc->proto_data; |
2713 struct gaim_xfer *xfer; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2714 #endif |
4617 | 2715 va_list ap; |
2716 fu16_t reason; | |
2717 char *data, *buf; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2718 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2719 va_start(ap, fr); |
4617 | 2720 reason = (fu16_t)va_arg(ap, unsigned int); |
3752 | 2721 data = va_arg(ap, char *); |
2086 | 2722 va_end(ap); |
2723 | |
4617 | 2724 debug_printf("Message error with data %s and reason %hu\n", data, reason); |
2725 | |
2726 /* BBB */ | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2727 #if 0 |
4617 | 2728 /* If this was a file transfer request, data is a cookie */ |
2729 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
|
2730 gaim_xfer_cancel_remote(xfer); |
3630 | 2731 return 1; |
2732 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2733 #endif |
3630 | 2734 |
4617 | 2735 /* Data is assumed to be the destination sn */ |
2736 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
4342 | 2737 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
4617 | 2738 g_free(buf); |
2086 | 2739 |
2740 return 1; | |
2741 } | |
2742 | |
3595 | 2743 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
2744 struct gaim_connection *gc = sess->aux_data; | |
2745 va_list ap; | |
2746 fu16_t type1, type2; | |
2747 char *sn; | |
2748 | |
2749 va_start(ap, fr); | |
4199 | 2750 type1 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2751 sn = va_arg(ap, char *); |
4199 | 2752 type2 = (fu16_t) va_arg(ap, unsigned int); |
3595 | 2753 va_end(ap); |
2754 | |
2755 switch (type2) { | |
2756 case 0x0000: { /* Text has been cleared */ | |
2757 serv_got_typing_stopped(gc, sn); | |
2758 } break; | |
2759 | |
2760 case 0x0001: { /* Paused typing */ | |
3768 | 2761 serv_got_typing(gc, sn, 0, TYPED); |
3595 | 2762 } break; |
2763 | |
2764 case 0x0002: { /* Typing */ | |
3768 | 2765 serv_got_typing(gc, sn, 0, TYPING); |
3595 | 2766 } break; |
2767 | |
2768 default: { | |
4624 | 2769 printf("Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); |
3595 | 2770 } break; |
2771 } | |
2772 | |
2773 return 1; | |
2774 } | |
2775 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2776 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 2777 va_list ap; |
2778 char *destn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2779 fu16_t reason; |
2086 | 2780 char buf[1024]; |
2781 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2782 va_start(ap, fr); |
4199 | 2783 reason = (fu16_t) va_arg(ap, unsigned int); |
2086 | 2784 destn = va_arg(ap, char *); |
2785 va_end(ap); | |
2786 | |
3574 | 2787 snprintf(buf, sizeof(buf), _("User information for %s unavailable:"), destn); |
4342 | 2788 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
2086 | 2789 |
2790 return 1; | |
2791 } | |
2792 | |
2793 static char *images(int flags) { | |
2794 static char buf[1024]; | |
3101 | 2795 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
2679 | 2796 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
2086 | 2797 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
2798 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
3101 | 2799 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
2086 | 2800 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
3079 | 2801 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
2802 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
2086 | 2803 return buf; |
2804 } | |
2805 | |
3101 | 2806 |
2920 | 2807 static char *caps_string(guint caps) |
2808 { | |
2809 static char buf[512], *tmp; | |
2810 int count = 0, i = 0; | |
2811 guint bit = 1; | |
4742 | 2812 |
2813 if (!caps) { | |
4744 | 2814 return NULL; |
4743 | 2815 } else while (bit <= 0x20000) { |
2920 | 2816 if (bit & caps) { |
2817 switch (bit) { | |
2818 case 0x1: | |
2819 tmp = _("Buddy Icon"); | |
2820 break; | |
2821 case 0x2: | |
2822 tmp = _("Voice"); | |
2823 break; | |
2824 case 0x4: | |
2825 tmp = _("IM Image"); | |
2826 break; | |
2827 case 0x8: | |
2828 tmp = _("Chat"); | |
2829 break; | |
2830 case 0x10: | |
2831 tmp = _("Get File"); | |
2832 break; | |
2833 case 0x20: | |
2834 tmp = _("Send File"); | |
2835 break; | |
2836 case 0x40: | |
2837 case 0x200: | |
2838 tmp = _("Games"); | |
2839 break; | |
2840 case 0x80: | |
2841 tmp = _("Stocks"); | |
2842 break; | |
2843 case 0x100: | |
2844 tmp = _("Send Buddy List"); | |
2845 break; | |
2846 case 0x400: | |
2847 tmp = _("EveryBuddy Bug"); | |
2848 break; | |
2849 case 0x800: | |
2850 tmp = _("AP User"); | |
2851 break; | |
2852 case 0x1000: | |
2853 tmp = _("ICQ RTF"); | |
2854 break; | |
2855 case 0x2000: | |
2856 tmp = _("Nihilist"); | |
2857 break; | |
2858 case 0x4000: | |
2859 tmp = _("ICQ Server Relay"); | |
2860 break; | |
2861 case 0x8000: | |
2862 tmp = _("ICQ Unknown"); | |
2863 break; | |
2864 case 0x10000: | |
2865 tmp = _("Trillian Encryption"); | |
2866 break; | |
4742 | 2867 case 0x20000: |
2868 tmp = _("ICQ UTF8"); | |
2869 break; | |
2920 | 2870 default: |
2871 tmp = NULL; | |
2872 break; | |
2873 } | |
2874 if (tmp) | |
2875 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
2876 tmp); | |
2877 count++; | |
2878 } | |
2879 bit <<= 1; | |
2880 } | |
4744 | 2881 return buf; |
2920 | 2882 } |
2883 | |
4732 | 2884 static char *oscar_tooltip_text(struct buddy *b) { |
4738 | 2885 struct gaim_connection *gc = b->account->gc; |
2886 struct oscar_data *od = gc->proto_data; | |
2887 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name)); | |
2888 | |
4744 | 2889 if (bi) { |
2890 char *caps = caps_string(bi->caps); | |
2891 char *time = asctime(localtime(&bi->signon)); | |
2892 *(strchr(time, '\n')) = '\0'; | |
2893 return g_strdup_printf(_("<b>Online Since:</b> %s%s%s"), | |
2894 time, | |
2895 caps ? _("\n<b>Capabilities:</b> ") : "", caps ? caps : ""); | |
2896 } else { | |
4738 | 2897 return NULL; |
4744 | 2898 } |
4732 | 2899 } |
2900 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2901 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2902 aim_userinfo_t *info; |
4151 | 2903 char *text_enc = NULL, *text = NULL, *utf8 = NULL; |
2904 int text_len; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2905 fu16_t infotype; |
4151 | 2906 fu32_t flags; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2907 char header[BUF_LONG]; |
2086 | 2908 struct gaim_connection *gc = sess->aux_data; |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2909 struct oscar_data *od = gc->proto_data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2910 GSList *l = od->evilhack; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2911 gboolean evilhack = FALSE; |
2086 | 2912 va_list ap; |
2993 | 2913 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; |
2086 | 2914 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2915 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2916 info = va_arg(ap, aim_userinfo_t *); |
4199 | 2917 infotype = (fu16_t) va_arg(ap, unsigned int); |
4151 | 2918 text_enc = va_arg(ap, char *); |
2919 text = va_arg(ap, char *); | |
2920 text_len = va_arg(ap, int); | |
2086 | 2921 va_end(ap); |
2922 | |
4151 | 2923 if (text_len > 0) { |
2924 flags = parse_encoding (text_enc); | |
2925 switch (flags) { | |
2926 case 0: | |
4159 | 2927 utf8 = g_strndup(text, text_len); |
4151 | 2928 break; |
4166 | 2929 case AIM_IMFLAGS_ISO_8859_1: |
2930 utf8 = g_convert(text, text_len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
2931 break; | |
4151 | 2932 case AIM_IMFLAGS_UNICODE: |
2933 utf8 = g_convert(text, text_len, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
2934 break; | |
2935 default: | |
4152 | 2936 utf8 = g_strdup(_("<I>Unable to display information because it was sent in an unknown encoding.</I>")); |
4194 | 2937 debug_printf("Encountered an unknown encoding while parsing userinfo\n"); |
4151 | 2938 } |
2939 } | |
2940 | |
2993 | 2941 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
2942 onlinesince = g_strdup_printf("Online Since : <B>%s</B><BR>\n", | |
2943 asctime(localtime(&info->onlinesince))); | |
2944 } | |
2945 | |
2946 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
2947 membersince = g_strdup_printf("Member Since : <B>%s</B><BR>\n", | |
2948 asctime(localtime(&info->membersince))); | |
2949 } | |
2950 | |
2951 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
4426 | 2952 gchar *itime = sec_to_text(info->idletime*60); |
2953 idle = g_strdup_printf("Idle : <B>%s</B>", itime); | |
2954 g_free(itime); | |
2993 | 2955 } else |
2956 idle = g_strdup("Idle: <B>Active</B>"); | |
2957 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2958 g_snprintf(header, sizeof header, |
2086 | 2959 _("Username : <B>%s</B> %s <BR>\n" |
2993 | 2960 "Warning Level : <B>%d %%</B><BR>\n" |
2086 | 2961 "%s" |
2993 | 2962 "%s" |
4344 | 2963 "%s\n" |
3952 | 2964 "<HR>\n"), |
2086 | 2965 info->sn, images(info->flags), |
2966 info->warnlevel/10, | |
2993 | 2967 onlinesince ? onlinesince : "", |
2968 membersince ? membersince : "", | |
2969 idle ? idle : ""); | |
2970 | |
2971 g_free(onlinesince); | |
2972 g_free(membersince); | |
2973 g_free(idle); | |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
2974 |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2975 while (l) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2976 char *x = l->data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2977 if (!strcmp(x, normalize(info->sn))) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2978 evilhack = TRUE; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2979 g_free(x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2980 od->evilhack = g_slist_remove(od->evilhack, x); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2981 break; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2982 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2983 l = l->next; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2984 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2985 |
2920 | 2986 if (infotype == AIM_GETINFO_AWAYMESSAGE) { |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2987 if (evilhack) { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2988 g_show_info_text(gc, info->sn, 2, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2989 header, |
4151 | 2990 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
4207 | 2991 _("<i>User has no away message</i>"), NULL); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2992 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2993 g_show_info_text(gc, info->sn, 0, |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2994 header, |
4151 | 2995 (utf8 && *utf8) ? away_subs(utf8, gc->username) : NULL, |
4344 | 2996 (utf8 && *utf8) ? "<HR>" : NULL, |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2997 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2998 } |
2920 | 2999 } else if (infotype == AIM_GETINFO_CAPABILITIES) { |
3000 g_show_info_text(gc, info->sn, 2, | |
3001 header, | |
3002 "<i>", _("Client Capabilities: "), | |
3003 caps_string(info->capabilities), | |
3004 "</i>", | |
3005 NULL); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3006 } else { |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3007 g_show_info_text(gc, info->sn, 1, |
4151 | 3008 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
3009 _("<i>No Information Provided</i>"), | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3010 NULL); |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3011 } |
2086 | 3012 |
4151 | 3013 g_free(utf8); |
3014 | |
2086 | 3015 return 1; |
3016 } | |
3017 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3018 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3019 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3020 fu16_t id; |
2086 | 3021 va_list ap; |
3022 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3023 va_start(ap, fr); |
4199 | 3024 id = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3025 msg = va_arg(ap, char *); |
3026 va_end(ap); | |
3027 | |
4194 | 3028 debug_printf("MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
3029 if (id < 4) |
3427 | 3030 do_error_dialog(_("Your AIM connection may be lost."), NULL, GAIM_WARNING); |
2086 | 3031 |
3032 return 1; | |
3033 } | |
3034 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3035 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3036 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3037 fu16_t type; |
2086 | 3038 struct gaim_connection *gc = sess->aux_data; |
4617 | 3039 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3040 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3041 va_start(ap, fr); |
4199 | 3042 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3043 |
3044 switch(type) { | |
3045 case 0x0002: { | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3046 fu8_t maxrooms; |
2086 | 3047 struct aim_chat_exchangeinfo *exchanges; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3048 int exchangecount, i; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3049 |
4199 | 3050 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
2086 | 3051 exchangecount = va_arg(ap, int); |
3052 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
3053 | |
3054 debug_printf("chat info: Chat Rights:\n"); | |
4194 | 3055 debug_printf("chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
2086 | 3056 debug_printf("chat info: \tExchange List: (%d total)\n", exchangecount); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3057 for (i = 0; i < exchangecount; i++) |
4194 | 3058 debug_printf("chat info: \t\t%hu %s\n", exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
4617 | 3059 while (od->create_rooms) { |
3060 struct create_room *cr = od->create_rooms->data; | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3061 debug_printf("creating room %s\n", cr->name); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3062 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3063 g_free(cr->name); |
4617 | 3064 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
3065 g_free(cr); |
2086 | 3066 } |
3067 } | |
3068 break; | |
3069 case 0x0008: { | |
3070 char *fqcn, *name, *ck; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3071 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3072 fu8_t createperms; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3073 fu32_t createtime; |
2086 | 3074 |
3075 fqcn = va_arg(ap, char *); | |
4200 | 3076 instance = (fu16_t)va_arg(ap, unsigned int); |
3077 exchange = (fu16_t)va_arg(ap, unsigned int); | |
3078 flags = (fu16_t)va_arg(ap, unsigned int); | |
3079 createtime = va_arg(ap, fu32_t); | |
3080 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3081 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
3082 createperms = (fu8_t)va_arg(ap, unsigned int); | |
3083 unknown = (fu16_t)va_arg(ap, unsigned int); | |
3084 name = va_arg(ap, char *); | |
3085 ck = va_arg(ap, char *); | |
4194 | 3086 |
3087 debug_printf("created room: %s %hu %hu %hu %lu %hu %hu %hhu %hu %s %s\n", | |
2086 | 3088 fqcn, |
3089 exchange, instance, flags, | |
3090 createtime, | |
3091 maxmsglen, maxoccupancy, createperms, unknown, | |
3092 name, ck); | |
4617 | 3093 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
2086 | 3094 } |
3095 break; | |
3096 default: | |
4194 | 3097 debug_printf("chatnav info: unknown type (%04hx)\n", type); |
2086 | 3098 break; |
3099 } | |
4194 | 3100 |
3101 va_end(ap); | |
3102 | |
2086 | 3103 return 1; |
3104 } | |
3105 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3106 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3107 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3108 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3109 aim_userinfo_t *info; |
2086 | 3110 struct gaim_connection *g = sess->aux_data; |
3111 | |
3112 struct chat_connection *c = NULL; | |
3113 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3114 va_start(ap, fr); |
2086 | 3115 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3116 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3117 va_end(ap); |
3118 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3119 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3120 if (!c) |
3121 return 1; | |
3122 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3123 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3124 gaim_chat_add_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3125 |
3126 return 1; | |
3127 } | |
3128 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3129 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3130 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3131 int count, i; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3132 aim_userinfo_t *info; |
2086 | 3133 struct gaim_connection *g = sess->aux_data; |
3134 | |
3135 struct chat_connection *c = NULL; | |
3136 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3137 va_start(ap, fr); |
2086 | 3138 count = va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3139 info = va_arg(ap, aim_userinfo_t *); |
2086 | 3140 va_end(ap); |
3141 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3142 c = find_oscar_chat_by_conn(g, fr->conn); |
2086 | 3143 if (!c) |
3144 return 1; | |
3145 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3146 for (i = 0; i < count; i++) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
3147 gaim_chat_remove_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
2086 | 3148 |
3149 return 1; | |
3150 } | |
3151 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3152 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
|
3153 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3154 aim_userinfo_t *userinfo; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3155 struct aim_chat_roominfo *roominfo; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3156 char *roomname; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3157 int usercount; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3158 char *roomdesc; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3159 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3160 fu32_t creationtime; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3161 struct gaim_connection *gc = sess->aux_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3162 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
|
3163 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3164 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3165 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3166 roomname = va_arg(ap, char *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3167 usercount= va_arg(ap, int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3168 userinfo = va_arg(ap, aim_userinfo_t *); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3169 roomdesc = va_arg(ap, char *); |
4200 | 3170 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
3171 creationtime = va_arg(ap, fu32_t); | |
3172 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
3173 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
3174 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
3175 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3176 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3177 |
4194 | 3178 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
|
3179 maxmsglen, maxvisiblemsglen); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3180 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3181 ccon->maxlen = maxmsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3182 ccon->maxvis = maxvisiblemsglen; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3183 |
2086 | 3184 return 1; |
3185 } | |
3186 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3187 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
4269 | 3188 struct gaim_connection *gc = sess->aux_data; |
2086 | 3189 va_list ap; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3190 aim_userinfo_t *info; |
2086 | 3191 char *msg; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3192 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
2086 | 3193 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3194 va_start(ap, fr); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3195 info = va_arg(ap, aim_userinfo_t *); |
4194 | 3196 msg = va_arg(ap, char *); |
3197 va_end(ap); | |
2086 | 3198 |
4269 | 3199 serv_got_chat_in(gc, ccon->id, info->sn, 0, msg, time((time_t)NULL)); |
2086 | 3200 |
3201 return 1; | |
3202 } | |
3203 | |
3694 | 3204 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
3205 va_list ap; | |
3206 struct gaim_connection *gc = sess->aux_data; | |
3207 struct aim_emailinfo *emailinfo; | |
3725 | 3208 int havenewmail; |
3694 | 3209 |
3210 va_start(ap, fr); | |
3211 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
3725 | 3212 havenewmail = va_arg(ap, int); |
3694 | 3213 va_end(ap); |
3214 | |
3725 | 3215 if (emailinfo) { |
3216 if (emailinfo->unread) { | |
3217 if (havenewmail) | |
3218 connection_has_mail(gc, emailinfo->nummsgs ? emailinfo->nummsgs : -1, NULL, NULL, emailinfo->url); | |
3219 } else | |
3694 | 3220 connection_has_mail(gc, 0, NULL, NULL, emailinfo->url); |
3221 } | |
3222 | |
3223 return 1; | |
3224 } | |
3225 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3226 /* |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3227 * 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
|
3228 */ |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3229 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3230 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3231 fu16_t type; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3232 char *sn; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3233 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3234 va_start(ap, fr); |
4199 | 3235 type = (fu16_t) va_arg(ap, unsigned int); |
2086 | 3236 sn = va_arg(ap, char *); |
3237 va_end(ap); | |
3238 | |
3239 debug_printf("Sent message to %s.\n", sn); | |
3240 | |
3241 return 1; | |
3242 } | |
3243 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3244 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
|
3245 static const char *codes[5] = { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3246 "invalid", |
4194 | 3247 "change", |
3248 "warning", | |
3249 "limit", | |
3250 "limit cleared", | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3251 }; |
2086 | 3252 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3253 fu16_t code, rateclass; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3254 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3255 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3256 va_start(ap, fr); |
4200 | 3257 code = (fu16_t)va_arg(ap, unsigned int); |
3258 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
3259 windowsize = va_arg(ap, fu32_t); | |
3260 clear = va_arg(ap, fu32_t); | |
3261 alert = va_arg(ap, fu32_t); | |
3262 limit = va_arg(ap, fu32_t); | |
3263 disconnect = va_arg(ap, fu32_t); | |
3264 currentavg = va_arg(ap, fu32_t); | |
3265 maxavg = va_arg(ap, fu32_t); | |
2086 | 3266 va_end(ap); |
3267 | |
4194 | 3268 debug_printf("rate %s (param ID 0x%04hx): curavg = %lu, maxavg = %lu, alert at %lu, " |
3269 "clear warning at %lu, limit at %lu, disconnect at %lu (window size = %lu)\n", | |
2086 | 3270 (code < 5) ? codes[code] : codes[0], |
3271 rateclass, | |
3272 currentavg, maxavg, | |
3273 alert, clear, | |
3274 limit, disconnect, | |
3275 windowsize); | |
3276 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3277 /* XXX fix these values */ |
2086 | 3278 if (code == AIM_RATE_CODE_CHANGE) { |
3279 if (currentavg >= clear) | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3280 aim_conn_setlatency(fr->conn, 0); |
2086 | 3281 } else if (code == AIM_RATE_CODE_WARNING) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3282 aim_conn_setlatency(fr->conn, windowsize/4); |
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3283 } else if (code == AIM_RATE_CODE_LIMIT) { |
3427 | 3284 do_error_dialog(_("Rate limiting error."), |
3285 _("The last message was not sent because you are over the rate limit. " | |
3286 "Please wait 10 seconds and try again."), GAIM_ERROR); | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3287 aim_conn_setlatency(fr->conn, windowsize/2); |
2086 | 3288 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3289 aim_conn_setlatency(fr->conn, 0); |
2086 | 3290 } |
3291 | |
3292 return 1; | |
3293 } | |
3294 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3295 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3296 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3297 fu16_t newevil; |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3298 aim_userinfo_t *userinfo; |
2086 | 3299 struct gaim_connection *gc = sess->aux_data; |
3300 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3301 va_start(ap, fr); |
4199 | 3302 newevil = (fu16_t) va_arg(ap, unsigned int); |
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3303 userinfo = va_arg(ap, aim_userinfo_t *); |
2086 | 3304 va_end(ap); |
3305 | |
3306 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, newevil / 10); | |
3307 | |
3308 return 1; | |
3309 } | |
3310 | |
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3311 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
|
3312 va_list ap; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3313 aim_userinfo_t *info; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3314 struct gaim_connection *gc = sess->aux_data; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3315 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3316 va_start(ap, fr); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3317 info = va_arg(ap, aim_userinfo_t *); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3318 va_end(ap); |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3319 |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3320 gc->evil = info->warnlevel/10; |
2698
e80f4b4f840f
[gaim-migrate @ 2711]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2689
diff
changeset
|
3321 /* gc->correction_time = (info->onlinesince - gc->login_time); */ |
2507
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 return 1; |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3324 } |
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3325 |
4649 | 3326 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
3327 struct gaim_connection *gc = sess->aux_data; | |
4666 | 3328 struct oscar_data *od = gc->proto_data; |
4649 | 3329 va_list ap; |
3330 fu16_t code; | |
3331 char *msg; | |
3332 | |
3333 va_start(ap, fr); | |
3334 code = (fu16_t)va_arg(ap, int); | |
3335 msg = va_arg(ap, char *); | |
3336 va_end(ap); | |
3337 | |
3338 debug_printf("Disconnected. Code is 0x%04x and msg is %s\n", code, msg); | |
3339 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { | |
4651 | 3340 if (code == 0x0001) { |
4652 | 3341 hide_login_progress_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
4651 | 3342 } else { |
4652 | 3343 hide_login_progress_error(gc, _("You have been signed off for an unknown reason.")); |
4651 | 3344 } |
4666 | 3345 od->killme = TRUE; |
4649 | 3346 } |
3347 | |
3348 return 1; | |
3349 } | |
3350 | |
2675 | 3351 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
|
3352 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3353 aim_reqpersonalinfo(sess, fr->conn); |
4230 | 3354 |
3355 #ifndef NOSSI | |
3356 debug_printf("ssi: requesting ssi list\n"); | |
3357 aim_ssi_reqrights(sess, fr->conn); | |
3358 aim_ssi_reqdata(sess, fr->conn, sess->ssi.timestamp, sess->ssi.numitems); | |
3359 #endif | |
3360 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3361 aim_bos_reqlocaterights(sess, fr->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3362 aim_bos_reqbuddyrights(sess, fr->conn); |
4617 | 3363 aim_im_reqparams(sess); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3364 aim_bos_reqrights(sess, fr->conn); |
4230 | 3365 |
3366 #ifdef NOSSI | |
3367 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | |
3368 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
3369 #endif | |
2086 | 3370 |
3371 return 1; | |
3372 } | |
3373 | |
2675 | 3374 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
2647 | 3375 struct gaim_connection *gc = sess->aux_data; |
3376 struct oscar_data *od = gc->proto_data; | |
3377 | |
2672 | 3378 aim_clientready(sess, fr->conn); |
2675 | 3379 debug_printf("connected to admin\n"); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3380 |
2647 | 3381 if (od->chpass) { |
3382 debug_printf("changing password\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3383 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
2647 | 3384 g_free(od->oldp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3385 od->oldp = NULL; |
2647 | 3386 g_free(od->newp); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3387 od->newp = NULL; |
2647 | 3388 od->chpass = FALSE; |
3389 } | |
2979 | 3390 if (od->setnick) { |
3391 debug_printf("formatting screenname\n"); | |
3392 aim_admin_setnick(sess, fr->conn, od->newsn); | |
3393 g_free(od->newsn); | |
3394 od->newsn = NULL; | |
3395 od->setnick = FALSE; | |
3396 } | |
2647 | 3397 if (od->conf) { |
3398 debug_printf("confirming account\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3399 aim_admin_reqconfirm(sess, fr->conn); |
2647 | 3400 od->conf = FALSE; |
3401 } | |
3402 if (od->reqemail) { | |
3403 debug_printf("requesting email\n"); | |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3404 aim_admin_getinfo(sess, fr->conn, 0x0011); |
2647 | 3405 od->reqemail = FALSE; |
3406 } | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3407 if (od->setemail) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3408 debug_printf("setting email\n"); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3409 aim_admin_setemail(sess, fr->conn, od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3410 g_free(od->email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3411 od->setemail = FALSE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3412 } |
2647 | 3413 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3414 return 1; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3415 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3416 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3417 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
|
3418 struct aim_icbmparameters *params; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3419 va_list ap; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3420 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3421 va_start(ap, fr); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3422 params = va_arg(ap, struct aim_icbmparameters *); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3423 va_end(ap); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3424 |
4194 | 3425 /* XXX - evidently this crashes on solaris. i have no clue why |
3426 debug_printf("ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " | |
3427 "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
|
3428 params->maxchan, params->flags, params->maxmsglen, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3429 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3430 params->minmsginterval); |
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3431 */ |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3432 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3433 /* Maybe senderwarn and recverwarn should be user preferences... */ |
3595 | 3434 params->flags = 0x0000000b; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3435 params->maxmsglen = 8000; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3436 params->minmsginterval = 0; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3437 |
4617 | 3438 aim_im_setparams(sess, params); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3439 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3440 return 1; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3441 } |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3442 |
2993 | 3443 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
3444 { | |
3445 va_list ap; | |
3446 fu16_t maxsiglen; | |
3447 struct gaim_connection *gc = sess->aux_data; | |
4617 | 3448 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4151 | 3449 char *unicode; |
3450 int unicode_len; | |
3451 fu32_t flags; | |
2993 | 3452 |
3453 va_start(ap, fr); | |
4199 | 3454 maxsiglen = (fu16_t) va_arg(ap, int); |
2993 | 3455 va_end(ap); |
3456 | |
3457 debug_printf("locate rights: max sig len = %d\n", maxsiglen); | |
3458 | |
4617 | 3459 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3460 | |
3461 if (od->icq) | |
4151 | 3462 aim_bos_setprofile(sess, fr->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
3463 else { | |
4491 | 3464 flags = check_encoding (gc->account->user_info); |
4151 | 3465 |
3466 if (flags == 0) { | |
4600 | 3467 aim_bos_setprofile(sess, fr->conn, "us-ascii", gc->account->user_info, |
4491 | 3468 strlen(gc->account->user_info), NULL, NULL, 0, caps_aim); |
4151 | 3469 } else { |
4491 | 3470 unicode = g_convert (gc->account->user_info, strlen(gc->account->user_info), |
4151 | 3471 "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); |
3472 aim_bos_setprofile(sess, fr->conn, "unicode-2-0", unicode, unicode_len, | |
3473 NULL, NULL, 0, caps_aim); | |
3474 g_free(unicode); | |
3475 } | |
3476 } | |
2993 | 3477 |
3478 return 1; | |
3479 } | |
3480 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3481 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
|
3482 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3483 fu16_t maxbuddies, maxwatchers; |
2993 | 3484 struct gaim_connection *gc = sess->aux_data; |
4617 | 3485 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3486 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3487 va_start(ap, fr); |
4199 | 3488 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
3489 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3490 va_end(ap); |
3491 | |
4194 | 3492 debug_printf("buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
2086 | 3493 |
4617 | 3494 od->rights.maxbuddies = (guint)maxbuddies; |
3495 od->rights.maxwatchers = (guint)maxwatchers; | |
2993 | 3496 |
2086 | 3497 return 1; |
3498 } | |
3499 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3500 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
|
3501 fu16_t maxpermits, maxdenies; |
2086 | 3502 va_list ap; |
2993 | 3503 struct gaim_connection *gc = sess->aux_data; |
4617 | 3504 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 3505 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3506 va_start(ap, fr); |
4199 | 3507 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
3508 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
2086 | 3509 va_end(ap); |
3510 | |
4194 | 3511 debug_printf("BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
2086 | 3512 |
4617 | 3513 od->rights.maxpermits = (guint)maxpermits; |
3514 od->rights.maxdenies = (guint)maxdenies; | |
2993 | 3515 |
3516 account_online(gc); | |
3517 serv_finish_login(gc); | |
3518 | |
3519 debug_printf("buddy list loaded\n"); | |
3520 | |
2672 | 3521 aim_clientready(sess, fr->conn); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3522 |
4617 | 3523 /* XXX - Should call aim_bos_setidle with 0x0000 */ |
3524 | |
4664 | 3525 if (od->icq) { |
3526 aim_icq_reqofflinemsgs(sess); | |
3527 aim_icq_hideip(sess); | |
3528 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3529 |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3530 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
4102 | 3531 if (sess->authinfo->email) |
3532 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
2086 | 3533 |
3534 return 1; | |
3535 } | |
3536 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3537 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
|
3538 va_list ap; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3539 struct aim_icq_offlinemsg *msg; |
4075 | 3540 struct aim_incomingim_ch4_args args; |
3541 time_t t; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3542 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3543 va_start(ap, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3544 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3545 va_end(ap); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3546 |
4075 | 3547 debug_printf("Received offline message. Converting to channel 4 ICBM...\n"); |
3548 args.uin = msg->sender; | |
3549 args.type = msg->type; | |
4173 | 3550 args.flags = msg->flags; |
4076 | 3551 args.msglen = msg->msglen; |
4075 | 3552 args.msg = msg->msg; |
3553 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); | |
3554 incomingim_chan4(sess, fr->conn, NULL, &args, t); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3555 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3556 return 1; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3557 } |
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 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
|
3560 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3561 aim_icq_ackofflinemsgs(sess); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3562 return 1; |
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 |
4624 | 3565 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
|
3566 { |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
3567 struct gaim_connection *gc = sess->aux_data; |
4624 | 3568 gchar *buf, *tmp; |
3569 gchar who[16]; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3570 va_list ap; |
4151 | 3571 struct aim_icq_info *info; |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3572 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3573 va_start(ap, fr); |
4151 | 3574 info = va_arg(ap, struct aim_icq_info *); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3575 va_end(ap); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3576 |
4664 | 3577 if (!info->uin) |
3578 return 0; | |
3579 | |
4151 | 3580 g_snprintf(who, sizeof(who), "%lu", info->uin); |
4624 | 3581 buf = g_strdup_printf("<b>UIN:</b> %s", who); |
4641 | 3582 if (info->nick && info->nick[0]) { |
4624 | 3583 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Nick:</b> ", info->nick, NULL); g_free(tmp); |
4151 | 3584 } |
4641 | 3585 if (info->first && info->first[0]) { |
4624 | 3586 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>First Name:</b> ", info->first, NULL); g_free(tmp); |
4151 | 3587 } |
4641 | 3588 if (info->last && info->last[0]) { |
4624 | 3589 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Last Name:</b> ", info->last, NULL); g_free(tmp); |
4151 | 3590 } |
4641 | 3591 if (info->email && info->email[0]) { |
4625 | 3592 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Email Address:</b> <a href=\"mailto:", info->email, "\">", info->email, "</a>", NULL); g_free(tmp); |
3593 } | |
3594 if (info->numaddresses && info->email2) { | |
3595 int i; | |
3596 for (i = 0; i < info->numaddresses; i++) { | |
4643 | 3597 if (info->email2[i] && info->email2[i][0]) { |
4625 | 3598 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 | 3599 } |
4625 | 3600 } |
4624 | 3601 } |
4641 | 3602 if (info->mobile && info->mobile[0]) { |
4625 | 3603 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Mobile Phone:</b> ", info->mobile, NULL); g_free(tmp); |
3604 } | |
3605 if (info->gender) { | |
3606 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Gender:</b> ", info->gender==1 ? "Female" : "Male", NULL); g_free(tmp); | |
4151 | 3607 } |
4624 | 3608 if (info->birthyear || info->birthmonth || info->birthday) { |
4627 | 3609 char date[30]; |
3610 struct tm tm; | |
3611 tm.tm_mday = (int)info->birthday; | |
3612 tm.tm_mon = (int)info->birthmonth-1; | |
3613 tm.tm_year = (int)info->birthyear-1900; | |
4628 | 3614 strftime(date, sizeof(date), "%x", &tm); |
4624 | 3615 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Birthday:</b> ", date, NULL); g_free(tmp); |
4151 | 3616 } |
4624 | 3617 if (info->age) { |
3618 char age[5]; | |
3619 snprintf(age, sizeof(age), "%hhd", info->age); | |
3620 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Age:</b> ", age, NULL); g_free(tmp); | |
4151 | 3621 } |
4641 | 3622 if (info->personalwebpage && info->personalwebpage[0]) { |
4624 | 3623 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 | 3624 } |
4641 | 3625 if (info->info && info->info[0]) { |
4624 | 3626 tmp = buf; buf = g_strconcat(tmp, "<hr><b>Additional Information:</b><br>", info->info, NULL); g_free(tmp); |
3627 } | |
3628 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | |
4641 | 3629 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
4624 | 3630 tmp = buf; buf = g_strconcat(tmp, "<b>Home Address:</b>", NULL); g_free(tmp); |
4641 | 3631 if (info->homeaddr && info->homeaddr[0]) { |
4624 | 3632 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Address:</b> ", info->homeaddr, NULL); g_free(tmp); |
3633 } | |
4641 | 3634 if (info->homecity && info->homecity[0]) { |
4624 | 3635 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>City:</b> ", info->homecity, NULL); g_free(tmp); |
3636 } | |
4641 | 3637 if (info->homestate && info->homestate[0]) { |
4624 | 3638 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>State:</b> ", info->homestate, NULL); g_free(tmp); |
3639 } | |
4641 | 3640 if (info->homezip && info->homezip[0]) { |
4624 | 3641 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Zip Code:</b> ", info->homezip, NULL); g_free(tmp); |
3642 } | |
3643 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3644 } |
4641 | 3645 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
4624 | 3646 tmp = buf; buf = g_strconcat(tmp, "<b>Work Address:</b>", NULL); g_free(tmp); |
4641 | 3647 if (info->workaddr && info->workaddr[0]) { |
4624 | 3648 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Address:</b> ", info->workaddr, NULL); g_free(tmp); |
3649 } | |
4641 | 3650 if (info->workcity && info->workcity[0]) { |
4624 | 3651 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>City:</b> ", info->workcity, NULL); g_free(tmp); |
3652 } | |
4641 | 3653 if (info->workstate && info->workstate[0]) { |
4624 | 3654 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>State:</b> ", info->workstate, NULL); g_free(tmp); |
3655 } | |
4641 | 3656 if (info->workzip && info->workzip[0]) { |
4624 | 3657 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Zip Code:</b> ", info->workzip, NULL); g_free(tmp); |
3658 } | |
3659 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
3660 } | |
4641 | 3661 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
4624 | 3662 tmp = buf; buf = g_strconcat(tmp, "<b>Work Information:</b>", NULL); g_free(tmp); |
4641 | 3663 if (info->workcompany && info->workcompany[0]) { |
4624 | 3664 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Company:</b> ", info->workcompany, NULL); g_free(tmp); |
3665 } | |
4641 | 3666 if (info->workdivision && info->workdivision[0]) { |
4624 | 3667 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Division:</b> ", info->workdivision, NULL); g_free(tmp); |
3668 } | |
4641 | 3669 if (info->workposition && info->workposition[0]) { |
4624 | 3670 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Position:</b> ", info->workposition, NULL); g_free(tmp); |
3671 } | |
4641 | 3672 if (info->workwebpage && info->workwebpage[0]) { |
4624 | 3673 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Web Page:</b> <a href=\"", info->workwebpage, "\">", info->workwebpage, "</a>", NULL); g_free(tmp); |
3674 } | |
3675 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4151 | 3676 } |
3677 | |
3678 g_show_info_text(gc, who, 2, buf, NULL); | |
3679 g_free(buf); | |
3680 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3681 return 1; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3682 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3683 |
4759 | 3684 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
3685 { | |
3686 struct gaim_connection *gc = sess->aux_data; | |
3687 gchar who[16]; | |
3688 struct buddy *b; | |
3689 va_list ap; | |
3690 struct aim_icq_info *info; | |
3691 | |
3692 va_start(ap, fr); | |
3693 info = va_arg(ap, struct aim_icq_info *); | |
3694 va_end(ap); | |
3695 | |
3696 if (info->uin && info->nick && info->nick[0]) { | |
3697 g_snprintf(who, sizeof(who), "%lu", info->uin); | |
3698 serv_got_alias(gc, who, info->nick); | |
3699 if ((b = gaim_find_buddy(gc->account, who))) { | |
3700 gaim_buddy_set_setting(b, "servernick", info->nick); | |
3701 gaim_blist_save(); | |
3702 } | |
3703 } | |
3704 | |
3705 return 1; | |
3706 } | |
3707 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3708 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
|
3709 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3710 char *msg, *url; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3711 fu16_t wid, hei, delay; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3712 va_list ap; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3713 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3714 va_start(ap, fr); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3715 msg = va_arg(ap, char *); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3716 url = va_arg(ap, char *); |
4199 | 3717 wid = (fu16_t) va_arg(ap, int); |
3718 hei = (fu16_t) va_arg(ap, int); | |
3719 delay = (fu16_t) va_arg(ap, int); | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3720 va_end(ap); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3721 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3722 serv_got_popup(msg, url, wid, hei); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3723 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3724 return 1; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3725 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3726 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3727 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3728 va_list ap; |
3729 char *address, *SNs; | |
3730 int i, num; | |
3731 char *buf; | |
3732 int at = 0, len; | |
3733 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3734 va_start(ap, fr); |
2086 | 3735 address = va_arg(ap, char *); |
3736 num = va_arg(ap, int); | |
3737 SNs = va_arg(ap, char *); | |
3738 va_end(ap); | |
3739 | |
3740 len = num * (MAXSNLEN + 1) + 1024; | |
3741 buf = g_malloc(len); | |
3742 at += g_snprintf(buf + at, len - at, "<B>%s has the following screen names:</B><BR>", address); | |
3743 for (i = 0; i < num; i++) | |
3744 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | |
3212 | 3745 g_show_info_text(NULL, NULL, 2, buf, NULL); |
2086 | 3746 g_free(buf); |
3747 | |
3748 return 1; | |
3749 } | |
3750 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3751 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 3752 va_list ap; |
3753 char *address; | |
3754 char buf[BUF_LONG]; | |
3755 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3756 va_start(ap, fr); |
2086 | 3757 address = va_arg(ap, char *); |
3758 va_end(ap); | |
3759 | |
3760 g_snprintf(buf, sizeof(buf), "No results found for email address %s", address); | |
3427 | 3761 do_error_dialog(buf, NULL, GAIM_ERROR); |
2086 | 3762 |
3763 return 1; | |
3764 } | |
3765 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3766 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
|
3767 fu16_t status; |
2086 | 3768 va_list ap; |
3769 char msg[256]; | |
3770 struct gaim_connection *gc = sess->aux_data; | |
3771 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3772 va_start(ap, fr); |
4199 | 3773 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
2086 | 3774 va_end(ap); |
3775 | |
3776 debug_printf("account confirmation returned status 0x%04x (%s)\n", status, | |
3912 | 3777 status ? "unknown" : "email sent"); |
3778 if (!status) { | |
2086 | 3779 g_snprintf(msg, sizeof(msg), "You should receive an email asking to confirm %s.", |
3780 gc->username); | |
4056 | 3781 do_error_dialog(_("Account Confirmation Requested"), msg, GAIM_INFO); |
2086 | 3782 } |
3783 | |
3784 return 1; | |
3785 } | |
3786 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3787 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
3912 | 3788 struct gaim_connection *gc = sess->aux_data; |
2086 | 3789 va_list ap; |
3912 | 3790 fu16_t perms, err; |
3791 char *url, *sn, *email; | |
3792 int change; | |
2086 | 3793 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3794 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3795 change = va_arg(ap, int); |
4199 | 3796 perms = (fu16_t) va_arg(ap, unsigned int); |
3797 err = (fu16_t) va_arg(ap, unsigned int); | |
3912 | 3798 url = va_arg(ap, char *); |
3799 sn = va_arg(ap, char *); | |
3800 email = va_arg(ap, char *); | |
2086 | 3801 va_end(ap); |
3802 | |
3912 | 3803 debug_printf("account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
3804 change ? "change" : "request", perms, err, url, sn, email); | |
3805 | |
3806 if (err && url) { | |
3807 char *dialog_msg; | |
3808 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
3809 switch (err) { | |
3810 case 0x0001: { | |
3811 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
3812 } break; | |
3813 case 0x0006: { | |
3814 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
3815 } break; | |
3816 case 0x000b: { | |
3817 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
3818 } break; | |
3819 case 0x001d: { | |
3820 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); | |
3821 } break; | |
3822 case 0x0021: { | |
3823 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); | |
3824 } break; | |
3825 case 0x0023: { | |
3826 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
3827 } break; | |
3828 default: { | |
3829 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
3830 } break; | |
3831 } | |
3832 do_error_dialog(dialog_top, dialog_msg, GAIM_ERROR); | |
3833 g_free(dialog_top); | |
3834 g_free(dialog_msg); | |
3835 return 1; | |
3836 } | |
3837 | |
3838 if (sn) { | |
4585 | 3839 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formatted as follows:\n%s"), sn); |
4056 | 3840 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
3912 | 3841 g_free(dialog_msg); |
3842 } | |
3843 | |
3844 if (email) { | |
3845 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), gc->username, email); | |
4056 | 3846 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
3912 | 3847 g_free(dialog_msg); |
2086 | 3848 } |
3849 | |
3850 return 1; | |
3851 } | |
3852 | |
3853 static void oscar_keepalive(struct gaim_connection *gc) { | |
4617 | 3854 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
3855 aim_flap_nop(od->sess, od->conn); | |
2086 | 3856 } |
3857 | |
3001 | 3858 static int oscar_send_typing(struct gaim_connection *gc, char *name, int typing) { |
4617 | 3859 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
3860 struct direct_im *dim = find_direct_im(od, name); | |
3595 | 3861 if (dim) |
4617 | 3862 aim_odc_send_typing(od->sess, dim->conn, typing); |
3595 | 3863 else { |
4738 | 3864 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); |
3865 if (bi && bi->typingnot) { | |
3596 | 3866 if (typing == TYPING) |
4617 | 3867 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
3596 | 3868 else if (typing == TYPED) |
4617 | 3869 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
3595 | 3870 else |
4617 | 3871 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); |
3595 | 3872 } |
3873 } | |
2993 | 3874 return 0; |
3875 } | |
3048 | 3876 static void oscar_ask_direct_im(struct gaim_connection *gc, char *name); |
2993 | 3877 |
3033 | 3878 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) { |
4617 | 3879 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
3880 struct direct_im *dim = find_direct_im(od, name); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3881 int ret = 0; |
3659 | 3882 GError *err = NULL; |
3458 | 3883 |
2086 | 3884 if (dim) { |
3009 | 3885 if (dim->connected) { /* If we're not connected yet, send through server */ |
4617 | 3886 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ |
3887 ret = aim_odc_send_im(od->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0); | |
3009 | 3888 if (ret == 0) |
3889 return 1; | |
3890 else return ret; | |
3891 } | |
3008 | 3892 debug_printf("Direct IM pending, but not connected; sending through server\n"); |
3044 | 3893 } else if (len != -1) { |
3894 /* Trying to send an IM image outside of a direct connection. */ | |
3895 oscar_ask_direct_im(gc, name); | |
3896 return -ENOTCONN; | |
3897 } | |
4738 | 3898 |
3008 | 3899 if (imflags & IM_FLAG_AWAY) { |
4617 | 3900 ret = aim_im_sendch1(od->sess, name, AIM_IMFLAGS_AWAY, message); |
2086 | 3901 } else { |
4738 | 3902 struct buddyinfo *bi; |
3008 | 3903 struct aim_sendimext_args args; |
3904 struct stat st; | |
4151 | 3905 int len; |
4269 | 3906 |
4738 | 3907 bi = g_hash_table_lookup(od->buddyinfo, normalize(name)); |
3908 if (!bi) { | |
3909 bi = g_new0(struct buddyinfo, 1); | |
3910 g_hash_table_insert(od->buddyinfo, g_strdup(normalize(name)), bi); | |
3911 } | |
3912 | |
3008 | 3913 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
4665 | 3914 if (od->icq) { |
3915 args.features = features_icq; | |
3916 args.featureslen = sizeof(features_icq); | |
3008 | 3917 args.flags |= AIM_IMFLAGS_OFFLINE; |
4665 | 3918 } else { |
3919 args.features = features_aim; | |
3920 args.featureslen = sizeof(features_aim); | |
3921 } | |
4269 | 3922 |
4738 | 3923 if (bi->ico_need) { |
3924 debug_printf("Sending buddy icon request with message\n"); | |
3008 | 3925 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
4738 | 3926 bi->ico_need = FALSE; |
3008 | 3927 } |
4269 | 3928 |
4491 | 3929 if (gc->account->iconfile[0] && !stat(gc->account->iconfile, &st)) { |
3930 FILE *file = fopen(gc->account->iconfile, "r"); | |
3008 | 3931 if (file) { |
3932 char *buf = g_malloc(st.st_size); | |
3933 fread(buf, 1, st.st_size, file); | |
4269 | 3934 |
3008 | 3935 args.iconlen = st.st_size; |
4617 | 3936 args.iconsum = aimutil_iconsum(buf, st.st_size); |
3008 | 3937 args.iconstamp = st.st_mtime; |
3938 | |
4738 | 3939 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) |
3940 bi->ico_informed = FALSE; | |
3941 | |
3942 if (!bi->ico_informed) { | |
3943 debug_printf("Claiming to have a buddy icon\n"); | |
3944 args.flags |= AIM_IMFLAGS_HASICON; | |
3945 bi->ico_me_len = args.iconlen; | |
3946 bi->ico_me_csum = args.iconsum; | |
3947 bi->ico_me_time = args.iconstamp; | |
3948 bi->ico_informed = TRUE; | |
3949 } | |
3950 | |
3008 | 3951 |
3952 fclose(file); | |
3953 g_free(buf); | |
2086 | 3954 } |
3955 } | |
4269 | 3956 |
3008 | 3957 args.destsn = name; |
4269 | 3958 |
3642 | 3959 len = strlen(message); |
4151 | 3960 args.flags |= check_encoding(message); |
3642 | 3961 if (args.flags & AIM_IMFLAGS_UNICODE) { |
4194 | 3962 debug_printf("Sending Unicode IM\n"); |
4662 | 3963 args.charset = 0x0002; |
4665 | 3964 args.charsubset = 0x0000; |
3659 | 3965 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
3966 if (err) { | |
3967 debug_printf("Error converting a unicode message: %s\n", err->message); | |
3968 debug_printf("This really shouldn't happen!\n"); | |
3969 /* We really shouldn't try to send the | |
3970 * IM now, but I'm not sure what to do */ | |
3971 } | |
3850 | 3972 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
4194 | 3973 debug_printf("Sending ISO-8859-1 IM\n"); |
4662 | 3974 args.charset = 0x0003; |
4665 | 3975 args.charsubset = 0x0000; |
3659 | 3976 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
3977 if (err) { | |
3978 debug_printf("conversion error: %s\n", err->message); | |
3642 | 3979 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); |
3980 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; | |
3981 len = strlen(message); | |
3659 | 3982 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
3983 if (err) { | |
4194 | 3984 debug_printf("Error in unicode fallback: %s\n", err->message); |
3659 | 3985 } |
3642 | 3986 } |
3987 } else { | |
4662 | 3988 args.charset = 0x0000; |
3989 args.charsubset = 0x0000; | |
3642 | 3990 args.msg = message; |
3991 } | |
3992 args.msglen = len; | |
4269 | 3993 |
4617 | 3994 ret = aim_im_sendch1_ext(od->sess, &args); |
2086 | 3995 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3996 if (ret >= 0) |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3997 return 1; |
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3998 return ret; |
2086 | 3999 } |
4000 | |
4001 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
4617 | 4002 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4003 if (od->icq) | |
4624 | 4004 aim_icq_getallinfo(od->sess, name); |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4005 else |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4006 /* 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
|
4007 * 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
|
4008 * insert in the middle. i hate people. */ |
4617 | 4009 aim_getinfo(od->sess, od->conn, name, AIM_GETINFO_AWAYMESSAGE); |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4010 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4011 |
3212 | 4012 static void oscar_get_away(struct gaim_connection *g, char *who) { |
4617 | 4013 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4014 if (od->icq) { | |
4687 | 4015 struct buddy *budlight = gaim_find_buddy(g->account, who); |
3212 | 4016 if (budlight) |
3595 | 4017 if ((budlight->uc & 0xffff0000) >> 16) |
4687 | 4018 aim_im_sendch2_geticqaway(od->sess, who, (budlight->uc & 0xffff0000) >> 16); |
3212 | 4019 else |
4020 debug_printf("Error: The user %s has no status message, therefore not requesting.\n", who); | |
4021 else | |
4022 debug_printf("Error: Could not find %s in local contact list, therefore unable to request status message.\n", who); | |
4023 } else | |
4617 | 4024 aim_getinfo(od->sess, od->conn, who, AIM_GETINFO_GENERALINFO); |
2086 | 4025 } |
4026 | |
4617 | 4027 #if 0 |
2920 | 4028 static void oscar_get_caps(struct gaim_connection *g, char *name) { |
4617 | 4029 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4030 aim_getinfo(od->sess, od->conn, name, AIM_GETINFO_CAPABILITIES); | |
2920 | 4031 } |
4617 | 4032 #endif |
2920 | 4033 |
3466 | 4034 static void oscar_set_dir(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
4035 const char *maiden, const char *city, const char *state, const char *country, int web) { | |
4617 | 4036 /* XXX - some of these things are wrong, but i'm lazy */ |
4037 struct oscar_data *od = (struct oscar_data *)g->proto_data; | |
4038 aim_setdirectoryinfo(od->sess, od->conn, first, middle, last, | |
2086 | 4039 maiden, NULL, NULL, city, state, NULL, 0, web); |
4040 } | |
4041 | |
4042 | |
4043 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
4617 | 4044 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4045 aim_bos_setidle(od->sess, od->conn, time); | |
2086 | 4046 } |
4047 | |
4048 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
4617 | 4049 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
4151 | 4050 gchar *inforeal, *unicode; |
4051 fu32_t flags; | |
4052 int unicode_len; | |
2993 | 4053 |
4617 | 4054 if (od->rights.maxsiglen == 0) |
3427 | 4055 do_error_dialog(_("Unable to set AIM profile."), |
4056 _("You have probably requested to set your profile before the login procedure completed. " | |
4057 "Your profile remains unset; try setting it again when you are fully connected."), GAIM_ERROR); | |
2993 | 4058 |
4617 | 4059 if (strlen(info) > od->rights.maxsiglen) { |
2993 | 4060 gchar *errstr; |
4061 | |
3427 | 4062 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. " |
4617 | 4063 "Gaim has truncated and set it."), od->rights.maxsiglen); |
3427 | 4064 do_error_dialog("Profile too long.", errstr, GAIM_WARNING); |
2993 | 4065 |
4066 g_free(errstr); | |
4067 } | |
4068 | |
4617 | 4069 inforeal = g_strndup(info, od->rights.maxsiglen); |
4070 | |
4071 if (od->icq) | |
4072 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); | |
4151 | 4073 else { |
4074 flags = check_encoding(inforeal); | |
4075 | |
4076 if (flags == 0) { | |
4617 | 4077 aim_bos_setprofile(od->sess, od->conn, "us-ascii", inforeal, strlen (inforeal), |
4151 | 4078 NULL, NULL, 0, caps_aim); |
4079 } else { | |
4080 unicode = g_convert (inforeal, strlen(inforeal), "UCS-2BE", "UTF-8", NULL, | |
4081 &unicode_len, NULL); | |
4617 | 4082 aim_bos_setprofile(od->sess, od->conn, "unicode-2-0", unicode, unicode_len, |
4151 | 4083 NULL, NULL, 0, caps_aim); |
4084 g_free(unicode); | |
4085 } | |
4086 } | |
2993 | 4087 g_free(inforeal); |
4088 | |
4089 return; | |
2086 | 4090 } |
4091 | |
2993 | 4092 static void oscar_set_away_aim(struct gaim_connection *gc, struct oscar_data *od, const char *message) |
4093 { | |
4151 | 4094 fu32_t flags; |
4095 char *unicode; | |
4096 int unicode_len; | |
2993 | 4097 |
4098 if (od->rights.maxawaymsglen == 0) | |
3427 | 4099 do_error_dialog(_("Unable to set AIM away message."), |
4100 _("You have probably requested to set your away message before the login procedure completed. " | |
4101 "You remain in a \"present\" state; try setting it again when you are fully connected."), GAIM_ERROR); | |
4102 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4103 if (gc->away) { |
2993 | 4104 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4105 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4106 } |
2993 | 4107 |
4108 if (!message) { | |
4151 | 4109 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
|
4110 return; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4111 } |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4112 |
2993 | 4113 if (strlen(message) > od->rights.maxawaymsglen) { |
4114 gchar *errstr; | |
4115 | |
3427 | 4116 errstr = g_strdup_printf(_("The away message length of %d bytes has been exceeded. " |
4117 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen); | |
4118 do_error_dialog("Away message too long.", errstr, GAIM_WARNING); | |
2993 | 4119 g_free(errstr); |
4120 } | |
4121 | |
4122 gc->away = g_strndup(message, od->rights.maxawaymsglen); | |
4151 | 4123 flags = check_encoding(message); |
4124 | |
4125 if (flags == 0) { | |
4126 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", gc->away, strlen(gc->away), | |
4127 caps_aim); | |
4128 } else { | |
4129 unicode = g_convert(message, strlen(message), "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); | |
4130 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", unicode, unicode_len, | |
4131 caps_aim); | |
4132 g_free(unicode); | |
4133 } | |
2993 | 4134 |
4135 return; | |
4136 } | |
4137 | |
4138 static void oscar_set_away_icq(struct gaim_connection *gc, struct oscar_data *od, const char *state, const char *message) | |
4139 { | |
4140 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4141 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4142 g_free(gc->away); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4143 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4144 } |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4145 |
4342 | 4146 if (strcmp(state, _("Invisible"))) { |
4491 | 4147 if (aim_ssi_getpermdeny(od->sess->ssi.local) != gc->account->permdeny) |
4148 aim_ssi_setpermdeny(od->sess, od->conn, gc->account->permdeny, | |
4349 | 4149 0xffffffff); |
4491 | 4150 gc->account->permdeny = 4; |
4342 | 4151 } else { |
4152 if (aim_ssi_getpermdeny(od->sess->ssi.local) != 0x03) | |
4153 aim_ssi_setpermdeny(od->sess, od->conn, 0x03, 0xffffffff); | |
4491 | 4154 gc->account->permdeny = 3; |
4342 | 4155 } |
4156 | |
4157 if (!strcmp(state, _("Online"))) | |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2865
diff
changeset
|
4158 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
4342 | 4159 else if (!strcmp(state, _("Away"))) { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4160 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4161 gc->away = g_strdup(""); |
4342 | 4162 } else if (!strcmp(state, _("Do Not Disturb"))) { |
3212 | 4163 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
|
4164 gc->away = g_strdup(""); |
4342 | 4165 } else if (!strcmp(state, _("Not Available"))) { |
3101 | 4166 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
|
4167 gc->away = g_strdup(""); |
4342 | 4168 } else if (!strcmp(state, _("Occupied"))) { |
3212 | 4169 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
|
4170 gc->away = g_strdup(""); |
4342 | 4171 } else if (!strcmp(state, _("Free For Chat"))) { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4172 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT); |
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, _("Invisible"))) { |
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4175 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
4176 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4177 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
2998 | 4178 if (message) { |
3101 | 4179 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
|
4180 gc->away = g_strdup(""); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4181 } else { |
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2865
diff
changeset
|
4182 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4183 } |
2086 | 4184 } |
2993 | 4185 |
4186 return; | |
4187 } | |
4188 | |
4189 static void oscar_set_away(struct gaim_connection *gc, char *state, char *message) | |
4190 { | |
4191 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4192 | |
4193 if (od->icq) | |
4194 oscar_set_away_icq(gc, od, state, message); | |
4195 else | |
4196 oscar_set_away_aim(gc, od, message); | |
4197 | |
4198 return; | |
2086 | 4199 } |
4200 | |
4230 | 4201 static void oscar_warn(struct gaim_connection *gc, char *name, int anon) { |
4617 | 4202 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4203 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); | |
2086 | 4204 } |
4205 | |
4230 | 4206 static void oscar_dir_search(struct gaim_connection *gc, const char *first, const char *middle, const char *last, |
3466 | 4207 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
4617 | 4208 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2086 | 4209 if (strlen(email)) |
4617 | 4210 aim_usersearch_address(od->sess, od->conn, email); |
2086 | 4211 } |
4212 | |
4230 | 4213 static void oscar_add_buddy(struct gaim_connection *gc, const char *name) { |
4214 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4215 #ifdef NOSSI | |
4216 aim_add_buddy(od->sess, od->conn, name); | |
4217 #else | |
4218 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
4687 | 4219 struct buddy *buddy = gaim_find_buddy(gc->account, name); |
4220 struct group *group = gaim_find_buddys_group(buddy); | |
4230 | 4221 if (buddy && group) { |
4222 debug_printf("ssi: adding buddy %s to group %s\n", name, group->name); | |
4687 | 4223 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4224 } |
4225 } | |
4226 #endif | |
4759 | 4227 if (od->icq) |
4228 aim_icq_getalias(od->sess, name); | |
4230 | 4229 } |
4230 | |
4231 static void oscar_add_buddies(struct gaim_connection *gc, GList *buddies) { | |
4232 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4233 #ifdef NOSSI | |
4234 char buf[MSG_LEN]; | |
4235 int n=0; | |
4236 while (buddies) { | |
4237 if (n > MSG_LEN - 18) { | |
4238 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4239 n = 0; | |
3092 | 4240 } |
4230 | 4241 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); |
4242 buddies = buddies->next; | |
4243 } | |
4244 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
4245 #else | |
4246 if (od->sess->ssi.received_data) { | |
4247 while (buddies) { | |
4687 | 4248 struct buddy *buddy = gaim_find_buddy(gc->account, (const char *)buddies->data); |
4249 struct group *group = gaim_find_buddys_group(buddy); | |
4230 | 4250 if (buddy && group) { |
4251 debug_printf("ssi: adding buddy %s to group %s\n", (const char *)buddies->data, group->name); | |
4687 | 4252 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); |
4230 | 4253 } |
4254 buddies = buddies->next; | |
4255 } | |
4256 } | |
4257 #endif | |
4258 } | |
4259 | |
4260 static void oscar_remove_buddy(struct gaim_connection *gc, char *name, char *group) { | |
4261 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4262 #ifdef NOSSI | |
4263 aim_remove_buddy(od->sess, od->conn, name); | |
4264 #else | |
4265 if (od->sess->ssi.received_data) { | |
4266 debug_printf("ssi: deleting buddy %s from group %s\n", name, group); | |
4267 aim_ssi_delbuddy(od->sess, od->conn, name, group); | |
4268 } | |
4269 #endif | |
4270 } | |
4271 | |
4272 static void oscar_remove_buddies(struct gaim_connection *gc, GList *buddies, const char *group) { | |
4273 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4274 #ifdef NOSSI | |
4275 GList *cur; | |
4276 for (cur=buddies; cur; cur=cur->next) | |
4277 aim_remove_buddy(od->sess, od->conn, cur->data); | |
4278 #else | |
4279 if (od->sess->ssi.received_data) { | |
3092 | 4280 while (buddies) { |
4230 | 4281 debug_printf("ssi: deleting buddy %s from group %s\n", (char *)buddies->data, group); |
4282 aim_ssi_delbuddy(od->sess, od->conn, buddies->data, group); | |
3092 | 4283 buddies = buddies->next; |
4284 } | |
4230 | 4285 } |
4286 #endif | |
4287 } | |
4288 | |
4289 #ifndef NOSSI | |
4269 | 4290 static void oscar_move_buddy(struct gaim_connection *gc, const char *name, const char *old_group, const char *new_group) { |
4291 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4303 | 4292 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
4269 | 4293 debug_printf("ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
4294 aim_ssi_movebuddy(od->sess, od->conn, old_group, new_group, name); | |
4295 } | |
4296 } | |
4297 | |
4298 static void oscar_alias_buddy(struct gaim_connection *gc, const char *name, const char *alias) { | |
4299 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4300 if (od->sess->ssi.received_data) { | |
4301 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
4302 if (gname) { | |
4303 debug_printf("ssi: changing the alias for buddy %s to %s\n", name, alias); | |
4304 aim_ssi_aliasbuddy(od->sess, od->conn, gname, name, alias); | |
4305 } | |
4306 } | |
4307 } | |
4308 | |
4230 | 4309 static void oscar_rename_group(struct gaim_connection *g, const char *old_group, const char *new_group, GList *members) { |
4310 struct oscar_data *od = (struct oscar_data *)g->proto_data; | |
4311 | |
4312 if (od->sess->ssi.received_data) { | |
4313 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
4314 oscar_remove_buddies(g, members, old_group); | |
4315 oscar_add_buddies(g, members); | |
4316 debug_printf("ssi: moved all buddies from group %s to %s\n", old_group, new_group); | |
4317 } else { | |
4318 aim_ssi_rename_group(od->sess, od->conn, old_group, new_group); | |
4319 debug_printf("ssi: renamed group %s to %s\n", old_group, new_group); | |
2995 | 4320 } |
4321 } | |
4322 } | |
4323 | |
4642 | 4324 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
4325 struct gaim_connection *gc = sess->aux_data; | |
4326 struct oscar_data *od = gc->proto_data; | |
4327 va_list ap; | |
4328 fu16_t reason; | |
4329 | |
4330 va_start(ap, fr); | |
4331 reason = (fu16_t)va_arg(ap, unsigned int); | |
4332 va_end(ap); | |
4333 | |
4334 debug_printf("ssi: SNAC error %hu\n", reason); | |
4335 | |
4336 if (reason == 0x0005) { | |
4337 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); | |
4338 } | |
4339 | |
4340 /* Activate SSI */ | |
4341 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4342 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
4343 debug_printf("ssi: activating server-stored buddy list\n"); | |
4344 aim_ssi_enable(od->sess); | |
4345 | |
4346 return 1; | |
4347 } | |
4348 | |
2991 | 4349 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
4230 | 4350 struct gaim_connection *gc = sess->aux_data; |
4351 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4352 int numtypes, i; | |
4353 fu16_t *maxitems; | |
2991 | 4354 va_list ap; |
4355 | |
4356 va_start(ap, fr); | |
4230 | 4357 numtypes = va_arg(ap, int); |
4358 maxitems = va_arg(ap, fu16_t *); | |
2991 | 4359 va_end(ap); |
4360 | |
4230 | 4361 debug_printf("ssi rights:"); |
4362 for (i=0; i<numtypes; i++) | |
4617 | 4363 debug_printf(" max type 0x%04x=%hd,", i, maxitems[i]); |
4317 | 4364 debug_printf("\n"); |
4230 | 4365 |
4366 if (numtypes >= 0) | |
4367 od->rights.maxbuddies = maxitems[0]; | |
4368 if (numtypes >= 1) | |
4369 od->rights.maxgroups = maxitems[1]; | |
4370 if (numtypes >= 2) | |
4371 od->rights.maxpermits = maxitems[2]; | |
4372 if (numtypes >= 3) | |
4373 od->rights.maxdenies = maxitems[3]; | |
2991 | 4374 |
4375 return 1; | |
4376 } | |
4377 | |
4378 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4379 struct gaim_connection *gc = sess->aux_data; | |
4230 | 4380 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
2995 | 4381 struct aim_ssi_item *curitem; |
2991 | 4382 int tmp; |
4778 | 4383 gboolean export = FALSE; |
4617 | 4384 /* XXX - use these? |
4230 | 4385 va_list ap; |
4386 | |
4387 va_start(ap, fr); | |
4388 fmtver = (fu16_t)va_arg(ap, int); | |
4389 numitems = (fu16_t)va_arg(ap, int); | |
4390 items = va_arg(ap, struct aim_ssi_item); | |
4391 timestamp = va_arg(ap, fu32_t); | |
4392 va_end(ap); */ | |
2991 | 4393 |
4394 debug_printf("ssi: syncing local list and server list\n"); | |
4395 | |
4396 /* Clean the buddy list */ | |
4779 | 4397 aim_ssi_cleanlist(sess, fr->conn); |
2991 | 4398 |
4399 /* Add from server list to local list */ | |
4230 | 4400 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
2991 | 4401 switch (curitem->type) { |
4230 | 4402 case 0x0000: { /* Buddy */ |
4251 | 4403 if (curitem->name) { |
4292 | 4404 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
4458 | 4405 char *gname_utf8 = gaim_try_conv_to_utf8(gname); |
4282 | 4406 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
4458 | 4407 char *alias_utf8 = gaim_try_conv_to_utf8(alias); |
4687 | 4408 struct buddy *buddy = gaim_find_buddy(gc->account, curitem->name); |
4458 | 4409 /* Should gname be freed here? -- elb */ |
4754 | 4410 /* Not with the current code, but that might be cleaner -- med */ |
4458 | 4411 free(alias); |
4282 | 4412 if (buddy) { |
4292 | 4413 /* Get server stored alias */ |
4705 | 4414 if (alias_utf8) { |
4415 g_free(buddy->alias); | |
4416 buddy->alias = g_strdup(alias_utf8); | |
4417 } | |
4282 | 4418 } else { |
4687 | 4419 struct group *g; |
4420 buddy = gaim_buddy_new(gc->account, curitem->name, alias_utf8); | |
4421 | |
4754 | 4422 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
4687 | 4423 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
4754 | 4424 gaim_blist_add_group(g, NULL); |
4425 } | |
4687 | 4426 |
4251 | 4427 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); |
4687 | 4428 gaim_blist_add_buddy(buddy, g, NULL); |
4778 | 4429 export = TRUE; |
4251 | 4430 } |
4458 | 4431 free(gname_utf8); |
4432 free(alias_utf8); | |
2991 | 4433 } |
4230 | 4434 } break; |
4435 | |
4436 case 0x0001: { /* Group */ | |
4282 | 4437 /* Shouldn't add empty groups */ |
4230 | 4438 } break; |
4439 | |
4440 case 0x0002: { /* Permit buddy */ | |
2991 | 4441 if (curitem->name) { |
4230 | 4442 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
2991 | 4443 GSList *list; |
4491 | 4444 for (list=gc->account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4445 if (!list) { |
2995 | 4446 debug_printf("ssi: adding permit buddy %s to local list\n", curitem->name); |
4491 | 4447 gaim_privacy_permit_add(gc->account, curitem->name); |
2991 | 4448 build_allow_list(); |
4778 | 4449 export = TRUE; |
2991 | 4450 } |
4451 } | |
4230 | 4452 } break; |
4453 | |
4454 case 0x0003: { /* Deny buddy */ | |
2991 | 4455 if (curitem->name) { |
4456 GSList *list; | |
4491 | 4457 for (list=gc->account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
2991 | 4458 if (!list) { |
2995 | 4459 debug_printf("ssi: adding deny buddy %s to local list\n", curitem->name); |
4491 | 4460 gaim_privacy_deny_add(gc->account, curitem->name); |
2991 | 4461 build_block_list(); |
4778 | 4462 export = TRUE; |
2991 | 4463 } |
4464 } | |
4230 | 4465 } break; |
4466 | |
4467 case 0x0004: { /* Permit/deny setting */ | |
2991 | 4468 if (curitem->data) { |
4469 fu8_t permdeny; | |
4491 | 4470 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != gc->account->permdeny)) { |
4471 debug_printf("ssi: changing permdeny from %d to %hhu\n", gc->account->permdeny, permdeny); | |
4472 gc->account->permdeny = permdeny; | |
4473 if (od->icq && gc->account->permdeny == 0x03) { | |
4342 | 4474 serv_set_away(gc, "Invisible", ""); |
4475 } | |
4778 | 4476 export = TRUE; |
2991 | 4477 } |
4478 } | |
4230 | 4479 } break; |
4480 | |
4481 case 0x0005: { /* Presence setting */ | |
3109 | 4482 /* We don't want to change Gaim's setting because it applies to all accounts */ |
4230 | 4483 } break; |
2991 | 4484 } /* End of switch on curitem->type */ |
4485 } /* End of for loop */ | |
4230 | 4486 |
4487 /* If changes were made, then flush buddy list to file */ | |
4778 | 4488 if (export) |
4349 | 4489 gaim_blist_save(); |
2991 | 4490 |
4780 | 4491 #if 0 |
4759 | 4492 { /* Add from local list to server list */ |
4493 GaimBlistNode *gnode, *bnode; | |
4494 struct group *group; | |
4495 struct buddy *buddy; | |
4496 struct gaim_buddy_list *blist; | |
3017 | 4497 GSList *cur; |
4498 | |
2991 | 4499 /* Buddies */ |
4759 | 4500 if ((blist = gaim_get_blist())) |
4501 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
4502 group = (struct group *)gnode; | |
4503 for (bnode = gnode->child; bnode; bnode = bnode->next) { | |
4504 buddy = (struct buddy *)bnode; | |
4505 if (buddy->account == gc->account) { | |
4506 gchar *servernick = gaim_buddy_get_setting(buddy, "servernick"); | |
4507 if (servernick) { | |
4508 serv_got_alias(gc, buddy->name, servernick); | |
4509 g_free(servernick); | |
4510 } | |
4511 if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { | |
4512 /* Store local alias on server */ | |
4513 char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); | |
4514 if (!alias && buddy->alias) | |
4515 aim_ssi_aliasbuddy(sess, od->conn, group->name, buddy->name, buddy->alias); | |
4516 free(alias); | |
4517 } else { | |
4518 debug_printf("ssi: adding buddy %s from local list to server list\n", buddy->name); | |
4519 aim_ssi_addbuddy(sess, od->conn, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); | |
4520 } | |
4349 | 4521 } |
4230 | 4522 } |
4292 | 4523 } |
2991 | 4524 /* Permit list */ |
4491 | 4525 if (gc->account->permit) { |
4526 for (cur=gc->account->permit; cur; cur=cur->next) | |
4230 | 4527 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
4528 debug_printf("ssi: adding permit %s from local list to server list\n", (char *)cur->data); | |
4292 | 4529 aim_ssi_addpermit(sess, od->conn, cur->data); |
4230 | 4530 } |
2991 | 4531 } |
4532 | |
4533 /* Deny list */ | |
4491 | 4534 if (gc->account->deny) { |
4535 for (cur=gc->account->deny; cur; cur=cur->next) | |
4230 | 4536 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
4537 debug_printf("ssi: adding deny %s from local list to server list\n", (char *)cur->data); | |
4292 | 4538 aim_ssi_adddeny(sess, od->conn, cur->data); |
4230 | 4539 } |
2991 | 4540 } |
3109 | 4541 /* Presence settings (idle time visibility) */ |
4230 | 4542 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) |
3109 | 4543 if (report_idle && !(tmp & 0x400)) |
4544 aim_ssi_setpresence(sess, fr->conn, tmp | 0x400); | |
4778 | 4545 } /* end adding buddies from local list to server list */ |
4780 | 4546 #endif |
4778 | 4547 |
4548 { /* Check for maximum number of buddies */ | |
4549 GSList *groups = gaim_blist_groups(), *cur; | |
4349 | 4550 for (cur=groups, tmp=0; cur; cur=g_slist_next(cur)) { |
3214 | 4551 struct group* gr = (struct group*)cur->data; |
4770 | 4552 GSList *buds = gaim_blist_members(gr); |
4553 GSList *buds1 = buds; | |
4554 while(buds1) { | |
4555 struct buddy *b = buds1->data; | |
4491 | 4556 if(b->account == gc->account) |
4349 | 4557 tmp++; |
4770 | 4558 buds1 = buds1->next; |
4349 | 4559 } |
4770 | 4560 g_slist_free(buds); |
3214 | 4561 } |
4770 | 4562 g_slist_free(groups); |
4563 | |
4230 | 4564 if (tmp > od->rights.maxbuddies) { |
3210 | 4565 char *dialog_msg = g_strdup_printf(_("The maximum number of buddies allowed in your buddy list is %d, and you have %d." |
4566 " Until you are below the limit, some buddies will not show up as online."), | |
4230 | 4567 od->rights.maxbuddies, tmp); |
4642 | 4568 do_error_dialog(_("Maximum buddy list length exceeded."), dialog_msg, GAIM_WARNING); |
3210 | 4569 g_free(dialog_msg); |
4570 } | |
4778 | 4571 } |
3214 | 4572 |
4342 | 4573 /* Activate SSI */ |
4574 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
4575 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
4576 debug_printf("ssi: activating server-stored buddy list\n"); | |
4642 | 4577 aim_ssi_enable(sess); |
4342 | 4578 |
2991 | 4579 return 1; |
2086 | 4580 } |
4230 | 4581 |
4582 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4583 struct gaim_connection *gc = sess->aux_data; | |
4584 va_list ap; | |
4585 struct aim_ssi_tmp *retval; | |
4586 | |
4587 va_start(ap, fr); | |
4588 retval = va_arg(ap, struct aim_ssi_tmp *); | |
4589 va_end(ap); | |
4590 | |
4591 while (retval) { | |
4592 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"); | |
4593 | |
4594 if (retval->ack != 0xffff) | |
4595 switch (retval->ack) { | |
4596 case 0x0000: { /* added successfully */ | |
4597 } break; | |
4598 | |
4599 case 0x000e: { /* contact requires authorization */ | |
4269 | 4600 if (retval->action == AIM_CB_SSI_ADD) |
4601 gaim_auth_sendrequest(gc, retval->name); | |
4230 | 4602 } break; |
4603 | |
4604 default: { /* La la la */ | |
4605 debug_printf("ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); | |
4606 /* Should remove buddy from local list and give an error message? */ | |
4607 } break; | |
4608 } | |
4609 | |
4610 retval = retval->next; | |
4611 } | |
4612 | |
4613 return 1; | |
4614 } | |
4615 | |
4616 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4617 struct gaim_connection *gc = sess->aux_data; | |
4618 va_list ap; | |
4619 char *sn, *msg; | |
4236 | 4620 gchar *dialog_msg, *nombre; |
4230 | 4621 struct name_data *data; |
4236 | 4622 struct buddy *buddy; |
4230 | 4623 |
4624 va_start(ap, fr); | |
4625 sn = va_arg(ap, char *); | |
4626 msg = va_arg(ap, char *); | |
4627 va_end(ap); | |
4628 | |
4629 debug_printf("ssi: %s has given you permission to add him to your buddy list\n", sn); | |
4630 | |
4687 | 4631 buddy = gaim_find_buddy(gc->account, sn); |
4632 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4633 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4634 else |
4635 nombre = g_strdup(sn); | |
4636 | |
4637 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 | 4638 data = g_new(struct name_data, 1); |
4639 data->gc = gc; | |
4640 data->name = g_strdup(sn); | |
4641 data->nick = NULL; | |
4249 | 4642 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 | 4643 |
4230 | 4644 g_free(dialog_msg); |
4236 | 4645 g_free(nombre); |
4230 | 4646 |
4647 return 1; | |
4648 } | |
4649 | |
4650 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4651 struct gaim_connection *gc = sess->aux_data; | |
4652 va_list ap; | |
4653 char *sn, *msg; | |
4236 | 4654 gchar *dialog_msg, *nombre; |
4230 | 4655 struct name_data *data; |
4236 | 4656 struct buddy *buddy; |
4230 | 4657 |
4658 va_start(ap, fr); | |
4659 sn = va_arg(ap, char *); | |
4660 msg = va_arg(ap, char *); | |
4661 va_end(ap); | |
4662 | |
4663 debug_printf("ssi: received authorization request from %s\n", sn); | |
4664 | |
4687 | 4665 buddy = gaim_find_buddy(gc->account, sn); |
4666 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4667 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4668 else |
4669 nombre = g_strdup(sn); | |
4670 | |
4337 | 4671 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 | 4672 data = g_new(struct name_data, 1); |
4673 data->gc = gc; | |
4674 data->name = g_strdup(sn); | |
4675 data->nick = NULL; | |
4337 | 4676 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 | 4677 |
4230 | 4678 g_free(dialog_msg); |
4236 | 4679 g_free(nombre); |
4230 | 4680 |
4681 return 1; | |
4682 } | |
4683 | |
4684 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4236 | 4685 struct gaim_connection *gc = sess->aux_data; |
4230 | 4686 va_list ap; |
4687 char *sn, *msg; | |
4236 | 4688 gchar *dialog_msg, *nombre; |
4230 | 4689 fu8_t reply; |
4236 | 4690 struct buddy *buddy; |
4230 | 4691 |
4692 va_start(ap, fr); | |
4693 sn = va_arg(ap, char *); | |
4694 reply = (fu8_t)va_arg(ap, int); | |
4695 msg = va_arg(ap, char *); | |
4696 va_end(ap); | |
4697 | |
4236 | 4698 debug_printf("ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
4699 | |
4687 | 4700 buddy = gaim_find_buddy(gc->account, sn); |
4701 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
4702 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
4236 | 4703 else |
4704 nombre = g_strdup(sn); | |
4705 | |
4230 | 4706 if (reply) { |
4707 /* Granted */ | |
4236 | 4708 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your contact list."), nombre); |
4230 | 4709 do_error_dialog(_("Authorization Granted"), dialog_msg, GAIM_INFO); |
4710 } else { | |
4711 /* Denied */ | |
4236 | 4712 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 | 4713 do_error_dialog(_("Authorization Denied"), dialog_msg, GAIM_INFO); |
4714 } | |
4715 g_free(dialog_msg); | |
4236 | 4716 g_free(nombre); |
4230 | 4717 |
4718 return 1; | |
4719 } | |
4720 | |
4721 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4722 struct gaim_connection *gc = sess->aux_data; | |
4723 va_list ap; | |
4724 char *sn; | |
4236 | 4725 struct buddy *buddy; |
4230 | 4726 |
4727 va_start(ap, fr); | |
4728 sn = va_arg(ap, char *); | |
4729 va_end(ap); | |
4730 | |
4687 | 4731 buddy = gaim_find_buddy(gc->account, sn); |
4230 | 4732 debug_printf("ssi: %s added you to their buddy list\n", sn); |
4687 | 4733 show_got_added(gc, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
4230 | 4734 |
4735 return 1; | |
4736 } | |
4269 | 4737 #endif |
2086 | 4738 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4739 static GList *oscar_chat_info(struct gaim_connection *gc) { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4740 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4741 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4742 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4743 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4744 pce->label = _("Join what group:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4745 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4746 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4747 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4748 pce->label = _("Exchange:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4749 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4750 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4751 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4752 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4753 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4754 return m; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4755 } |
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 static void oscar_join_chat(struct gaim_connection *g, GList *data) { |
4617 | 4758 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4759 aim_conn_t *cur; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4760 char *name; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4761 int *exchange; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4762 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4763 if (!data || !data->next) |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4764 return; |
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 name = data->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4767 exchange = data->next->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4768 |
2086 | 4769 debug_printf("Attempting to join chat room %s.\n", name); |
4617 | 4770 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
2086 | 4771 debug_printf("chatnav exists, creating room\n"); |
4617 | 4772 aim_chatnav_createroom(od->sess, cur, name, *exchange); |
2086 | 4773 } else { |
4774 /* this gets tricky */ | |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4775 struct create_room *cr = g_new0(struct create_room, 1); |
2086 | 4776 debug_printf("chatnav does not exist, opening chatnav\n"); |
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4777 cr->exchange = *exchange; |
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4778 cr->name = g_strdup(name); |
4617 | 4779 od->create_rooms = g_slist_append(od->create_rooms, cr); |
4780 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
2086 | 4781 } |
4782 } | |
4783 | |
3466 | 4784 static void oscar_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) { |
4617 | 4785 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 4786 struct chat_connection *ccon = find_oscar_chat(g, id); |
4787 | |
4788 if (!ccon) | |
4789 return; | |
4790 | |
4617 | 4791 aim_chat_invite(od->sess, od->conn, name, message ? message : "", |
2086 | 4792 ccon->exchange, ccon->name, 0x0); |
4793 } | |
4794 | |
4795 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
4617 | 4796 struct oscar_data *od = g ? (struct oscar_data *)g->proto_data : NULL; |
2086 | 4797 GSList *bcs = g->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4798 struct gaim_conversation *b = NULL; |
2086 | 4799 struct chat_connection *c = NULL; |
4800 int count = 0; | |
4801 | |
4802 while (bcs) { | |
4803 count++; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4804 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4805 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 4806 break; |
4807 bcs = bcs->next; | |
4808 b = NULL; | |
4809 } | |
4810 | |
4811 if (!b) | |
4812 return; | |
4813 | |
4814 debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count); | |
4815 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4816 c = find_oscar_chat(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 4817 if (c != NULL) { |
4617 | 4818 if (od) |
4819 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
2086 | 4820 if (c->inpa > 0) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4821 gaim_input_remove(c->inpa); |
4617 | 4822 if (g && od->sess) |
4823 aim_conn_kill(od->sess, &c->conn); | |
2086 | 4824 g_free(c->name); |
4825 g_free(c->show); | |
4826 g_free(c); | |
4827 } | |
4828 /* 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
|
4829 serv_got_chat_left(g, gaim_chat_get_id(GAIM_CHAT(b))); |
2086 | 4830 } |
4831 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4832 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
4617 | 4833 struct oscar_data *od = (struct oscar_data *)g->proto_data; |
2086 | 4834 GSList *bcs = g->buddy_chats; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4835 struct gaim_conversation *b = NULL; |
2086 | 4836 struct chat_connection *c = NULL; |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4837 char *buf, *buf2; |
2086 | 4838 int i, j; |
4839 | |
4840 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4841 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4842 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 4843 break; |
4844 bcs = bcs->next; | |
4845 b = NULL; | |
4846 } | |
4847 if (!b) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4848 return -EINVAL; |
2086 | 4849 |
4617 | 4850 bcs = od->oscar_chats; |
2086 | 4851 while (bcs) { |
4852 c = (struct chat_connection *)bcs->data; | |
4853 if (b == c->cnv) | |
4854 break; | |
4855 bcs = bcs->next; | |
4856 c = NULL; | |
4857 } | |
4858 if (!c) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4859 return -EINVAL; |
2086 | 4860 |
4861 buf = g_malloc(strlen(message) * 4 + 1); | |
4862 for (i = 0, j = 0; i < strlen(message); i++) { | |
4863 if (message[i] == '\n') { | |
4864 buf[j++] = '<'; | |
4865 buf[j++] = 'B'; | |
4866 buf[j++] = 'R'; | |
4867 buf[j++] = '>'; | |
4868 } else { | |
4869 buf[j++] = message[i]; | |
4870 } | |
4871 } | |
4872 buf[j] = '\0'; | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4873 |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4874 if (strlen(buf) > c->maxlen) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4875 return -E2BIG; |
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 buf2 = strip_html(buf); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4878 if (strlen(buf2) > c->maxvis) { |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4879 g_free(buf2); |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4880 return -E2BIG; |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4881 } |
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 |
4617 | 4884 aim_chat_send_im(od->sess, c->conn, 0, buf, strlen(buf)); |
2086 | 4885 g_free(buf); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4886 return 0; |
2086 | 4887 } |
4888 | |
4687 | 4889 static const char *oscar_list_icon(struct gaim_account *a, struct buddy *b) { |
4766 | 4890 if (!b || (b && b->name && b->name[0] == '+')) { |
4687 | 4891 if (isdigit(a->username[0])) |
4892 return "icq"; | |
4893 else | |
4894 return "aim"; | |
4895 } | |
4896 | |
4897 if (isdigit(b->name[0])) | |
4898 return "icq"; | |
4899 return "aim"; | |
4900 } | |
4901 | |
4690 | 4902 static void oscar_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) |
4687 | 4903 { |
4904 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
4905 int i = 0; | |
4906 | |
4766 | 4907 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
4908 /* int uc = b->uc >> 16; | |
4909 if (uc & AIM_ICQ_STATE_INVISIBLE) | |
4910 emblems[i++] = "icq_invisible"; | |
4911 else if (uc & AIM_ICQ_STATE_CHAT) | |
4912 emblems[i++] = "icq_chat"; | |
4913 else if (uc & AIM_ICQ_STATE_DND) | |
4914 emblems[i++] = "icq_dnd"; | |
4915 else if (uc & AIM_ICQ_STATE_OUT) | |
4916 emblems[i++] = "icq_out"; | |
4917 else if (uc & AIM_ICQ_STATE_BUSY) | |
4918 emblems[i++] = "icq_busy"; | |
4919 else if (uc & AIM_ICQ_STATE_AWAY) | |
4920 emblems[i++] = "icq_away"; | |
4921 */ | |
4922 if (b->uc & UC_UNAVAILABLE) | |
4923 emblems[i++] = "away"; | |
4924 } else { | |
4925 if (b->uc & UC_UNAVAILABLE) | |
4926 emblems[i++] = "away"; | |
4927 } | |
4687 | 4928 if (b->uc & UC_WIRELESS) |
4929 emblems[i++] = "wireless"; | |
4930 if (b->uc & UC_AOL) | |
4931 emblems[i++] = "aol"; | |
4932 if (b->uc & UC_ADMIN) | |
4933 emblems[i++] = "admin"; | |
4934 if (b->uc & UC_AB && i < 4) | |
4935 emblems[i++] = "activebuddy"; | |
4766 | 4936 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
4937 emblems[i++] = "unconfirmed"; */ | |
4687 | 4938 *se = emblems[0]; |
4939 *sw = emblems[1]; | |
4940 *nw = emblems[2]; | |
4941 *ne = emblems[3]; | |
4942 } | |
4943 | |
3952 | 4944 /* |
4617 | 4945 * We have just established a socket with the other dude, so set up some handlers. |
3952 | 4946 */ |
4617 | 4947 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 4948 struct gaim_connection *gc = sess->aux_data; |
4949 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4950 struct gaim_conversation *cnv; |
2086 | 4951 struct direct_im *dim; |
4952 char buf[256]; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4953 char *sn; |
4617 | 4954 va_list ap; |
4955 aim_conn_t *newconn, *listenerconn; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4956 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4957 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4958 newconn = va_arg(ap, aim_conn_t *); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4959 listenerconn = va_arg(ap, aim_conn_t *); |
2086 | 4960 va_end(ap); |
4961 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4962 aim_conn_close(listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4963 aim_conn_kill(sess, &listenerconn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4964 |
4617 | 4965 sn = g_strdup(aim_odc_getsn(newconn)); |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4966 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4967 debug_printf("DirectIM: initiate success to %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4968 dim = find_direct_im(od, sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4969 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4970 if (!(cnv = gaim_find_conversation(sn))) |
4491 | 4971 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
|
4972 gaim_input_remove(dim->watcher); |
2086 | 4973 dim->conn = newconn; |
4617 | 4974 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
3008 | 4975 dim->connected = TRUE; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4976 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4977 g_free(sn); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4978 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
2086 | 4979 |
4617 | 4980 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
4981 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
4982 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_update_ui, 0); | |
4983 | |
2993 | 4984 return 1; |
4985 } | |
4986 | |
4987 static int gaim_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
4988 va_list ap; | |
4989 char *sn; | |
4990 double percent; | |
4991 struct gaim_connection *gc = sess->aux_data; | |
4992 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4993 struct gaim_conversation *c; |
2993 | 4994 struct direct_im *dim; |
4995 | |
4996 va_start(ap, fr); | |
4997 sn = va_arg(ap, char *); | |
4998 percent = va_arg(ap, double); | |
4999 va_end(ap); | |
5000 | |
2994 | 5001 if (!(dim = find_direct_im(od, sn))) |
5002 return 1; | |
3059 | 5003 if (dim->watcher) { |
5004 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
5005 dim->watcher = 0; | |
5006 } | |
3044 | 5007 while (gtk_events_pending()) |
5008 gtk_main_iteration(); | |
5009 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5010 if ((c = gaim_find_conversation(sn))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
5011 gaim_conversation_update_progress(c, percent); |
2993 | 5012 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
5013 oscar_callback, dim->conn); | |
2086 | 5014 |
5015 return 1; | |
5016 } | |
5017 | |
4617 | 5018 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5019 va_list ap; |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5020 char *msg, *sn; |
3952 | 5021 int len, encoding; |
2086 | 5022 struct gaim_connection *gc = sess->aux_data; |
5023 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5024 va_start(ap, fr); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5025 sn = va_arg(ap, char *); |
2086 | 5026 msg = va_arg(ap, char *); |
2993 | 5027 len = va_arg(ap, int); |
3952 | 5028 encoding = va_arg(ap, int); |
2086 | 5029 va_end(ap); |
5030 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5031 debug_printf("Got DirectIM message from %s\n", sn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5032 |
4617 | 5033 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
2993 | 5034 serv_got_im(gc, sn, msg, 0, time(NULL), len); |
2086 | 5035 |
5036 return 1; | |
5037 } | |
5038 | |
4617 | 5039 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
2086 | 5040 va_list ap; |
5041 char *sn; | |
2993 | 5042 int typing; |
5043 struct gaim_connection *gc = sess->aux_data; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5044 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5045 va_start(ap, fr); |
2086 | 5046 sn = va_arg(ap, char *); |
2993 | 5047 typing = va_arg(ap, int); |
2086 | 5048 va_end(ap); |
5049 | |
2993 | 5050 if (typing) { |
5051 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
5052 debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
4342 | 5053 serv_got_typing(gc, sn, 0, TYPING); |
2993 | 5054 } else |
4342 | 5055 serv_got_typing_stopped(gc, sn); |
2086 | 5056 return 1; |
5057 } | |
5058 | |
5059 struct ask_do_dir_im { | |
5060 char *who; | |
5061 struct gaim_connection *gc; | |
5062 }; | |
5063 | |
3730 | 5064 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
2086 | 5065 g_free(data); |
5066 } | |
5067 | |
3730 | 5068 static void oscar_direct_im(struct ask_do_dir_im *data) { |
2086 | 5069 struct gaim_connection *gc = data->gc; |
4244 | 5070 struct oscar_data *od; |
2086 | 5071 struct direct_im *dim; |
5072 | |
4244 | 5073 if (!g_slist_find(connections, gc)) { |
5074 g_free(data); | |
5075 return; | |
5076 } | |
5077 | |
5078 od = (struct oscar_data *)gc->proto_data; | |
5079 | |
2086 | 5080 dim = find_direct_im(od, data->who); |
5081 if (dim) { | |
3008 | 5082 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
5083 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
5084 gaim_input_remove(dim->watcher); | |
5085 g_free(dim); | |
5086 debug_printf("Gave up on old direct IM, trying again\n"); | |
5087 } else { | |
3427 | 5088 do_error_dialog("DirectIM already open.", NULL, GAIM_ERROR); |
4244 | 5089 g_free(data); |
3008 | 5090 return; |
5091 } | |
2086 | 5092 } |
5093 dim = g_new0(struct direct_im, 1); | |
5094 dim->gc = gc; | |
5095 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
5096 | |
4617 | 5097 dim->conn = aim_odc_initiate(od->sess, data->who); |
2086 | 5098 if (dim->conn != NULL) { |
5099 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
5100 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
2086 | 5101 oscar_callback, dim->conn); |
4617 | 5102 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, |
5103 gaim_odc_initiate, 0); | |
2086 | 5104 } else { |
3427 | 5105 do_error_dialog(_("Unable to open Direct IM"), NULL, GAIM_ERROR); |
2086 | 5106 g_free(dim); |
5107 } | |
4244 | 5108 |
5109 g_free(data); | |
2086 | 5110 } |
5111 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
5112 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
2086 | 5113 char buf[BUF_LONG]; |
5114 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | |
5115 data->who = who; | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
5116 data->gc = gc; |
3730 | 5117 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); |
4249 | 5118 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 | 5119 } |
5120 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5121 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
|
5122 struct oscar_data *od = gc->proto_data; |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5123 od->evilhack = g_slist_append(od->evilhack, g_strdup(normalize(who))); |
3212 | 5124 if (od->icq) { |
4687 | 5125 struct buddy *budlight = gaim_find_buddy(gc->account, who); |
3212 | 5126 if (budlight) |
4687 | 5127 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 | 5128 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
4344 | 5129 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 | 5130 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
5131 free(state_msg); | |
5132 free(dialog_msg); | |
5133 } | |
5134 else { | |
3595 | 5135 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
4344 | 5136 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 | 5137 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
5138 free(state_msg); | |
5139 free(dialog_msg); | |
5140 } | |
5141 else | |
3427 | 5142 do_error_dialog("Could not find contact in local list, therefore unable to request status message.\n", NULL, GAIM_ERROR); |
3212 | 5143 } else |
5144 oscar_get_info(gc, who); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5145 } |
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5146 |
2086 | 5147 static void oscar_set_permit_deny(struct gaim_connection *gc) { |
5148 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
4230 | 5149 #ifdef NOSSI |
4770 | 5150 GSList *list, *g = gaim_blist_groups(), *g1; |
4230 | 5151 char buf[MAXMSGLEN]; |
5152 int at; | |
5153 | |
4491 | 5154 switch(gc->account->permdeny) { |
4687 | 5155 case 1: |
4230 | 5156 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username); |
5157 break; | |
5158 case 2: | |
5159 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username); | |
5160 break; | |
5161 case 3: | |
4642 | 5162 list = gc->account->permit; |
4230 | 5163 at = 0; |
5164 while (list) { | |
5165 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5166 list = list->next; | |
5167 } | |
5168 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
5169 break; | |
5170 case 4: | |
4642 | 5171 list = gc->account->deny; |
4230 | 5172 at = 0; |
5173 while (list) { | |
5174 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
5175 list = list->next; | |
5176 } | |
5177 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
5178 break; | |
5179 case 5: | |
4770 | 5180 g1 = g; |
4230 | 5181 at = 0; |
4770 | 5182 while (g1) { |
5183 list = gaim_blist_members((struct group *)g->data); | |
5184 GSList list1 = list; | |
5185 while (list1) { | |
5186 struct buddy *b = list1->data; | |
4491 | 5187 if(b->account == gc->account) |
4349 | 5188 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", b->name); |
4770 | 5189 list1 = list1->next; |
2995 | 5190 } |
4770 | 5191 g_slist_free(list); |
5192 g1 = g1->next; | |
4349 | 5193 } |
4770 | 5194 g_slist_free(g); |
4230 | 5195 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); |
5196 break; | |
5197 default: | |
5198 break; | |
2086 | 5199 } |
4230 | 5200 signoff_blocked(gc); |
5201 #else | |
5202 if (od->sess->ssi.received_data) | |
4491 | 5203 aim_ssi_setpermdeny(od->sess, od->conn, gc->account->permdeny, 0xffffffff); |
4230 | 5204 #endif |
2086 | 5205 } |
5206 | |
4349 | 5207 static void oscar_add_permit(struct gaim_connection *gc, const char *who) { |
4269 | 5208 #ifdef NOSSI |
4491 | 5209 if (gc->account->permdeny == 3) |
4269 | 5210 oscar_set_permit_deny(gc); |
5211 #else | |
2991 | 5212 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5213 debug_printf("ssi: About to add a permit\n"); |
5214 if (od->sess->ssi.received_data) | |
5215 aim_ssi_addpermit(od->sess, od->conn, who); | |
5216 #endif | |
2086 | 5217 } |
5218 | |
4349 | 5219 static void oscar_add_deny(struct gaim_connection *gc, const char *who) { |
4269 | 5220 #ifdef NOSSI |
4491 | 5221 if (gc->account->permdeny == 4) |
4269 | 5222 oscar_set_permit_deny(gc); |
5223 #else | |
2991 | 5224 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5225 debug_printf("ssi: About to add a deny\n"); |
5226 if (od->sess->ssi.received_data) | |
5227 aim_ssi_adddeny(od->sess, od->conn, who); | |
5228 #endif | |
2086 | 5229 } |
5230 | |
4349 | 5231 static void oscar_rem_permit(struct gaim_connection *gc, const char *who) { |
4269 | 5232 #ifdef NOSSI |
4491 | 5233 if (gc->account->permdeny == 3) |
4269 | 5234 oscar_set_permit_deny(gc); |
5235 #else | |
2991 | 5236 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5237 debug_printf("ssi: About to delete a permit\n"); |
5238 if (od->sess->ssi.received_data) | |
5239 aim_ssi_delpermit(od->sess, od->conn, who); | |
5240 #endif | |
2086 | 5241 } |
5242 | |
4349 | 5243 static void oscar_rem_deny(struct gaim_connection *gc, const char *who) { |
4269 | 5244 #ifdef NOSSI |
4491 | 5245 if (gc->account->permdeny == 4) |
4269 | 5246 oscar_set_permit_deny(gc); |
5247 #else | |
2991 | 5248 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
4230 | 5249 debug_printf("ssi: About to delete a deny\n"); |
5250 if (od->sess->ssi.received_data) | |
5251 aim_ssi_deldeny(od->sess, od->conn, who); | |
5252 #endif | |
2086 | 5253 } |
5254 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5255 static GList *oscar_away_states(struct gaim_connection *gc) |
2086 | 5256 { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5257 struct oscar_data *od = gc->proto_data; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5258 GList *m = NULL; |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5259 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5260 if (!od->icq) |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5261 return g_list_append(m, GAIM_AWAY_CUSTOM); |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5262 |
4333 | 5263 m = g_list_append(m, _("Online")); |
5264 m = g_list_append(m, _("Away")); | |
5265 m = g_list_append(m, _("Do Not Disturb")); | |
5266 m = g_list_append(m, _("Not Available")); | |
5267 m = g_list_append(m, _("Occupied")); | |
5268 m = g_list_append(m, _("Free For Chat")); | |
5269 m = g_list_append(m, _("Invisible")); | |
5270 | |
5271 return m; | |
5272 } | |
5273 | |
5274 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { | |
5275 struct oscar_data *od = gc->proto_data; | |
5276 GList *m = NULL; | |
5277 struct proto_buddy_menu *pbm; | |
5278 | |
5279 if (od->icq) { | |
4624 | 5280 #if 0 |
4333 | 5281 pbm = g_new0(struct proto_buddy_menu, 1); |
5282 pbm->label = _("Get Status Msg"); | |
5283 pbm->callback = oscar_get_away_msg; | |
5284 pbm->gc = gc; | |
5285 m = g_list_append(m, pbm); | |
4624 | 5286 #endif |
4333 | 5287 } else { |
4687 | 5288 struct buddy *b = gaim_find_buddy(gc->account, who); |
4356 | 5289 |
5290 if (!b || (b->uc & UC_UNAVAILABLE)) { | |
5291 pbm = g_new0(struct proto_buddy_menu, 1); | |
5292 pbm->label = _("Get Away Msg"); | |
5293 pbm->callback = oscar_get_away_msg; | |
5294 pbm->gc = gc; | |
5295 m = g_list_append(m, pbm); | |
5296 } | |
4333 | 5297 |
5298 if (aim_sncmp(gc->username, who)) { | |
5299 pbm = g_new0(struct proto_buddy_menu, 1); | |
5300 pbm->label = _("Direct IM"); | |
5301 pbm->callback = oscar_ask_direct_im; | |
5302 pbm->gc = gc; | |
5303 m = g_list_append(m, pbm); | |
4650 | 5304 |
4333 | 5305 pbm = g_new0(struct proto_buddy_menu, 1); |
5306 pbm->label = _("Send File"); | |
4617 | 5307 pbm->callback = oscar_ask_sendfile; |
4333 | 5308 pbm->gc = gc; |
5309 m = g_list_append(m, pbm); | |
5310 } | |
5311 } | |
5312 | |
4617 | 5313 #if 0 |
4333 | 5314 pbm = g_new0(struct proto_buddy_menu, 1); |
5315 pbm->label = _("Get Capabilities"); | |
5316 pbm->callback = oscar_get_caps; | |
5317 pbm->gc = gc; | |
5318 m = g_list_append(m, pbm); | |
4617 | 5319 #endif |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5320 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5321 return m; |
2086 | 5322 } |
5323 | |
4333 | 5324 static GList *oscar_edit_buddy_menu(struct gaim_connection *gc, char *who) |
5325 { | |
5326 struct oscar_data *od = gc->proto_data; | |
5327 GList *m = NULL; | |
5328 struct proto_buddy_menu *pbm; | |
5329 | |
5330 if (od->icq) { | |
5331 pbm = g_new0(struct proto_buddy_menu, 1); | |
5332 pbm->label = _("Get Info"); | |
5333 pbm->callback = oscar_get_info; | |
5334 pbm->gc = gc; | |
5335 m = g_list_append(m, pbm); | |
5336 } | |
5337 | |
5338 if (od->sess->ssi.received_data) { | |
5339 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
5340 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
5341 pbm = g_new0(struct proto_buddy_menu, 1); | |
5342 pbm->label = _("Re-request Authorization"); | |
5343 pbm->callback = gaim_auth_sendrequest; | |
5344 pbm->gc = gc; | |
5345 m = g_list_append(m, pbm); | |
5346 } | |
5347 } | |
5348 | |
5349 return m; | |
5350 } | |
5351 | |
5352 static void oscar_format_screenname(struct gaim_connection *gc, char *nick) { | |
5353 struct oscar_data *od = gc->proto_data; | |
5354 if (!aim_sncmp(gc->username, nick)) { | |
5355 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
5356 od->setnick = TRUE; | |
5357 od->newsn = g_strdup(nick); | |
5358 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5359 } else { | |
5360 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
5361 } | |
5362 } else { | |
5363 do_error_dialog(_("The new formatting is invalid."), | |
5364 _("Screenname formatting can change only capitalization and whitespace."), GAIM_ERROR); | |
5365 } | |
5366 } | |
5367 | |
5368 static void oscar_show_format_screenname(struct gaim_connection *gc) | |
5369 { | |
5370 do_prompt_dialog(_("New screenname formatting:"), gc->displayname, gc, oscar_format_screenname, NULL); | |
5371 } | |
5372 | |
5373 static void oscar_confirm_account(struct gaim_connection *gc) | |
5374 { | |
5375 struct oscar_data *od = gc->proto_data; | |
5376 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
5377 | |
5378 if (conn) { | |
5379 aim_admin_reqconfirm(od->sess, conn); | |
5380 } else { | |
5381 od->conf = TRUE; | |
5382 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5383 } | |
5384 } | |
5385 | |
5386 static void oscar_show_email(struct gaim_connection *gc) | |
5387 { | |
5388 struct oscar_data *od = gc->proto_data; | |
5389 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
5390 | |
5391 if (conn) { | |
5392 aim_admin_getinfo(od->sess, conn, 0x11); | |
5393 } else { | |
5394 od->reqemail = TRUE; | |
5395 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5396 } | |
5397 } | |
5398 | |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5399 static void oscar_change_email(struct gaim_connection *gc, char *email) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5400 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5401 struct oscar_data *od = gc->proto_data; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5402 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
|
5403 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5404 if (conn) { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5405 aim_admin_setemail(od->sess, conn, email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5406 } else { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5407 od->setemail = TRUE; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5408 od->email = g_strdup(email); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5409 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5410 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5411 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5412 |
4333 | 5413 static void oscar_show_change_email(struct gaim_connection *gc) |
5414 { | |
5415 do_prompt_dialog(_("Change Address To: "), NULL, gc, oscar_change_email, NULL); | |
5416 } | |
5417 | |
5418 static void oscar_show_awaitingauth(struct gaim_connection *gc) | |
5419 { | |
2979 | 5420 struct oscar_data *od = gc->proto_data; |
4333 | 5421 gchar *nombre, *text, *tmp; |
4776 | 5422 GSList *curg = gaim_blist_groups(), *curg1; |
4333 | 5423 int num=0; |
5424 | |
5425 text = g_strdup(_("You are awaiting authorization from the following buddies:<BR>")); | |
5426 | |
4770 | 5427 for (curg1 = curg; curg1; curg1=g_slist_next(curg1)) { |
5428 struct group *group = curg1->data; | |
4776 | 5429 GSList *curb = gaim_blist_members(group), *curb1; |
4770 | 5430 for (curb1=curb; curb1; curb1=g_slist_next(curb1)) { |
5431 struct buddy *buddy = curb1->data; | |
4491 | 5432 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { |
4687 | 5433 if (gaim_get_buddy_alias_only(buddy)) |
5434 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
4333 | 5435 else |
4337 | 5436 nombre = g_strdup_printf(" %s", buddy->name); |
4333 | 5437 tmp = g_strdup_printf("%s<BR>%s", text, nombre); |
5438 g_free(text); | |
5439 text = tmp; | |
5440 g_free(nombre); | |
5441 num++; | |
5442 } | |
2979 | 5443 } |
4770 | 5444 g_slist_free(curb); |
4333 | 5445 } |
4770 | 5446 g_slist_free(curg); |
4333 | 5447 |
5448 if (!num) { | |
5449 tmp = g_strdup_printf("%s<BR>%s", text, _("<i>you are not waiting for authorization</i>")); | |
5450 g_free(text); | |
5451 text = tmp; | |
2979 | 5452 } |
4333 | 5453 |
5454 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); | |
5455 g_free(text); | |
5456 text = tmp; | |
5457 g_show_info_text(gc, gc->username, 2, text, NULL); | |
5458 g_free(text); | |
2979 | 5459 } |
5460 | |
4333 | 5461 static void oscar_show_chpassurl(struct gaim_connection *gc) |
5462 { | |
5463 struct oscar_data *od = gc->proto_data; | |
5464 open_url(NULL, od->sess->authinfo->chpassurl); | |
5465 } | |
5466 | |
5467 static GList *oscar_actions(struct gaim_connection *gc) | |
2086 | 5468 { |
5469 struct oscar_data *od = gc->proto_data; | |
4333 | 5470 struct proto_actions_menu *pam; |
5471 GList *m = NULL; | |
5472 | |
5473 pam = g_new0(struct proto_actions_menu, 1); | |
5474 pam->label = _("Set User Info"); | |
5475 pam->callback = show_set_info; | |
5476 pam->gc = gc; | |
5477 m = g_list_append(m, pam); | |
5478 | |
4617 | 5479 if ((od->sess->authinfo->regstatus == 0x0003) || (od->icq)) { |
4333 | 5480 pam = g_new0(struct proto_actions_menu, 1); |
5481 pam->label = _("Change Password"); | |
5482 pam->callback = show_change_passwd; | |
5483 pam->gc = gc; | |
5484 m = g_list_append(m, pam); | |
4617 | 5485 } |
5486 | |
5487 if (od->sess->authinfo->chpassurl) { | |
5488 pam = g_new0(struct proto_actions_menu, 1); | |
5489 pam->label = _("Change Password (URL)"); | |
5490 pam->callback = oscar_show_chpassurl; | |
5491 pam->gc = gc; | |
5492 m = g_list_append(m, pam); | |
5493 } | |
5494 | |
5495 if (od->sess->authinfo->regstatus == 0x0003) { | |
5496 /* AIM actions */ | |
5497 m = g_list_append(m, NULL); | |
4333 | 5498 |
5499 pam = g_new0(struct proto_actions_menu, 1); | |
5500 pam->label = _("Format Screenname"); | |
5501 pam->callback = oscar_show_format_screenname; | |
5502 pam->gc = gc; | |
5503 m = g_list_append(m, pam); | |
5504 | |
5505 pam = g_new0(struct proto_actions_menu, 1); | |
5506 pam->label = _("Confirm Account"); | |
5507 pam->callback = oscar_confirm_account; | |
5508 pam->gc = gc; | |
5509 m = g_list_append(m, pam); | |
5510 | |
5511 pam = g_new0(struct proto_actions_menu, 1); | |
5512 pam->label = _("Display Current Registered Address"); | |
5513 pam->callback = oscar_show_email; | |
5514 pam->gc = gc; | |
5515 m = g_list_append(m, pam); | |
5516 | |
5517 pam = g_new0(struct proto_actions_menu, 1); | |
5518 pam->label = _("Change Current Registered Address"); | |
5519 pam->callback = oscar_show_change_email; | |
5520 pam->gc = gc; | |
5521 m = g_list_append(m, pam); | |
2086 | 5522 } |
4333 | 5523 |
5524 m = g_list_append(m, NULL); | |
5525 | |
5526 pam = g_new0(struct proto_actions_menu, 1); | |
5527 pam->label = _("Show Buddies Awaiting Authorization"); | |
5528 pam->callback = oscar_show_awaitingauth; | |
5529 pam->gc = gc; | |
5530 m = g_list_append(m, pam); | |
5531 | |
2086 | 5532 m = g_list_append(m, NULL); |
4333 | 5533 |
5534 pam = g_new0(struct proto_actions_menu, 1); | |
5535 pam->label = _("Search for Buddy by Email"); | |
5536 pam->callback = show_find_email; | |
5537 pam->gc = gc; | |
5538 m = g_list_append(m, pam); | |
5539 | |
4336 | 5540 /* pam = g_new0(struct proto_actions_menu, 1); |
4333 | 5541 pam->label = _("Search for Buddy by Information"); |
5542 pam->callback = show_find_info; | |
5543 pam->gc = gc; | |
4336 | 5544 m = g_list_append(m, pam); */ |
2086 | 5545 |
5546 return m; | |
5547 } | |
5548 | |
3466 | 5549 static void oscar_change_passwd(struct gaim_connection *gc, const char *old, const char *new) |
2086 | 5550 { |
5551 struct oscar_data *od = gc->proto_data; | |
4617 | 5552 |
5553 if (od->icq) { | |
5554 aim_icq_changepasswd(od->sess, new); | |
2086 | 5555 } else { |
4617 | 5556 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
5557 if (conn) { | |
5558 aim_admin_changepasswd(od->sess, conn, new, old); | |
5559 } else { | |
5560 od->chpass = TRUE; | |
5561 od->oldp = g_strdup(old); | |
5562 od->newp = g_strdup(new); | |
5563 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
5564 } | |
2086 | 5565 } |
5566 } | |
5567 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5568 static void oscar_convo_closed(struct gaim_connection *gc, char *who) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5569 { |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5570 struct oscar_data *od = gc->proto_data; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5571 struct direct_im *dim = find_direct_im(od, who); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5572 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5573 if (!dim) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5574 return; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5575 |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5576 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5577 gaim_input_remove(dim->watcher); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5578 aim_conn_kill(od->sess, &dim->conn); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5579 g_free(dim); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5580 } |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5581 |
4151 | 5582 static fu32_t check_encoding(const char *utf8) |
5583 { | |
5584 int i = 0; | |
5585 fu32_t encodingflag = 0; | |
5586 | |
5587 /* Determine how we can send this message. Per the | |
5588 * warnings elsewhere in this file, these little | |
5589 * checks determine the simplest encoding we can use | |
5590 * for a given message send using it. */ | |
5591 while (utf8[i]) { | |
5592 if ((unsigned char)utf8[i] > 0x7f) { | |
5593 /* not ASCII! */ | |
5594 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
5595 break; | |
5596 } | |
5597 i++; | |
5598 } | |
5599 while (utf8[i]) { | |
5600 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
5601 * followed by 0xc0-0xc3 in the second */ | |
5602 if ((unsigned char)utf8[i] < 0x80) { | |
5603 i++; | |
5604 continue; | |
5605 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
5606 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
5607 i += 2; | |
5608 continue; | |
5609 } | |
5610 encodingflag = AIM_IMFLAGS_UNICODE; | |
5611 break; | |
5612 } | |
5613 | |
5614 return encodingflag; | |
5615 } | |
5616 | |
5617 static fu32_t parse_encoding(const char *enc) | |
5618 { | |
5619 char *charset; | |
5620 | |
5621 /* If anything goes wrong, fall back on ASCII and print a message */ | |
4643 | 5622 if (enc == NULL) { |
5623 debug_printf("Encoding was null, that's odd\n"); | |
5624 return 0; | |
5625 } | |
4151 | 5626 charset = strstr(enc, "charset="); |
5627 if (charset == NULL) { | |
5628 debug_printf("No charset specified for info, assuming ASCII\n"); | |
5629 return 0; | |
5630 } | |
5631 charset += 8; | |
4600 | 5632 if (!strcmp(charset, "\"us-ascii\"") || !strcmp(charset, "\"utf-8\"")) { |
5633 /* UTF-8 is our native charset, ASCII is a proper subset */ | |
4151 | 5634 return 0; |
4166 | 5635 } else if (!strcmp(charset, "\"iso-8859-1\"")) { |
5636 return AIM_IMFLAGS_ISO_8859_1; | |
4151 | 5637 } else if (!strcmp(charset, "\"unicode-2-0\"")) { |
5638 return AIM_IMFLAGS_UNICODE; | |
5639 } else { | |
5640 debug_printf("Unrecognized character set '%s', using ASCII\n", charset); | |
5641 return 0; | |
5642 } | |
5643 } | |
3035 | 5644 |
3630 | 5645 G_MODULE_EXPORT void oscar_init(struct prpl *ret) { |
3572 | 5646 struct proto_user_opt *puo; |
2086 | 5647 ret->protocol = PROTO_OSCAR; |
3694 | 5648 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE; |
3858 | 5649 ret->name = g_strdup("AIM/ICQ"); |
2086 | 5650 ret->list_icon = oscar_list_icon; |
4687 | 5651 ret->list_emblems = oscar_list_emblems; |
2086 | 5652 ret->away_states = oscar_away_states; |
5653 ret->actions = oscar_actions; | |
5654 ret->buddy_menu = oscar_buddy_menu; | |
3456 | 5655 ret->edit_buddy_menu = oscar_edit_buddy_menu; |
2086 | 5656 ret->login = oscar_login; |
5657 ret->close = oscar_close; | |
5658 ret->send_im = oscar_send_im; | |
2993 | 5659 ret->send_typing = oscar_send_typing; |
2086 | 5660 ret->set_info = oscar_set_info; |
5661 ret->get_info = oscar_get_info; | |
5662 ret->set_away = oscar_set_away; | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5663 ret->get_away = oscar_get_away; |
2086 | 5664 ret->set_dir = oscar_set_dir; |
5665 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
5666 ret->dir_search = oscar_dir_search; | |
5667 ret->set_idle = oscar_set_idle; | |
5668 ret->change_passwd = oscar_change_passwd; | |
5669 ret->add_buddy = oscar_add_buddy; | |
5670 ret->add_buddies = oscar_add_buddies; | |
4269 | 5671 ret->remove_buddy = oscar_remove_buddy; |
5672 ret->remove_buddies = oscar_remove_buddies; | |
4230 | 5673 #ifndef NOSSI |
3140 | 5674 ret->group_buddy = oscar_move_buddy; |
4269 | 5675 ret->alias_buddy = oscar_alias_buddy; |
3348 | 5676 ret->rename_group = oscar_rename_group; |
4230 | 5677 #endif |
4269 | 5678 ret->add_permit = oscar_add_permit; |
5679 ret->add_deny = oscar_add_deny; | |
5680 ret->rem_permit = oscar_rem_permit; | |
5681 ret->rem_deny = oscar_rem_deny; | |
5682 ret->set_permit_deny = oscar_set_permit_deny; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5683 |
2086 | 5684 ret->warn = oscar_warn; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5685 ret->chat_info = oscar_chat_info; |
2086 | 5686 ret->join_chat = oscar_join_chat; |
5687 ret->chat_invite = oscar_chat_invite; | |
5688 ret->chat_leave = oscar_chat_leave; | |
5689 ret->chat_whisper = NULL; | |
5690 ret->chat_send = oscar_chat_send; | |
5691 ret->keepalive = oscar_keepalive; | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5692 ret->convo_closed = oscar_convo_closed; |
4732 | 5693 ret->tooltip_text = oscar_tooltip_text; |
2086 | 5694 |
3572 | 5695 puo = g_new0(struct proto_user_opt, 1); |
5696 puo->label = g_strdup("Auth Host:"); | |
5697 puo->def = g_strdup("login.oscar.aol.com"); | |
5698 puo->pos = USEROPT_AUTH; | |
5699 ret->user_opts = g_list_append(ret->user_opts, puo); | |
5700 | |
5701 puo = g_new0(struct proto_user_opt, 1); | |
5702 puo->label = g_strdup("Auth Port:"); | |
5703 puo->def = g_strdup("5190"); | |
5704 puo->pos = USEROPT_AUTHPORT; | |
5705 ret->user_opts = g_list_append(ret->user_opts, puo); | |
5706 | |
2086 | 5707 my_protocol = ret; |
5708 } | |
5709 | |
5710 #ifndef STATIC | |
5711 | |
3630 | 5712 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 5713 { |
3572 | 5714 oscar_init(prpl); |
5715 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 5716 } |
5717 | |
5718 #endif |