annotate src/rvous.c @ 936:311b3f72e7b9

[gaim-migrate @ 946] Sha la la la la la la, mmm, uh huh Was down at the linux expo, starin' at this blue octane, Mr. Flynn strikes up a conversation, with a black haired CS Major. She codes in C while her father hacks, oh, she's suddenly geeky. We all want something geeky, man I wish I was geeky. So come hack in silence down through the morning, sha la la la la la la la, yeah, uhh huh, yeah. Cut up Mark Spencer, show me some of that free software, and pass me a laptop, Mr. Flynn! Believe in me! Help me believe in anything, cuz, I wanna be someone geeky! Mr. Flynn and Me, tell each other linux tales, and we stare at the beautiful penguins, it's lookin' at you, oh no no, it's looking at me. Smiling in the CRT, Mp3's on the stero, when everyone's geeky, you can never be lonely. Well I'm gonna hack a program, syntax highlighting in blue and red and black and grey. All of the beautiful colours are very very meaningingful. Well you know C is my favorite language, I felt so symbolic yesterday. If I knew R. Stallman, I'd buy myself a grey keyboard and hack! Mr. Flynn and me look into the future! We stare at the beautiful Penguins, it's lookin at me, I dont think so, It's looking at me. Hacking in the CRT, I bought myself a grey keyboard, When everbody's geeky, I will never be lonely. I will never be lonely. I'm never gonna be .. loonely. I wanna be a penguin. Eeh -- everybody wanna pass as birds, they all wanna be big big birds, but we got different reasons for that. Believe in me, cuz I don't believe in anything. And I, wanna be someone, geeky, geeky, geeky, yeaaaah! Mr. Flynn and me, storming through the expo, and we stare at the beautiful penguin! It's coming for you, man there's got to be one for me! I wanna be L. Torvalds, Mr. Flynn wishes he was someone just a little more geeky, when everybody loves you, oh son! It's just about as geeky as you can be! Mr. Flynn and me .. starin' at the penguins, when I look at slashdot I wanna see me, staring right back at me. We all wanna be big geeks, but we dont know why and we don't know how .. when everybody loves me I'll be just about as geeky as I can be ... Mr. Flynn and me.. gonna be big geeks. **bows and cheers** Thank You, Thank You. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sun, 24 Sep 2000 22:48:54 +0000
parents 2876c40108cd
children 2586b2a3725e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include <string.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include <stdio.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <stdlib.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <time.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <sys/types.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <sys/stat.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <fcntl.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <sys/socket.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <netdb.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <netinet/in.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <unistd.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <netinet/in.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include <arpa/inet.h>
218
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
38 #include <errno.h>
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include <gtk/gtk.h>
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include "gaim.h"
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 static void do_send_file(GtkWidget *, struct file_transfer *);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 static void do_get_file (GtkWidget *, struct file_transfer *);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
45 static int snpa = -1;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
46
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
47 static void toggle(GtkWidget *w, int *m)
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
48 {
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
49 *m = !(*m);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
50 }
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
51
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
52 static void free_ft(struct file_transfer *ft)
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
53 {
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
54 if (ft->window) { gtk_widget_destroy(ft->window); ft->window = NULL; }
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
55 if (ft->filename) g_free(ft->filename);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
56 if (ft->user) g_free(ft->user);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
57 if (ft->message) g_free(ft->message);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
58 if (ft->ip) g_free(ft->ip);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
59 if (ft->cookie) g_free(ft->cookie);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
60 g_free(ft);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
61 }
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
62
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 static void warn_callback(GtkWidget *widget, struct file_transfer *ft)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 show_warn_dialog(ft->user);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 static void info_callback(GtkWidget *widget, struct file_transfer *ft)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 serv_get_info(ft->user);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 static void cancel_callback(GtkWidget *widget, struct file_transfer *ft)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 if (ft->accepted) {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 return;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
260
325d9804df10 [gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 253
diff changeset
79 serv_rvous_cancel(ft->user, ft->cookie, ft->UID);
325d9804df10 [gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 253
diff changeset
80
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
81 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 static void accept_callback(GtkWidget *widget, struct file_transfer *ft)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 {
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
86 char buf[BUF_LEN];
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
87 char fname[BUF_LEN];
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 char *c;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 if (!strcmp(ft->UID, FILE_SEND_UID)) {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 c = ft->filename + strlen(ft->filename);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 while (c != ft->filename) {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 if (*c == '/' || *c == '\\') {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 strcpy(fname, c+1);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 break;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 c--;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 if (c == ft->filename)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 strcpy(fname, ft->filename);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 gtk_widget_destroy(ft->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 ft->window = NULL;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
108 ft->window = gtk_file_selection_new(_("Gaim - Save As..."));
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(ft->window));
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 if (!strcmp(ft->UID, FILE_SEND_UID))
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), fname);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 else
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME"));
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 gtk_file_selection_set_filename(GTK_FILE_SELECTION(ft->window), buf);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 gtk_signal_connect(GTK_OBJECT(ft->window), "destroy",
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 GTK_SIGNAL_FUNC(cancel_callback), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 if (!strcmp(ft->UID, FILE_SEND_UID)) {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 gtk_signal_connect(GTK_OBJECT(
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 GTK_FILE_SELECTION(ft->window)->ok_button),
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 "clicked", GTK_SIGNAL_FUNC(do_get_file), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 } else {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 gtk_signal_connect(GTK_OBJECT(
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 GTK_FILE_SELECTION(ft->window)->ok_button),
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 "clicked", GTK_SIGNAL_FUNC(do_send_file), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button),
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 "clicked", GTK_SIGNAL_FUNC(cancel_callback), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 gtk_widget_show(ft->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
136 static int read_file_header(int fd, struct file_header *header) {
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
137 char buf[257];
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
138 int read_rv = read(fd, buf, 256);
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
139 if (read_rv < 0)
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
140 return read_rv;
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
141 memcpy(&header->magic, buf + 0, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
142 memcpy(&header->hdrlen, buf + 4, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
143 memcpy(&header->hdrtype, buf + 6, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
144 memcpy(&header->bcookie, buf + 8, 8);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
145 memcpy(&header->encrypt, buf + 16, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
146 memcpy(&header->compress, buf + 18, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
147 memcpy(&header->totfiles, buf + 20, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
148 memcpy(&header->filesleft, buf + 22, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
149 memcpy(&header->totparts, buf + 24, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
150 memcpy(&header->partsleft, buf + 26, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
151 memcpy(&header->totsize, buf + 28, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
152 memcpy(&header->size, buf + 32, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
153 memcpy(&header->modtime, buf + 36, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
154 memcpy(&header->checksum, buf + 40, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
155 memcpy(&header->rfrcsum, buf + 44, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
156 memcpy(&header->rfsize, buf + 48, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
157 memcpy(&header->cretime, buf + 52, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
158 memcpy(&header->rfcsum, buf + 56, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
159 memcpy(&header->nrecvd, buf + 60, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
160 memcpy(&header->recvcsum, buf + 64, 4);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
161 memcpy(&header->idstring, buf + 68, 32);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
162 memcpy(&header->flags, buf + 100, 1);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
163 memcpy(&header->lnameoffset, buf + 101, 1);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
164 memcpy(&header->lsizeoffset, buf + 102, 1);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
165 memcpy(&header->dummy, buf + 103, 69);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
166 memcpy(&header->macfileinfo, buf + 172, 16);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
167 memcpy(&header->nencode, buf + 188, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
168 memcpy(&header->nlanguage, buf + 190, 2);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
169 memcpy(&header->name, buf + 192, 64);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
170 return read_rv;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
171 }
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
172
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
173 static int write_file_header(int fd, struct file_header *header) {
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
174 char buf[257];
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
175 memcpy(buf + 0, &header->magic, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
176 memcpy(buf + 4, &header->hdrlen, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
177 memcpy(buf + 6, &header->hdrtype, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
178 memcpy(buf + 8, &header->bcookie, 8);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
179 memcpy(buf + 16, &header->encrypt, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
180 memcpy(buf + 18, &header->compress, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
181 memcpy(buf + 20, &header->totfiles, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
182 memcpy(buf + 22, &header->filesleft, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
183 memcpy(buf + 24, &header->totparts, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
184 memcpy(buf + 26, &header->partsleft, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
185 memcpy(buf + 28, &header->totsize, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
186 memcpy(buf + 32, &header->size, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
187 memcpy(buf + 36, &header->modtime, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
188 memcpy(buf + 40, &header->checksum, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
189 memcpy(buf + 44, &header->rfrcsum, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
190 memcpy(buf + 48, &header->rfsize, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
191 memcpy(buf + 52, &header->cretime, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
192 memcpy(buf + 56, &header->rfcsum, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
193 memcpy(buf + 60, &header->nrecvd, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
194 memcpy(buf + 64, &header->recvcsum, 4);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
195 memcpy(buf + 68, &header->idstring, 32);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
196 memcpy(buf + 100, &header->flags, 1);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
197 memcpy(buf + 101, &header->lnameoffset, 1);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
198 memcpy(buf + 102, &header->lsizeoffset, 1);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
199 memcpy(buf + 103, &header->dummy, 69);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
200 memcpy(buf + 172, &header->macfileinfo, 16);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
201 memcpy(buf + 188, &header->nencode, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
202 memcpy(buf + 190, &header->nlanguage, 2);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
203 memcpy(buf + 192, &header->name, 64);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
204 return write(fd, buf, 256);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
205 }
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
206
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 static void do_get_file(GtkWidget *w, struct file_transfer *ft)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 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
210 char buf[BUF_LONG];
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
211 char *buf2;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
212 struct file_header header;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 int read_rv;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 guint32 rcv;
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
215 int cont = 1;
212
89c9334d3484 [gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 211
diff changeset
216 GtkWidget *fw = NULL, *fbar = NULL, *label = NULL;
89c9334d3484 [gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 211
diff changeset
217 GtkWidget *button = NULL, *pct = NULL;
211
2042a38da38b [gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
218
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 if (!(ft->f = fopen(file,"w"))) {
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
220 g_snprintf(buf, BUF_LONG / 2, _("Error writing file %s"), file);
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
221 do_error_dialog(buf, _("Error"));
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 ft->accepted = 0;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 accept_callback(NULL, ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 return;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 ft->accepted = 1;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 gtk_widget_destroy(ft->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 ft->window = NULL;
260
325d9804df10 [gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 253
diff changeset
231 serv_rvous_accept(ft->user, ft->cookie, ft->UID);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
234 ft->fd = connect_address(inet_addr(ft->ip), ft->port);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
236 if (ft->fd <= -1) {
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
237 fclose(ft->f);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
238 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
239 return;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
240 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
241
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
242 read_rv = read_file_header(ft->fd, &header);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
243 if(read_rv < 0) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
244 close(ft->fd);
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
245 fclose(ft->f);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
246 free_ft(ft);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
247 return;
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
248 }
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
249
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
250 sprintf(debug_buff, "header length %d\n", header.hdrlen);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 debug_print(debug_buff);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
253 header.hdrtype = 0x202;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
255 buf2 = frombase64(ft->cookie);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
256 memcpy(header.bcookie, buf2, 8);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
257 snprintf(header.idstring, 32, "Gaim");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
258 g_free(buf2);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
259 header.encrypt = 0; header.compress = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
260 header.totparts = 1; header.partsleft = 1;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 sprintf(debug_buff, "sending confirmation\n");
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 debug_print(debug_buff);
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
264 write_file_header(ft->fd, &header);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 rcv = 0;
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
267
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 fw = gtk_dialog_new();
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
269 snprintf(buf, 2048, _("Receiving %s from %s"), ft->filename, ft->user);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 label = gtk_label_new(buf);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->vbox), label, 0, 0, 5);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 gtk_widget_show(label);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 fbar = gtk_progress_bar_new();
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(fw)->action_area), fbar, 0, 0, 5);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 gtk_widget_show(fbar);
212
89c9334d3484 [gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 211
diff changeset
276 pct = gtk_label_new("0 %");
89c9334d3484 [gaim-migrate @ 222]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 211
diff changeset
277 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
278 gtk_widget_show(pct);
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
279 button = gtk_button_new_with_label(_("Cancel"));
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
280 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
281 gtk_widget_show(button);
535
f03f041c1aa9 [gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
282 if (display_options & OPT_DISP_COOL_LOOK)
f03f041c1aa9 [gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
283 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
284 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)toggle, &cont);
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
285 gtk_window_set_title(GTK_WINDOW(fw), _("Gaim - File Transfer"));
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 gtk_widget_realize(fw);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 aol_icon(fw->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 gtk_widget_show(fw);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 sprintf(debug_buff, "Receiving %s from %s (%d bytes)\n", ft->filename,
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 ft->user, ft->size);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 debug_print(debug_buff);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
218
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
294 fcntl(ft->fd, F_SETFL, O_NONBLOCK);
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
295
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
296 while (rcv != ft->size && cont) {
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 int i;
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
298 float pcnt = ((float)rcv)/((float)ft->size);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 int remain = ft->size - rcv > 1024 ? 1024 : ft->size - rcv;
218
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
300 read_rv = read(ft->fd, buf, remain);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 if(read_rv < 0) {
218
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
302 if (errno == EWOULDBLOCK) {
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
303 while(gtk_events_pending())
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
304 gtk_main_iteration();
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
305 continue;
1a5ee1f8b39e [gaim-migrate @ 228]
Rob Flynn <gaim@robflynn.com>
parents: 217
diff changeset
306 }
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
307 gtk_widget_destroy(fw);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
308 fw = NULL;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 fclose(ft->f);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 close(ft->fd);
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
311 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 return;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 rcv += read_rv;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 for (i = 0; i < read_rv; i++)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 fprintf(ft->f, "%c", buf[i]);
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
317 gtk_progress_bar_update(GTK_PROGRESS_BAR(fbar), pcnt);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
318 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
319 gtk_label_set_text(GTK_LABEL(pct), buf);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 while(gtk_events_pending())
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 gtk_main_iteration();
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 }
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
323 fclose(ft->f);
201
d9a5f7b1d500 [gaim-migrate @ 211]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 200
diff changeset
324 gtk_widget_destroy(fw);
d9a5f7b1d500 [gaim-migrate @ 211]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 200
diff changeset
325 fw = NULL;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
327 if (!cont) {
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
328 char *tmp = frombase64(ft->cookie);
260
325d9804df10 [gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 253
diff changeset
329 serv_rvous_cancel(ft->user, tmp, ft->UID);
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
330 close(ft->fd);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
331 free_ft(ft);
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
332 return;
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
333 }
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
334
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
335 sprintf(debug_buff, "Download complete.\n");
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
336 debug_print(debug_buff);
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
337
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
338 header.hdrtype = 0x402;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
339 header.totparts = 0; header.partsleft = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
340 header.flags = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
341 header.recvcsum = header.checksum;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
342 header.nrecvd = header.totsize;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
343 write_file_header(ft->fd, &header);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 close(ft->fd);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345
200
bc117fbcf527 [gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 198
diff changeset
346 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
349 static void send_file_callback(gpointer data, gint source,
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
350 GdkInputCondition condition) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
351 struct file_transfer *ft = (struct file_transfer *)data;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
352 struct file_header fhdr;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 int read_rv;
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
354 char buf[2048];
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
355 GtkWidget *fw = NULL, *fbar = NULL, *label = NULL;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
356 GtkWidget *button = NULL, *pct = NULL;
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
357 int rcv, cont;
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
359 gdk_input_remove(snpa);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
360 snpa = -1;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
361
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
362 if (condition & GDK_INPUT_EXCEPTION) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
363 fclose(ft->f);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 close(ft->fd);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
365 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 return;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
369 /* 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
370 * 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
371 * 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
372 * and we're done. */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
373
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
374 /* 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
375 * all the information we need in the file_header */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
376
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
377 read_rv = read_file_header(ft->fd, &fhdr);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
378 if (read_rv < 0) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
379 fclose(ft->f);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 close(ft->fd);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
381 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 return;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384
264
ced25773243c [gaim-migrate @ 274]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 261
diff changeset
385 if (fhdr.hdrtype != 0xc12) {
ced25773243c [gaim-migrate @ 274]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 261
diff changeset
386 sprintf(debug_buff, "%s decided to cancel. (%x)\n", ft->user,
ced25773243c [gaim-migrate @ 274]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 261
diff changeset
387 fhdr.hdrtype);
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
388 debug_print(debug_buff);
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
389 fclose(ft->f);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 close(ft->fd);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
391 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 return;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
395 /* 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
396 * 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
397 * my sniffing from :-P */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
398 fhdr.hdrtype = ntohs(0x101);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
399 fhdr.totfiles = 1;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
400 fhdr.filesleft = 1;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
401 fhdr.flags = 0x20;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
402 write_file_header(ft->fd, &fhdr);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
403 read_file_header(ft->fd, &fhdr);
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
404
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
405 fw = gtk_dialog_new();
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
406 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
407 label = gtk_label_new(buf);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
408 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
409 gtk_widget_show(label);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
410 fbar = gtk_progress_bar_new();
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
411 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
412 gtk_widget_show(fbar);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
413 pct = gtk_label_new("0 %");
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
414 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
415 gtk_widget_show(pct);
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
416 button = gtk_button_new_with_label(_("Cancel"));
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
417 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
418 gtk_widget_show(button);
535
f03f041c1aa9 [gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
419 if (display_options & OPT_DISP_COOL_LOOK)
f03f041c1aa9 [gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
420 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
421 gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)toggle, &cont);
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
422 gtk_window_set_title(GTK_WINDOW(fw), _("Gaim - File Transfer"));
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
423 gtk_widget_realize(fw);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
424 aol_icon(fw->window);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
425 gtk_widget_show(fw);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
426
411
a330017b3aa4 [gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 350
diff changeset
427 sprintf(debug_buff, "Sending %s to %s (%ld bytes)\n", fhdr.name,
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
428 ft->user, fhdr.totsize);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
429 debug_print(debug_buff);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
430
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
431 rcv = 0; cont = 1;
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
432 while (rcv != ntohl(fhdr.totsize) && cont) {
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
433 int i;
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
434 float pcnt = ((float)rcv)/((float)ntohl(fhdr.totsize));
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
435 int remain = ntohl(fhdr.totsize) - rcv > 1024 ? 1024 :
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
436 ntohl(fhdr.totsize) - rcv;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
437 for (i = 0; i < remain; i++)
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
438 fscanf(ft->f, "%c", &buf[i]);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
439 read_rv = write(ft->fd, buf, remain);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
440 if (read_rv < 0) {
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
441 fclose(ft->f);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
442 gtk_widget_destroy(fw);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
443 fw = NULL;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
444 fclose(ft->f);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
445 close(ft->fd);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
446 free_ft(ft);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
447 return;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
448 }
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
449 rcv += read_rv;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
450 gtk_progress_bar_update(GTK_PROGRESS_BAR(fbar), pcnt);
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
451 sprintf(buf, "%d / %d K (%2.0f %%)", rcv/1024,
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
452 ntohl(fhdr.totsize)/1024, 100*pcnt);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
453 gtk_label_set_text(GTK_LABEL(pct), buf);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
454 while(gtk_events_pending())
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
455 gtk_main_iteration();
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
456 }
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
457 fclose(ft->f);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
458 gtk_widget_destroy(fw);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
459 fw = NULL;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
460
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
461 if (!cont) {
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
462 char *tmp = frombase64(ft->cookie);
260
325d9804df10 [gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 253
diff changeset
463 serv_rvous_cancel(ft->user, tmp, ft->UID);
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
464 close(ft->fd);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
465 free_ft(ft);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
466 return;
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
467 }
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
468
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
469 sprintf(debug_buff, "Upload complete.\n");
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
470 debug_print(debug_buff);
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
471
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
472 read_file_header(ft->fd, &fhdr);
217
fba779cc01f5 [gaim-migrate @ 227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 216
diff changeset
473
221
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
474 close(ft->fd);
b2f9f629525e [gaim-migrate @ 231]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 218
diff changeset
475 free_ft(ft);
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
478 static void do_send_file(GtkWidget *w, struct file_transfer *ft) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
479 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
480 char buf[BUF_LONG];
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
481 char *buf2;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
482 int read_rv;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
483 struct file_header fhdr;
411
a330017b3aa4 [gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 350
diff changeset
484 guint32 rcv = 0;
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
485 char *c;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
486 struct stat st;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
487 struct tm *fortime;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
488
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
489 stat(file, &st);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
490 if (!(ft->f = fopen(file, "r"))) {
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
491 g_snprintf(buf, BUF_LONG / 2, _("Error reading file %s"), file);
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
492 do_error_dialog(buf, _("Error"));
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
493 ft->accepted = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
494 accept_callback(NULL, ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
495 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
496 return;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
497 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
498
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
499 ft->accepted = 1;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
500 ft->filename = file;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
501
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
502 gtk_widget_destroy(ft->window);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
503 ft->window = NULL;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
504 serv_rvous_accept(ft->user, ft->cookie, ft->UID);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
505
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
506
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
507
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
508 ft->fd = connect_address(inet_addr(ft->ip), ft->port);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
509
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
510 if (ft->fd <= -1) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
511 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
512 return;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
513 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
514
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
515 /* here's where we differ from do_get_file */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
516 /* 1. build/send header
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
517 * 2. receive header
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
518 * 3. send listing file
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
519 * 4. receive header
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
520 *
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
521 * 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
522 *
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
523 */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
524
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
525 /* 1. build/send header */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
526 c = file + strlen(file);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
527 while (*(c - 1) != '/') c--;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
528 buf2 = frombase64(ft->cookie);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
529 sprintf(debug_buff, "Building header to send %s (cookie: %s)\n", file, buf2);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
530 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
531 fhdr.magic[0] = 'O'; fhdr.magic[1] = 'F';
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
532 fhdr.magic[2] = 'T'; fhdr.magic[3] = '2';
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
533 fhdr.hdrlen = htons(256);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
534 fhdr.hdrtype = htons(0x1108);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
535 snprintf(fhdr.bcookie, 8, "%s", buf2);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
536 g_free(buf2);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
537 fhdr.encrypt = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
538 fhdr.compress = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
539 fhdr.totfiles = htons(1);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
540 fhdr.filesleft = htons(1);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
541 fhdr.totparts = htons(1);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
542 fhdr.partsleft = htons(1);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
543 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
544 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
545 fhdr.size = htonl(28 + strlen(c)); /* size of listing.txt */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
546 fhdr.modtime = htonl(time(NULL)); /* time since UNIX epoch */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
547 fhdr.checksum = htonl(0x89f70000); /* ? i don't think this matters */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
548 fhdr.rfrcsum = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
549 fhdr.rfsize = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
550 fhdr.cretime = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
551 fhdr.rfcsum = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
552 fhdr.nrecvd = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
553 fhdr.recvcsum = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
554 snprintf(fhdr.idstring, 32, "OFT_Windows ICBMFT V1.1 32");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
555 fhdr.flags = 0x02; /* don't ask me why */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
556 fhdr.lnameoffset = 0x1A; /* ? still no clue */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
557 fhdr.lsizeoffset = 0x10; /* whatever */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
558 memset(fhdr.dummy, 0, 69);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
559 memset(fhdr.macfileinfo, 0, 16);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
560 fhdr.nencode = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
561 fhdr.nlanguage = 0;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
562 snprintf(fhdr.name, 64, "listing.txt");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
563 read_rv = write_file_header(ft->fd, &fhdr);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
564 if (read_rv <= -1) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
565 sprintf(debug_buff, "Couldn't write opening header\n");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
566 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
567 close(ft->fd);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
568 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
569 return;
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 /* 2. receive header */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
573 sprintf(debug_buff, "Receiving header\n");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
574 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
575 read_rv = read_file_header(ft->fd, &fhdr);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
576 if (read_rv <= -1) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
577 sprintf(debug_buff, "Couldn't read header\n");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
578 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
579 close(ft->fd);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
580 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
581 return;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
582 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
583
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
584 /* 3. send listing file */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
585 /* mm/dd/yyyy hh:mm sizesize name.ext\r\n */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
586 /* creation date ^ */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
587 sprintf(debug_buff, "Sending file\n");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
588 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
589 fortime = localtime(&st.st_ctime);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
590 snprintf(buf, ntohl(fhdr.size) + 1, "%2d/%2d/%4d %2d:%2d %8ld %s\r\n",
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
591 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900,
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
592 fortime->tm_hour + 1, fortime->tm_min + 1,
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
593 st.st_size, c);
411
a330017b3aa4 [gaim-migrate @ 421]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 350
diff changeset
594 sprintf(debug_buff, "Sending listing.txt (%d bytes) to %s\n",
261
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
595 ntohl(fhdr.size) + 1, ft->user);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
596 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
597
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
598 read_rv = write(ft->fd, buf, ntohl(fhdr.size));
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
599 if (read_rv <= -1) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
600 sprintf(debug_buff, "Could not send file, wrote %d\n", rcv);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
601 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
602 close(ft->fd);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
603 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
604 return;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
605 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
606
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
607 /* 4. receive header */
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
608 sprintf(debug_buff, "Receiving closing header\n");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
609 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
610 read_rv = read_file_header(ft->fd, &fhdr);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
611 if (read_rv <= -1) {
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
612 sprintf(debug_buff, "Couldn't read closing header\n");
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
613 debug_print(debug_buff);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
614 close(ft->fd);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
615 free_ft(ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
616 return;
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
617 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
618
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
619 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
620 send_file_callback, ft);
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
621
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
622 }
aebbe6ca6919 [gaim-migrate @ 271]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 260
diff changeset
623
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 void accept_file_dialog(struct file_transfer *ft)
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 GtkWidget *accept, *info, *warn, *cancel;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 GtkWidget *label;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 GtkWidget *vbox, *bbox;
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 char buf[1024];
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 ft->window = gtk_window_new(GTK_WINDOW_DIALOG);
905
2876c40108cd [gaim-migrate @ 915]
Rob Flynn <gaim@robflynn.com>
parents: 617
diff changeset
633 gtk_window_set_wmclass(GTK_WINDOW(ft->window), "accept_file", "Gaim");
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
635 accept = gtk_button_new_with_label(_("Accept"));
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
636 info = gtk_button_new_with_label(_("Info"));
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
637 warn = gtk_button_new_with_label(_("Warn"));
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
638 cancel = gtk_button_new_with_label(_("Cancel"));
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640 bbox = gtk_hbox_new(TRUE, 10);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 vbox = gtk_vbox_new(FALSE, 5);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 gtk_widget_show(accept);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 gtk_widget_show(info);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 gtk_widget_show(warn);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 gtk_widget_show(cancel);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647
617
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
648 if (display_options & OPT_DISP_COOL_LOOK)
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
649 {
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
650 gtk_button_set_relief(GTK_BUTTON(accept), GTK_RELIEF_NONE);
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
651 gtk_button_set_relief(GTK_BUTTON(info), GTK_RELIEF_NONE);
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
652 gtk_button_set_relief(GTK_BUTTON(warn), GTK_RELIEF_NONE);
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
653 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE);
50f7a0bc76fc [gaim-migrate @ 627]
Todd Kulesza <fflewddur>
parents: 535
diff changeset
654 }
535
f03f041c1aa9 [gaim-migrate @ 545]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
655
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 gtk_box_pack_start(GTK_BOX(bbox), accept, TRUE, TRUE, 10);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 10);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 10);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 if (!strcmp(ft->UID, FILE_SEND_UID)) {
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
662 g_snprintf(buf, sizeof(buf), _("%s requests you to accept the file: %s (%d bytes)"),
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 ft->user, ft->filename, ft->size);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 } else {
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
665 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"),
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 ft->user);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 }
211
2042a38da38b [gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
668 if (ft->message)
2042a38da38b [gaim-migrate @ 221]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 210
diff changeset
669 strncat(buf, ft->message, sizeof(buf) - strlen(buf));
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 label = gtk_label_new(buf);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671 gtk_widget_show(label);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674
350
fd3cc0a28d5d [gaim-migrate @ 360]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 349
diff changeset
675 gtk_window_set_title(GTK_WINDOW(ft->window), _("Gaim - File Transfer?"));
198
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676 gtk_window_set_focus(GTK_WINDOW(ft->window), accept);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 gtk_container_add(GTK_CONTAINER(ft->window), vbox);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 gtk_container_border_width(GTK_CONTAINER(ft->window), 10);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 gtk_widget_show(vbox);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680 gtk_widget_show(bbox);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 gtk_widget_realize(ft->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 aol_icon(ft->window->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 gtk_widget_show(ft->window);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 gtk_signal_connect(GTK_OBJECT(accept), "clicked",
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 GTK_SIGNAL_FUNC(accept_callback), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 GTK_SIGNAL_FUNC(cancel_callback), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 gtk_signal_connect(GTK_OBJECT(warn), "clicked",
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 GTK_SIGNAL_FUNC(warn_callback), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 gtk_signal_connect(GTK_OBJECT(info), "clicked",
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 GTK_SIGNAL_FUNC(info_callback), ft);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 if (ft->message) {
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 /* we'll do this later
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699 while(gtk_events_pending())
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 gtk_main_iteration();
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 html_print(text, ft->message);
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702 */
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 }
73e9a0bfff62 [gaim-migrate @ 208]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 }