Mercurial > pidgin.yaz
annotate src/ft.c @ 13753:c066473fff04
[gaim-migrate @ 16164]
SF Patch #1482906 from Sadrul
"The timestamp plugin was not working. This makes it
work again. Looks like I didn't update this one when
the displaying- signals were moved to gtkconv from conv.
Also, I think having this timestamp work for chat
windows can't hurt. So I have added support for that too."
If you object to the change in functionality, that's easy to remove. I wasn't sure, since I don't use this plugin, but I kept it because I can't think of a reason you wouldn't want the timestamps in chats as well.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 09 May 2006 01:42:39 +0000 |
parents | 4b6308145fcd |
children | 5ddde4ad1ca2 |
rev | line source |
---|---|
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1 /** |
7820 | 2 * @file ft.c File Transfer API |
3609 | 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 * |
8046 | 6 * Gaim is the legal property of its developers, whose names are too numerous |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | |
8 * source distribution. | |
4538 | 9 * |
3609 | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
25 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
26 #include "ft.h" |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
27 #include "network.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
28 #include "notify.h" |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
29 #include "prefs.h" |
3609 | 30 #include "proxy.h" |
9511 | 31 #include "request.h" |
32 #include "util.h" | |
5494
d557a53e35c5
[gaim-migrate @ 5890]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5436
diff
changeset
|
33 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
34 static GaimXferUiOps *xfer_ui_ops = NULL; |
3609 | 35 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
36 GaimXfer * |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
37 gaim_xfer_new(GaimAccount *account, GaimXferType type, const char *who) |
3609 | 38 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
39 GaimXfer *xfer; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
40 GaimXferUiOps *ui_ops; |
3609 | 41 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
42 g_return_val_if_fail(type != GAIM_XFER_UNKNOWN, NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
43 g_return_val_if_fail(account != NULL, NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
44 g_return_val_if_fail(who != NULL, NULL); |
3609 | 45 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
46 xfer = g_new0(GaimXfer, 1); |
3609 | 47 |
7805 | 48 xfer->ref = 1; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
49 xfer->type = type; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
50 xfer->account = account; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
51 xfer->who = g_strdup(who); |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6482
diff
changeset
|
52 xfer->ui_ops = gaim_xfers_get_ui_ops(); |
9933 | 53 xfer->message = NULL; |
3609 | 54 |
5169 | 55 ui_ops = gaim_xfer_get_ui_ops(xfer); |
56 | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
57 if (ui_ops != NULL && ui_ops->new_xfer != NULL) |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
58 ui_ops->new_xfer(xfer); |
5169 | 59 |
3609 | 60 return xfer; |
61 } | |
62 | |
7805 | 63 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
64 gaim_xfer_destroy(GaimXfer *xfer) |
3609 | 65 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
66 GaimXferUiOps *ui_ops; |
4247
3ea14f99c35c
[gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents:
4245
diff
changeset
|
67 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
68 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
69 |
9512 | 70 /* Close the file browser, if it's open */ |
71 gaim_request_close_with_handle(xfer); | |
72 | |
7805 | 73 if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_STARTED) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
74 gaim_xfer_cancel_local(xfer); |
3609 | 75 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
76 ui_ops = gaim_xfer_get_ui_ops(xfer); |
3609 | 77 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
78 if (ui_ops != NULL && ui_ops->destroy != NULL) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
79 ui_ops->destroy(xfer); |
3609 | 80 |
9789 | 81 g_free(xfer->who); |
82 g_free(xfer->filename); | |
83 g_free(xfer->remote_ip); | |
84 g_free(xfer->local_filename); | |
3609 | 85 |
86 g_free(xfer); | |
87 } | |
88 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
89 void |
7805 | 90 gaim_xfer_ref(GaimXfer *xfer) |
91 { | |
92 g_return_if_fail(xfer != NULL); | |
93 | |
94 xfer->ref++; | |
95 } | |
96 | |
97 void | |
98 gaim_xfer_unref(GaimXfer *xfer) | |
99 { | |
100 g_return_if_fail(xfer != NULL); | |
12250
5e2a365af01b
[gaim-migrate @ 14552]
Richard Laager <rlaager@wiktel.com>
parents:
12151
diff
changeset
|
101 g_return_if_fail(xfer->ref > 0); |
7805 | 102 |
103 xfer->ref--; | |
104 | |
105 if (xfer->ref == 0) | |
106 gaim_xfer_destroy(xfer); | |
107 } | |
108 | |
9788 | 109 static void |
110 gaim_xfer_set_status(GaimXfer *xfer, GaimXferStatusType status) | |
111 { | |
112 g_return_if_fail(xfer != NULL); | |
113 | |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
114 if(xfer->type == GAIM_XFER_SEND) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
115 switch(status) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
116 case GAIM_XFER_STATUS_ACCEPTED: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
117 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-accept", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
118 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
119 case GAIM_XFER_STATUS_STARTED: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
120 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-start", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
121 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
122 case GAIM_XFER_STATUS_DONE: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
123 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-complete", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
124 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
125 case GAIM_XFER_STATUS_CANCEL_LOCAL: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
126 case GAIM_XFER_STATUS_CANCEL_REMOTE: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
127 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-cancel", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
128 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
129 default: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
130 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
131 } |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
132 } else if(xfer->type == GAIM_XFER_RECEIVE) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
133 switch(status) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
134 case GAIM_XFER_STATUS_ACCEPTED: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
135 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-accept", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
136 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
137 case GAIM_XFER_STATUS_STARTED: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
138 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-start", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
139 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
140 case GAIM_XFER_STATUS_DONE: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
141 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-complete", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
142 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
143 case GAIM_XFER_STATUS_CANCEL_LOCAL: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
144 case GAIM_XFER_STATUS_CANCEL_REMOTE: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
145 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-cancel", xfer); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
146 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
147 default: |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
148 break; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
149 } |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
150 } |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
151 |
9788 | 152 xfer->status = status; |
153 } | |
154 | |
11084 | 155 void gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error) |
9932 | 156 { |
157 GaimConversation *conv = NULL; | |
158 GaimMessageFlags flags = GAIM_MESSAGE_SYSTEM; | |
10774 | 159 char *escaped; |
9932 | 160 |
161 g_return_if_fail(xfer != NULL); | |
162 g_return_if_fail(message != NULL); | |
163 | |
11338 | 164 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, xfer->who, |
10246 | 165 gaim_xfer_get_account(xfer)); |
9932 | 166 |
167 if (conv == NULL) | |
168 return; | |
169 | |
10774 | 170 escaped = g_markup_escape_text(message, -1); |
9932 | 171 |
172 if (is_error) | |
173 flags = GAIM_MESSAGE_ERROR; | |
174 | |
10774 | 175 gaim_conversation_write(conv, NULL, escaped, flags, time(NULL)); |
176 g_free(escaped); | |
9932 | 177 } |
178 | |
9796 | 179 static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename) |
9785 | 180 { |
10919 | 181 int err = errno; |
182 gchar *msg = NULL, *utf8; | |
9796 | 183 GaimXferType xfer_type = gaim_xfer_get_type(xfer); |
10654 | 184 GaimAccount *account = gaim_xfer_get_account(xfer); |
9785 | 185 |
10919 | 186 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
9796 | 187 switch(xfer_type) { |
188 case GAIM_XFER_SEND: | |
189 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), | |
10919 | 190 utf8, strerror(err)); |
9795 | 191 break; |
9796 | 192 case GAIM_XFER_RECEIVE: |
193 msg = g_strdup_printf(_("Error writing %s: \n%s.\n"), | |
10919 | 194 utf8, strerror(err)); |
9785 | 195 break; |
196 default: | |
9796 | 197 msg = g_strdup_printf(_("Error accessing %s: \n%s.\n"), |
10919 | 198 utf8, strerror(err)); |
9785 | 199 break; |
10919 | 200 } |
201 g_free(utf8); | |
9785 | 202 |
9932 | 203 gaim_xfer_conversation_write(xfer, msg, TRUE); |
10654 | 204 gaim_xfer_error(xfer_type, account, xfer->who, msg); |
9796 | 205 g_free(msg); |
9785 | 206 } |
207 | |
9511 | 208 static void |
209 gaim_xfer_choose_file_ok_cb(void *user_data, const char *filename) | |
210 { | |
211 GaimXfer *xfer; | |
212 struct stat st; | |
213 | |
214 xfer = (GaimXfer *)user_data; | |
215 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
216 if (g_stat(filename, &st) != 0) { |
9511 | 217 /* File not found. */ |
218 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
219 gaim_xfer_request_accepted(xfer, filename); | |
220 } | |
221 else { | |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
222 gaim_xfer_show_file_error(xfer, filename); |
9511 | 223 gaim_xfer_request_denied(xfer); |
224 } | |
225 } | |
226 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) && | |
227 (st.st_size == 0)) { | |
228 | |
229 gaim_notify_error(NULL, NULL, | |
230 _("Cannot send a file of 0 bytes."), NULL); | |
231 | |
232 gaim_xfer_request_denied(xfer); | |
233 } | |
9785 | 234 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) && |
235 S_ISDIR(st.st_mode)) { | |
236 /* | |
237 * XXX - Sending a directory should be valid for some protocols. | |
238 */ | |
239 gaim_notify_error(NULL, NULL, | |
240 _("Cannot send a directory."), NULL); | |
241 | |
242 gaim_xfer_request_denied(xfer); | |
243 } | |
244 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) && | |
245 S_ISDIR(st.st_mode)) { | |
10919 | 246 char *msg, *utf8; |
247 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); | |
248 msg = g_strdup_printf( | |
249 _("%s is not a regular file. Cowardly refusing to overwrite it.\n"), utf8); | |
250 g_free(utf8); | |
9785 | 251 gaim_notify_error(NULL, NULL, msg, NULL); |
252 g_free(msg); | |
253 gaim_xfer_request_denied(xfer); | |
254 } | |
9511 | 255 else { |
9785 | 256 gaim_xfer_request_accepted(xfer, filename); |
9511 | 257 } |
258 | |
259 gaim_xfer_unref(xfer); | |
260 } | |
261 | |
262 static void | |
263 gaim_xfer_choose_file_cancel_cb(void *user_data, const char *filename) | |
264 { | |
265 GaimXfer *xfer = (GaimXfer *)user_data; | |
266 | |
11159 | 267 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL); |
9511 | 268 gaim_xfer_request_denied(xfer); |
269 } | |
270 | |
271 static int | |
272 gaim_xfer_choose_file(GaimXfer *xfer) | |
273 { | |
274 gaim_request_file(xfer, NULL, gaim_xfer_get_filename(xfer), | |
275 (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE), | |
276 G_CALLBACK(gaim_xfer_choose_file_ok_cb), | |
277 G_CALLBACK(gaim_xfer_choose_file_cancel_cb), xfer); | |
278 | |
279 return 0; | |
280 } | |
281 | |
282 static int | |
283 cancel_recv_cb(GaimXfer *xfer) | |
284 { | |
11159 | 285 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL); |
9511 | 286 gaim_xfer_request_denied(xfer); |
287 gaim_xfer_unref(xfer); | |
288 | |
289 return 0; | |
290 } | |
291 | |
292 static void | |
293 gaim_xfer_ask_recv(GaimXfer *xfer) | |
294 { | |
10774 | 295 char *buf, *size_buf; |
9511 | 296 size_t size; |
297 | |
298 /* If we have already accepted the request, ask the destination file | |
299 name directly */ | |
300 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) { | |
10654 | 301 GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who); |
302 | |
10470 | 303 if (gaim_xfer_get_filename(xfer) != NULL) |
304 { | |
305 size = gaim_xfer_get_size(xfer); | |
306 size_buf = gaim_str_size_to_units(size); | |
307 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), | |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
308 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
309 gaim_xfer_get_filename(xfer), size_buf); |
10470 | 310 g_free(size_buf); |
311 } | |
312 else | |
313 { | |
10654 | 314 buf = g_strdup_printf(_("%s wants to send you a file"), |
315 buddy ? gaim_buddy_get_alias(buddy) : xfer->who); | |
10470 | 316 } |
9511 | 317 |
9933 | 318 if (xfer->message != NULL) |
319 serv_got_im(gaim_account_get_connection(xfer->account), | |
320 xfer->who, xfer->message, 0, time(NULL)); | |
321 | |
9976 | 322 gaim_request_accept_cancel(xfer, NULL, buf, NULL, |
323 GAIM_DEFAULT_ACTION_NONE, xfer, | |
324 G_CALLBACK(gaim_xfer_choose_file), | |
325 G_CALLBACK(cancel_recv_cb)); | |
9933 | 326 |
9511 | 327 g_free(buf); |
328 } else | |
329 gaim_xfer_choose_file(xfer); | |
330 } | |
331 | |
332 static int | |
333 ask_accept_ok(GaimXfer *xfer) | |
334 { | |
335 gaim_xfer_request_accepted(xfer, NULL); | |
336 | |
337 return 0; | |
338 } | |
339 | |
340 static int | |
341 ask_accept_cancel(GaimXfer *xfer) | |
342 { | |
343 gaim_xfer_request_denied(xfer); | |
344 gaim_xfer_unref(xfer); | |
345 | |
346 return 0; | |
347 } | |
348 | |
349 static void | |
350 gaim_xfer_ask_accept(GaimXfer *xfer) | |
351 { | |
352 char *buf, *buf2 = NULL; | |
10654 | 353 GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who); |
9511 | 354 |
355 buf = g_strdup_printf(_("Accept file transfer request from %s?"), | |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
356 buddy ? gaim_buddy_get_alias(buddy) : xfer->who); |
9511 | 357 if (gaim_xfer_get_remote_ip(xfer) && |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
358 gaim_xfer_get_remote_port(xfer)) |
9511 | 359 buf2 = g_strdup_printf(_("A file is available for download from:\n" |
360 "Remote host: %s\nRemote port: %d"), | |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
361 gaim_xfer_get_remote_ip(xfer), |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
362 gaim_xfer_get_remote_port(xfer)); |
9976 | 363 gaim_request_accept_cancel(xfer, NULL, buf, buf2, |
364 GAIM_DEFAULT_ACTION_NONE, xfer, | |
365 G_CALLBACK(ask_accept_ok), | |
366 G_CALLBACK(ask_accept_cancel)); | |
9511 | 367 g_free(buf); |
368 g_free(buf2); | |
369 } | |
370 | |
7805 | 371 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
372 gaim_xfer_request(GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
373 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
374 g_return_if_fail(xfer != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
375 g_return_if_fail(xfer->ops.init != NULL); |
3609 | 376 |
9511 | 377 gaim_xfer_ref(xfer); |
4247
3ea14f99c35c
[gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents:
4245
diff
changeset
|
378 |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
379 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
380 { |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
381 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-request", xfer); |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
382 if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
383 { |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
384 /* The file-transfer was cancelled by a plugin */ |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
385 gaim_xfer_cancel_local(xfer); |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
386 } |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
387 else if (gaim_xfer_get_filename(xfer) || |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
388 gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_ACCEPTED) |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
389 { |
11084 | 390 gchar* message = NULL; |
391 message = g_strdup_printf(_("%s is offering to send file %s"), | |
392 xfer->who, gaim_xfer_get_filename(xfer)); | |
393 gaim_xfer_conversation_write(xfer, message, FALSE); | |
394 g_free(message); | |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
395 /* Ask for a filename to save to if it's not already given by a plugin */ |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
396 if (xfer->local_filename == NULL) |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
397 gaim_xfer_ask_recv(xfer); |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
398 } |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
399 else |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
400 { |
9511 | 401 gaim_xfer_ask_accept(xfer); |
11084 | 402 } |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
403 } |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
404 else |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
405 { |
9511 | 406 gaim_xfer_choose_file(xfer); |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
407 } |
3609 | 408 } |
409 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
410 void |
7805 | 411 gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename) |
3609 | 412 { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
413 GaimXferType type; |
9785 | 414 struct stat st; |
10919 | 415 char *msg, *utf8; |
10654 | 416 GaimAccount *account; |
417 GaimBuddy *buddy; | |
3609 | 418 |
8585 | 419 if (xfer == NULL) |
420 return; | |
421 | |
422 type = gaim_xfer_get_type(xfer); | |
10654 | 423 account = gaim_xfer_get_account(xfer); |
8585 | 424 |
425 if (!filename && type == GAIM_XFER_RECEIVE) { | |
426 xfer->status = GAIM_XFER_STATUS_ACCEPTED; | |
427 xfer->ops.init(xfer); | |
3609 | 428 return; |
4150 | 429 } |
3609 | 430 |
10654 | 431 buddy = gaim_find_buddy(account, xfer->who); |
432 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
433 if (type == GAIM_XFER_SEND) { |
13594 | 434 /* Sending a file */ |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
435 /* Check the filename. */ |
11934
525cf7ecd919
[gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents:
11338
diff
changeset
|
436 #ifdef _WIN32 |
525cf7ecd919
[gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents:
11338
diff
changeset
|
437 if (g_strrstr(filename, "../") || g_strrstr(filename, "..\\")) { |
525cf7ecd919
[gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents:
11338
diff
changeset
|
438 #else |
525cf7ecd919
[gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents:
11338
diff
changeset
|
439 if (g_strrstr(filename, "../")) { |
525cf7ecd919
[gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents:
11338
diff
changeset
|
440 #endif |
10919 | 441 char *utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
3609 | 442 |
10919 | 443 msg = g_strdup_printf(_("%s is not a valid filename.\n"), utf8); |
10654 | 444 gaim_xfer_error(type, account, xfer->who, msg); |
10919 | 445 g_free(utf8); |
9932 | 446 g_free(msg); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
447 |
7805 | 448 gaim_xfer_unref(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
449 return; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
450 } |
3609 | 451 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
452 if (g_stat(filename, &st) == -1) { |
11159 | 453 gaim_xfer_show_file_error(xfer, filename); |
7805 | 454 gaim_xfer_unref(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
455 return; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
456 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
457 |
4605 | 458 gaim_xfer_set_local_filename(xfer, filename); |
9785 | 459 gaim_xfer_set_size(xfer, st.st_size); |
10134 | 460 |
10919 | 461 utf8 = g_filename_to_utf8(g_basename(filename), -1, NULL, NULL, NULL); |
462 gaim_xfer_set_filename(xfer, utf8); | |
463 | |
9932 | 464 msg = g_strdup_printf(_("Offering to send %s to %s"), |
10919 | 465 utf8, buddy ? gaim_buddy_get_alias(buddy) : xfer->who); |
466 g_free(utf8); | |
467 | |
9932 | 468 gaim_xfer_conversation_write(xfer, msg, FALSE); |
469 g_free(msg); | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
470 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
471 else { |
13594 | 472 /* Receiving a file */ |
9785 | 473 xfer->status = GAIM_XFER_STATUS_ACCEPTED; |
4605 | 474 gaim_xfer_set_local_filename(xfer, filename); |
10654 | 475 |
476 msg = g_strdup_printf(_("Starting transfer of %s from %s"), | |
477 xfer->filename, buddy ? gaim_buddy_get_alias(buddy) : xfer->who); | |
478 gaim_xfer_conversation_write(xfer, msg, FALSE); | |
479 g_free(msg); | |
3609 | 480 } |
4150 | 481 |
10259 | 482 gaim_xfer_add(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
483 xfer->ops.init(xfer); |
10259 | 484 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
485 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
486 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
487 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
488 gaim_xfer_request_denied(GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
489 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
490 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
491 |
7805 | 492 if (xfer->ops.request_denied != NULL) |
493 xfer->ops.request_denied(xfer); | |
5164 | 494 |
7805 | 495 gaim_xfer_unref(xfer); |
4514
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 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
498 GaimXferType |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
499 gaim_xfer_get_type(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
500 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
501 g_return_val_if_fail(xfer != NULL, GAIM_XFER_UNKNOWN); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
502 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
503 return xfer->type; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
504 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
505 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5495
diff
changeset
|
506 GaimAccount * |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
507 gaim_xfer_get_account(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
508 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
509 g_return_val_if_fail(xfer != NULL, NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
510 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
511 return xfer->account; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
512 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
513 |
7805 | 514 GaimXferStatusType |
515 gaim_xfer_get_status(const GaimXfer *xfer) | |
516 { | |
517 g_return_val_if_fail(xfer != NULL, GAIM_XFER_STATUS_UNKNOWN); | |
518 | |
519 return xfer->status; | |
520 } | |
521 | |
522 gboolean | |
7738 | 523 gaim_xfer_is_canceled(const GaimXfer *xfer) |
524 { | |
525 g_return_val_if_fail(xfer != NULL, TRUE); | |
526 | |
7805 | 527 if ((gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) || |
528 (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_REMOTE)) | |
529 return TRUE; | |
530 else | |
531 return FALSE; | |
7738 | 532 } |
533 | |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
534 gboolean |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
535 gaim_xfer_is_completed(const GaimXfer *xfer) |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
536 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
537 g_return_val_if_fail(xfer != NULL, TRUE); |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
538 |
7805 | 539 return (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_DONE); |
4539
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
540 } |
05476ef20d58
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
541 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
542 const char * |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
543 gaim_xfer_get_filename(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
544 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
545 g_return_val_if_fail(xfer != NULL, NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
546 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
547 return xfer->filename; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
548 } |
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 const char * |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
551 gaim_xfer_get_local_filename(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
552 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
553 g_return_val_if_fail(xfer != NULL, NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
554 |
4605 | 555 return xfer->local_filename; |
4514
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 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
558 size_t |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
559 gaim_xfer_get_bytes_sent(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
560 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
561 g_return_val_if_fail(xfer != NULL, 0); |
4514
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 return xfer->bytes_sent; |
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 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
566 size_t |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
567 gaim_xfer_get_bytes_remaining(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
568 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
569 g_return_val_if_fail(xfer != NULL, 0); |
4514
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 return xfer->bytes_remaining; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
572 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
573 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
574 size_t |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
575 gaim_xfer_get_size(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
576 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
577 g_return_val_if_fail(xfer != NULL, 0); |
4514
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 return xfer->size; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
580 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
581 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
582 double |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
583 gaim_xfer_get_progress(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
584 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
585 g_return_val_if_fail(xfer != NULL, 0.0); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
586 |
4517
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
587 if (gaim_xfer_get_size(xfer) == 0) |
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
588 return 0.0; |
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
589 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
590 return ((double)gaim_xfer_get_bytes_sent(xfer) / |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
591 (double)gaim_xfer_get_size(xfer)); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
592 } |
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 unsigned int |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
595 gaim_xfer_get_local_port(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
596 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
597 g_return_val_if_fail(xfer != NULL, -1); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
598 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
599 return xfer->local_port; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
600 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
601 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
602 const char * |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
603 gaim_xfer_get_remote_ip(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
604 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
605 g_return_val_if_fail(xfer != NULL, NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
606 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
607 return xfer->remote_ip; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
608 } |
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 unsigned int |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
611 gaim_xfer_get_remote_port(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
612 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
613 g_return_val_if_fail(xfer != NULL, -1); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
614 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
615 return xfer->remote_port; |
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 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
618 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
619 gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed) |
4538 | 620 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
621 GaimXferUiOps *ui_ops; |
4656 | 622 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
623 g_return_if_fail(xfer != NULL); |
4538 | 624 |
10654 | 625 if (completed == TRUE) { |
626 char *msg = NULL; | |
7805 | 627 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_DONE); |
4656 | 628 |
10654 | 629 if (gaim_xfer_get_filename(xfer) != NULL) |
630 msg = g_strdup_printf(_("Transfer of file %s complete"), | |
631 gaim_xfer_get_filename(xfer)); | |
632 else | |
633 msg = g_strdup_printf(_("File transfer complete")); | |
634 gaim_xfer_conversation_write(xfer, msg, FALSE); | |
635 g_free(msg); | |
636 } | |
637 | |
4656 | 638 ui_ops = gaim_xfer_get_ui_ops(xfer); |
639 | |
640 if (ui_ops != NULL && ui_ops->update_progress != NULL) | |
641 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer)); | |
4538 | 642 } |
643 | |
644 void | |
9933 | 645 gaim_xfer_set_message(GaimXfer *xfer, const char *message) |
646 { | |
647 g_return_if_fail(xfer != NULL); | |
648 | |
649 g_free(xfer->message); | |
650 | |
651 if (message != NULL) | |
652 xfer->message = g_strdup(message); | |
653 else | |
654 xfer->message = NULL; | |
655 } | |
656 | |
657 void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
658 gaim_xfer_set_filename(GaimXfer *xfer, const char *filename) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
659 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
660 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
661 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
662 if (xfer->filename != NULL) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
663 g_free(xfer->filename); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
664 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
665 xfer->filename = (filename == NULL ? NULL : g_strdup(filename)); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
666 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
667 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
668 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
669 gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
670 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
671 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
672 |
4605 | 673 if (xfer->local_filename != NULL) |
674 g_free(xfer->local_filename); | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
675 |
4605 | 676 xfer->local_filename = (filename == NULL ? NULL : g_strdup(filename)); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
677 } |
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 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
680 gaim_xfer_set_size(GaimXfer *xfer, size_t size) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
681 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
682 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
683 |
4540
d83c5b925a05
[gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents:
4539
diff
changeset
|
684 if (xfer->size == 0) |
4538 | 685 xfer->bytes_remaining = size - xfer->bytes_sent; |
686 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
687 xfer->size = size; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
688 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
689 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
690 GaimXferUiOps * |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
691 gaim_xfer_get_ui_ops(const GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
692 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
693 g_return_val_if_fail(xfer != NULL, NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
694 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
695 return xfer->ui_ops; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
696 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
697 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
698 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
699 gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
700 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
701 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
702 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
703 xfer->ops.init = fnc; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
704 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
705 |
7805 | 706 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)) |
707 { | |
708 g_return_if_fail(xfer != NULL); | |
709 | |
710 xfer->ops.request_denied = fnc; | |
711 } | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
712 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
713 void |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
714 gaim_xfer_set_read_fnc(GaimXfer *xfer, gssize (*fnc)(guchar **, GaimXfer *)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
715 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
716 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
717 |
5495
5b678994929b
[gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5494
diff
changeset
|
718 xfer->ops.read = fnc; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
719 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
720 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
721 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
722 gaim_xfer_set_write_fnc(GaimXfer *xfer, |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
723 gssize (*fnc)(const guchar *, size_t, GaimXfer *)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
724 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
725 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
726 |
5495
5b678994929b
[gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5494
diff
changeset
|
727 xfer->ops.write = fnc; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
728 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
729 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
730 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
731 gaim_xfer_set_ack_fnc(GaimXfer *xfer, |
11159 | 732 void (*fnc)(GaimXfer *, const guchar *, size_t)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
733 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
734 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
735 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
736 xfer->ops.ack = fnc; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
737 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
738 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
739 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
740 gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
741 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
742 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
743 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
744 xfer->ops.start = fnc; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
745 } |
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 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
748 gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
749 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
750 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
751 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
752 xfer->ops.end = fnc; |
3609 | 753 } |
754 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
755 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
756 gaim_xfer_set_cancel_send_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)) |
3609 | 757 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
758 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
759 |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
760 xfer->ops.cancel_send = fnc; |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
761 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
762 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
763 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
764 gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *)) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
765 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
766 g_return_if_fail(xfer != NULL); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
767 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
768 xfer->ops.cancel_recv = fnc; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
769 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
770 |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
771 gssize |
11159 | 772 gaim_xfer_read(GaimXfer *xfer, guchar **buffer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
773 { |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
774 gssize s, r; |
3609 | 775 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
776 g_return_val_if_fail(xfer != NULL, 0); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
777 g_return_val_if_fail(buffer != NULL, 0); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
778 |
4517
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
779 if (gaim_xfer_get_size(xfer) == 0) |
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
780 s = 4096; |
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
781 else |
a2b2cce63fb8
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
782 s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); |
3609 | 783 |
5495
5b678994929b
[gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5494
diff
changeset
|
784 if (xfer->ops.read != NULL) |
5b678994929b
[gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5494
diff
changeset
|
785 r = (xfer->ops.read)(buffer, xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
786 else { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
787 *buffer = g_malloc0(s); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
788 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
789 r = read(xfer->fd, *buffer, s); |
13011
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
790 if (r < 0 && errno == EAGAIN) |
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
791 r = 0; |
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
792 else if (r < 0) |
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
793 r = -1; |
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
794 else if ((gaim_xfer_get_size(xfer) > 0) && |
4617 | 795 ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer))) |
4538 | 796 gaim_xfer_set_completed(xfer, TRUE); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
797 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
798 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
799 return r; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
800 } |
3609 | 801 |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
802 gssize |
13727
4b6308145fcd
[gaim-migrate @ 16138]
Richard Laager <rlaager@wiktel.com>
parents:
13598
diff
changeset
|
803 gaim_xfer_write(GaimXfer *xfer, const guchar *buffer, gsize size) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
804 { |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
805 gssize r, s; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
806 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
807 g_return_val_if_fail(xfer != NULL, 0); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
808 g_return_val_if_fail(buffer != NULL, 0); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
809 g_return_val_if_fail(size != 0, 0); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
810 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
811 s = MIN(gaim_xfer_get_bytes_remaining(xfer), size); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
812 |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
813 if (xfer->ops.write != NULL) { |
5495
5b678994929b
[gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5494
diff
changeset
|
814 r = (xfer->ops.write)(buffer, s, xfer); |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
815 } else { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
816 r = write(xfer->fd, buffer, s); |
13011
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
817 if (r < 0 && errno == EAGAIN) |
5e14039d0415
[gaim-migrate @ 15364]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12250
diff
changeset
|
818 r = 0; |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
819 if ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer)) |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
820 gaim_xfer_set_completed(xfer, TRUE); |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
821 } |
3609 | 822 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
823 return r; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
824 } |
3609 | 825 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
826 static void |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
827 transfer_cb(gpointer data, gint source, GaimInputCondition condition) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
828 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
829 GaimXferUiOps *ui_ops; |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
830 GaimXfer *xfer = (GaimXfer *)data; |
11159 | 831 guchar *buffer = NULL; |
12151
de798f2f4bf1
[gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents:
11934
diff
changeset
|
832 gssize r = 0; |
3609 | 833 |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
834 if (condition & GAIM_INPUT_READ) { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
835 r = gaim_xfer_read(xfer, &buffer); |
8316 | 836 if (r > 0) { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
837 fwrite(buffer, 1, r, xfer->dest_fp); |
8316 | 838 } else if(r < 0) { |
839 gaim_xfer_cancel_remote(xfer); | |
840 return; | |
13108
8695e933ad64
[gaim-migrate @ 15470]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13107
diff
changeset
|
841 } |
3609 | 842 } |
9798 | 843 |
844 if (condition & GAIM_INPUT_WRITE) { | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
845 size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
846 |
8351 | 847 /* this is so the prpl can keep the connection open |
848 if it needs to for some odd reason. */ | |
849 if (s == 0) { | |
9798 | 850 if (xfer->watcher) { |
8351 | 851 gaim_input_remove(xfer->watcher); |
852 xfer->watcher = 0; | |
853 } | |
854 return; | |
855 } | |
856 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
857 buffer = g_malloc0(s); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
858 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
859 fread(buffer, 1, s, xfer->dest_fp); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
860 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
861 /* Write as much as we're allowed to. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
862 r = gaim_xfer_write(xfer, buffer, s); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
863 |
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
864 if (r == -1) { |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
865 gaim_xfer_cancel_remote(xfer); |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
866 g_free(buffer); |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
867 return; |
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8208
diff
changeset
|
868 } else if (r < s) { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
869 /* We have to seek back in the file now. */ |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
870 fseek(xfer->dest_fp, r - s, SEEK_CUR); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
871 } |
3609 | 872 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
873 |
13107
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
874 if (r > 0) { |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
875 if (gaim_xfer_get_size(xfer) > 0) |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
876 xfer->bytes_remaining -= r; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
877 |
13107
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
878 xfer->bytes_sent += r; |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
879 |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
880 if (xfer->ops.ack != NULL) |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
881 xfer->ops.ack(xfer, buffer, r); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
882 |
13107
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
883 g_free(buffer); |
4594 | 884 |
13107
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
885 ui_ops = gaim_xfer_get_ui_ops(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
886 |
13107
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
887 if (ui_ops != NULL && ui_ops->update_progress != NULL) |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
888 ui_ops->update_progress(xfer, |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
889 gaim_xfer_get_progress(xfer)); |
d65fa65eac02
[gaim-migrate @ 15469]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13011
diff
changeset
|
890 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
891 |
4553
d03fcb3f4be2
[gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents:
4540
diff
changeset
|
892 if (gaim_xfer_is_completed(xfer)) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
893 gaim_xfer_end(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
894 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
895 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
896 static void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
897 begin_transfer(GaimXfer *xfer, GaimInputCondition cond) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
898 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
899 GaimXferType type = gaim_xfer_get_type(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
900 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
901 xfer->dest_fp = g_fopen(gaim_xfer_get_local_filename(xfer), |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
902 type == GAIM_XFER_RECEIVE ? "wb" : "rb"); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
903 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
904 if (xfer->dest_fp == NULL) { |
9796 | 905 gaim_xfer_show_file_error(xfer, gaim_xfer_get_local_filename(xfer)); |
9785 | 906 gaim_xfer_cancel_local(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
907 return; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
908 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
909 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
910 xfer->watcher = gaim_input_add(xfer->fd, cond, transfer_cb, xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
911 |
13598 | 912 xfer->start_time = time(NULL); |
913 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
914 if (xfer->ops.start != NULL) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
915 xfer->ops.start(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
916 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
917 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
918 static void |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
919 connect_cb(gpointer data, gint source, GaimInputCondition condition) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
920 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
921 GaimXfer *xfer = (GaimXfer *)data; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
922 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
923 xfer->fd = source; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
924 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
925 begin_transfer(xfer, condition); |
3609 | 926 } |
927 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
928 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
929 gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
930 unsigned int port) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
931 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
932 GaimInputCondition cond; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
933 GaimXferType type; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
934 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
935 g_return_if_fail(xfer != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
936 g_return_if_fail(gaim_xfer_get_type(xfer) != GAIM_XFER_UNKNOWN); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
937 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
938 type = gaim_xfer_get_type(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
939 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
940 xfer->bytes_remaining = gaim_xfer_get_size(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
941 xfer->bytes_sent = 0; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
942 |
7805 | 943 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_STARTED); |
944 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
945 if (type == GAIM_XFER_RECEIVE) { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
946 cond = GAIM_INPUT_READ; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
947 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
948 if (ip != NULL) { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
949 xfer->remote_ip = g_strdup(ip); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
950 xfer->remote_port = port; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
951 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
952 /* Establish a file descriptor. */ |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
953 gaim_proxy_connect(xfer->account, xfer->remote_ip, |
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
954 xfer->remote_port, connect_cb, xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
955 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
956 return; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
957 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
958 else { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
959 xfer->fd = fd; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
960 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
961 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
962 else { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
963 cond = GAIM_INPUT_WRITE; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
964 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
965 xfer->fd = fd; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
966 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
967 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
968 begin_transfer(xfer, cond); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
969 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
970 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
971 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
972 gaim_xfer_end(GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
973 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
974 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
975 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
976 /* See if we are actually trying to cancel this. */ |
13594 | 977 if (!gaim_xfer_is_completed(xfer)) { |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
978 gaim_xfer_cancel_local(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
979 return; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
980 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
981 |
13598 | 982 xfer->end_time = time(NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
983 if (xfer->ops.end != NULL) |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
984 xfer->ops.end(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
985 |
4521
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
986 if (xfer->watcher != 0) { |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
987 gaim_input_remove(xfer->watcher); |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
988 xfer->watcher = 0; |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
989 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
990 |
4521
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
991 if (xfer->fd != 0) |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
992 close(xfer->fd); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
993 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
994 if (xfer->dest_fp != NULL) { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
995 fclose(xfer->dest_fp); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
996 xfer->dest_fp = NULL; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
997 } |
7805 | 998 |
999 gaim_xfer_unref(xfer); | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1000 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1001 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1002 void |
8585 | 1003 gaim_xfer_add(GaimXfer *xfer) |
1004 { | |
1005 GaimXferUiOps *ui_ops; | |
1006 | |
1007 g_return_if_fail(xfer != NULL); | |
1008 | |
1009 ui_ops = gaim_xfer_get_ui_ops(xfer); | |
1010 | |
1011 if (ui_ops != NULL && ui_ops->add_xfer != NULL) | |
1012 ui_ops->add_xfer(xfer); | |
1013 } | |
1014 | |
1015 void | |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1016 gaim_xfer_cancel_local(GaimXfer *xfer) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1017 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1018 GaimXferUiOps *ui_ops; |
10774 | 1019 char *msg = NULL; |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1020 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1021 g_return_if_fail(xfer != NULL); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1022 |
7805 | 1023 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL); |
13598 | 1024 xfer->end_time = time(NULL); |
7738 | 1025 |
10470 | 1026 if (gaim_xfer_get_filename(xfer) != NULL) |
1027 { | |
1028 msg = g_strdup_printf(_("You canceled the transfer of %s"), | |
10774 | 1029 gaim_xfer_get_filename(xfer)); |
10470 | 1030 } |
1031 else | |
1032 { | |
1033 msg = g_strdup_printf(_("File transfer cancelled")); | |
1034 } | |
9932 | 1035 gaim_xfer_conversation_write(xfer, msg, FALSE); |
1036 g_free(msg); | |
1037 | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1038 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1039 { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1040 if (xfer->ops.cancel_send != NULL) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1041 xfer->ops.cancel_send(xfer); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1042 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1043 else |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1044 { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1045 if (xfer->ops.cancel_recv != NULL) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1046 xfer->ops.cancel_recv(xfer); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1047 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1048 |
4521
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1049 if (xfer->watcher != 0) { |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1050 gaim_input_remove(xfer->watcher); |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1051 xfer->watcher = 0; |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1052 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1053 |
4521
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1054 if (xfer->fd != 0) |
dda0fbba1c46
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1055 close(xfer->fd); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1056 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1057 if (xfer->dest_fp != NULL) { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1058 fclose(xfer->dest_fp); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1059 xfer->dest_fp = NULL; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1060 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1061 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1062 ui_ops = gaim_xfer_get_ui_ops(xfer); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1063 |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1064 if (ui_ops != NULL && ui_ops->cancel_local != NULL) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1065 ui_ops->cancel_local(xfer); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1066 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1067 xfer->bytes_remaining = 0; |
7805 | 1068 |
1069 gaim_xfer_unref(xfer); | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1070 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1071 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1072 void |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1073 gaim_xfer_cancel_remote(GaimXfer *xfer) |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1074 { |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1075 GaimXferUiOps *ui_ops; |
10774 | 1076 gchar *msg; |
10654 | 1077 GaimAccount *account; |
1078 GaimBuddy *buddy; | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1079 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1080 g_return_if_fail(xfer != NULL); |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1081 |
9771 | 1082 gaim_request_close_with_handle(xfer); |
9932 | 1083 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE); |
13598 | 1084 xfer->end_time = time(NULL); |
9771 | 1085 |
10654 | 1086 account = gaim_xfer_get_account(xfer); |
1087 buddy = gaim_find_buddy(account, xfer->who); | |
1088 | |
10470 | 1089 if (gaim_xfer_get_filename(xfer) != NULL) |
1090 { | |
1091 msg = g_strdup_printf(_("%s canceled the transfer of %s"), | |
10774 | 1092 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, gaim_xfer_get_filename(xfer)); |
10470 | 1093 } |
1094 else | |
1095 { | |
10654 | 1096 msg = g_strdup_printf(_("%s canceled the file transfer"), |
1097 buddy ? gaim_buddy_get_alias(buddy) : xfer->who); | |
10470 | 1098 } |
9932 | 1099 gaim_xfer_conversation_write(xfer, msg, TRUE); |
10654 | 1100 gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg); |
9771 | 1101 g_free(msg); |
1102 | |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1103 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1104 { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1105 if (xfer->ops.cancel_send != NULL) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1106 xfer->ops.cancel_send(xfer); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1107 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1108 else |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1109 { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1110 if (xfer->ops.cancel_recv != NULL) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1111 xfer->ops.cancel_recv(xfer); |
7272
02f697df677b
[gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1112 } |
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1113 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1114 if (xfer->watcher != 0) { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1115 gaim_input_remove(xfer->watcher); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1116 xfer->watcher = 0; |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1117 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1118 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1119 if (xfer->fd != 0) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1120 close(xfer->fd); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1121 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1122 if (xfer->dest_fp != NULL) { |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1123 fclose(xfer->dest_fp); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1124 xfer->dest_fp = NULL; |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1125 } |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1126 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1127 ui_ops = gaim_xfer_get_ui_ops(xfer); |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1128 |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1129 if (ui_ops != NULL && ui_ops->cancel_remote != NULL) |
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1130 ui_ops->cancel_remote(xfer); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1131 |
4528
f8fec48f0fde
[gaim-migrate @ 4806]
Christian Hammond <chipx86@chipx86.com>
parents:
4521
diff
changeset
|
1132 xfer->bytes_remaining = 0; |
7805 | 1133 |
1134 gaim_xfer_unref(xfer); | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1135 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1136 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1137 void |
10654 | 1138 gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg) |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1139 { |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1140 char *title; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1141 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1142 g_return_if_fail(msg != NULL); |
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1143 g_return_if_fail(type != GAIM_XFER_UNKNOWN); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1144 |
10654 | 1145 if (account) { |
1146 GaimBuddy *buddy; | |
1147 buddy = gaim_find_buddy(account, who); | |
1148 if (buddy) | |
1149 who = gaim_buddy_get_alias(buddy); | |
1150 } | |
1151 | |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1152 if (type == GAIM_XFER_SEND) |
11231
64e2c65ef650
[gaim-migrate @ 13371]
Richard Laager <rlaager@wiktel.com>
parents:
11159
diff
changeset
|
1153 title = g_strdup_printf(_("File transfer to %s failed."), who); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1154 else |
11231
64e2c65ef650
[gaim-migrate @ 13371]
Richard Laager <rlaager@wiktel.com>
parents:
11159
diff
changeset
|
1155 title = g_strdup_printf(_("File transfer from %s failed."), who); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1156 |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5169
diff
changeset
|
1157 gaim_notify_error(NULL, NULL, title, msg); |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1158 |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1159 g_free(title); |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1160 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1161 |
8585 | 1162 void |
1163 gaim_xfer_update_progress(GaimXfer *xfer) | |
1164 { | |
1165 GaimXferUiOps *ui_ops; | |
1166 | |
1167 g_return_if_fail(xfer != NULL); | |
1168 | |
1169 ui_ops = gaim_xfer_get_ui_ops(xfer); | |
1170 if (ui_ops != NULL && ui_ops->update_progress != NULL) | |
1171 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer)); | |
1172 } | |
1173 | |
1174 | |
6263
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
1175 /************************************************************************** |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
1176 * File Transfer Subsystem API |
3565ee7a5dd3
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
1177 **************************************************************************/ |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1178 void * |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1179 gaim_xfers_get_handle(void) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1180 static int handle = 0; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1181 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1182 return &handle; |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1183 } |
6241
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
1184 |
9ce44a7f9ae7
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
1185 void |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1186 gaim_xfers_init(void) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1187 void *handle = gaim_xfers_get_handle(); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1188 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1189 /* register signals */ |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1190 gaim_signal_register(handle, "file-recv-accept", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1191 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1192 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1193 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1194 gaim_signal_register(handle, "file-send-accept", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1195 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1196 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1197 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1198 gaim_signal_register(handle, "file-recv-start", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1199 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1200 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1201 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1202 gaim_signal_register(handle, "file-send-start", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1203 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1204 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1205 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1206 gaim_signal_register(handle, "file-send-cancel", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1207 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1208 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1209 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1210 gaim_signal_register(handle, "file-recv-cancel", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1211 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1212 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1213 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1214 gaim_signal_register(handle, "file-send-complete", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1215 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1216 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1217 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1218 gaim_signal_register(handle, "file-recv-complete", |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1219 gaim_marshal_VOID__POINTER, |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1220 NULL, 1, |
13219
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1221 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1222 gaim_signal_register(handle, "file-recv-request", |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1223 gaim_marshal_VOID__POINTER, |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1224 NULL, 1, |
d0f7f698b6de
[gaim-migrate @ 15583]
Richard Laager <rlaager@wiktel.com>
parents:
13108
diff
changeset
|
1225 gaim_value_new(GAIM_TYPE_POINTER, GAIM_SUBTYPE_XFER)); |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1226 } |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1227 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1228 void |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1229 gaim_xfers_uninit(void) { |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1230 gaim_signals_disconnect_by_handle(gaim_xfers_get_handle()); |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1231 } |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1232 |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1233 void |
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1234 gaim_xfers_set_ui_ops(GaimXferUiOps *ops) { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1235 xfer_ui_ops = ops; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1236 } |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1237 |
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1238 GaimXferUiOps * |
11281
920a37a4c1be
[gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents:
11231
diff
changeset
|
1239 gaim_xfers_get_ui_ops(void) { |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1240 return xfer_ui_ops; |
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1241 } |