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