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