annotate src/ft.c @ 5755:9587ee01dc5d

[gaim-migrate @ 6180] strcmp NULL check from Phroggie. Thanks! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 05 Jun 2003 00:53:27 +0000
parents 46d7ad0dfa26
children 059d95c67cda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1 /**
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2 * @file ft.c The file transfer interface.
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
4 * gaim
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
5 *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
6 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org>
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
7 *
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * (at your option) any later version.
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 *
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * GNU General Public License for more details.
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 *
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 *
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 */
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <config.h>
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #endif
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <sys/stat.h>
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <unistd.h>
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <errno.h>
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <string.h>
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <gtk/gtk.h>
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include "gaim.h"
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include "proxy.h"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
36 #include "notify.h"
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37
5494
d557a53e35c5 [gaim-migrate @ 5890]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5436
diff changeset
38 #ifdef _WIN32
d557a53e35c5 [gaim-migrate @ 5890]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5436
diff changeset
39 #include "win32dep.h"
d557a53e35c5 [gaim-migrate @ 5890]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5436
diff changeset
40 #endif
d557a53e35c5 [gaim-migrate @ 5890]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5436
diff changeset
41
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
42 static struct gaim_xfer_ui_ops *xfer_ui_ops = NULL;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
44 struct gaim_xfer *
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5495
diff changeset
45 gaim_xfer_new(GaimAccount *account, GaimXferType type,
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
46 const char *who)
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
48 struct gaim_xfer *xfer;
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
49 struct gaim_xfer_ui_ops *ui_ops;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
51 if (account == NULL || type == GAIM_XFER_UNKNOWN || who == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
52 return NULL;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
54 xfer = g_malloc0(sizeof(struct gaim_xfer));
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
56 xfer->type = type;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
57 xfer->account = account;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
58 xfer->who = g_strdup(who);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
59 xfer->ui_ops = gaim_get_xfer_ui_ops();
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
61 ui_ops = gaim_xfer_get_ui_ops(xfer);
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
62
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
63 if (ui_ops != NULL && ui_ops->new != NULL)
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
64 ui_ops->new(xfer);
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
65
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 return xfer;
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
69 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
70 gaim_xfer_destroy(struct gaim_xfer *xfer)
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
72 struct gaim_xfer_ui_ops *ui_ops;
4247
3ea14f99c35c [gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents: 4245
diff changeset
73
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
74 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
75 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
76
5146
ac9ca88d4b25 [gaim-migrate @ 5510]
Mark Doliner <mark@kingant.net>
parents: 4675
diff changeset
77 if (!xfer->completed)
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
78 gaim_xfer_cancel_local(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
80 ui_ops = gaim_xfer_get_ui_ops(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
82 if (ui_ops != NULL && ui_ops->destroy != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
83 ui_ops->destroy(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
85 g_free(xfer->who);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
86 g_free(xfer->filename);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
88 if (xfer->remote_ip != NULL) g_free(xfer->remote_ip);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
89 if (xfer->local_ip != NULL) g_free(xfer->local_ip);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
91 if (xfer->local_filename != NULL)
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
92 g_free(xfer->local_filename);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94 g_free(xfer);
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
97 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
98 gaim_xfer_request(struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
99 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
100 struct gaim_xfer_ui_ops *ui_ops;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
102 if (xfer == NULL || xfer->ops.init == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
103 return;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
105 ui_ops = gaim_get_xfer_ui_ops();
4247
3ea14f99c35c [gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents: 4245
diff changeset
106
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
107 if (ui_ops == NULL || ui_ops->request_file == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
108 return;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
110 ui_ops->request_file(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
112
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
113 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
114 gaim_xfer_request_accepted(struct gaim_xfer *xfer, char *filename)
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
116 GaimXferType type;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
118 if (xfer == NULL || filename == NULL) {
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
120 if (filename != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
121 g_free(filename);
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
122
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123 return;
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
124 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
126 type = gaim_xfer_get_type(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
127
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
128 if (type == GAIM_XFER_SEND) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
129 struct stat sb;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
130
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
131 /* Check the filename. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
132 if (g_strrstr(filename, "..")) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
133 char *msg;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
134
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
135 msg = g_strdup_printf(_("%s is not a valid filename.\n"),
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
136 filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
137
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
138 gaim_xfer_error(type, xfer->who, msg);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
139
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
140 g_free(msg);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
141 g_free(filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
142
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
143 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
144 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
145
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
146 if (stat(filename, &sb) == -1) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
147 char *msg;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
148
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
149 msg = g_strdup_printf(_("%s was not found.\n"), filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
150
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
151 gaim_xfer_error(type, xfer->who, msg);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
152
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
153 g_free(msg);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
154 g_free(filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
155
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
156 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
157 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
158
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
159 gaim_xfer_set_local_filename(xfer, filename);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
160 gaim_xfer_set_size(xfer, sb.st_size);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
161 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
162 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
163 /* TODO: Sanity checks and file overwrite checks. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
164
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
165 gaim_xfer_set_local_filename(xfer, filename);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166 }
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
167
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
168 g_free(filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
169
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
170 xfer->ops.init(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
171 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
172
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
173 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
174 gaim_xfer_request_denied(struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
175 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
176 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
177 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
178
5164
98d16e2d1bf9 [gaim-migrate @ 5528]
Mark Doliner <mark@kingant.net>
parents: 5146
diff changeset
179 gaim_xfer_destroy(xfer);
98d16e2d1bf9 [gaim-migrate @ 5528]
Mark Doliner <mark@kingant.net>
parents: 5146
diff changeset
180
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
181 /* TODO */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
182 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
183
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
184 GaimXferType
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
185 gaim_xfer_get_type(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
186 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
187 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
188 return GAIM_XFER_UNKNOWN;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
189
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
190 return xfer->type;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
191 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
192
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5495
diff changeset
193 GaimAccount *
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
194 gaim_xfer_get_account(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
195 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
196 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
197 return NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
198
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
199 return xfer->account;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
200 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
201
4539
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
202 gboolean
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
203 gaim_xfer_is_completed(const struct gaim_xfer *xfer)
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
204 {
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
205 if (xfer == NULL)
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
206 return TRUE;
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
207
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
208 return xfer->completed;
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
209 }
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
210
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
211 const char *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
212 gaim_xfer_get_filename(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
213 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
214 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
215 return NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
216
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
217 return xfer->filename;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
218 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
219
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
220 const char *
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
221 gaim_xfer_get_local_filename(const struct gaim_xfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
222 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
223 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
224 return NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
225
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
226 return xfer->local_filename;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
227 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
228
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
229 size_t
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
230 gaim_xfer_get_bytes_sent(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
231 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
232 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
233 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
234
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
235 return xfer->bytes_sent;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
236 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
237
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
238 size_t
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
239 gaim_xfer_get_bytes_remaining(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
240 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
241 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
242 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
243
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
244 return xfer->bytes_remaining;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
245 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
246
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
247 size_t
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
248 gaim_xfer_get_size(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
249 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
250 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
251 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
252
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
253 return xfer->size;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
254 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
255
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
256 double
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
257 gaim_xfer_get_progress(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
258 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
259 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
260 return 0.0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
261
4517
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
262 if (gaim_xfer_get_size(xfer) == 0)
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
263 return 0.0;
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
264
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
265 return ((double)gaim_xfer_get_bytes_sent(xfer) /
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
266 (double)gaim_xfer_get_size(xfer));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
267 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
268
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
269 const char *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
270 gaim_xfer_get_local_ip(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
271 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
272 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
273 return NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
274
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
275 return xfer->local_ip;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
276 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
277
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
278 unsigned int
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
279 gaim_xfer_get_local_port(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
280 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
281 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
282 return -1;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
283
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
284 return xfer->local_port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
285 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
286
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
287 const char *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
288 gaim_xfer_get_remote_ip(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
289 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
290 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
291 return NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
292
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
293 return xfer->remote_ip;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
294 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
295
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
296 unsigned int
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
297 gaim_xfer_get_remote_port(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
298 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
299 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
300 return -1;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
301
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
302 return xfer->remote_port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
303 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
304
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
305 void
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
306 gaim_xfer_set_completed(struct gaim_xfer *xfer, gboolean completed)
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
307 {
4656
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
308 struct gaim_xfer_ui_ops *ui_ops;
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
309
4540
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
310 if (xfer == NULL)
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
311 return;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
312
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
313 xfer->completed = completed;
4656
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
314
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
315 ui_ops = gaim_xfer_get_ui_ops(xfer);
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
316
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
317 if (ui_ops != NULL && ui_ops->update_progress != NULL)
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
318 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
319
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
320 }
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
321
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
322 void
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
323 gaim_xfer_set_filename(struct gaim_xfer *xfer, const char *filename)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
324 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
325 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
326 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
327
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
328 if (xfer->filename != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
329 g_free(xfer->filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
330
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
331 xfer->filename = (filename == NULL ? NULL : g_strdup(filename));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
332 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
333
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
334 void
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
335 gaim_xfer_set_local_filename(struct gaim_xfer *xfer, const char *filename)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
336 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
337 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
338 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
339
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
340 if (xfer->local_filename != NULL)
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
341 g_free(xfer->local_filename);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
342
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
343 xfer->local_filename = (filename == NULL ? NULL : g_strdup(filename));
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
344 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
345
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
346 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
347 gaim_xfer_set_size(struct gaim_xfer *xfer, size_t size)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
348 {
4517
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
349 if (xfer == NULL)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
350 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
351
4540
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
352 if (xfer->size == 0)
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
353 xfer->bytes_remaining = size - xfer->bytes_sent;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
354
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
355 xfer->size = size;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
356 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
357
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
358 struct gaim_xfer_ui_ops *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
359 gaim_xfer_get_ui_ops(const struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
360 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
361 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
362 return NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
363
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
364 return xfer->ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
365 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
366
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
367 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
368 gaim_xfer_set_init_fnc(struct gaim_xfer *xfer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
369 void (*fnc)(struct gaim_xfer *))
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
370 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
371 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
372 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
373
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
374 xfer->ops.init = fnc;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
375 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
376
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
377
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
378 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
379 gaim_xfer_set_read_fnc(struct gaim_xfer *xfer,
4518
a6be92358df3 [gaim-migrate @ 4796]
Christian Hammond <chipx86@chipx86.com>
parents: 4517
diff changeset
380 size_t (*fnc)(char **, struct gaim_xfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
381 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
382 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
383 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
384
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
385 xfer->ops.read = fnc;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
386 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
387
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
388 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
389 gaim_xfer_set_write_fnc(struct gaim_xfer *xfer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
390 size_t (*fnc)(const char *, size_t,
4518
a6be92358df3 [gaim-migrate @ 4796]
Christian Hammond <chipx86@chipx86.com>
parents: 4517
diff changeset
391 struct gaim_xfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
392 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
393 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
394 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
395
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
396 xfer->ops.write = fnc;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
397 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
398
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
399 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
400 gaim_xfer_set_ack_fnc(struct gaim_xfer *xfer,
4595
63c022ca157c [gaim-migrate @ 4880]
Mark Doliner <mark@kingant.net>
parents: 4594
diff changeset
401 void (*fnc)(struct gaim_xfer *, const char *, size_t))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
402 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
403 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
404 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
405
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
406 xfer->ops.ack = fnc;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
407 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
408
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
409 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
410 gaim_xfer_set_start_fnc(struct gaim_xfer *xfer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
411 void (*fnc)(struct gaim_xfer *))
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
412 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
413 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
414 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
415
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
416 xfer->ops.start = fnc;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
417 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
418
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
419 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
420 gaim_xfer_set_end_fnc(struct gaim_xfer *xfer,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
421 void (*fnc)(struct gaim_xfer *))
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
422 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
423 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
424 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
425
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
426 xfer->ops.end = fnc;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
427 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
428
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
429 void
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
430 gaim_xfer_set_cancel_send_fnc(struct gaim_xfer *xfer,
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
431 void (*fnc)(struct gaim_xfer *))
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
432 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
433 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
434 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
435
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
436 xfer->ops.cancel_send = fnc;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
437 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
438
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
439 void
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
440 gaim_xfer_set_cancel_recv_fnc(struct gaim_xfer *xfer,
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
441 void (*fnc)(struct gaim_xfer *))
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
442 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
443 if (xfer == NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
444 return;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
445
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
446 xfer->ops.cancel_recv = fnc;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
447 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
448
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
449 size_t
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
450 gaim_xfer_read(struct gaim_xfer *xfer, char **buffer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
451 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
452 size_t s, r;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
453
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
454 if (xfer == NULL || buffer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
455 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
456
4517
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
457 if (gaim_xfer_get_size(xfer) == 0)
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
458 s = 4096;
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
459 else
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
460 s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
462 if (xfer->ops.read != NULL)
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
463 r = (xfer->ops.read)(buffer, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
464 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
465 *buffer = g_malloc0(s);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
466
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
467 r = read(xfer->fd, *buffer, s);
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4605
diff changeset
468 if ((gaim_xfer_get_size > 0) &&
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4605
diff changeset
469 ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer)))
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
470 gaim_xfer_set_completed(xfer, TRUE);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
471 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
472
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
473 return r;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
474 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
476 size_t
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
477 gaim_xfer_write(struct gaim_xfer *xfer, const char *buffer, size_t size)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
478 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
479 size_t r, s;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
480
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
481 if (xfer == NULL || buffer == NULL || size == 0)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
482 return 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
483
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
484 s = MIN(gaim_xfer_get_bytes_remaining(xfer), size);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
485
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
486 if (xfer->ops.write != NULL)
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
487 r = (xfer->ops.write)(buffer, s, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
488 else
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
489 r = write(xfer->fd, buffer, s);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
491 return r;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
492 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
493
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
494 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
495 transfer_cb(gpointer data, gint source, GaimInputCondition condition)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
496 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
497 struct gaim_xfer_ui_ops *ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
498 struct gaim_xfer *xfer = (struct gaim_xfer *)data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
499 char *buffer = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
500 size_t r;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
501
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
502 if (condition & GAIM_INPUT_READ) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
503 r = gaim_xfer_read(xfer, &buffer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
504 if (r > 0)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
505 fwrite(buffer, 1, r, xfer->dest_fp);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
506 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 else {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
508 size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
509
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
510 buffer = g_malloc0(s);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
511
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
512 fread(buffer, 1, s, xfer->dest_fp);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
513
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
514 /* Write as much as we're allowed to. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
515 r = gaim_xfer_write(xfer, buffer, s);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
516
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
517 if (r < s) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
518 /* We have to seek back in the file now. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
519 fseek(xfer->dest_fp, r - s, SEEK_CUR);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
520 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
522
4540
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
523 if (gaim_xfer_get_size(xfer) > 0)
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
524 xfer->bytes_remaining -= r;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
525
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
526 xfer->bytes_sent += r;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
527
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
528 if (xfer->ops.ack != NULL)
4594
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4582
diff changeset
529 xfer->ops.ack(xfer, buffer, r);
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4582
diff changeset
530
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4582
diff changeset
531 g_free(buffer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
532
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
533 ui_ops = gaim_xfer_get_ui_ops(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
534
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
535 if (ui_ops != NULL && ui_ops->update_progress != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
536 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
537
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4540
diff changeset
538 if (gaim_xfer_is_completed(xfer))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
539 gaim_xfer_end(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
540 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
541
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
542 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
543 begin_transfer(struct gaim_xfer *xfer, GaimInputCondition cond)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
544 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
545 struct gaim_xfer_ui_ops *ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
546 GaimXferType type = gaim_xfer_get_type(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
547
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
548 ui_ops = gaim_xfer_get_ui_ops(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
549
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
550 /*
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
551 * We'll have already tried to open this earlier to make sure we can
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
552 * read/write here. Should be safe.
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
553 */
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
554 xfer->dest_fp = fopen(gaim_xfer_get_local_filename(xfer),
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
555 type == GAIM_XFER_RECEIVE ? "wb" : "rb");
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
556
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
557 /* Just in case, though. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
558 if (xfer->dest_fp == NULL) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
559 gaim_xfer_cancel_local(xfer); /* ? */
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
560 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
561 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
562
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
563 xfer->watcher = gaim_input_add(xfer->fd, cond, transfer_cb, xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
564
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
565 if (ui_ops != NULL && ui_ops->add_xfer != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
566 ui_ops->add_xfer(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
567
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
568 if (xfer->ops.start != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
569 xfer->ops.start(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
570 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
571
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
572 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
573 connect_cb(gpointer data, gint source, GaimInputCondition condition)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
574 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
575 struct gaim_xfer *xfer = (struct gaim_xfer *)data;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
576
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
577 xfer->fd = source;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
578
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
579 begin_transfer(xfer, condition);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
582 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
583 gaim_xfer_start(struct gaim_xfer *xfer, int fd, const char *ip,
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
584 unsigned int port)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
585 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
586 GaimInputCondition cond;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
587 GaimXferType type;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
588
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
589 if (xfer == NULL || gaim_xfer_get_type(xfer) == GAIM_XFER_UNKNOWN)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
590 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
591
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
592 type = gaim_xfer_get_type(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
593
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
594 xfer->bytes_remaining = gaim_xfer_get_size(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
595 xfer->bytes_sent = 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
596
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
597 if (type == GAIM_XFER_RECEIVE) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
598 cond = GAIM_INPUT_READ;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
599
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
600 if (ip != NULL) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
601 xfer->remote_ip = g_strdup(ip);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
602 xfer->remote_port = port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
603
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
604 /* Establish a file descriptor. */
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
605 gaim_proxy_connect(xfer->account, xfer->remote_ip,
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
606 xfer->remote_port, connect_cb, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
607
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
608 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
609 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
610 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
611 xfer->fd = fd;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
612 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
613 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
614 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
615 cond = GAIM_INPUT_WRITE;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
616
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
617 xfer->fd = fd;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
618 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
619
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
620 begin_transfer(xfer, cond);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
621 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
622
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
623 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
624 gaim_xfer_end(struct gaim_xfer *xfer)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
625 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
626 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
627 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
628
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
629 /* See if we are actually trying to cancel this. */
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
630 if (!xfer->completed) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
631 gaim_xfer_cancel_local(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
632 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
633 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
634
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
635 if (xfer->ops.end != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
636 xfer->ops.end(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
637
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
638 if (xfer->watcher != 0) {
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
639 gaim_input_remove(xfer->watcher);
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
640 xfer->watcher = 0;
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
641 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
642
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
643 if (xfer->fd != 0)
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
644 close(xfer->fd);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
645
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
646 if (xfer->dest_fp != NULL) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
647 fclose(xfer->dest_fp);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
648 xfer->dest_fp = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
649 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
650 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
651
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
652 void
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
653 gaim_xfer_cancel_local(struct gaim_xfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
654 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
655 struct gaim_xfer_ui_ops *ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
656
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
657 if (xfer == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
658 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
659
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
660 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
661 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
662 if (xfer->ops.cancel_send != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
663 xfer->ops.cancel_send(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
664 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
665 else
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
666 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
667 if (xfer->ops.cancel_recv != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
668 xfer->ops.cancel_recv(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
669 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
670
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
671 if (xfer->watcher != 0) {
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
672 gaim_input_remove(xfer->watcher);
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
673 xfer->watcher = 0;
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
674 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
675
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
676 if (xfer->fd != 0)
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
677 close(xfer->fd);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
678
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
679 if (xfer->dest_fp != NULL) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
680 fclose(xfer->dest_fp);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
681 xfer->dest_fp = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
682 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
683
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
684 ui_ops = gaim_xfer_get_ui_ops(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
685
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
686 if (ui_ops != NULL && ui_ops->cancel_local != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
687 ui_ops->cancel_local(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
688
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
689 xfer->bytes_remaining = 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
690 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
691
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
692 void
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
693 gaim_xfer_cancel_remote(struct gaim_xfer *xfer)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
694 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
695 struct gaim_xfer_ui_ops *ui_ops;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
696
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
697 if (xfer == NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
698 return;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
699
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
700 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
701 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
702 if (xfer->ops.cancel_send != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
703 xfer->ops.cancel_send(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
704 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
705 else
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
706 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
707 if (xfer->ops.cancel_recv != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
708 xfer->ops.cancel_recv(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
709 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
710
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
711 if (xfer->watcher != 0) {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
712 gaim_input_remove(xfer->watcher);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
713 xfer->watcher = 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
714 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
715
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
716 if (xfer->fd != 0)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
717 close(xfer->fd);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
718
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
719 if (xfer->dest_fp != NULL) {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
720 fclose(xfer->dest_fp);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
721 xfer->dest_fp = NULL;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
722 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
723
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
724 ui_ops = gaim_xfer_get_ui_ops(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
725
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
726 if (ui_ops != NULL && ui_ops->cancel_remote != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
727 ui_ops->cancel_remote(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
728
4528
f8fec48f0fde [gaim-migrate @ 4806]
Christian Hammond <chipx86@chipx86.com>
parents: 4521
diff changeset
729 xfer->bytes_remaining = 0;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
730 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
731
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
732 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
733 gaim_xfer_error(GaimXferType type, const char *who, const char *msg)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
734 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
735 char *title;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
736
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
737 if (msg == NULL || type == GAIM_XFER_UNKNOWN)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
738 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
739
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
740 if (type == GAIM_XFER_SEND)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
741 title = g_strdup_printf(_("File transfer to %s aborted.\n"), who);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
742 else
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
743 title = g_strdup_printf(_("File transfer from %s aborted.\n"), who);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
744
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
745 gaim_notify_error(NULL, NULL, title, msg);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
746
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
747 g_free(title);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
748 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
749
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
750 void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
751 gaim_set_xfer_ui_ops(struct gaim_xfer_ui_ops *ops)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
752 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
753 if (ops == NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
754 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
755
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
756 xfer_ui_ops = ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
757 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
758
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
759 struct gaim_xfer_ui_ops *
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
760 gaim_get_xfer_ui_ops(void)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
761 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
762 return xfer_ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
763 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
764