Mercurial > pidgin.yaz
annotate src/rvous.c @ 1406:cabde2947ba4
[gaim-migrate @ 1416]
bah
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 13 Jan 2001 09:05:41 +0000 |
parents | b5783215b245 |
children |
rev | line source |
---|---|
198 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
264
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
264
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
264
diff
changeset
|
24 #endif |
198 | 25 #include <string.h> |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <time.h> | |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
31 #include <fcntl.h> | |
32 #include <sys/socket.h> | |
33 #include <netdb.h> | |
34 #include <netinet/in.h> | |
35 #include <unistd.h> | |
36 #include <netinet/in.h> | |
37 #include <arpa/inet.h> | |
218 | 38 #include <errno.h> |
198 | 39 #include <gtk/gtk.h> |
1092
a930439f29b1
[gaim-migrate @ 1102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
40 #include "proxy.h" |
198 | 41 #include "gaim.h" |
42 | |
1106
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
43 #define TYPE_DATA 2 /* from toc.c */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
44 |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
45 struct file_header { |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
46 char magic[4]; /* 0 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
47 short hdrlen; /* 4 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
48 short hdrtype; /* 6 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
49 char bcookie[8]; /* 8 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
50 short encrypt; /* 16 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
51 short compress; /* 18 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
52 short totfiles; /* 20 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
53 short filesleft; /* 22 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
54 short totparts; /* 24 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
55 short partsleft; /* 26 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
56 long totsize; /* 28 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
57 long size; /* 32 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
58 long modtime; /* 36 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
59 long checksum; /* 40 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
60 long rfrcsum; /* 44 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
61 long rfsize; /* 48 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
62 long cretime; /* 52 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
63 long rfcsum; /* 56 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
64 long nrecvd; /* 60 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
65 long recvcsum; /* 64 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
66 char idstring[32]; /* 68 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
67 char flags; /* 100 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
68 char lnameoffset; /* 101 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
69 char lsizeoffset; /* 102 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
70 char dummy[69]; /* 103 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
71 char macfileinfo[16]; /* 172 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
72 short nencode; /* 188 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
73 short nlanguage; /* 190 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
74 char name[64]; /* 192 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
75 /* 256 */ |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
76 }; |
5bc8fdacd2cb
[gaim-migrate @ 1116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1102
diff
changeset
|
77 |
198 | 78 static void do_send_file(GtkWidget *, struct file_transfer *); |
79 static void do_get_file (GtkWidget *, struct file_transfer *); | |
1114
c61f9c384413
[gaim-migrate @ 1124]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1106
diff
changeset
|
80 extern int sflap_send(struct gaim_connection *, char *, int, int); |
198 | 81 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
82 static int snpa = -1; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
83 |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
84 static void toggle(GtkWidget *w, int *m) |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
85 { |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
86 *m = !(*m); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
87 } |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
88 |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
89 static void free_ft(struct file_transfer *ft) |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
90 { |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
91 if (ft->window) { gtk_widget_destroy(ft->window); ft->window = NULL; } |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
92 if (ft->filename) g_free(ft->filename); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
93 if (ft->user) g_free(ft->user); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
94 if (ft->message) g_free(ft->message); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
95 if (ft->ip) g_free(ft->ip); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
96 if (ft->cookie) g_free(ft->cookie); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
97 g_free(ft); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
98 } |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
99 |
198 | 100 static void warn_callback(GtkWidget *widget, struct file_transfer *ft) |
101 { | |
978
563c409e26a1
[gaim-migrate @ 988]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
102 show_warn_dialog(ft->gc, ft->user); |
198 | 103 } |
104 | |
105 static void info_callback(GtkWidget *widget, struct file_transfer *ft) | |
106 { | |
1032
643a4d81c18a
[gaim-migrate @ 1042]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
978
diff
changeset
|
107 serv_get_info(ft->gc, ft->user); |
198 | 108 } |
109 | |
110 static void cancel_callback(GtkWidget *widget, struct file_transfer *ft) | |
111 { | |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
112 char buf[MSG_LEN]; |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
113 |
198 | 114 if (ft->accepted) { |
115 return; | |
116 } | |
117 | |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
118 g_snprintf(buf, MSG_LEN, "toc_rvous_cancel %s %s %s", ft->user, ft->cookie, ft->UID); |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
119 sflap_send(ft->gc, buf, -1, TYPE_DATA); |
260
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
120 |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
121 free_ft(ft); |
198 | 122 } |
123 | |
124 static void accept_callback(GtkWidget *widget, struct file_transfer *ft) | |
125 { | |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
126 char buf[BUF_LEN]; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
127 char fname[BUF_LEN]; |
198 | 128 char *c; |
129 | |
130 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
131 c = ft->filename + strlen(ft->filename); | |
132 | |
133 while (c != ft->filename) { | |
134 if (*c == '/' || *c == '\\') { | |
135 strcpy(fname, c+1); | |
136 break; | |
137 } | |
138 c--; | |
139 } | |
140 | |
141 if (c == ft->filename) | |
142 strcpy(fname, ft->filename); | |
143 } | |
144 | |
145 gtk_widget_destroy(ft->window); | |
146 ft->window = NULL; | |
147 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
148 ft->window = gtk_file_selection_new(_("Gaim - Save As...")); |
198 | 149 |
150 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(ft->window)); | |
151 | |
152 if (!strcmp(ft->UID, FILE_SEND_UID)) | |
153 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), fname); | |
154 else | |
155 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME")); | |
156 gtk_file_selection_set_filename(GTK_FILE_SELECTION(ft->window), buf); | |
157 | |
158 gtk_signal_connect(GTK_OBJECT(ft->window), "destroy", | |
159 GTK_SIGNAL_FUNC(cancel_callback), ft); | |
160 | |
161 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
162 gtk_signal_connect(GTK_OBJECT( | |
163 GTK_FILE_SELECTION(ft->window)->ok_button), | |
164 "clicked", GTK_SIGNAL_FUNC(do_get_file), ft); | |
165 } else { | |
166 gtk_signal_connect(GTK_OBJECT( | |
167 GTK_FILE_SELECTION(ft->window)->ok_button), | |
168 "clicked", GTK_SIGNAL_FUNC(do_send_file), ft); | |
169 } | |
170 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | |
171 "clicked", GTK_SIGNAL_FUNC(cancel_callback), ft); | |
172 | |
173 gtk_widget_show(ft->window); | |
174 } | |
175 | |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
176 static int read_file_header(int fd, struct file_header *header) { |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
177 char buf[257]; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
178 int read_rv = read(fd, buf, 256); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
179 if (read_rv < 0) |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
180 return read_rv; |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
181 memcpy(&header->magic, buf + 0, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
182 memcpy(&header->hdrlen, buf + 4, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
183 memcpy(&header->hdrtype, buf + 6, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
184 memcpy(&header->bcookie, buf + 8, 8); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
185 memcpy(&header->encrypt, buf + 16, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
186 memcpy(&header->compress, buf + 18, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
187 memcpy(&header->totfiles, buf + 20, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
188 memcpy(&header->filesleft, buf + 22, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
189 memcpy(&header->totparts, buf + 24, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
190 memcpy(&header->partsleft, buf + 26, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
191 memcpy(&header->totsize, buf + 28, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
192 memcpy(&header->size, buf + 32, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
193 memcpy(&header->modtime, buf + 36, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
194 memcpy(&header->checksum, buf + 40, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
195 memcpy(&header->rfrcsum, buf + 44, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
196 memcpy(&header->rfsize, buf + 48, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
197 memcpy(&header->cretime, buf + 52, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
198 memcpy(&header->rfcsum, buf + 56, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
199 memcpy(&header->nrecvd, buf + 60, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
200 memcpy(&header->recvcsum, buf + 64, 4); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
201 memcpy(&header->idstring, buf + 68, 32); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
202 memcpy(&header->flags, buf + 100, 1); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
203 memcpy(&header->lnameoffset, buf + 101, 1); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
204 memcpy(&header->lsizeoffset, buf + 102, 1); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
205 memcpy(&header->dummy, buf + 103, 69); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
206 memcpy(&header->macfileinfo, buf + 172, 16); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
207 memcpy(&header->nencode, buf + 188, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
208 memcpy(&header->nlanguage, buf + 190, 2); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
209 memcpy(&header->name, buf + 192, 64); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
210 return read_rv; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
211 } |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
212 |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
213 static int write_file_header(int fd, struct file_header *header) { |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
214 char buf[257]; |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
215 memcpy(buf + 0, &header->magic, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
216 memcpy(buf + 4, &header->hdrlen, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
217 memcpy(buf + 6, &header->hdrtype, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
218 memcpy(buf + 8, &header->bcookie, 8); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
219 memcpy(buf + 16, &header->encrypt, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
220 memcpy(buf + 18, &header->compress, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
221 memcpy(buf + 20, &header->totfiles, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
222 memcpy(buf + 22, &header->filesleft, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
223 memcpy(buf + 24, &header->totparts, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
224 memcpy(buf + 26, &header->partsleft, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
225 memcpy(buf + 28, &header->totsize, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
226 memcpy(buf + 32, &header->size, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
227 memcpy(buf + 36, &header->modtime, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
228 memcpy(buf + 40, &header->checksum, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
229 memcpy(buf + 44, &header->rfrcsum, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
230 memcpy(buf + 48, &header->rfsize, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
231 memcpy(buf + 52, &header->cretime, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
232 memcpy(buf + 56, &header->rfcsum, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
233 memcpy(buf + 60, &header->nrecvd, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
234 memcpy(buf + 64, &header->recvcsum, 4); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
235 memcpy(buf + 68, &header->idstring, 32); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
236 memcpy(buf + 100, &header->flags, 1); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
237 memcpy(buf + 101, &header->lnameoffset, 1); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
238 memcpy(buf + 102, &header->lsizeoffset, 1); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
239 memcpy(buf + 103, &header->dummy, 69); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
240 memcpy(buf + 172, &header->macfileinfo, 16); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
241 memcpy(buf + 188, &header->nencode, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
242 memcpy(buf + 190, &header->nlanguage, 2); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
243 memcpy(buf + 192, &header->name, 64); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
244 return write(fd, buf, 256); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
245 } |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
246 |
198 | 247 static void do_get_file(GtkWidget *w, struct file_transfer *ft) |
248 { | |
249 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window)); | |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
250 char buf[BUF_LONG]; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
251 char *buf2; |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
252 char tmp_buf[MSG_LEN]; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
253 struct file_header header; |
198 | 254 int read_rv; |
255 guint32 rcv; | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
256 int cont = 1; |
212
89c9334d3484
[gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
211
diff
changeset
|
257 GtkWidget *fw = NULL, *fbar = NULL, *label = NULL; |
89c9334d3484
[gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
211
diff
changeset
|
258 GtkWidget *button = NULL, *pct = NULL; |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
259 |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
260 if (file_is_dir(file, ft->window)) { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
261 return; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
262 } |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
263 |
198 | 264 if (!(ft->f = fopen(file,"w"))) { |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
265 g_snprintf(buf, BUF_LONG / 2, _("Error writing file %s"), file); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
266 do_error_dialog(buf, _("Error")); |
198 | 267 ft->accepted = 0; |
268 accept_callback(NULL, ft); | |
269 return; | |
270 } | |
271 | |
272 ft->accepted = 1; | |
273 | |
274 gtk_widget_destroy(ft->window); | |
275 ft->window = NULL; | |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
276 g_snprintf(tmp_buf, MSG_LEN, "toc_rvous_accept %s %s %s", ft->user, ft->cookie, ft->UID); |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
277 sflap_send(ft->gc, tmp_buf, -1, TYPE_DATA); |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
278 |
198 | 279 |
1087
56c7ceb986a8
[gaim-migrate @ 1097]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1035
diff
changeset
|
280 |
56c7ceb986a8
[gaim-migrate @ 1097]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1035
diff
changeset
|
281 /* XXX is ft->port in host order or network order? */ |
1092
a930439f29b1
[gaim-migrate @ 1102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
282 ft->fd = proxy_connect(ft->ip, ft->port, NULL, 0, -1); |
198 | 283 |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
284 if (ft->fd <= -1) { |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
285 fclose(ft->f); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
286 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
287 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
288 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
289 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
290 read_rv = read_file_header(ft->fd, &header); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
291 if(read_rv < 0) { |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
292 close(ft->fd); |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
293 fclose(ft->f); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
294 free_ft(ft); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
295 return; |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
296 } |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
297 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
298 debug_printf("header length %d\n", header.hdrlen); |
198 | 299 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
300 header.hdrtype = 0x202; |
198 | 301 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
302 buf2 = frombase64(ft->cookie); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
303 memcpy(header.bcookie, buf2, 8); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
304 snprintf(header.idstring, 32, "Gaim"); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
305 g_free(buf2); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
306 header.encrypt = 0; header.compress = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
307 header.totparts = 1; header.partsleft = 1; |
198 | 308 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
309 debug_printf("sending confirmation\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
310 write_file_header(ft->fd, &header); |
198 | 311 |
312 rcv = 0; | |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
313 |
198 | 314 fw = gtk_dialog_new(); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
315 snprintf(buf, 2048, _("Receiving %s from %s"), ft->filename, ft->user); |
198 | 316 label = gtk_label_new(buf); |
317 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->vbox), label, 0, 0, 5); | |
318 gtk_widget_show(label); | |
319 fbar = gtk_progress_bar_new(); | |
320 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), fbar, 0, 0, 5); | |
321 gtk_widget_show(fbar); | |
212
89c9334d3484
[gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
211
diff
changeset
|
322 pct = gtk_label_new("0 %"); |
89c9334d3484
[gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
211
diff
changeset
|
323 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), pct, 0, 0, 5); |
89c9334d3484
[gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
211
diff
changeset
|
324 gtk_widget_show(pct); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
325 button = gtk_button_new_with_label(_("Cancel")); |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
326 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), button, 0, 0, 5); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
327 gtk_widget_show(button); |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
328 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
329 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
330 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)toggle, &cont); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
331 gtk_window_set_title(GTK_WINDOW(fw), _("Gaim - File Transfer")); |
198 | 332 gtk_widget_realize(fw); |
333 aol_icon(fw->window); | |
334 gtk_widget_show(fw); | |
335 | |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
336 debug_printf("Receiving %s from %s (%d bytes)\n", ft->filename, ft->user, ft->size); |
198 | 337 |
218 | 338 fcntl(ft->fd, F_SETFL, O_NONBLOCK); |
339 | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
340 while (rcv != ft->size && cont) { |
198 | 341 int i; |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
342 float pcnt = ((float)rcv)/((float)ft->size); |
198 | 343 int remain = ft->size - rcv > 1024 ? 1024 : ft->size - rcv; |
218 | 344 read_rv = read(ft->fd, buf, remain); |
198 | 345 if(read_rv < 0) { |
218 | 346 if (errno == EWOULDBLOCK) { |
347 while(gtk_events_pending()) | |
348 gtk_main_iteration(); | |
349 continue; | |
350 } | |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
351 gtk_widget_destroy(fw); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
352 fw = NULL; |
198 | 353 fclose(ft->f); |
354 close(ft->fd); | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
355 free_ft(ft); |
198 | 356 return; |
357 } | |
358 rcv += read_rv; | |
359 for (i = 0; i < read_rv; i++) | |
360 fprintf(ft->f, "%c", buf[i]); | |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
361 gtk_progress_bar_update(GTK_PROGRESS_BAR(fbar), pcnt); |
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
362 sprintf(buf, "%d / %d K (%2.0f %%)", rcv/1024, ft->size/1024, 100*pcnt); |
212
89c9334d3484
[gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
211
diff
changeset
|
363 gtk_label_set_text(GTK_LABEL(pct), buf); |
198 | 364 while(gtk_events_pending()) |
365 gtk_main_iteration(); | |
366 } | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
367 fclose(ft->f); |
201
d9a5f7b1d500
[gaim-migrate @ 211]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
368 gtk_widget_destroy(fw); |
d9a5f7b1d500
[gaim-migrate @ 211]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
369 fw = NULL; |
198 | 370 |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
371 if (!cont) { |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
372 g_snprintf(tmp_buf, MSG_LEN, "toc_rvous_cancel %s %s %s", ft->user, ft->cookie, ft->UID); |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
373 sflap_send(ft->gc, tmp_buf, -1, TYPE_DATA); |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
374 close(ft->fd); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
375 free_ft(ft); |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
376 return; |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
377 } |
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
378 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
379 debug_printf("Download complete.\n"); |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
380 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
381 header.hdrtype = 0x402; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
382 header.totparts = 0; header.partsleft = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
383 header.flags = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
384 header.recvcsum = header.checksum; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
385 header.nrecvd = header.totsize; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
386 write_file_header(ft->fd, &header); |
198 | 387 close(ft->fd); |
388 | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
198
diff
changeset
|
389 free_ft(ft); |
198 | 390 } |
391 | |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
392 static void send_file_callback(gpointer data, gint source, |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
393 GdkInputCondition condition) { |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
394 struct file_transfer *ft = (struct file_transfer *)data; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
395 struct file_header fhdr; |
198 | 396 int read_rv; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
397 char buf[2048]; |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
398 GtkWidget *fw = NULL, *fbar = NULL, *label = NULL; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
399 GtkWidget *button = NULL, *pct = NULL; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
400 int rcv, cont; |
198 | 401 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
402 gdk_input_remove(snpa); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
403 snpa = -1; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
404 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
405 if (condition & GDK_INPUT_EXCEPTION) { |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
406 fclose(ft->f); |
198 | 407 close(ft->fd); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
408 free_ft(ft); |
198 | 409 return; |
410 } | |
411 | |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
412 /* OK, so here's what's going on: we need to send a file. The person |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
413 * sends us a file_header, then we send a file_header, then they send |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
414 * us a file header, then we send the file, then they send a header, |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
415 * and we're done. */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
416 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
417 /* we can do some neat tricks because the other person sends us back |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
418 * all the information we need in the file_header */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
419 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
420 read_rv = read_file_header(ft->fd, &fhdr); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
421 if (read_rv < 0) { |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
422 fclose(ft->f); |
198 | 423 close(ft->fd); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
424 free_ft(ft); |
198 | 425 return; |
426 } | |
427 | |
264
ced25773243c
[gaim-migrate @ 274]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
261
diff
changeset
|
428 if (fhdr.hdrtype != 0xc12) { |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
429 debug_printf("%s decided to cancel. (%x)\n", ft->user, fhdr.hdrtype); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
430 fclose(ft->f); |
198 | 431 close(ft->fd); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
432 free_ft(ft); |
198 | 433 return; |
434 } | |
435 | |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
436 /* now we need to set the hdrtype to a certain value, but I don't know |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
437 * what that value is, and I don't happen to have a win computer to do |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
438 * my sniffing from :-P */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
439 fhdr.hdrtype = ntohs(0x101); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
440 fhdr.totfiles = 1; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
441 fhdr.filesleft = 1; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
442 fhdr.flags = 0x20; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
443 write_file_header(ft->fd, &fhdr); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
444 read_file_header(ft->fd, &fhdr); |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
445 |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
446 fw = gtk_dialog_new(); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
447 snprintf(buf, 2048, _("Sending %s to %s"), fhdr.name, ft->user); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
448 label = gtk_label_new(buf); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
449 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->vbox), label, 0, 0, 5); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
450 gtk_widget_show(label); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
451 fbar = gtk_progress_bar_new(); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
452 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), fbar, 0, 0, 5); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
453 gtk_widget_show(fbar); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
454 pct = gtk_label_new("0 %"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
455 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), pct, 0, 0, 5); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
456 gtk_widget_show(pct); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
457 button = gtk_button_new_with_label(_("Cancel")); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
458 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), button, 0, 0, 5); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
459 gtk_widget_show(button); |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
460 if (display_options & OPT_DISP_COOL_LOOK) |
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
461 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
462 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)toggle, &cont); |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
463 gtk_window_set_title(GTK_WINDOW(fw), _("Gaim - File Transfer")); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
464 gtk_widget_realize(fw); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
465 aol_icon(fw->window); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
466 gtk_widget_show(fw); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
467 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
468 debug_printf("Sending %s to %s (%ld bytes)\n", fhdr.name, ft->user, fhdr.totsize); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
469 |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
470 rcv = 0; cont = 1; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
471 while (rcv != ntohl(fhdr.totsize) && cont) { |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
472 int i; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
473 float pcnt = ((float)rcv)/((float)ntohl(fhdr.totsize)); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
474 int remain = ntohl(fhdr.totsize) - rcv > 1024 ? 1024 : |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
475 ntohl(fhdr.totsize) - rcv; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
476 for (i = 0; i < remain; i++) |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
477 fscanf(ft->f, "%c", &buf[i]); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
478 read_rv = write(ft->fd, buf, remain); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
479 if (read_rv < 0) { |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
480 fclose(ft->f); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
481 gtk_widget_destroy(fw); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
482 fw = NULL; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
483 fclose(ft->f); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
484 close(ft->fd); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
485 free_ft(ft); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
486 return; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
487 } |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
488 rcv += read_rv; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
489 gtk_progress_bar_update(GTK_PROGRESS_BAR(fbar), pcnt); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
490 sprintf(buf, "%d / %d K (%2.0f %%)", rcv/1024, |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
491 ntohl(fhdr.totsize)/1024, 100*pcnt); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
492 gtk_label_set_text(GTK_LABEL(pct), buf); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
493 while(gtk_events_pending()) |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
494 gtk_main_iteration(); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
495 } |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
496 fclose(ft->f); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
497 gtk_widget_destroy(fw); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
498 fw = NULL; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
499 |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
500 if (!cont) { |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
501 char tmp_buf[MSG_LEN]; |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
502 g_snprintf(tmp_buf, MSG_LEN, "toc_rvous_cancel %s %s %s", ft->user, ft->cookie, ft->UID); |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
503 sflap_send(ft->gc, tmp_buf, -1, TYPE_DATA); |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
504 close(ft->fd); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
505 free_ft(ft); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
506 return; |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
507 } |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
508 |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
509 debug_printf("Upload complete.\n"); |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
510 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
511 read_file_header(ft->fd, &fhdr); |
217
fba779cc01f5
[gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
216
diff
changeset
|
512 |
221
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
513 close(ft->fd); |
b2f9f629525e
[gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
218
diff
changeset
|
514 free_ft(ft); |
198 | 515 } |
516 | |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
517 static void do_send_file(GtkWidget *w, struct file_transfer *ft) { |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
518 char *file = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window))); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
519 char buf[BUF_LONG]; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
520 char *buf2; |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
521 char tmp_buf[MSG_LEN]; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
522 int read_rv; |
1162
37257f175ed8
[gaim-migrate @ 1172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
523 int at; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
524 struct file_header fhdr; |
411
a330017b3aa4
[gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
350
diff
changeset
|
525 guint32 rcv = 0; |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
526 char *c; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
527 struct stat st; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
528 struct tm *fortime; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
529 |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
530 if (file_is_dir (file, ft->window)) { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
531 g_free(file); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
532 return; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
533 } |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
534 |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
535 stat(file, &st); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
536 if (!(ft->f = fopen(file, "r"))) { |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
537 g_snprintf(buf, BUF_LONG / 2, _("Error reading file %s"), file); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
538 do_error_dialog(buf, _("Error")); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
539 ft->accepted = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
540 accept_callback(NULL, ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
541 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
542 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
543 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
544 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
545 ft->accepted = 1; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
546 ft->filename = file; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
547 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
548 gtk_widget_destroy(ft->window); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
549 ft->window = NULL; |
1102
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
550 g_snprintf(tmp_buf, MSG_LEN, "toc_rvous_accept %s %s %s", ft->user, ft->cookie, ft->UID); |
d7944415b1cc
[gaim-migrate @ 1112]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1092
diff
changeset
|
551 sflap_send(ft->gc, tmp_buf, -1, TYPE_DATA); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
552 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
553 |
1087
56c7ceb986a8
[gaim-migrate @ 1097]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1035
diff
changeset
|
554 /* XXX is ft->port in host order or network order? */ |
1092
a930439f29b1
[gaim-migrate @ 1102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1087
diff
changeset
|
555 ft->fd = proxy_connect(ft->ip, ft->port, NULL, 0, -1); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
556 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
557 if (ft->fd <= -1) { |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
558 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
559 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
560 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
561 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
562 /* here's where we differ from do_get_file */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
563 /* 1. build/send header |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
564 * 2. receive header |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
565 * 3. send listing file |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
566 * 4. receive header |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
567 * |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
568 * then we need to wait to actually send the file, if they want. |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
569 * |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
570 */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
571 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
572 /* 1. build/send header */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
573 c = file + strlen(file); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
574 while (*(c - 1) != '/') c--; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
575 buf2 = frombase64(ft->cookie); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
576 debug_printf("Building header to send %s (cookie: %s)\n", file, buf2); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
577 fhdr.magic[0] = 'O'; fhdr.magic[1] = 'F'; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
578 fhdr.magic[2] = 'T'; fhdr.magic[3] = '2'; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
579 fhdr.hdrlen = htons(256); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
580 fhdr.hdrtype = htons(0x1108); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
581 snprintf(fhdr.bcookie, 8, "%s", buf2); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
582 g_free(buf2); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
583 fhdr.encrypt = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
584 fhdr.compress = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
585 fhdr.totfiles = htons(1); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
586 fhdr.filesleft = htons(1); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
587 fhdr.totparts = htons(1); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
588 fhdr.partsleft = htons(1); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
589 fhdr.totsize = htonl((long)st.st_size); /* combined size of all files */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
590 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
591 fhdr.size = htonl(28 + strlen(c)); /* size of listing.txt */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
592 fhdr.modtime = htonl(time(NULL)); /* time since UNIX epoch */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
593 fhdr.checksum = htonl(0x89f70000); /* ? i don't think this matters */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
594 fhdr.rfrcsum = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
595 fhdr.rfsize = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
596 fhdr.cretime = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
597 fhdr.rfcsum = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
598 fhdr.nrecvd = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
599 fhdr.recvcsum = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
600 snprintf(fhdr.idstring, 32, "OFT_Windows ICBMFT V1.1 32"); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
601 fhdr.flags = 0x02; /* don't ask me why */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
602 fhdr.lnameoffset = 0x1A; /* ? still no clue */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
603 fhdr.lsizeoffset = 0x10; /* whatever */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
604 memset(fhdr.dummy, 0, 69); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
605 memset(fhdr.macfileinfo, 0, 16); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
606 fhdr.nencode = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
607 fhdr.nlanguage = 0; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
608 snprintf(fhdr.name, 64, "listing.txt"); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
609 read_rv = write_file_header(ft->fd, &fhdr); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
610 if (read_rv <= -1) { |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
611 debug_printf("Couldn't write opening header\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
612 close(ft->fd); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
613 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
614 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
615 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
616 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
617 /* 2. receive header */ |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
618 debug_printf("Receiving header\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
619 read_rv = read_file_header(ft->fd, &fhdr); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
620 if (read_rv <= -1) { |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
621 debug_printf("Couldn't read header\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
622 close(ft->fd); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
623 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
624 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
625 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
626 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
627 /* 3. send listing file */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
628 /* mm/dd/yyyy hh:mm sizesize name.ext\r\n */ |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
629 /* creation date ^ */ |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
630 debug_printf("Sending file\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
631 fortime = localtime(&st.st_ctime); |
1162
37257f175ed8
[gaim-migrate @ 1172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
632 at = g_snprintf(buf, ntohl(fhdr.size) + 1, "%2d/%2d/%4d %2d:%2d %8ld ", |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
633 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
634 fortime->tm_hour + 1, fortime->tm_min + 1, |
1233
728a90516211
[gaim-migrate @ 1243]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1162
diff
changeset
|
635 (long)st.st_size); |
1162
37257f175ed8
[gaim-migrate @ 1172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1114
diff
changeset
|
636 g_snprintf(buf + at, ntohl(fhdr.size) + 1 - at, "%s\r\n", c); |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
637 debug_printf("Sending listing.txt (%d bytes) to %s\n", ntohl(fhdr.size) + 1, ft->user); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
638 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
639 read_rv = write(ft->fd, buf, ntohl(fhdr.size)); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
640 if (read_rv <= -1) { |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
641 debug_printf("Could not send file, wrote %d\n", rcv); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
642 close(ft->fd); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
643 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
644 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
645 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
646 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
647 /* 4. receive header */ |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
648 debug_printf("Receiving closing header\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
649 read_rv = read_file_header(ft->fd, &fhdr); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
650 if (read_rv <= -1) { |
1250
b5783215b245
[gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1233
diff
changeset
|
651 debug_printf("Couldn't read closing header\n"); |
261
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
652 close(ft->fd); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
653 free_ft(ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
654 return; |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
655 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
656 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
657 snpa = gdk_input_add(ft->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
658 send_file_callback, ft); |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
659 |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
660 } |
aebbe6ca6919
[gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
661 |
198 | 662 void accept_file_dialog(struct file_transfer *ft) |
663 { | |
664 GtkWidget *accept, *info, *warn, *cancel; | |
665 GtkWidget *label; | |
666 GtkWidget *vbox, *bbox; | |
667 char buf[1024]; | |
668 | |
669 | |
670 ft->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
905 | 671 gtk_window_set_wmclass(GTK_WINDOW(ft->window), "accept_file", "Gaim"); |
198 | 672 |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
673 accept = gtk_button_new_with_label(_("Accept")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
674 info = gtk_button_new_with_label(_("Info")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
675 warn = gtk_button_new_with_label(_("Warn")); |
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
676 cancel = gtk_button_new_with_label(_("Cancel")); |
198 | 677 |
678 bbox = gtk_hbox_new(TRUE, 10); | |
679 vbox = gtk_vbox_new(FALSE, 5); | |
680 | |
681 gtk_widget_show(accept); | |
682 gtk_widget_show(info); | |
683 gtk_widget_show(warn); | |
684 gtk_widget_show(cancel); | |
685 | |
617 | 686 if (display_options & OPT_DISP_COOL_LOOK) |
687 { | |
688 gtk_button_set_relief(GTK_BUTTON(accept), GTK_RELIEF_NONE); | |
689 gtk_button_set_relief(GTK_BUTTON(info), GTK_RELIEF_NONE); | |
690 gtk_button_set_relief(GTK_BUTTON(warn), GTK_RELIEF_NONE); | |
691 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); | |
692 } | |
535
f03f041c1aa9
[gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
693 |
198 | 694 gtk_box_pack_start(GTK_BOX(bbox), accept, TRUE, TRUE, 10); |
695 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 10); | |
696 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 10); | |
697 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
698 | |
699 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
700 g_snprintf(buf, sizeof(buf), _("%s requests you to accept the file: %s (%d bytes)"), |
198 | 701 ft->user, ft->filename, ft->size); |
702 } else { | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
703 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), |
198 | 704 ft->user); |
705 } | |
211
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
706 if (ft->message) |
2042a38da38b
[gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
707 strncat(buf, ft->message, sizeof(buf) - strlen(buf)); |
198 | 708 label = gtk_label_new(buf); |
709 gtk_widget_show(label); | |
710 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); | |
711 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5); | |
712 | |
350
fd3cc0a28d5d
[gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
713 gtk_window_set_title(GTK_WINDOW(ft->window), _("Gaim - File Transfer?")); |
198 | 714 gtk_window_set_focus(GTK_WINDOW(ft->window), accept); |
715 gtk_container_add(GTK_CONTAINER(ft->window), vbox); | |
716 gtk_container_border_width(GTK_CONTAINER(ft->window), 10); | |
717 gtk_widget_show(vbox); | |
718 gtk_widget_show(bbox); | |
719 gtk_widget_realize(ft->window); | |
720 aol_icon(ft->window->window); | |
721 | |
722 gtk_widget_show(ft->window); | |
723 | |
724 | |
725 gtk_signal_connect(GTK_OBJECT(accept), "clicked", | |
726 GTK_SIGNAL_FUNC(accept_callback), ft); | |
727 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
728 GTK_SIGNAL_FUNC(cancel_callback), ft); | |
729 gtk_signal_connect(GTK_OBJECT(warn), "clicked", | |
730 GTK_SIGNAL_FUNC(warn_callback), ft); | |
731 gtk_signal_connect(GTK_OBJECT(info), "clicked", | |
732 GTK_SIGNAL_FUNC(info_callback), ft); | |
733 | |
734 | |
735 if (ft->message) { | |
736 /* we'll do this later | |
737 while(gtk_events_pending()) | |
738 gtk_main_iteration(); | |
739 html_print(text, ft->message); | |
740 */ | |
741 } | |
742 } |