Mercurial > pidgin.yaz
annotate src/protocols/toc/toc.c @ 4617:858979ab3867
[gaim-migrate @ 4908]
Big Changes:
-Rewrote some of the perl stuff so perl scripts can change a few of their
parameters
-Receiving a file with AIM over oscar works pretty well
Now, the "nitty gritty":
Very minor change to prefs.c: In the plugins details tab, I changed "URL"
to "Web Site." I was just going to fix the tabbing, but silvestrij
suggested changing it to "Web site," and I thought that sounded good.
I think it fits better, too. I dunno, maybe that's just me.
"Get Capabilities" has stopped working for some reason. I'm just going to
blame AOL. It's really not important anyway, and some people wanted it
taken off. It is now #ifdef 0'ed out. I'll remove it completely if it
continues to no longer function.
I took out a few plugin_event calls from oscar.c and put them in core code.
"event_error" should be, uh, "evented" when there is an error signing on.
Hopefully no one was using this. It's really pretty useless. The parameter
is now the reason for not being able to connect rather than the archaic
toc error code.
I screwed around with how perl functions are called some. There was way the
hell too much malloc'ing going on here. I think all in all it's an
improvement, though I'm still not a big fan of how changes to parameters
propagate to the actual memory.
I really think it would be nice if the perl stuff was made into a C plugin.
It's just so much cleaner. Especially if someone wanted to write, say, a
python or tcl interpreter. That's how xchat2 does it. I just think that
would be really slick. Like butter. Or ice. Very unlike Velcro.
I added a "Change Password" Protocol Action for ICQ over oscar. This was
really pretty easy. I'd like to thank my housemate Andrew for complaining
a lot that having to use Windows ICQ to change his password was a pain.
I rewrote a lot of the oscar file transfer stuff to use Christian's new
xfer interface. This involved moving a few functions from ft.c to im.c,
where they belong. I also removed all the #if 0'ed getfile functions.
I'll be rewritting them soonish. Receiving a file should work perfectly,
aside from maybe a small memleak when stuff is canceled. Sending a file is
currently disabled. No ETA on when I'll have that working.
I renamed pretty much all of the functions in im.c so they have kind of a
scheme now. They should all be aim_im_bleh, since "im" is the family
name. There comes a time when you must break the crap out of any clients
that might be using libfaim in order to make stuff cleaner. Maybe.
I got rid of the snac destructor stuff for now. I'll probably add it back
later. I wasn't entirely comfortable with how it was done.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 26 Feb 2003 05:01:37 +0000 |
parents | 1969709eee1e |
children | d19872836812 |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
25 #include <config.h> |
2086 | 26 #endif |
3630 | 27 |
28 #ifndef _WIN32 | |
2086 | 29 #include <netdb.h> |
30 #include <unistd.h> | |
31 #include <netinet/in.h> | |
32 #include <arpa/inet.h> | |
3630 | 33 #include <sys/socket.h> |
34 #else | |
35 #include <winsock.h> | |
36 #endif | |
37 | |
38 #include <gtk/gtk.h> | |
39 #include <errno.h> | |
2086 | 40 #include <string.h> |
41 #include <stdlib.h> | |
42 #include <stdio.h> | |
43 #include <time.h> | |
44 #include <sys/types.h> | |
45 #include <sys/stat.h> | |
46 #include "prpl.h" | |
47 #include "multi.h" | |
48 #include "gaim.h" | |
49 #include "proxy.h" | |
50 | |
3630 | 51 #ifdef _WIN32 |
52 #include "win32dep.h" | |
53 #endif | |
54 | |
3490 | 55 #include "pixmaps/protocols/oscar/admin_icon.xpm" |
56 #include "pixmaps/protocols/oscar/aol_icon.xpm" | |
57 #include "pixmaps/protocols/oscar/away_icon.xpm" | |
58 #include "pixmaps/protocols/oscar/dt_icon.xpm" | |
59 #include "pixmaps/protocols/oscar/free_icon.xpm" | |
60 #include "pixmaps/protocols/oscar/wireless_icon.xpm" | |
2086 | 61 |
4249 | 62 static struct prpl *my_protocol = NULL; |
63 | |
3630 | 64 /* for win32 compatability */ |
65 G_MODULE_IMPORT GSList *connections; | |
66 | |
2086 | 67 #define REVISION "penguin" |
68 | |
69 #define TYPE_SIGNON 1 | |
70 #define TYPE_DATA 2 | |
71 #define TYPE_ERROR 3 | |
72 #define TYPE_SIGNOFF 4 | |
73 #define TYPE_KEEPALIVE 5 | |
74 | |
75 #define FLAPON "FLAPON\r\n\r\n" | |
76 #define ROAST "Tic/Toc" | |
77 | |
78 #define TOC_HOST "toc.oscar.aol.com" | |
79 #define TOC_PORT 9898 | |
80 #define AUTH_HOST "login.oscar.aol.com" | |
81 #define AUTH_PORT 5190 | |
82 #define LANGUAGE "english" | |
83 | |
84 #define STATE_OFFLINE 0 | |
85 #define STATE_FLAPON 1 | |
86 #define STATE_SIGNON_REQUEST 2 | |
87 #define STATE_ONLINE 3 | |
88 #define STATE_PAUSE 4 | |
89 | |
90 #define VOICE_UID "09461341-4C7F-11D1-8222-444553540000" | |
91 #define FILE_SEND_UID "09461343-4C7F-11D1-8222-444553540000" | |
92 #define IMAGE_UID "09461345-4C7F-11D1-8222-444553540000" | |
93 #define B_ICON_UID "09461346-4C7F-11D1-8222-444553540000" | |
94 #define STOCKS_UID "09461347-4C7F-11D1-8222-444553540000" | |
95 #define FILE_GET_UID "09461348-4C7F-11D1-8222-444553540000" | |
96 #define GAMES_UID "0946134a-4C7F-11D1-8222-444553540000" | |
97 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
98 #define UC_AOL 0x02 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
99 #define UC_ADMIN 0x04 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
100 #define UC_UNCONFIRMED 0x08 |
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
101 #define UC_NORMAL 0x10 |
3083 | 102 #define UC_WIRELESS 0x20 |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
103 |
2086 | 104 struct ft_request { |
105 struct gaim_connection *gc; | |
106 char *user; | |
107 char UID[2048]; | |
108 char *cookie; | |
109 char *ip; | |
110 int port; | |
111 char *message; | |
112 char *filename; | |
113 int files; | |
114 int size; | |
115 }; | |
116 | |
117 struct buddy_icon { | |
118 guint32 hash; | |
119 guint32 len; | |
120 time_t time; | |
121 void *data; | |
122 }; | |
123 | |
124 struct toc_data { | |
125 int toc_fd; | |
4597 | 126 char toc_ip[20]; |
2086 | 127 int seqno; |
128 int state; | |
129 }; | |
130 | |
131 struct sflap_hdr { | |
132 unsigned char ast; | |
133 unsigned char type; | |
134 unsigned short seqno; | |
135 unsigned short len; | |
136 }; | |
137 | |
138 struct signon { | |
139 unsigned int ver; | |
140 unsigned short tag; | |
141 unsigned short namelen; | |
142 char username[80]; | |
143 }; | |
144 | |
145 /* constants to identify proto_opts */ | |
146 #define USEROPT_AUTH 0 | |
147 #define USEROPT_AUTHPORT 1 | |
148 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
149 static void toc_login_callback(gpointer, gint, GaimInputCondition); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
150 static void toc_callback(gpointer, gint, GaimInputCondition); |
2086 | 151 static void accept_file_dialog(struct ft_request *); |
152 | |
3630 | 153 /* The following were added for win32 port - Herman */ |
154 | |
155 int toc_write(int fd, const void *buffer, int len) | |
156 { | |
157 #ifndef _WIN32 | |
158 return write(fd, buffer, len); | |
159 #else | |
160 return send(fd, buffer, len, 0); | |
161 #endif | |
162 } | |
163 | |
164 int toc_read(int fd, void *buffer, int size) | |
165 { | |
166 #ifndef _WIN32 | |
167 return read(fd, buffer, size); | |
168 #else | |
169 return recv(fd, buffer, size, 0); | |
170 #endif | |
171 } | |
172 | |
173 int toc_soc_close( int fd ) | |
174 { | |
175 #ifndef _WIN32 | |
176 return close(fd); | |
177 #else | |
178 return closesocket(fd); | |
179 #endif | |
180 } | |
181 | |
182 | |
2086 | 183 /* ok. this function used to take username/password, and return 0 on success. |
184 * now, it takes username/password, and returns NULL on error or a new gaim_connection | |
185 * on success. */ | |
4491 | 186 static void toc_login(struct gaim_account *account) |
2086 | 187 { |
188 struct gaim_connection *gc; | |
189 struct toc_data *tdt; | |
190 char buf[80]; | |
191 | |
4491 | 192 gc = new_gaim_conn(account); |
2086 | 193 gc->proto_data = tdt = g_new0(struct toc_data, 1); |
2918
4df759d607f3
[gaim-migrate @ 2931]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2916
diff
changeset
|
194 gc->flags |= OPT_CONN_HTML; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
195 gc->flags |= OPT_CONN_AUTO_RESP; |
2086 | 196 |
197 g_snprintf(buf, sizeof buf, "Looking up %s", | |
4491 | 198 account->proto_opt[USEROPT_AUTH][0] ? account->proto_opt[USEROPT_AUTH] : TOC_HOST); |
2086 | 199 set_login_progress(gc, 1, buf); |
200 | |
201 debug_printf("* Client connects to TOC\n"); | |
4491 | 202 if (proxy_connect(account->proto_opt[USEROPT_AUTH][0] ? |
203 account->proto_opt[USEROPT_AUTH] : TOC_HOST, | |
204 account->proto_opt[USEROPT_AUTHPORT][0] ? | |
205 atoi(account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, | |
206 toc_login_callback, gc) != 0 || !account->gc) { | |
207 g_snprintf(buf, sizeof(buf), "Connect to %s failed", account->proto_opt[USEROPT_AUTH]); | |
2086 | 208 hide_login_progress(gc, buf); |
209 signoff(gc); | |
210 return; | |
211 } | |
212 } | |
213 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
214 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) |
2086 | 215 { |
216 struct gaim_connection *gc = data; | |
217 struct toc_data *tdt; | |
218 char buf[80]; | |
4597 | 219 struct sockaddr_in name; |
220 socklen_t namelen; | |
2086 | 221 |
222 if (!g_slist_find(connections, data)) { | |
3630 | 223 toc_soc_close(source); |
2086 | 224 return; |
225 } | |
226 | |
227 tdt = gc->proto_data; | |
228 | |
229 if (source == -1) { | |
230 /* we didn't successfully connect. tdt->toc_fd is valid here */ | |
231 hide_login_progress(gc, "Unable to connect."); | |
232 signoff(gc); | |
233 return; | |
234 } | |
4452 | 235 tdt->toc_fd = source; |
2086 | 236 |
4597 | 237 /* |
238 * Copy the IP that we're connected to. We need this because "GOTO_URL"'s | |
239 * should open on the exact server we're connected to. toc.oscar.aol.com | |
240 * doesn't work because that hostname resolves to multiple IP addresses. | |
241 */ | |
242 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) | |
243 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); | |
244 else if (gc->account && gc->account->proto_opt[USEROPT_AUTH][0]) | |
245 strncpy(tdt->toc_ip, gc->account->proto_opt[USEROPT_AUTH], sizeof(tdt->toc_ip)); | |
246 else | |
247 strncpy(tdt->toc_ip, TOC_HOST, sizeof(tdt->toc_ip)); | |
248 | |
2086 | 249 debug_printf("* Client sends \"FLAPON\\r\\n\\r\\n\"\n"); |
3630 | 250 if (toc_write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { |
2086 | 251 hide_login_progress(gc, "Disconnected."); |
252 signoff(gc); | |
253 return; | |
254 } | |
255 tdt->state = STATE_FLAPON; | |
256 | |
257 /* i know a lot of people like to look at gaim to see how TOC works. so i'll comment | |
258 * on what this does. it's really simple. when there's data ready to be read from the | |
259 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
260 gc->inpa = gaim_input_add(tdt->toc_fd, GAIM_INPUT_READ, toc_callback, gc); |
2086 | 261 |
262 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); | |
263 set_login_progress(gc, 2, buf); | |
264 } | |
265 | |
266 static void toc_close(struct gaim_connection *gc) | |
267 { | |
268 if (gc->inpa > 0) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
269 gaim_input_remove(gc->inpa); |
2086 | 270 gc->inpa = 0; |
3630 | 271 toc_soc_close(((struct toc_data *)gc->proto_data)->toc_fd); |
2086 | 272 g_free(gc->proto_data); |
273 } | |
274 | |
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
275 static int escape_message(char *msg) |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
276 { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
277 char *c, *cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
278 int cnt = 0; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
279 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
280 if (strlen(msg) > BUF_LEN) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
281 debug_printf("Warning: truncating message to 2048 bytes\n"); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
282 msg[2047] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
283 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
284 |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
285 cpy = g_strdup(msg); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
286 c = cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
287 while (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
288 switch (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
289 case '$': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
290 case '[': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
291 case ']': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
292 case '(': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
293 case ')': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
294 msg[cnt++] = '\\'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
295 /* Fall through */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
296 default: |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
297 msg[cnt++] = *c; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
298 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
299 c++; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
300 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
301 msg[cnt] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
302 g_free(cpy); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
303 return cnt; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
304 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
305 |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
306 static int escape_text(char *msg) |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
307 { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
308 char *c, *cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
309 int cnt = 0; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
310 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
311 if (strlen(msg) > BUF_LEN) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
312 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
313 msg[2047] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
314 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
315 |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
316 cpy = g_strdup(msg); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
317 c = cpy; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
318 while (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
319 switch (*c) { |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
320 case '\n': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
321 msg[cnt++] = '<'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
322 msg[cnt++] = 'B'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
323 msg[cnt++] = 'R'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
324 msg[cnt++] = '>'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
325 break; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
326 case '{': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
327 case '}': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
328 case '\\': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
329 case '"': |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
330 msg[cnt++] = '\\'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
331 /* Fall through */ |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
332 default: |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
333 msg[cnt++] = *c; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
334 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
335 c++; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
336 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
337 msg[cnt] = '\0'; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
338 g_free(cpy); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
339 return cnt; |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
340 } |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
341 |
2086 | 342 static int sflap_send(struct gaim_connection *gc, char *buf, int olen, int type) |
343 { | |
344 int len; | |
345 int slen = 0; | |
346 struct sflap_hdr hdr; | |
347 char obuf[MSG_LEN]; | |
348 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | |
349 | |
350 if (tdt->state == STATE_PAUSE) | |
351 /* TOC has given us the PAUSE message; sending could cause a disconnect | |
352 * so we just return here like everything went through fine */ | |
353 return 0; | |
354 | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
355 if (olen < 0) |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
356 len = escape_message(buf); |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
357 else |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
358 len = olen; |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
359 |
2086 | 360 /* One _last_ 2048 check here! This shouldn't ever |
361 * get hit though, hopefully. If it gets hit on an IM | |
362 * It'll lose the last " and the message won't go through, | |
363 * but this'll stop a segfault. */ | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
364 if (len > MSG_LEN) { |
2086 | 365 debug_printf("message too long, truncating\n"); |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
366 buf[MSG_LEN - 1] = '\0'; |
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
367 len = MSG_LEN; |
2086 | 368 } |
369 | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
370 if (olen < 0) |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
371 debug_printf("TOC C: %s\n", buf); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
372 |
2086 | 373 hdr.ast = '*'; |
374 hdr.type = type; | |
375 hdr.seqno = htons(tdt->seqno++ & 0xffff); | |
376 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); | |
377 | |
378 memcpy(obuf, &hdr, sizeof(hdr)); | |
379 slen += sizeof(hdr); | |
380 memcpy(&obuf[slen], buf, len); | |
381 slen += len; | |
382 if (type != TYPE_SIGNON) { | |
383 obuf[slen] = '\0'; | |
384 slen += 1; | |
385 } | |
386 | |
3630 | 387 return toc_write(tdt->toc_fd, obuf, slen); |
2086 | 388 } |
389 | |
390 static int wait_reply(struct gaim_connection *gc, char *buffer, size_t buflen) | |
391 { | |
392 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | |
393 struct sflap_hdr *hdr; | |
394 int ret; | |
395 | |
3630 | 396 if (toc_read(tdt->toc_fd, buffer, sizeof(struct sflap_hdr)) < 0) { |
2086 | 397 debug_printf("error, couldn't read flap header\n"); |
398 return -1; | |
399 } | |
400 | |
401 hdr = (struct sflap_hdr *)buffer; | |
402 | |
403 if (buflen < ntohs(hdr->len)) { | |
404 /* fake like there's a read error */ | |
405 debug_printf("buffer too small (have %d, need %d)\n", buflen, ntohs(hdr->len)); | |
406 return -1; | |
407 } | |
408 | |
409 if (ntohs(hdr->len) > 0) { | |
410 int count = 0; | |
411 ret = 0; | |
412 do { | |
413 count += ret; | |
3630 | 414 ret = toc_read(tdt->toc_fd, |
2086 | 415 buffer + sizeof(struct sflap_hdr) + count, ntohs(hdr->len) - count); |
416 } while (count + ret < ntohs(hdr->len) && ret > 0); | |
417 buffer[sizeof(struct sflap_hdr) + count + ret] = '\0'; | |
418 return ret; | |
419 } else | |
420 return 0; | |
421 } | |
422 | |
423 static unsigned char *roast_password(char *pass) | |
424 { | |
425 /* Trivial "encryption" */ | |
426 static unsigned char rp[256]; | |
427 static char *roast = ROAST; | |
428 int pos = 2; | |
429 int x; | |
430 strcpy(rp, "0x"); | |
431 for (x = 0; (x < 150) && pass[x]; x++) | |
432 pos += sprintf(&rp[pos], "%02x", pass[x] ^ roast[x % strlen(roast)]); | |
433 rp[pos] = '\0'; | |
434 return rp; | |
435 } | |
436 | |
4322 | 437 static void toc_got_info(gpointer data, char *url_text, unsigned long len) |
2086 | 438 { |
439 if (!url_text) | |
440 return; | |
441 | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
442 g_show_info_text(NULL, NULL, 2, url_text, NULL); |
2086 | 443 } |
444 | |
2453
b72143059ad4
[gaim-migrate @ 2466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
445 static char *show_error_message() |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
446 { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
447 int no = atoi(strtok(NULL, ":")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
448 char *w = strtok(NULL, ":"); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
449 static char buf[256]; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
450 |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
451 switch(no) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
452 case 69: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
453 g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
454 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
455 case 169: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
456 g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
457 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
458 case 269: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
459 g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
460 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
461 case 901: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
462 g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
463 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
464 case 902: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
465 g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
466 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
467 case 903: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
468 g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
469 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
470 case 950: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
471 g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
472 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
473 case 960: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
474 g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
475 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
476 case 961: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
477 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
478 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
479 case 962: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
480 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
481 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
482 case 970: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
483 g_snprintf(buf, sizeof(buf), _("Failure.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
484 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
485 case 971: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
486 g_snprintf(buf, sizeof(buf), _("Too many matches.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
487 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
488 case 972: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
489 g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
490 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
491 case 973: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
492 g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
493 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
494 case 974: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
495 g_snprintf(buf, sizeof(buf), _("Email lookup restricted.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
496 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
497 case 975: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
498 g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
499 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
500 case 976: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
501 g_snprintf(buf, sizeof(buf), _("No keywords.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
502 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
503 case 977: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
504 g_snprintf(buf, sizeof(buf), _("User has no directory information.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
505 /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
506 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
507 case 978: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
508 g_snprintf(buf, sizeof(buf), _("Country not supported.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
509 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
510 case 979: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
511 g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
512 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
513 case 980: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
514 g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
515 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
516 case 981: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
517 g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
518 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
519 case 982: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
520 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
521 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
522 case 983: |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
523 g_snprintf(buf, sizeof(buf), _("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.")); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
524 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
525 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
526 break; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
527 default: |
3100 | 528 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w); |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
529 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
530 |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
531 return buf; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
532 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
533 |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
534 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 535 { |
536 struct gaim_connection *gc = (struct gaim_connection *)data; | |
537 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | |
538 struct sflap_hdr *hdr; | |
539 struct signon so; | |
540 char buf[8 * 1024], *c; | |
541 char snd[BUF_LEN * 2]; | |
542 | |
543 /* there's data waiting to be read, so read it. */ | |
544 if (wait_reply(gc, buf, 8 * 1024) <= 0) { | |
3074 | 545 hide_login_progress_error(gc, _("Connection Closed")); |
2086 | 546 signoff(gc); |
547 return; | |
548 } | |
549 | |
550 if (tdt->state == STATE_FLAPON) { | |
551 hdr = (struct sflap_hdr *)buf; | |
552 if (hdr->type != TYPE_SIGNON) | |
553 debug_printf("problem, hdr->type != TYPE_SIGNON\n"); | |
554 else | |
555 debug_printf("* TOC sends Client FLAP SIGNON\n"); | |
556 tdt->seqno = ntohs(hdr->seqno); | |
557 tdt->state = STATE_SIGNON_REQUEST; | |
558 | |
559 debug_printf("* Client sends TOC FLAP SIGNON\n"); | |
560 g_snprintf(so.username, sizeof(so.username), "%s", gc->username); | |
561 so.ver = htonl(1); | |
562 so.tag = htons(1); | |
563 so.namelen = htons(strlen(so.username)); | |
564 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { | |
565 hide_login_progress(gc, _("Disconnected.")); | |
566 signoff(gc); | |
567 return; | |
568 } | |
569 | |
570 debug_printf("* Client sends TOC \"toc_signon\" message\n"); | |
2853
f0633f458a1c
[gaim-migrate @ 2866]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
571 /* i hate icq. */ |
f0633f458a1c
[gaim-migrate @ 2866]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
572 if (gc->username[0] >= '0' && gc->username[0] <= '9') |
f0633f458a1c
[gaim-migrate @ 2866]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
573 gc->password[9] = '\0'; |
2086 | 574 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
575 AUTH_HOST, AUTH_PORT, normalize(gc->username), | |
576 roast_password(gc->password), LANGUAGE, REVISION); | |
577 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | |
578 hide_login_progress(gc, _("Disconnected.")); | |
579 signoff(gc); | |
580 return; | |
581 } | |
582 | |
583 set_login_progress(gc, 3, _("Waiting for reply...")); | |
584 return; | |
585 } | |
586 | |
587 if (tdt->state == STATE_SIGNON_REQUEST) { | |
588 debug_printf("* TOC sends client SIGN_ON reply\n"); | |
589 if (g_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { | |
590 debug_printf("Didn't get SIGN_ON! buf was: %s\n", | |
591 buf + sizeof(struct sflap_hdr)); | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
592 if (!g_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
593 strtok(buf + sizeof(struct sflap_hdr), ":"); |
2453
b72143059ad4
[gaim-migrate @ 2466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
594 hide_login_progress(gc, show_error_message()); |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
595 } else |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
596 hide_login_progress(gc, _("Authentication Failed")); |
2086 | 597 signoff(gc); |
598 return; | |
599 } | |
600 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ | |
2128
bc79be34eb73
[gaim-migrate @ 2138]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
601 debug_printf("TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
2086 | 602 |
603 /* we used to check for the CONFIG here, but we'll wait until we've sent our | |
604 * version of the config and then the toc_init_done message. we'll come back to | |
605 * the callback in a better state if we get CONFIG anyway */ | |
606 | |
607 tdt->state = STATE_ONLINE; | |
608 | |
609 account_online(gc); | |
610 serv_finish_login(gc); | |
611 | |
612 /* Client sends TOC toc_init_done message */ | |
613 debug_printf("* Client sends TOC toc_init_done message\n"); | |
614 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
615 sflap_send(gc, snd, -1, TYPE_DATA); | |
616 | |
617 /* | |
618 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s %s", | |
619 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID); | |
620 */ | |
621 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); | |
622 sflap_send(gc, snd, -1, TYPE_DATA); | |
623 | |
624 return; | |
625 } | |
626 | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
627 debug_printf("TOC S: %s\n", buf + sizeof(struct sflap_hdr)); |
2086 | 628 |
629 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | |
630 | |
631 if (!g_strcasecmp(c, "SIGN_ON")) { | |
632 /* we should only get here after a PAUSE */ | |
633 if (tdt->state != STATE_PAUSE) | |
634 debug_printf("got SIGN_ON but not PAUSE!\n"); | |
635 else { | |
636 tdt->state = STATE_ONLINE; | |
637 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | |
638 AUTH_HOST, AUTH_PORT, normalize(gc->username), | |
639 roast_password(gc->password), LANGUAGE, REVISION); | |
640 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { | |
641 hide_login_progress(gc, _("Disconnected.")); | |
642 signoff(gc); | |
643 return; | |
644 } | |
645 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
646 sflap_send(gc, snd, -1, TYPE_DATA); | |
647 do_error_dialog(_("TOC has come back from its pause. You may now send" | |
3427 | 648 " messages again."), NULL, GAIM_INFO); |
2086 | 649 } |
650 } else if (!strcasecmp(c, "CONFIG")) { | |
651 c = strtok(NULL, ":"); | |
4491 | 652 parse_toc_buddy_list(gc->account, c); |
2086 | 653 } else if (!strcasecmp(c, "NICK")) { |
654 /* ignore NICK so that things get imported/exported properly | |
655 c = strtok(NULL, ":"); | |
656 g_snprintf(gc->username, sizeof(gc->username), "%s", c); | |
657 */ | |
658 } else if (!strcasecmp(c, "IM_IN")) { | |
659 char *away, *message; | |
660 int a = 0; | |
661 | |
662 c = strtok(NULL, ":"); | |
663 away = strtok(NULL, ":"); | |
664 | |
665 message = away; | |
666 while (*message && (*message != ':')) | |
667 message++; | |
668 message++; | |
669 | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2232
diff
changeset
|
670 a = (away && (*away == 'T')) ? IM_FLAG_AWAY : 0; |
2086 | 671 |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2853
diff
changeset
|
672 serv_got_im(gc, c, message, a, time(NULL), -1); |
2086 | 673 } else if (!strcasecmp(c, "UPDATE_BUDDY")) { |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
674 char *l, *uc, *tmp; |
2086 | 675 int logged, evil, idle, type = 0; |
676 time_t signon, time_idle; | |
677 | |
678 c = strtok(NULL, ":"); /* name */ | |
679 l = strtok(NULL, ":"); /* online */ | |
680 sscanf(strtok(NULL, ":"), "%d", &evil); | |
681 sscanf(strtok(NULL, ":"), "%ld", &signon); | |
682 sscanf(strtok(NULL, ":"), "%d", &idle); | |
683 uc = strtok(NULL, ":"); | |
684 | |
685 logged = (l && (*l == 'T')) ? 1 : 0; | |
686 | |
687 if (uc[0] == 'A') | |
688 type |= UC_AOL; | |
689 switch (uc[1]) { | |
690 case 'A': | |
691 type |= UC_ADMIN; | |
692 break; | |
693 case 'U': | |
694 type |= UC_UNCONFIRMED; | |
695 break; | |
696 case 'O': | |
697 type |= UC_NORMAL; | |
698 break; | |
3083 | 699 case 'C': |
700 type |= UC_WIRELESS; | |
701 break; | |
2086 | 702 default: |
703 break; | |
704 } | |
705 if (uc[2] == 'U') | |
706 type |= UC_UNAVAILABLE; | |
707 | |
708 if (idle) { | |
709 time(&time_idle); | |
710 time_idle -= idle * 60; | |
711 } else | |
712 time_idle = 0; | |
713 | |
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
714 tmp = g_strdup(normalize(gc->username)); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
715 if (!strcmp(tmp, normalize(c))) |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
716 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", c); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
717 g_free(tmp); |
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
718 |
2086 | 719 serv_got_update(gc, c, logged, evil, signon, time_idle, type, 0); |
720 } else if (!strcasecmp(c, "ERROR")) { | |
3427 | 721 do_error_dialog(show_error_message(), NULL, GAIM_ERROR); |
2086 | 722 } else if (!strcasecmp(c, "EVILED")) { |
723 int lev; | |
724 char *name; | |
725 | |
726 sscanf(strtok(NULL, ":"), "%d", &lev); | |
727 name = strtok(NULL, ":"); | |
728 | |
729 serv_got_eviled(gc, name, lev); | |
730 } else if (!strcasecmp(c, "CHAT_JOIN")) { | |
731 char *name; | |
732 int id; | |
733 | |
734 sscanf(strtok(NULL, ":"), "%d", &id); | |
735 name = strtok(NULL, ":"); | |
736 | |
737 serv_got_joined_chat(gc, id, name); | |
738 } else if (!strcasecmp(c, "CHAT_IN")) { | |
739 int id, w; | |
740 char *m, *who, *whisper; | |
741 | |
742 sscanf(strtok(NULL, ":"), "%d", &id); | |
743 who = strtok(NULL, ":"); | |
744 whisper = strtok(NULL, ":"); | |
745 m = whisper; | |
746 while (*m && (*m != ':')) | |
747 m++; | |
748 m++; | |
749 | |
750 w = (whisper && (*whisper == 'T')) ? 1 : 0; | |
751 | |
752 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); | |
753 } else if (!strcasecmp(c, "CHAT_UPDATE_BUDDY")) { | |
754 int id; | |
755 char *in, *buddy; | |
756 GSList *bcs = gc->buddy_chats; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
757 struct gaim_conversation *b = NULL; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
758 struct gaim_chat *chat; |
2086 | 759 |
760 sscanf(strtok(NULL, ":"), "%d", &id); | |
761 in = strtok(NULL, ":"); | |
762 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
763 chat = GAIM_CHAT(b); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
764 |
2086 | 765 while (bcs) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
766 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
767 if (id == gaim_chat_get_id(chat)) |
2086 | 768 break; |
769 bcs = bcs->next; | |
770 b = NULL; | |
771 } | |
772 | |
773 if (!b) | |
774 return; | |
775 | |
776 if (in && (*in == 'T')) | |
777 while ((buddy = strtok(NULL, ":")) != NULL) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
778 gaim_chat_add_user(chat, buddy, NULL); |
2086 | 779 else |
780 while ((buddy = strtok(NULL, ":")) != NULL) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
781 gaim_chat_remove_user(chat, buddy, NULL); |
2086 | 782 } else if (!strcasecmp(c, "CHAT_INVITE")) { |
783 char *name, *who, *message; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
784 int *id = g_new0(int, 1); |
2086 | 785 |
786 name = strtok(NULL, ":"); | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
787 sscanf(strtok(NULL, ":"), "%d", id); |
2086 | 788 who = strtok(NULL, ":"); |
789 message = strtok(NULL, ":"); | |
790 | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
791 serv_got_chat_invite(gc, name, who, message, g_list_append(NULL, id)); |
2086 | 792 } else if (!strcasecmp(c, "CHAT_LEFT")) { |
793 GSList *bcs = gc->buddy_chats; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
794 struct gaim_conversation *b = NULL; |
2086 | 795 int id; |
796 | |
797 sscanf(strtok(NULL, ":"), "%d", &id); | |
798 | |
799 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
800 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
801 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 802 break; |
803 b = NULL; | |
804 bcs = bcs->next; | |
805 } | |
806 | |
807 if (!b) | |
808 return; | |
809 | |
810 if (b->window) { | |
811 char error_buf[BUF_LONG]; | |
4491 | 812 gaim_conversation_set_account(b, NULL); |
2086 | 813 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
814 " from chat room %s."), b->name); | |
3427 | 815 do_error_dialog(error_buf, NULL, GAIM_ERROR); |
2086 | 816 } else |
817 serv_got_chat_left(gc, id); | |
818 } else if (!strcasecmp(c, "GOTO_URL")) { | |
819 char *name, *url, tmp[256]; | |
820 | |
821 name = strtok(NULL, ":"); | |
822 url = strtok(NULL, ":"); | |
823 | |
4597 | 824 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
4491 | 825 gc->account->proto_opt[USEROPT_AUTHPORT][0] ? |
826 atoi(gc->account->proto_opt[USEROPT_AUTHPORT]) : TOC_PORT, | |
2086 | 827 url); |
2584
34812d648f72
[gaim-migrate @ 2597]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2526
diff
changeset
|
828 grab_url(tmp, FALSE, toc_got_info, NULL); |
2086 | 829 } else if (!strcasecmp(c, "DIR_STATUS")) { |
830 } else if (!strcasecmp(c, "ADMIN_NICK_STATUS")) { | |
831 } else if (!strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | |
3427 | 832 do_error_dialog(_("Password Change Successful"), NULL, GAIM_INFO); |
2086 | 833 } else if (!strcasecmp(c, "PAUSE")) { |
834 tdt->state = STATE_PAUSE; | |
3427 | 835 do_error_dialog(_("TOC has sent a PAUSE command."), _("When this happens, TOC ignores" |
2086 | 836 " any messages sent to it, and may kick you off if you send a" |
837 " message. Gaim will prevent anything from going through. This" | |
3427 | 838 " is only temporary, please be patient."), GAIM_WARNING); |
2086 | 839 } else if (!strcasecmp(c, "RVOUS_PROPOSE")) { |
840 char *user, *uuid, *cookie; | |
841 int seq; | |
3159 | 842 char *rip, *pip, *vip, *trillian = NULL; |
2086 | 843 int port; |
3126 | 844 |
2086 | 845 user = strtok(NULL, ":"); |
846 uuid = strtok(NULL, ":"); | |
847 cookie = strtok(NULL, ":"); | |
848 sscanf(strtok(NULL, ":"), "%d", &seq); | |
849 rip = strtok(NULL, ":"); | |
850 pip = strtok(NULL, ":"); | |
851 vip = strtok(NULL, ":"); | |
852 sscanf(strtok(NULL, ":"), "%d", &port); | |
853 | |
854 if (!strcmp(uuid, FILE_SEND_UID)) { | |
855 /* they want us to get a file */ | |
856 int unk[4], i; | |
857 char *messages[4], *tmp, *name; | |
858 int subtype, files, totalsize = 0; | |
859 struct ft_request *ft; | |
860 | |
861 for (i = 0; i < 4; i++) { | |
3126 | 862 trillian = strtok(NULL, ":"); |
863 sscanf(trillian, "%d", &unk[i]); | |
2086 | 864 if (unk[i] == 10001) |
865 break; | |
3126 | 866 /* Trillian likes to send an empty token as a message, rather than |
867 no message at all. */ | |
868 if (*(trillian + strlen(trillian) +1) != ':') | |
869 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
2086 | 870 } |
3126 | 871 |
2086 | 872 frombase64(strtok(NULL, ":"), &tmp, NULL); |
873 | |
874 subtype = tmp[1]; | |
875 files = tmp[3]; | |
876 | |
877 totalsize |= (tmp[4] << 24) & 0xff000000; | |
878 totalsize |= (tmp[5] << 16) & 0x00ff0000; | |
879 totalsize |= (tmp[6] << 8) & 0x0000ff00; | |
880 totalsize |= (tmp[7] << 0) & 0x000000ff; | |
881 | |
882 if (!totalsize) { | |
883 g_free(tmp); | |
884 for (i--; i >= 0; i--) | |
885 g_free(messages[i]); | |
886 return; | |
887 } | |
888 | |
889 name = tmp + 8; | |
890 | |
891 ft = g_new0(struct ft_request, 1); | |
892 ft->cookie = g_strdup(cookie); | |
893 ft->ip = g_strdup(pip); | |
894 ft->port = port; | |
895 if (i) | |
896 ft->message = g_strdup(messages[0]); | |
897 else | |
898 ft->message = NULL; | |
899 ft->filename = g_strdup(name); | |
900 ft->user = g_strdup(user); | |
901 ft->size = totalsize; | |
902 ft->files = files; | |
903 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_SEND_UID); | |
904 ft->gc = gc; | |
905 | |
906 g_free(tmp); | |
907 for (i--; i >= 0; i--) | |
908 g_free(messages[i]); | |
909 | |
910 debug_printf("English translation of RVOUS_PROPOSE: %s requests Send File (i.e." | |
911 " send a file to you); %s:%d (verified_ip:port), %d files at" | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
912 " total size of %d bytes.\n", user, vip, port, files, totalsize); |
2086 | 913 accept_file_dialog(ft); |
914 } else if (!strcmp(uuid, FILE_GET_UID)) { | |
915 /* they want us to send a file */ | |
916 int unk[4], i; | |
917 char *messages[4], *tmp; | |
918 struct ft_request *ft; | |
919 | |
920 for (i = 0; i < 4; i++) { | |
921 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
922 if (unk[i] == 10001) | |
923 break; | |
3126 | 924 /* Trillian likes to send an empty token as a message, rather than |
925 no message at all. */ | |
926 if (*(trillian + strlen(trillian) +1) != ':') | |
927 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
2086 | 928 } |
929 frombase64(strtok(NULL, ":"), &tmp, NULL); | |
930 | |
931 ft = g_new0(struct ft_request, 1); | |
932 ft->cookie = g_strdup(cookie); | |
933 ft->ip = g_strdup(pip); | |
934 ft->port = port; | |
935 if (i) | |
936 ft->message = g_strdup(messages[0]); | |
937 else | |
938 ft->message = NULL; | |
939 ft->user = g_strdup(user); | |
940 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_GET_UID); | |
941 ft->gc = gc; | |
942 | |
943 g_free(tmp); | |
944 for (i--; i >= 0; i--) | |
945 g_free(messages[i]); | |
946 | |
947 accept_file_dialog(ft); | |
948 } else if (!strcmp(uuid, VOICE_UID)) { | |
949 /* oh goody. voice over ip. fun stuff. */ | |
950 } else if (!strcmp(uuid, B_ICON_UID)) { | |
951 /* | |
952 int unk[4], i; | |
953 char *messages[4]; | |
954 struct buddy_icon *icon; | |
955 | |
956 for (i = 0; i < 4; i++) { | |
957 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
958 if (unk[i] == 10001) | |
959 break; | |
960 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
961 } | |
962 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | |
963 | |
964 debug_printf("received icon of length %d\n", icon->len); | |
965 g_free(icon); | |
966 for (i--; i >= 0; i--) | |
967 g_free(messages[i]); | |
968 */ | |
969 } else if (!strcmp(uuid, IMAGE_UID)) { | |
970 /* aka Direct IM */ | |
971 } else { | |
972 debug_printf("Don't know what to do with RVOUS UUID %s\n", uuid); | |
973 /* do we have to do anything here? i think it just times out */ | |
974 } | |
975 } else { | |
976 debug_printf("don't know what to do with %s\n", c); | |
977 } | |
978 } | |
979 | |
3033 | 980 static int toc_send_im(struct gaim_connection *gc, char *name, char *message, int len, int flags) |
2086 | 981 { |
982 char buf[BUF_LEN * 2]; | |
2343
29449a6b79e6
[gaim-migrate @ 2356]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2334
diff
changeset
|
983 char *tmp = g_malloc(strlen(message) * 4 + 1); /* 4 because \n gets replaced with <BR> */ |
2086 | 984 |
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
985 strcpy(tmp, message); |
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
986 escape_text(tmp); |
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
987 if (strlen(tmp) + 52 > MSG_LEN) { |
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
988 g_free(tmp); |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
989 return -E2BIG; |
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
990 } |
2086 | 991 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2205
diff
changeset
|
992 tmp, ((flags & IM_FLAG_AWAY) ? " auto" : "")); |
2086 | 993 sflap_send(gc, buf, -1, TYPE_DATA); |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
994 |
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
995 g_free(tmp); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2281
diff
changeset
|
996 return 1; |
2086 | 997 } |
998 | |
999 static void toc_set_config(struct gaim_connection *gc) | |
1000 { | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1001 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
4491 | 1002 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
2086 | 1003 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
1004 sflap_send(gc, snd, -1, TYPE_DATA); | |
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1005 g_free(buf); |
2086 | 1006 } |
1007 | |
1008 static void toc_get_info(struct gaim_connection *g, char *name) | |
1009 { | |
1010 char buf[BUF_LEN * 2]; | |
1011 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | |
1012 sflap_send(g, buf, -1, TYPE_DATA); | |
1013 } | |
1014 | |
1015 static void toc_get_dir(struct gaim_connection *g, char *name) | |
1016 { | |
1017 char buf[BUF_LEN * 2]; | |
1018 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | |
1019 sflap_send(g, buf, -1, TYPE_DATA); | |
1020 } | |
1021 | |
3466 | 1022 static void toc_set_dir(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
1023 const char *maiden, const char *city, const char *state, const char *country, int web) | |
2086 | 1024 { |
1025 char buf2[BUF_LEN * 4], buf[BUF_LEN]; | |
1026 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | |
1027 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | |
1028 escape_text(buf2); | |
1029 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | |
1030 sflap_send(g, buf, -1, TYPE_DATA); | |
1031 } | |
1032 | |
3466 | 1033 static void toc_dir_search(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
1034 const char *maiden, const char *city, const char *state, const char *country, const char *email) | |
2086 | 1035 { |
1036 char buf[BUF_LONG]; | |
1037 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | |
1038 last, maiden, city, state, country, email); | |
1039 debug_printf("Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, | |
1040 city, state, country); | |
1041 sflap_send(g, buf, -1, TYPE_DATA); | |
1042 } | |
1043 | |
1044 static void toc_set_away(struct gaim_connection *g, char *state, char *message) | |
1045 { | |
1046 char buf[BUF_LEN * 2]; | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1047 if (g->away) { |
2086 | 1048 g_free (g->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1049 g->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1050 } |
2086 | 1051 if (message) { |
3188 | 1052 char *tmp = g_malloc(strlen(message) * 4 + 1); |
1053 strcpy(tmp, message); | |
2086 | 1054 g->away = g_strdup (message); |
3188 | 1055 escape_text(tmp); |
1056 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", tmp); | |
1057 g_free(tmp); | |
2086 | 1058 } else |
1059 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | |
1060 sflap_send(g, buf, -1, TYPE_DATA); | |
1061 } | |
1062 | |
1063 static void toc_set_info(struct gaim_connection *g, char *info) | |
1064 { | |
1065 char buf[BUF_LEN * 2], buf2[BUF_LEN * 2]; | |
1066 g_snprintf(buf2, sizeof buf2, "%s", info); | |
1067 escape_text(buf2); | |
1068 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); | |
1069 sflap_send(g, buf, -1, TYPE_DATA); | |
1070 } | |
1071 | |
3466 | 1072 static void toc_change_passwd(struct gaim_connection *g, const char *orig, const char *new) |
2086 | 1073 { |
1074 char buf[BUF_LEN * 2]; | |
1075 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | |
1076 sflap_send(g, buf, strlen(buf), TYPE_DATA); | |
1077 } | |
1078 | |
3466 | 1079 static void toc_add_buddy(struct gaim_connection *g, const char *name) |
2086 | 1080 { |
1081 char buf[BUF_LEN * 2]; | |
1082 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | |
1083 sflap_send(g, buf, -1, TYPE_DATA); | |
1084 toc_set_config(g); | |
1085 } | |
1086 | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1087 static void toc_add_buddies(struct gaim_connection *g, GList *buddies) |
2086 | 1088 { |
1089 char buf[BUF_LEN * 2]; | |
1090 int n; | |
1091 | |
1092 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
1093 while (buddies) { | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2128
diff
changeset
|
1094 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { |
2086 | 1095 sflap_send(g, buf, -1, TYPE_DATA); |
1096 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
1097 } | |
1098 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | |
1099 buddies = buddies->next; | |
1100 } | |
1101 sflap_send(g, buf, -1, TYPE_DATA); | |
1102 } | |
1103 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1104 static void toc_remove_buddy(struct gaim_connection *g, char *name, char *group) |
2086 | 1105 { |
1106 char buf[BUF_LEN * 2]; | |
1107 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | |
1108 sflap_send(g, buf, -1, TYPE_DATA); | |
1109 toc_set_config(g); | |
1110 } | |
1111 | |
3867 | 1112 static void toc_remove_buddies(struct gaim_connection *g, GList *buddies, const char *group) |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1113 { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1114 char buf[BUF_LEN * 2]; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1115 int n; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1116 |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1117 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1118 while (buddies) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1119 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1120 sflap_send(g, buf, -1, TYPE_DATA); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1121 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1122 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1123 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1124 buddies = buddies->next; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1125 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1126 sflap_send(g, buf, -1, TYPE_DATA); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1127 toc_set_config(g); |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1128 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1129 |
2086 | 1130 static void toc_set_idle(struct gaim_connection *g, int time) |
1131 { | |
1132 char buf[BUF_LEN * 2]; | |
1133 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
1134 sflap_send(g, buf, -1, TYPE_DATA); | |
1135 } | |
1136 | |
1137 static void toc_warn(struct gaim_connection *g, char *name, int anon) | |
1138 { | |
1139 char send[BUF_LEN * 2]; | |
1140 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | |
1141 sflap_send(g, send, -1, TYPE_DATA); | |
1142 } | |
1143 | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1144 static GList *toc_chat_info(struct gaim_connection *gc) |
2086 | 1145 { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1146 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1147 struct proto_chat_entry *pce; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1148 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1149 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1150 pce->label = _("Join what group:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1151 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1152 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1153 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1154 pce->label = _("Exchange:"); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1155 pce->is_int = TRUE; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1156 pce->min = 4; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1157 pce->max = 20; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1158 m = g_list_append(m, pce); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1159 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1160 return m; |
2086 | 1161 } |
1162 | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1163 static void toc_join_chat(struct gaim_connection *g, GList *data) |
2086 | 1164 { |
1165 char buf[BUF_LONG]; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1166 int *exchange; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1167 char *name; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1168 int *i; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1169 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1170 if (!data) |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1171 return; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1172 |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1173 if (!data->next) { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1174 i = data->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1175 g_snprintf(buf, 255, "toc_chat_accept %d", *i); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1176 } else { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1177 name = data->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1178 exchange = data->next->data; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1179 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_join %d \"%s\"", *exchange, name); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1180 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1181 |
2086 | 1182 sflap_send(g, buf, -1, TYPE_DATA); |
1183 } | |
1184 | |
3466 | 1185 static void toc_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) |
2086 | 1186 { |
1187 char buf[BUF_LONG]; | |
2719
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1188 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1189 message ? message : "", normalize(name)); |
2086 | 1190 sflap_send(g, buf, -1, TYPE_DATA); |
1191 } | |
1192 | |
1193 static void toc_chat_leave(struct gaim_connection *g, int id) | |
1194 { | |
1195 GSList *bcs = g->buddy_chats; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1196 struct gaim_conversation *b = NULL; |
2086 | 1197 char buf[BUF_LEN * 2]; |
1198 | |
1199 while (bcs) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1200 b = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1201 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
2086 | 1202 break; |
1203 b = NULL; | |
1204 bcs = bcs->next; | |
1205 } | |
1206 | |
1207 if (!b) | |
1208 return; /* can this happen? */ | |
1209 | |
4491 | 1210 if (gaim_conversation_get_account(b) == NULL) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1211 /* TOC already kicked us out of this room */ |
2086 | 1212 serv_got_chat_left(g, id); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1213 } |
2086 | 1214 else { |
1215 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
1216 sflap_send(g, buf, -1, TYPE_DATA); | |
1217 } | |
1218 } | |
1219 | |
1220 static void toc_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) | |
1221 { | |
1222 char buf2[BUF_LEN * 2]; | |
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
1223 escape_text(message); |
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
1224 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, normalize(who), message); |
2086 | 1225 sflap_send(g, buf2, -1, TYPE_DATA); |
1226 } | |
1227 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1228 static int toc_chat_send(struct gaim_connection *g, int id, char *message) |
2086 | 1229 { |
1230 char buf[BUF_LEN * 2]; | |
1231 escape_text(message); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1232 if (strlen(message) > 2000) |
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1233 return -E2BIG; |
2086 | 1234 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"", id, message); |
1235 sflap_send(g, buf, -1, TYPE_DATA); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1236 return 0; |
2086 | 1237 } |
1238 | |
1239 static void toc_keepalive(struct gaim_connection *gc) | |
1240 { | |
1241 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | |
1242 } | |
1243 | |
1244 static char **toc_list_icon(int uc) | |
1245 { | |
1246 if (uc & UC_UNAVAILABLE) | |
1247 return (char **)away_icon_xpm; | |
1248 if (uc & UC_AOL) | |
1249 return (char **)aol_icon_xpm; | |
1250 if (uc & UC_NORMAL) | |
1251 return (char **)free_icon_xpm; | |
1252 if (uc & UC_ADMIN) | |
1253 return (char **)admin_icon_xpm; | |
1254 if (uc & UC_UNCONFIRMED) | |
1255 return (char **)dt_icon_xpm; | |
3083 | 1256 if (uc & UC_WIRELESS) |
1257 return (char **)wireless_icon_xpm; | |
2086 | 1258 return NULL; |
1259 } | |
1260 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1261 static GList *toc_buddy_menu(struct gaim_connection *gc, char *who) |
2086 | 1262 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1263 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1264 struct proto_buddy_menu *pbm; |
2086 | 1265 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1266 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1267 pbm->label = _("Get Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1268 pbm->callback = toc_get_info; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1269 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1270 m = g_list_append(m, pbm); |
2086 | 1271 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1272 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1273 pbm->label = _("Get Dir Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1274 pbm->callback = toc_get_dir; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1275 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1276 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1277 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1278 return m; |
2086 | 1279 } |
1280 | |
4349 | 1281 static void toc_add_permit(struct gaim_connection *gc, const char *who) |
2086 | 1282 { |
1283 char buf2[BUF_LEN * 2]; | |
4491 | 1284 if (gc->account->permdeny != 3) |
2086 | 1285 return; |
1286 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who)); | |
1287 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1288 toc_set_config(gc); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2584
diff
changeset
|
1289 signoff_blocked(gc); |
2086 | 1290 } |
1291 | |
4349 | 1292 static void toc_add_deny(struct gaim_connection *gc, const char *who) |
2086 | 1293 { |
1294 char buf2[BUF_LEN * 2]; | |
4491 | 1295 if (gc->account->permdeny != 4) |
2086 | 1296 return; |
1297 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who)); | |
1298 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1299 toc_set_config(gc); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2584
diff
changeset
|
1300 signoff_blocked(gc); |
2086 | 1301 } |
1302 | |
1303 static void toc_set_permit_deny(struct gaim_connection *gc) | |
1304 { | |
1305 char buf2[BUF_LEN * 2]; | |
1306 GSList *list; | |
1307 int at; | |
1308 | |
4491 | 1309 switch (gc->account->permdeny) { |
2086 | 1310 case 1: |
1311 /* permit all, deny none. to get here reliably we need to have been in permit | |
1312 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ | |
1313 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1314 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1315 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1316 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1317 break; | |
1318 case 2: | |
1319 /* deny all, permit none. to get here reliably we need to have been in deny | |
1320 * mode, and send an empty toc_add_permit message, which will switch us to permit none */ | |
1321 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1322 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1323 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1324 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1325 break; | |
1326 case 3: | |
1327 /* permit some. we want to switch to deny mode first, then send the toc_add_permit | |
1328 * message, which will clear and set our permit list. toc sucks. */ | |
1329 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1330 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1331 | |
1332 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
4491 | 1333 list = gc->account->permit; |
2086 | 1334 while (list) { |
1335 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); | |
1336 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | |
1337 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1338 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1339 } | |
1340 list = list->next; | |
1341 } | |
1342 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1343 break; | |
1344 case 4: | |
1345 /* deny some. we want to switch to permit mode first, then send the toc_add_deny | |
1346 * message, which will clear and set our deny list. toc sucks. */ | |
1347 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
1348 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1349 | |
1350 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
4491 | 1351 list = gc->account->deny; |
2086 | 1352 while (list) { |
1353 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); | |
1354 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ | |
1355 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1356 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
1357 } | |
1358 list = list->next; | |
1359 } | |
1360 sflap_send(gc, buf2, -1, TYPE_DATA); | |
1361 break; | |
1362 default: | |
1363 break; | |
1364 } | |
1365 toc_set_config(gc); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2584
diff
changeset
|
1366 signoff_blocked(gc); |
2086 | 1367 } |
1368 | |
4349 | 1369 static void toc_rem_permit(struct gaim_connection *gc, const char *who) |
2086 | 1370 { |
4491 | 1371 if (gc->account->permdeny != 3) |
2086 | 1372 return; |
1373 toc_set_permit_deny(gc); | |
1374 } | |
1375 | |
4349 | 1376 static void toc_rem_deny(struct gaim_connection *gc, const char *who) |
2086 | 1377 { |
4491 | 1378 if (gc->account->permdeny != 4) |
2086 | 1379 return; |
1380 toc_set_permit_deny(gc); | |
1381 } | |
1382 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
1383 static GList *toc_away_states(struct gaim_connection *gc) |
2086 | 1384 { |
1385 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | |
1386 } | |
1387 | |
4333 | 1388 static GList *toc_actions(struct gaim_connection *gc) |
2086 | 1389 { |
1390 GList *m = NULL; | |
4333 | 1391 struct proto_actions_menu *pam; |
2086 | 1392 |
4333 | 1393 pam = g_new0(struct proto_actions_menu, 1); |
1394 pam->label = _("Set User Info"); | |
1395 pam->callback = show_set_info; | |
1396 pam->gc = gc; | |
1397 m = g_list_append(m, pam); | |
1398 | |
1399 pam = g_new0(struct proto_actions_menu, 1); | |
1400 pam->label = _("Set Dir Info"); | |
1401 pam->callback = show_set_dir; | |
1402 pam->gc = gc; | |
1403 m = g_list_append(m, pam); | |
1404 | |
1405 pam = g_new0(struct proto_actions_menu, 1); | |
1406 pam->label = _("Change Password"); | |
1407 pam->callback = show_change_passwd; | |
1408 pam->gc = gc; | |
1409 m = g_list_append(m, pam); | |
2086 | 1410 |
1411 return m; | |
1412 } | |
1413 | |
3630 | 1414 G_MODULE_EXPORT void toc_init(struct prpl *ret) |
3572 | 1415 { |
1416 struct proto_user_opt *puo; | |
2086 | 1417 ret->protocol = PROTO_TOC; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1418 ret->options = OPT_PROTO_CORRECT_TIME; |
3572 | 1419 ret->name = g_strdup("TOC"); |
2086 | 1420 ret->list_icon = toc_list_icon; |
1421 ret->away_states = toc_away_states; | |
1422 ret->actions = toc_actions; | |
1423 ret->buddy_menu = toc_buddy_menu; | |
1424 ret->login = toc_login; | |
1425 ret->close = toc_close; | |
1426 ret->send_im = toc_send_im; | |
1427 ret->set_info = toc_set_info; | |
1428 ret->get_info = toc_get_info; | |
1429 ret->set_away = toc_set_away; | |
1430 ret->set_dir = toc_set_dir; | |
1431 ret->get_dir = toc_get_dir; | |
1432 ret->dir_search = toc_dir_search; | |
1433 ret->set_idle = toc_set_idle; | |
1434 ret->change_passwd = toc_change_passwd; | |
1435 ret->add_buddy = toc_add_buddy; | |
1436 ret->add_buddies = toc_add_buddies; | |
1437 ret->remove_buddy = toc_remove_buddy; | |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1438 ret->remove_buddies = toc_remove_buddies; |
2086 | 1439 ret->add_permit = toc_add_permit; |
1440 ret->add_deny = toc_add_deny; | |
1441 ret->rem_permit = toc_rem_permit; | |
1442 ret->rem_deny = toc_rem_deny; | |
1443 ret->set_permit_deny = toc_set_permit_deny; | |
1444 ret->warn = toc_warn; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1445 ret->chat_info = toc_chat_info; |
2086 | 1446 ret->join_chat = toc_join_chat; |
1447 ret->chat_invite = toc_chat_invite; | |
1448 ret->chat_leave = toc_chat_leave; | |
1449 ret->chat_whisper = toc_chat_whisper; | |
1450 ret->chat_send = toc_chat_send; | |
1451 ret->keepalive = toc_keepalive; | |
1452 | |
3572 | 1453 puo = g_new0(struct proto_user_opt, 1); |
4115 | 1454 puo->label = g_strdup(_("TOC Host:")); |
3572 | 1455 puo->def = g_strdup("toc.oscar.aol.com"); |
1456 puo->pos = USEROPT_AUTH; | |
1457 ret->user_opts = g_list_append(ret->user_opts, puo); | |
1458 | |
1459 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 1460 puo->label = g_strdup(_("TOC Port:")); |
3572 | 1461 puo->def = g_strdup("9898"); |
1462 puo->pos = USEROPT_AUTHPORT; | |
1463 ret->user_opts = g_list_append(ret->user_opts, puo); | |
1464 | |
2086 | 1465 my_protocol = ret; |
1466 } | |
1467 | |
1468 #ifndef STATIC | |
1469 | |
3630 | 1470 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 1471 { |
3572 | 1472 toc_init(prpl); |
1473 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 1474 } |
1475 | |
1476 #endif | |
1477 | |
1478 /********* | |
1479 * RVOUS ACTIONS | |
1480 ********/ | |
1481 | |
1482 struct file_header { | |
1483 char magic[4]; /* 0 */ | |
1484 short hdrlen; /* 4 */ | |
1485 short hdrtype; /* 6 */ | |
1486 char bcookie[8]; /* 8 */ | |
1487 short encrypt; /* 16 */ | |
1488 short compress; /* 18 */ | |
1489 short totfiles; /* 20 */ | |
1490 short filesleft; /* 22 */ | |
1491 short totparts; /* 24 */ | |
1492 short partsleft; /* 26 */ | |
1493 long totsize; /* 28 */ | |
1494 long size; /* 32 */ | |
1495 long modtime; /* 36 */ | |
1496 long checksum; /* 40 */ | |
1497 long rfrcsum; /* 44 */ | |
1498 long rfsize; /* 48 */ | |
1499 long cretime; /* 52 */ | |
1500 long rfcsum; /* 56 */ | |
1501 long nrecvd; /* 60 */ | |
1502 long recvcsum; /* 64 */ | |
1503 char idstring[32]; /* 68 */ | |
1504 char flags; /* 100 */ | |
1505 char lnameoffset; /* 101 */ | |
1506 char lsizeoffset; /* 102 */ | |
1507 char dummy[69]; /* 103 */ | |
1508 char macfileinfo[16]; /* 172 */ | |
1509 short nencode; /* 188 */ | |
1510 short nlanguage; /* 190 */ | |
1511 char name[64]; /* 192 */ | |
1512 /* 256 */ | |
1513 }; | |
1514 | |
1515 struct file_transfer { | |
1516 struct file_header hdr; | |
1517 | |
1518 struct gaim_connection *gc; | |
1519 | |
1520 char *user; | |
1521 char *cookie; | |
1522 char *ip; | |
1523 int port; | |
1524 long size; | |
1525 struct stat st; | |
1526 | |
1527 GtkWidget *window; | |
1528 int files; | |
1529 char *filename; | |
1530 FILE *file; | |
1531 int recvsize; | |
1532 | |
1533 gint inpa; | |
1534 }; | |
1535 | |
1536 static void debug_header(struct file_transfer *ft) { | |
1537 struct file_header *f = (struct file_header *)ft; | |
1538 debug_printf("TOC FT HEADER:\n" | |
1539 "\t%s %d 0x%04x\n" | |
1540 "\t%s %d %d\n" | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1541 "\t%d %d %d %d %d %d\n" |
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1542 "\t%d %d %d %d %d %d %d %d\n" |
2086 | 1543 "\t%s\n" |
1544 "\t0x%02x, 0x%02x, 0x%02x\n" | |
1545 "\t%s %s\n" | |
1546 "\t%d %d\n" | |
1547 "\t%s\n", | |
1548 f->magic, ntohs(f->hdrlen), f->hdrtype, | |
1549 f->bcookie, ntohs(f->encrypt), ntohs(f->compress), | |
1550 ntohs(f->totfiles), ntohs(f->filesleft), ntohs(f->totparts), | |
1551 ntohs(f->partsleft), ntohl(f->totsize), ntohl(f->size), | |
1552 ntohl(f->modtime), ntohl(f->checksum), ntohl(f->rfrcsum), ntohl(f->rfsize), | |
1553 ntohl(f->cretime), ntohl(f->rfcsum), ntohl(f->nrecvd), | |
1554 ntohl(f->recvcsum), | |
1555 f->idstring, | |
1556 f->flags, f->lnameoffset, f->lsizeoffset, | |
1557 f->dummy, f->macfileinfo, | |
1558 ntohs(f->nencode), ntohs(f->nlanguage), | |
1559 f->name); | |
1560 } | |
1561 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1562 static void toc_send_file_callback(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1563 { |
1564 char buf[BUF_LONG]; | |
1565 int rt, i; | |
1566 | |
1567 struct file_transfer *ft = data; | |
1568 | |
1569 if (ft->hdr.hdrtype != 0x202) { | |
1570 char *buf; | |
1571 frombase64(ft->cookie, &buf, NULL); | |
1572 | |
3630 | 1573 toc_read(source, ft, 8); |
1574 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1575 debug_header(ft); |
1576 | |
1577 ft->hdr.hdrtype = 0x202; | |
1578 memcpy(ft->hdr.bcookie, buf, 8); | |
1579 g_free(buf); | |
1580 ft->hdr.encrypt = 0; ft->hdr.compress = 0; | |
1581 debug_header(ft); | |
3630 | 1582 toc_write(source, ft, 256); |
2086 | 1583 |
1584 if (ft->files == 1) { | |
1585 ft->file = fopen(ft->filename, "w"); | |
1586 if (!ft->file) { | |
4115 | 1587 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); |
3427 | 1588 do_error_dialog(buf, strerror(errno), GAIM_ERROR); |
2086 | 1589 g_free(buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1590 gaim_input_remove(ft->inpa); |
3630 | 1591 toc_soc_close(source); |
2086 | 1592 g_free(ft->filename); |
1593 g_free(ft->user); | |
1594 g_free(ft->ip); | |
1595 g_free(ft->cookie); | |
1596 g_free(ft); | |
1597 } | |
1598 } else { | |
1599 buf = g_strdup_printf("%s/%s", ft->filename, ft->hdr.name); | |
1600 ft->file = fopen(buf, "w"); | |
1601 g_free(buf); | |
1602 if (!ft->file) { | |
1603 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | |
1604 ft->hdr.name); | |
3427 | 1605 do_error_dialog(buf, strerror(errno), GAIM_ERROR); |
2086 | 1606 g_free(buf); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1607 gaim_input_remove(ft->inpa); |
3630 | 1608 toc_soc_close(source); |
2086 | 1609 g_free(ft->filename); |
1610 g_free(ft->user); | |
1611 g_free(ft->ip); | |
1612 g_free(ft->cookie); | |
1613 g_free(ft); | |
1614 } | |
1615 } | |
1616 | |
1617 return; | |
1618 } | |
1619 | |
3630 | 1620 rt = toc_read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
2086 | 1621 if (rt < 0) { |
3427 | 1622 do_error_dialog("File transfer failed; other side probably canceled.", NULL, GAIM_ERROR); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1623 gaim_input_remove(ft->inpa); |
3630 | 1624 toc_soc_close(source); |
2086 | 1625 g_free(ft->user); |
1626 g_free(ft->ip); | |
1627 g_free(ft->cookie); | |
1628 if (ft->file) | |
1629 fclose(ft->file); | |
1630 g_free(ft); | |
1631 return; | |
1632 } | |
1633 ft->recvsize += rt; | |
1634 for (i = 0; i < rt; i++) | |
1635 fprintf(ft->file, "%c", buf[i]); | |
1636 | |
1637 if (ft->recvsize == ntohl(ft->hdr.size)) { | |
1638 ft->hdr.hdrtype = htons(0x0204); | |
1639 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); | |
1640 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); | |
1641 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ | |
1642 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); | |
1643 ft->hdr.flags = 0; | |
3630 | 1644 toc_write(source, ft, 256); |
2086 | 1645 debug_header(ft); |
1646 ft->recvsize = 0; | |
1647 fclose(ft->file); | |
1648 if (ft->hdr.filesleft == 0) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1649 gaim_input_remove(ft->inpa); |
3630 | 1650 toc_soc_close(source); |
2086 | 1651 g_free(ft->filename); |
1652 g_free(ft->user); | |
1653 g_free(ft->ip); | |
1654 g_free(ft->cookie); | |
1655 g_free(ft); | |
1656 } | |
1657 } | |
1658 } | |
1659 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1660 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) |
2086 | 1661 { |
1662 struct file_transfer *ft = data; | |
1663 | |
1664 if (src == -1) { | |
3427 | 1665 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); |
2086 | 1666 g_free(ft->filename); |
1667 g_free(ft->cookie); | |
1668 g_free(ft->user); | |
1669 g_free(ft->ip); | |
1670 g_free(ft); | |
1671 return; | |
1672 } | |
1673 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1674 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_send_file_callback, ft); |
2086 | 1675 } |
1676 | |
1677 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | |
1678 { | |
1679 struct file_transfer *ft; | |
1680 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
4491 | 1681 struct gaim_account *account; |
2086 | 1682 char buf[BUF_LEN * 2]; |
1683 | |
1684 if (file_is_dir(dirname, old_ft->window)) | |
1685 return; | |
1686 ft = g_new0(struct file_transfer, 1); | |
1687 if (old_ft->files == 1) | |
1688 ft->filename = g_strdup(dirname); | |
1689 else | |
1690 ft->filename = g_dirname(dirname); | |
1691 ft->cookie = g_strdup(old_ft->cookie); | |
1692 ft->user = g_strdup(old_ft->user); | |
1693 ft->ip = g_strdup(old_ft->ip); | |
1694 ft->files = old_ft->files; | |
1695 ft->port = old_ft->port; | |
1696 ft->gc = old_ft->gc; | |
4491 | 1697 account = ft->gc->account; |
2086 | 1698 gtk_widget_destroy(old_ft->window); |
1699 | |
1700 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | |
1701 sflap_send(ft->gc, buf, -1, TYPE_DATA); | |
1702 | |
4452 | 1703 if (proxy_connect(ft->ip, ft->port, toc_send_file_connect, ft) != 0) { |
3427 | 1704 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); |
2086 | 1705 g_free(ft->filename); |
1706 g_free(ft->cookie); | |
1707 g_free(ft->user); | |
1708 g_free(ft->ip); | |
1709 g_free(ft); | |
1710 return; | |
1711 } | |
1712 } | |
1713 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1714 static void toc_get_file_callback(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1715 { |
1716 char buf[BUF_LONG]; | |
1717 | |
1718 struct file_transfer *ft = data; | |
1719 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1720 if (cond & GAIM_INPUT_WRITE) { |
2086 | 1721 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); |
1722 int i; | |
1723 for (i = 0; i < remain; i++) | |
1724 fscanf(ft->file, "%c", &buf[i]); | |
3630 | 1725 toc_write(source, buf, remain); |
2086 | 1726 ft->recvsize += remain; |
1727 if (ft->recvsize == ntohl(ft->hdr.totsize)) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1728 gaim_input_remove(ft->inpa); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1729 ft->inpa = gaim_input_add(source, GAIM_INPUT_READ, |
2086 | 1730 toc_get_file_callback, ft); |
1731 } | |
1732 return; | |
1733 } | |
1734 | |
1735 if (ft->hdr.hdrtype == htons(0x1108)) { | |
1736 struct tm *fortime; | |
1737 struct stat st; | |
1738 | |
3630 | 1739 toc_read(source, ft, 8); |
1740 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1741 debug_header(ft); |
1742 | |
1743 stat(ft->filename, &st); | |
1744 fortime = localtime(&st.st_mtime); | |
1745 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", | |
1746 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, | |
1747 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, | |
1748 g_basename(ft->filename)); | |
3630 | 1749 toc_write(source, buf, ntohl(ft->hdr.size)); |
2086 | 1750 return; |
1751 } | |
1752 | |
1753 if (ft->hdr.hdrtype == htons(0x1209)) { | |
3630 | 1754 toc_read(source, ft, 8); |
1755 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1756 debug_header(ft); |
1757 return; | |
1758 } | |
1759 | |
1760 if (ft->hdr.hdrtype == htons(0x120b)) { | |
3630 | 1761 toc_read(source, ft, 8); |
1762 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1763 debug_header(ft); |
1764 | |
1765 if (ft->hdr.hdrtype != htons(0x120c)) { | |
1766 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); | |
3427 | 1767 do_error_dialog(buf, NULL, GAIM_ERROR); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1768 gaim_input_remove(ft->inpa); |
3630 | 1769 toc_soc_close(source); |
2086 | 1770 g_free(ft->filename); |
1771 g_free(ft->user); | |
1772 g_free(ft->ip); | |
1773 g_free(ft->cookie); | |
1774 if (ft->file) | |
1775 fclose(ft->file); | |
1776 g_free(ft); | |
1777 return; | |
1778 } | |
1779 | |
1780 ft->hdr.hdrtype = 0x0101; | |
1781 ft->hdr.totfiles = htons(1); ft->hdr.filesleft = htons(1); | |
1782 ft->hdr.flags = 0x20; | |
3630 | 1783 toc_write(source, ft, 256); |
2086 | 1784 return; |
1785 } | |
1786 | |
1787 if (ft->hdr.hdrtype == 0x0101) { | |
3630 | 1788 toc_read(source, ft, 8); |
1789 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1790 debug_header(ft); |
1791 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1792 gaim_input_remove(ft->inpa); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1793 ft->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, |
2086 | 1794 toc_get_file_callback, ft); |
1795 return; | |
1796 } | |
1797 | |
1798 if (ft->hdr.hdrtype == 0x0202) { | |
3630 | 1799 toc_read(source, ft, 8); |
1800 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
2086 | 1801 debug_header(ft); |
1802 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1803 gaim_input_remove(ft->inpa); |
3630 | 1804 toc_soc_close(source); |
2086 | 1805 g_free(ft->filename); |
1806 g_free(ft->user); | |
1807 g_free(ft->ip); | |
1808 g_free(ft->cookie); | |
1809 if (ft->file) | |
1810 fclose(ft->file); | |
1811 g_free(ft); | |
1812 return; | |
1813 } | |
1814 } | |
1815 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1816 static void toc_get_file_connect(gpointer data, gint src, GaimInputCondition cond) |
2086 | 1817 { |
1818 struct file_transfer *ft = data; | |
1819 struct file_header *hdr; | |
1820 char *buf; | |
1821 | |
1822 if (src == -1) { | |
3427 | 1823 do_error_dialog(_("Could not connect for transfer!"), NULL, GAIM_ERROR); |
2086 | 1824 fclose(ft->file); |
1825 g_free(ft->filename); | |
1826 g_free(ft->cookie); | |
1827 g_free(ft->user); | |
1828 g_free(ft->ip); | |
1829 g_free(ft); | |
1830 return; | |
1831 } | |
1832 | |
1833 hdr = (struct file_header *)ft; | |
1834 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | |
1835 hdr->hdrlen = htons(256); | |
1836 hdr->hdrtype = htons(0x1108); | |
1837 frombase64(ft->cookie, &buf, NULL); | |
1838 g_snprintf(hdr->bcookie, 8, "%s", buf); | |
1839 g_free(buf); | |
1840 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | |
1841 hdr->totparts = htons(1); hdr->partsleft = htons(1); | |
1842 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ | |
1843 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ | |
1844 hdr->size = htonl(28 + strlen(g_basename(ft->filename))); /* size of listing.txt */ | |
1845 hdr->modtime = htonl(ft->st.st_mtime); | |
1846 hdr->checksum = htonl(0x89f70000); /* uh... */ | |
1847 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); | |
1848 hdr->flags = 0x02; | |
1849 hdr->lnameoffset = 0x1A; | |
1850 hdr->lsizeoffset = 0x10; | |
1851 g_snprintf(hdr->name, 64, "listing.txt"); | |
3630 | 1852 if (toc_write(src, hdr, 256) < 0) { |
3427 | 1853 do_error_dialog(_("Could not write file header. The file will not be transferred."), NULL, GAIM_ERROR); |
2086 | 1854 fclose(ft->file); |
1855 g_free(ft->filename); | |
1856 g_free(ft->cookie); | |
1857 g_free(ft->user); | |
1858 g_free(ft->ip); | |
1859 g_free(ft); | |
1860 return; | |
1861 } | |
1862 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1863 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_get_file_callback, ft); |
2086 | 1864 } |
1865 | |
1866 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | |
1867 { | |
1868 struct file_transfer *ft; | |
1869 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
4491 | 1870 struct gaim_account *account; |
2086 | 1871 char *buf, buf2[BUF_LEN * 2]; |
1872 | |
1873 if (file_is_dir(dirname, old_ft->window)) | |
1874 return; | |
1875 ft = g_new0(struct file_transfer, 1); | |
1876 ft->filename = g_strdup(dirname); | |
1877 ft->file = fopen(ft->filename, "r"); | |
1878 if (!ft->file) { | |
3427 | 1879 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); |
1880 do_error_dialog(buf, NULL, GAIM_ERROR); | |
2086 | 1881 g_free(buf); |
1882 g_free(ft->filename); | |
1883 g_free(ft); | |
1884 return; | |
1885 } | |
1886 if (stat(dirname, &ft->st)) { | |
3427 | 1887 buf = g_strdup_printf("Unable to examine %s.", dirname); |
1888 do_error_dialog(buf, NULL, GAIM_ERROR); | |
2086 | 1889 g_free(buf); |
1890 g_free(ft->filename); | |
1891 g_free(ft); | |
1892 return; | |
1893 } | |
1894 ft->cookie = g_strdup(old_ft->cookie); | |
1895 ft->user = g_strdup(old_ft->user); | |
1896 ft->ip = g_strdup(old_ft->ip); | |
1897 ft->port = old_ft->port; | |
1898 ft->gc = old_ft->gc; | |
4491 | 1899 account = ft->gc->account; |
2086 | 1900 gtk_widget_destroy(old_ft->window); |
1901 | |
1902 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | |
1903 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | |
1904 | |
4452 | 1905 if (proxy_connect(ft->ip, ft->port, toc_get_file_connect, ft) < 0) { |
3427 | 1906 do_error_dialog(_("Could not connect for transfer."), NULL, GAIM_ERROR); |
2086 | 1907 fclose(ft->file); |
1908 g_free(ft->filename); | |
1909 g_free(ft->cookie); | |
1910 g_free(ft->user); | |
1911 g_free(ft->ip); | |
1912 g_free(ft); | |
1913 return; | |
1914 } | |
1915 } | |
1916 | |
1917 static void cancel_callback(gpointer a, struct file_transfer *ft) { | |
1918 gtk_widget_destroy(ft->window); | |
1919 if (a == ft->window) { | |
1920 g_free(ft->cookie); | |
1921 g_free(ft->user); | |
1922 g_free(ft->ip); | |
1923 g_free(ft); | |
1924 } | |
1925 } | |
1926 | |
3867 | 1927 static void toc_reject_ft(struct ft_request *ft) { |
1928 g_free(ft->user); | |
1929 g_free(ft->filename); | |
1930 g_free(ft->ip); | |
1931 g_free(ft->cookie); | |
1932 if (ft->message) | |
1933 g_free(ft->message); | |
1934 g_free(ft); | |
1935 } | |
1936 | |
1937 | |
3730 | 1938 static void toc_accept_ft(struct ft_request *fr) { |
4249 | 1939 if(g_slist_find(connections, fr->gc)) { |
1940 GtkWidget *window; | |
1941 char buf[BUF_LEN]; | |
2086 | 1942 |
4249 | 1943 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
1944 ft->gc = fr->gc; | |
1945 ft->user = g_strdup(fr->user); | |
1946 ft->cookie = g_strdup(fr->cookie); | |
1947 ft->ip = g_strdup(fr->ip); | |
1948 ft->port = fr->port; | |
1949 ft->files = fr->files; | |
2086 | 1950 |
4249 | 1951 ft->window = window = gtk_file_selection_new(_("Gaim - Save As...")); |
1952 g_snprintf(buf, sizeof(buf), "%s/%s", gaim_home_dir(), fr->filename ? fr->filename : ""); | |
1953 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
1954 gtk_signal_connect(GTK_OBJECT(window), "destroy", | |
1955 GTK_SIGNAL_FUNC(cancel_callback), ft); | |
1956 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), "clicked", | |
1957 GTK_SIGNAL_FUNC(cancel_callback), ft); | |
2086 | 1958 |
4249 | 1959 if (!strcmp(fr->UID, FILE_SEND_UID)) |
1960 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), "clicked", | |
1961 GTK_SIGNAL_FUNC(toc_send_file), ft); | |
1962 else | |
1963 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(window)->ok_button), "clicked", | |
1964 GTK_SIGNAL_FUNC(toc_get_file), ft); | |
2086 | 1965 |
4249 | 1966 gtk_widget_show(window); |
1967 } | |
1968 | |
3867 | 1969 toc_reject_ft(fr); |
2086 | 1970 } |
1971 | |
1972 static void accept_file_dialog(struct ft_request *ft) { | |
1973 char buf[BUF_LONG]; | |
1974 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
1975 /* holy crap. who the fuck would transfer gigabytes through AIM?! */ | |
1976 static char *sizes[4] = { "bytes", "KB", "MB", "GB" }; | |
1977 float size = ft->size; | |
1978 int index = 0; | |
1979 while ((index < 4) && (size > 1024)) { | |
1980 size /= 1024; | |
1981 index++; | |
1982 } | |
2943 | 1983 g_snprintf(buf, sizeof(buf), |
4276 | 1984 ngettext( |
1985 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | |
1986 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | |
1987 ft->files), | |
2943 | 1988 ft->user, ft->gc->username, ft->files, |
2086 | 1989 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
1990 (ft->message) ? ft->message : ""); | |
1991 } else { | |
1992 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | |
1993 } | |
4249 | 1994 do_ask_dialog(buf, NULL, ft, _("Accept"), toc_accept_ft, _("Cancel"), toc_reject_ft, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
2086 | 1995 } |