Sun, 29 Nov 2009 17:35:00 +0000
ft: Properly set a bitmask field (so it includes PURPLE_MESSAGE_SYSTEM like
all other ft messages).
committer: Paul Aurich <darkrain42@pidgin.im>
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1 | /** |
|
7820
06fc9f66d2cb
[gaim-migrate @ 8472]
Mark Doliner <markdoliner@pidgin.im>
parents:
7805
diff
changeset
|
2 | * @file ft.c File Transfer API |
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
3 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
4 | |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
5 | /* purple |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
6 | * |
| 15884 | 7 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 9 | * source distribution. | |
| 4538 | 10 | * |
| 3609 | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19733
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
19733
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
24 | * |
| 3609 | 25 | */ |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
26 | #include "internal.h" |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
27 | #include "dbus-maybe.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
28 | #include "ft.h" |
| 8231 | 29 | #include "network.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
30 | #include "notify.h" |
|
6241
34d166a31152
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
31 | #include "prefs.h" |
| 3609 | 32 | #include "proxy.h" |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
33 | #include "request.h" |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
34 | #include "util.h" |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
35 | #include "debug.h" |
|
5494
410d120ef10d
[gaim-migrate @ 5890]
Herman Bloggs <herman@bluedigits.com>
parents:
5436
diff
changeset
|
36 | |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
37 | #define FT_INITIAL_BUFFER_SIZE 4096 |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
38 | #define FT_MAX_BUFFER_SIZE 65535 |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
39 | |
| 15884 | 40 | static PurpleXferUiOps *xfer_ui_ops = NULL; |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
41 | static GList *xfers; |
| 3609 | 42 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
43 | /* |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
44 | * A hack to store more data since we can't extend the size of PurpleXfer |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
45 | * easily. |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
46 | */ |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
47 | static GHashTable *xfers_data = NULL; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
48 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
49 | typedef struct _PurpleXferPrivData { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
50 | /* |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
51 | * Used to moderate the file transfer when either the read/write ui_ops are |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
52 | * set or fd is not set. In those cases, the UI/prpl call the respective |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
53 | * function, which is somewhat akin to a fd watch being triggered. |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
54 | */ |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
55 | enum { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
56 | PURPLE_XFER_READY_NONE = 0x0, |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
57 | PURPLE_XFER_READY_UI = 0x1, |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
58 | PURPLE_XFER_READY_PRPL = 0x2, |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
59 | } ready; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
60 | } PurpleXferPrivData; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
61 | |
| 15884 | 62 | static int purple_xfer_choose_file(PurpleXfer *xfer); |
| 14967 | 63 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
64 | static void |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
65 | purple_xfer_priv_data_destroy(gpointer data) |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
66 | { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
67 | PurpleXferPrivData *priv = data; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
68 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
69 | g_free(priv); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
70 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
71 | |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
72 | GList * |
| 15884 | 73 | purple_xfers_get_all() |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
74 | { |
|
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
75 | return xfers; |
|
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
76 | } |
|
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
77 | |
| 15884 | 78 | PurpleXfer * |
| 79 | purple_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who) | |
| 3609 | 80 | { |
| 15884 | 81 | PurpleXfer *xfer; |
| 82 | PurpleXferUiOps *ui_ops; | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
83 | PurpleXferPrivData *priv; |
| 3609 | 84 | |
| 15884 | 85 | g_return_val_if_fail(type != PURPLE_XFER_UNKNOWN, NULL); |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
86 | g_return_val_if_fail(account != NULL, NULL); |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
87 | g_return_val_if_fail(who != NULL, NULL); |
| 3609 | 88 | |
| 15884 | 89 | xfer = g_new0(PurpleXfer, 1); |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
90 | PURPLE_DBUS_REGISTER_POINTER(xfer, PurpleXfer); |
| 3609 | 91 | |
| 7805 | 92 | xfer->ref = 1; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
93 | xfer->type = type; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
94 | xfer->account = account; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
95 | xfer->who = g_strdup(who); |
| 15884 | 96 | xfer->ui_ops = purple_xfers_get_ui_ops(); |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
97 | xfer->message = NULL; |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
98 | xfer->current_buffer_size = FT_INITIAL_BUFFER_SIZE; |
|
20061
c1e53ac90b75
grab revision ae2654a1c8a8119292950ba10857627abf2915f8 Initialize file-descriptors to -1.
Luke Schierer <lschiere@pidgin.im>
parents:
19859
diff
changeset
|
99 | xfer->fd = -1; |
| 3609 | 100 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
101 | priv = g_new0(PurpleXferPrivData, 1); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
102 | priv->ready = PURPLE_XFER_READY_NONE; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
103 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
104 | g_hash_table_insert(xfers_data, xfer, priv); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
105 | |
| 15884 | 106 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
5169
091d71968b59
[gaim-migrate @ 5533]
Mark Doliner <markdoliner@pidgin.im>
parents:
5164
diff
changeset
|
107 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
108 | if (ui_ops != NULL && ui_ops->new_xfer != NULL) |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
109 | ui_ops->new_xfer(xfer); |
|
5169
091d71968b59
[gaim-migrate @ 5533]
Mark Doliner <markdoliner@pidgin.im>
parents:
5164
diff
changeset
|
110 | |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
111 | xfers = g_list_prepend(xfers, xfer); |
| 3609 | 112 | return xfer; |
| 113 | } | |
| 114 | ||
| 7805 | 115 | static void |
| 15884 | 116 | purple_xfer_destroy(PurpleXfer *xfer) |
| 3609 | 117 | { |
| 15884 | 118 | PurpleXferUiOps *ui_ops; |
|
4247
a77b46afa096
[gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents:
4245
diff
changeset
|
119 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
120 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
121 | |
|
9512
d51da219ffb4
[gaim-migrate @ 10339]
Mark Doliner <markdoliner@pidgin.im>
parents:
9511
diff
changeset
|
122 | /* Close the file browser, if it's open */ |
| 15884 | 123 | purple_request_close_with_handle(xfer); |
|
9512
d51da219ffb4
[gaim-migrate @ 10339]
Mark Doliner <markdoliner@pidgin.im>
parents:
9511
diff
changeset
|
124 | |
| 15884 | 125 | if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) |
| 126 | purple_xfer_cancel_local(xfer); | |
| 3609 | 127 | |
| 15884 | 128 | ui_ops = purple_xfer_get_ui_ops(xfer); |
| 3609 | 129 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
130 | if (ui_ops != NULL && ui_ops->destroy != NULL) |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
131 | ui_ops->destroy(xfer); |
| 3609 | 132 | |
|
9789
9f056394f7f0
[gaim-migrate @ 10657]
Mark Doliner <markdoliner@pidgin.im>
parents:
9788
diff
changeset
|
133 | g_free(xfer->who); |
|
9f056394f7f0
[gaim-migrate @ 10657]
Mark Doliner <markdoliner@pidgin.im>
parents:
9788
diff
changeset
|
134 | g_free(xfer->filename); |
|
9f056394f7f0
[gaim-migrate @ 10657]
Mark Doliner <markdoliner@pidgin.im>
parents:
9788
diff
changeset
|
135 | g_free(xfer->remote_ip); |
|
9f056394f7f0
[gaim-migrate @ 10657]
Mark Doliner <markdoliner@pidgin.im>
parents:
9788
diff
changeset
|
136 | g_free(xfer->local_filename); |
| 3609 | 137 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
138 | g_hash_table_remove(xfers_data, xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
139 | |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
140 | PURPLE_DBUS_UNREGISTER_POINTER(xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
141 | xfers = g_list_remove(xfers, xfer); |
| 3609 | 142 | g_free(xfer); |
| 143 | } | |
| 144 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
145 | void |
| 15884 | 146 | purple_xfer_ref(PurpleXfer *xfer) |
| 7805 | 147 | { |
| 148 | g_return_if_fail(xfer != NULL); | |
| 149 | ||
| 150 | xfer->ref++; | |
| 151 | } | |
| 152 | ||
| 153 | void | |
| 15884 | 154 | purple_xfer_unref(PurpleXfer *xfer) |
| 7805 | 155 | { |
| 156 | g_return_if_fail(xfer != NULL); | |
|
12250
5b14301dd1ec
[gaim-migrate @ 14552]
Richard Laager <rlaager@pidgin.im>
parents:
12151
diff
changeset
|
157 | g_return_if_fail(xfer->ref > 0); |
| 7805 | 158 | |
| 159 | xfer->ref--; | |
| 160 | ||
| 161 | if (xfer->ref == 0) | |
| 15884 | 162 | purple_xfer_destroy(xfer); |
| 7805 | 163 | } |
| 164 | ||
|
9788
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
165 | static void |
| 15884 | 166 | purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatusType status) |
|
9788
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
167 | { |
|
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
168 | g_return_if_fail(xfer != NULL); |
|
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
169 | |
|
27993
857add008895
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <darkrain42@pidgin.im>
parents:
27944
diff
changeset
|
170 | if (xfer->status == status) |
|
857add008895
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <darkrain42@pidgin.im>
parents:
27944
diff
changeset
|
171 | return; |
|
857add008895
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <darkrain42@pidgin.im>
parents:
27944
diff
changeset
|
172 | |
|
27942
ace850ade78d
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
173 | xfer->status = status; |
|
ace850ade78d
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
174 | |
| 15884 | 175 | if(xfer->type == PURPLE_XFER_SEND) { |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
176 | switch(status) { |
| 15884 | 177 | case PURPLE_XFER_STATUS_ACCEPTED: |
| 178 | purple_signal_emit(purple_xfers_get_handle(), "file-send-accept", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
179 | break; |
| 15884 | 180 | case PURPLE_XFER_STATUS_STARTED: |
| 181 | purple_signal_emit(purple_xfers_get_handle(), "file-send-start", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
182 | break; |
| 15884 | 183 | case PURPLE_XFER_STATUS_DONE: |
| 184 | purple_signal_emit(purple_xfers_get_handle(), "file-send-complete", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
185 | break; |
| 15884 | 186 | case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
| 187 | case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
| 188 | purple_signal_emit(purple_xfers_get_handle(), "file-send-cancel", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
189 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
190 | default: |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
191 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
192 | } |
| 15884 | 193 | } else if(xfer->type == PURPLE_XFER_RECEIVE) { |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
194 | switch(status) { |
| 15884 | 195 | case PURPLE_XFER_STATUS_ACCEPTED: |
| 196 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-accept", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
197 | break; |
| 15884 | 198 | case PURPLE_XFER_STATUS_STARTED: |
| 199 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-start", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
200 | break; |
| 15884 | 201 | case PURPLE_XFER_STATUS_DONE: |
| 202 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-complete", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
203 | break; |
| 15884 | 204 | case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
| 205 | case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
| 206 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-cancel", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
207 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
208 | default: |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
209 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
210 | } |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
211 | } |
|
9788
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
212 | } |
|
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
213 | |
| 15884 | 214 | void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error) |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
215 | { |
| 15884 | 216 | PurpleConversation *conv = NULL; |
| 217 | PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM; | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
218 | char *escaped; |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
219 | |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
220 | g_return_if_fail(xfer != NULL); |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
221 | g_return_if_fail(message != NULL); |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
222 | |
| 15884 | 223 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, |
| 224 | purple_xfer_get_account(xfer)); | |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
225 | |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
226 | if (conv == NULL) |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
227 | return; |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
228 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
229 | escaped = g_markup_escape_text(message, -1); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
230 | |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
231 | if (is_error) |
|
29019
9cb4fa62242d
ft: Properly set a bitmask field (so it includes PURPLE_MESSAGE_SYSTEM like
Florian Quèze <florian@instantbird.org>
parents:
28659
diff
changeset
|
232 | flags |= PURPLE_MESSAGE_ERROR; |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
233 | |
| 15884 | 234 | purple_conversation_write(conv, NULL, escaped, flags, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
235 | g_free(escaped); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
236 | } |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
237 | |
| 15884 | 238 | static void purple_xfer_show_file_error(PurpleXfer *xfer, const char *filename) |
| 9785 | 239 | { |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
240 | int err = errno; |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
241 | gchar *msg = NULL, *utf8; |
| 15884 | 242 | PurpleXferType xfer_type = purple_xfer_get_type(xfer); |
| 243 | PurpleAccount *account = purple_xfer_get_account(xfer); | |
| 9785 | 244 | |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
245 | utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
246 | switch(xfer_type) { |
| 15884 | 247 | case PURPLE_XFER_SEND: |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
248 | msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20147
diff
changeset
|
249 | utf8, g_strerror(err)); |
| 9795 | 250 | break; |
| 15884 | 251 | case PURPLE_XFER_RECEIVE: |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
252 | msg = g_strdup_printf(_("Error writing %s: \n%s.\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20147
diff
changeset
|
253 | utf8, g_strerror(err)); |
| 9785 | 254 | break; |
| 255 | default: | |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
256 | msg = g_strdup_printf(_("Error accessing %s: \n%s.\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20147
diff
changeset
|
257 | utf8, g_strerror(err)); |
| 9785 | 258 | break; |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
259 | } |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
260 | g_free(utf8); |
| 9785 | 261 | |
| 15884 | 262 | purple_xfer_conversation_write(xfer, msg, TRUE); |
| 263 | purple_xfer_error(xfer_type, account, xfer->who, msg); | |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
264 | g_free(msg); |
| 9785 | 265 | } |
| 266 | ||
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
267 | static void |
| 15884 | 268 | purple_xfer_choose_file_ok_cb(void *user_data, const char *filename) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
269 | { |
| 15884 | 270 | PurpleXfer *xfer; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
271 | struct stat st; |
| 14967 | 272 | gchar *dir; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
273 | |
| 15884 | 274 | xfer = (PurpleXfer *)user_data; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
275 | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10504
diff
changeset
|
276 | if (g_stat(filename, &st) != 0) { |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
277 | /* File not found. */ |
| 15884 | 278 | if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) { |
|
15161
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
279 | #ifndef _WIN32 |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
280 | int mode = W_OK; |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
281 | #else |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
282 | int mode = F_OK; |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
283 | #endif |
| 14967 | 284 | dir = g_path_get_dirname(filename); |
| 285 | ||
|
15161
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
286 | if (g_access(dir, mode) == 0) { |
| 15884 | 287 | purple_xfer_request_accepted(xfer, filename); |
| 14967 | 288 | } else { |
| 15884 | 289 | purple_xfer_ref(xfer); |
| 290 | purple_notify_message( | |
| 291 | NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, | |
| 14967 | 292 | _("Directory is not writable."), NULL, |
| 15884 | 293 | (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
| 14967 | 294 | } |
| 295 | ||
| 296 | g_free(dir); | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
297 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
298 | else { |
| 15884 | 299 | purple_xfer_show_file_error(xfer, filename); |
| 300 | purple_xfer_request_denied(xfer); | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
301 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
302 | } |
| 15884 | 303 | else if ((purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) && |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
304 | (st.st_size == 0)) { |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
305 | |
| 15884 | 306 | purple_notify_error(NULL, NULL, |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
307 | _("Cannot send a file of 0 bytes."), NULL); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
308 | |
| 15884 | 309 | purple_xfer_request_denied(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
310 | } |
| 15884 | 311 | else if ((purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) && |
| 9785 | 312 | S_ISDIR(st.st_mode)) { |
| 313 | /* | |
| 314 | * XXX - Sending a directory should be valid for some protocols. | |
| 315 | */ | |
| 15884 | 316 | purple_notify_error(NULL, NULL, |
| 9785 | 317 | _("Cannot send a directory."), NULL); |
| 318 | ||
| 15884 | 319 | purple_xfer_request_denied(xfer); |
| 9785 | 320 | } |
| 15884 | 321 | else if ((purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) && |
| 9785 | 322 | S_ISDIR(st.st_mode)) { |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
323 | char *msg, *utf8; |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
324 | utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
325 | msg = g_strdup_printf( |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
326 | _("%s is not a regular file. Cowardly refusing to overwrite it.\n"), utf8); |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
327 | g_free(utf8); |
| 15884 | 328 | purple_notify_error(NULL, NULL, msg, NULL); |
| 9785 | 329 | g_free(msg); |
| 15884 | 330 | purple_xfer_request_denied(xfer); |
| 9785 | 331 | } |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
332 | else { |
| 15884 | 333 | purple_xfer_request_accepted(xfer, filename); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
334 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
335 | |
| 15884 | 336 | purple_xfer_unref(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
337 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
338 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
339 | static void |
| 15884 | 340 | purple_xfer_choose_file_cancel_cb(void *user_data, const char *filename) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
341 | { |
| 15884 | 342 | PurpleXfer *xfer = (PurpleXfer *)user_data; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
343 | |
| 15884 | 344 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
| 345 | purple_xfer_request_denied(xfer); | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
346 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
347 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
348 | static int |
| 15884 | 349 | purple_xfer_choose_file(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
350 | { |
| 15884 | 351 | purple_request_file(xfer, NULL, purple_xfer_get_filename(xfer), |
| 352 | (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE), | |
| 353 | G_CALLBACK(purple_xfer_choose_file_ok_cb), | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
354 | G_CALLBACK(purple_xfer_choose_file_cancel_cb), |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
355 | purple_xfer_get_account(xfer), xfer->who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
356 | xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
357 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
358 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
359 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
360 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
361 | static int |
| 15884 | 362 | cancel_recv_cb(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
363 | { |
| 15884 | 364 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
| 365 | purple_xfer_request_denied(xfer); | |
| 366 | purple_xfer_unref(xfer); | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
367 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
368 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
369 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
370 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
371 | static void |
| 15884 | 372 | purple_xfer_ask_recv(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
373 | { |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
374 | char *buf, *size_buf; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
375 | size_t size; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
376 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
377 | /* If we have already accepted the request, ask the destination file |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
378 | name directly */ |
| 15884 | 379 | if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_ACCEPTED) { |
| 380 | PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
381 | |
| 15884 | 382 | if (purple_xfer_get_filename(xfer) != NULL) |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
383 | { |
| 15884 | 384 | size = purple_xfer_get_size(xfer); |
| 385 | size_buf = purple_str_size_to_units(size); | |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
386 | buf = g_strdup_printf(_("%s wants to send you %s (%s)"), |
| 15884 | 387 | buddy ? purple_buddy_get_alias(buddy) : xfer->who, |
| 388 | purple_xfer_get_filename(xfer), size_buf); | |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
389 | g_free(size_buf); |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
390 | } |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
391 | else |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
392 | { |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
393 | buf = g_strdup_printf(_("%s wants to send you a file"), |
| 15884 | 394 | buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
395 | } |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
396 | |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
397 | if (xfer->message != NULL) |
| 15884 | 398 | serv_got_im(purple_account_get_connection(xfer->account), |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
399 | xfer->who, xfer->message, 0, time(NULL)); |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
400 | |
| 15884 | 401 | purple_request_accept_cancel(xfer, NULL, buf, NULL, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
402 | PURPLE_DEFAULT_ACTION_NONE, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
403 | xfer->account, xfer->who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
404 | xfer, |
| 15884 | 405 | G_CALLBACK(purple_xfer_choose_file), |
|
9976
5fceb5de48b8
[gaim-migrate @ 10887]
Dave West <kat@users.sourceforge.net>
parents:
9941
diff
changeset
|
406 | G_CALLBACK(cancel_recv_cb)); |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
407 | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
408 | g_free(buf); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
409 | } else |
| 15884 | 410 | purple_xfer_choose_file(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
411 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
412 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
413 | static int |
| 15884 | 414 | ask_accept_ok(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
415 | { |
| 15884 | 416 | purple_xfer_request_accepted(xfer, NULL); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
417 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
418 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
419 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
420 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
421 | static int |
| 15884 | 422 | ask_accept_cancel(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
423 | { |
| 15884 | 424 | purple_xfer_request_denied(xfer); |
| 425 | purple_xfer_unref(xfer); | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
426 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
427 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
428 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
429 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
430 | static void |
| 15884 | 431 | purple_xfer_ask_accept(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
432 | { |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
433 | char *buf, *buf2 = NULL; |
| 15884 | 434 | PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
435 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
436 | buf = g_strdup_printf(_("Accept file transfer request from %s?"), |
| 15884 | 437 | buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
| 438 | if (purple_xfer_get_remote_ip(xfer) && | |
| 439 | purple_xfer_get_remote_port(xfer)) | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
440 | buf2 = g_strdup_printf(_("A file is available for download from:\n" |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
441 | "Remote host: %s\nRemote port: %d"), |
| 15884 | 442 | purple_xfer_get_remote_ip(xfer), |
| 443 | purple_xfer_get_remote_port(xfer)); | |
| 444 | purple_request_accept_cancel(xfer, NULL, buf, buf2, | |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
445 | PURPLE_DEFAULT_ACTION_NONE, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
446 | xfer->account, xfer->who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
447 | xfer, |
|
9976
5fceb5de48b8
[gaim-migrate @ 10887]
Dave West <kat@users.sourceforge.net>
parents:
9941
diff
changeset
|
448 | G_CALLBACK(ask_accept_ok), |
|
5fceb5de48b8
[gaim-migrate @ 10887]
Dave West <kat@users.sourceforge.net>
parents:
9941
diff
changeset
|
449 | G_CALLBACK(ask_accept_cancel)); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
450 | g_free(buf); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
451 | g_free(buf2); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
452 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
453 | |
| 7805 | 454 | void |
| 15884 | 455 | purple_xfer_request(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
456 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
457 | g_return_if_fail(xfer != NULL); |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
458 | g_return_if_fail(xfer->ops.init != NULL); |
| 3609 | 459 | |
| 15884 | 460 | purple_xfer_ref(xfer); |
|
4247
a77b46afa096
[gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents:
4245
diff
changeset
|
461 | |
| 15884 | 462 | if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
463 | { |
| 15884 | 464 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-request", xfer); |
| 465 | if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) | |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
466 | { |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
467 | /* The file-transfer was cancelled by a plugin */ |
| 15884 | 468 | purple_xfer_cancel_local(xfer); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
469 | } |
| 15884 | 470 | else if (purple_xfer_get_filename(xfer) || |
| 471 | purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_ACCEPTED) | |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
472 | { |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
473 | gchar* message = NULL; |
| 15884 | 474 | PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
475 | message = g_strdup_printf(_("%s is offering to send file %s"), |
| 15884 | 476 | buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer)); |
| 477 | purple_xfer_conversation_write(xfer, message, FALSE); | |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
478 | g_free(message); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
479 | /* Ask for a filename to save to if it's not already given by a plugin */ |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
480 | if (xfer->local_filename == NULL) |
| 15884 | 481 | purple_xfer_ask_recv(xfer); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
482 | } |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
483 | else |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
484 | { |
| 15884 | 485 | purple_xfer_ask_accept(xfer); |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
486 | } |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
487 | } |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
488 | else |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
489 | { |
| 15884 | 490 | purple_xfer_choose_file(xfer); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
491 | } |
| 3609 | 492 | } |
| 493 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
494 | void |
| 15884 | 495 | purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename) |
| 3609 | 496 | { |
| 15884 | 497 | PurpleXferType type; |
| 9785 | 498 | struct stat st; |
|
26726
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
499 | char *msg, *utf8, *base; |
| 15884 | 500 | PurpleAccount *account; |
| 501 | PurpleBuddy *buddy; | |
| 3609 | 502 | |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
503 | if (xfer == NULL) |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
504 | return; |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
505 | |
| 15884 | 506 | type = purple_xfer_get_type(xfer); |
| 507 | account = purple_xfer_get_account(xfer); | |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
508 | |
| 15884 | 509 | if (!filename && type == PURPLE_XFER_RECEIVE) { |
| 510 | xfer->status = PURPLE_XFER_STATUS_ACCEPTED; | |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
511 | xfer->ops.init(xfer); |
| 3609 | 512 | return; |
| 4150 | 513 | } |
| 3609 | 514 | |
| 15884 | 515 | buddy = purple_find_buddy(account, xfer->who); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
516 | |
| 15884 | 517 | if (type == PURPLE_XFER_SEND) { |
|
13595
191c2d12a00c
[gaim-migrate @ 15980]
Mark Doliner <markdoliner@pidgin.im>
parents:
13220
diff
changeset
|
518 | /* Sending a file */ |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
519 | /* Check the filename. */ |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
520 | PurpleXferUiOps *ui_ops; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
521 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
522 | |
| 11934 | 523 | #ifdef _WIN32 |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21682
diff
changeset
|
524 | if (g_strrstr(filename, "../") || g_strrstr(filename, "..\\")) |
| 11934 | 525 | #else |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21682
diff
changeset
|
526 | if (g_strrstr(filename, "../")) |
| 11934 | 527 | #endif |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21682
diff
changeset
|
528 | { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
529 | utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
| 3609 | 530 | |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
531 | msg = g_strdup_printf(_("%s is not a valid filename.\n"), utf8); |
| 15884 | 532 | purple_xfer_error(type, account, xfer->who, msg); |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
533 | g_free(utf8); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
534 | g_free(msg); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
535 | |
| 15884 | 536 | purple_xfer_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
537 | return; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
538 | } |
| 3609 | 539 | |
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
540 | if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
541 | if (g_stat(filename, &st) == -1) { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
542 | purple_xfer_show_file_error(xfer, filename); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
543 | purple_xfer_unref(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
544 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
545 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
546 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
547 | purple_xfer_set_local_filename(xfer, filename); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
548 | purple_xfer_set_size(xfer, st.st_size); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
549 | } else { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
550 | utf8 = g_strdup(filename); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
551 | purple_xfer_set_local_filename(xfer, filename); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
552 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
553 | |
|
26726
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
554 | base = g_path_get_basename(filename); |
|
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
555 | utf8 = g_filename_to_utf8(base, -1, NULL, NULL, NULL); |
|
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
556 | g_free(base); |
| 15884 | 557 | purple_xfer_set_filename(xfer, utf8); |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
558 | |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
559 | msg = g_strdup_printf(_("Offering to send %s to %s"), |
| 15884 | 560 | utf8, buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
561 | g_free(utf8); |
| 15884 | 562 | purple_xfer_conversation_write(xfer, msg, FALSE); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
563 | g_free(msg); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
564 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
565 | else { |
|
13595
191c2d12a00c
[gaim-migrate @ 15980]
Mark Doliner <markdoliner@pidgin.im>
parents:
13220
diff
changeset
|
566 | /* Receiving a file */ |
| 15884 | 567 | xfer->status = PURPLE_XFER_STATUS_ACCEPTED; |
| 568 | purple_xfer_set_local_filename(xfer, filename); | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
569 | |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
570 | msg = g_strdup_printf(_("Starting transfer of %s from %s"), |
| 15884 | 571 | xfer->filename, buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
| 572 | purple_xfer_conversation_write(xfer, msg, FALSE); | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
573 | g_free(msg); |
| 3609 | 574 | } |
| 4150 | 575 | |
| 15884 | 576 | purple_xfer_add(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
577 | xfer->ops.init(xfer); |
| 10259 | 578 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
579 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
580 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
581 | void |
| 15884 | 582 | purple_xfer_request_denied(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
583 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
584 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
585 | |
| 7805 | 586 | if (xfer->ops.request_denied != NULL) |
| 587 | xfer->ops.request_denied(xfer); | |
|
5164
dda3bf92f195
[gaim-migrate @ 5528]
Mark Doliner <markdoliner@pidgin.im>
parents:
5146
diff
changeset
|
588 | |
| 15884 | 589 | purple_xfer_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
590 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
591 | |
| 15884 | 592 | PurpleXferType |
| 593 | purple_xfer_get_type(const PurpleXfer *xfer) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
594 | { |
| 15884 | 595 | g_return_val_if_fail(xfer != NULL, PURPLE_XFER_UNKNOWN); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
596 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
597 | return xfer->type; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
598 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
599 | |
| 15884 | 600 | PurpleAccount * |
| 601 | purple_xfer_get_account(const PurpleXfer *xfer) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
602 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
603 | g_return_val_if_fail(xfer != NULL, NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
604 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
605 | return xfer->account; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
606 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
607 | |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
608 | const char * |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
609 | purple_xfer_get_remote_user(const PurpleXfer *xfer) |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
610 | { |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
611 | g_return_val_if_fail(xfer != NULL, NULL); |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
612 | return xfer->who; |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
613 | } |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
614 | |
| 15884 | 615 | PurpleXferStatusType |
| 616 | purple_xfer_get_status(const PurpleXfer *xfer) | |
| 7805 | 617 | { |
| 15884 | 618 | g_return_val_if_fail(xfer != NULL, PURPLE_XFER_STATUS_UNKNOWN); |
| 7805 | 619 | |
| 620 | return xfer->status; | |
| 621 | } | |
| 622 | ||
| 623 | gboolean | |
| 15884 | 624 | purple_xfer_is_canceled(const PurpleXfer *xfer) |
| 7738 | 625 | { |
| 626 | g_return_val_if_fail(xfer != NULL, TRUE); | |
| 627 | ||
| 15884 | 628 | if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) || |
| 629 | (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE)) | |
| 7805 | 630 | return TRUE; |
| 631 | else | |
| 632 | return FALSE; | |
| 7738 | 633 | } |
| 634 | ||
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
635 | gboolean |
| 15884 | 636 | purple_xfer_is_completed(const PurpleXfer *xfer) |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
637 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
638 | g_return_val_if_fail(xfer != NULL, TRUE); |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
639 | |
| 15884 | 640 | return (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_DONE); |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
641 | } |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
642 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
643 | const char * |
| 15884 | 644 | purple_xfer_get_filename(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
645 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
646 | g_return_val_if_fail(xfer != NULL, NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
647 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
648 | return xfer->filename; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
649 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
650 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
651 | const char * |
| 15884 | 652 | purple_xfer_get_local_filename(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
653 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
654 | g_return_val_if_fail(xfer != NULL, NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
655 | |
|
4605
67526771e679
[gaim-migrate @ 4892]
Mark Doliner <markdoliner@pidgin.im>
parents:
4595
diff
changeset
|
656 | return xfer->local_filename; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
657 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
658 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
659 | size_t |
| 15884 | 660 | purple_xfer_get_bytes_sent(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
661 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
662 | g_return_val_if_fail(xfer != NULL, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
663 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
664 | return xfer->bytes_sent; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
665 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
666 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
667 | size_t |
| 15884 | 668 | purple_xfer_get_bytes_remaining(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
669 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
670 | g_return_val_if_fail(xfer != NULL, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
671 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
672 | return xfer->bytes_remaining; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
673 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
674 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
675 | size_t |
| 15884 | 676 | purple_xfer_get_size(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
677 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
678 | g_return_val_if_fail(xfer != NULL, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
679 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
680 | return xfer->size; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
681 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
682 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
683 | double |
| 15884 | 684 | purple_xfer_get_progress(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
685 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
686 | g_return_val_if_fail(xfer != NULL, 0.0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
687 | |
| 15884 | 688 | if (purple_xfer_get_size(xfer) == 0) |
|
4517
998c580f7f56
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
689 | return 0.0; |
|
998c580f7f56
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
690 | |
| 15884 | 691 | return ((double)purple_xfer_get_bytes_sent(xfer) / |
| 692 | (double)purple_xfer_get_size(xfer)); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
693 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
694 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
695 | unsigned int |
| 15884 | 696 | purple_xfer_get_local_port(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
697 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
698 | g_return_val_if_fail(xfer != NULL, -1); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
699 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
700 | return xfer->local_port; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
701 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
702 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
703 | const char * |
| 15884 | 704 | purple_xfer_get_remote_ip(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
705 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
706 | g_return_val_if_fail(xfer != NULL, NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
707 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
708 | return xfer->remote_ip; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
709 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
710 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
711 | unsigned int |
| 15884 | 712 | purple_xfer_get_remote_port(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
713 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
714 | g_return_val_if_fail(xfer != NULL, -1); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
715 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
716 | return xfer->remote_port; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
717 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
718 | |
|
22338
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
719 | time_t |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
720 | purple_xfer_get_start_time(const PurpleXfer *xfer) |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
721 | { |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
722 | g_return_val_if_fail(xfer != NULL, 0); |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
723 | |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
724 | return xfer->start_time; |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
725 | } |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
726 | |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
727 | time_t |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
728 | purple_xfer_get_end_time(const PurpleXfer *xfer) |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
729 | { |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
730 | g_return_val_if_fail(xfer != NULL, 0); |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
731 | |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
732 | return xfer->end_time; |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
733 | } |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
734 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
735 | void |
| 15884 | 736 | purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed) |
| 4538 | 737 | { |
| 15884 | 738 | PurpleXferUiOps *ui_ops; |
|
4656
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
739 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
740 | g_return_if_fail(xfer != NULL); |
| 4538 | 741 | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
742 | if (completed == TRUE) { |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
743 | char *msg = NULL; |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
744 | PurpleConversation *conv; |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
745 | |
| 15884 | 746 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE); |
|
4656
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
747 | |
| 15884 | 748 | if (purple_xfer_get_filename(xfer) != NULL) |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
749 | { |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
750 | char *filename = g_markup_escape_text(purple_xfer_get_filename(xfer), -1); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
751 | if (purple_xfer_get_local_filename(xfer) |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
752 | && purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
753 | { |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
754 | char *local = g_markup_escape_text(purple_xfer_get_local_filename(xfer), -1); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
755 | msg = g_strdup_printf(_("Transfer of file <A HREF=\"file://%s\">%s</A> complete"), |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
756 | local, filename); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
757 | g_free(local); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
758 | } |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
759 | else |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
760 | msg = g_strdup_printf(_("Transfer of file %s complete"), |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
761 | filename); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
762 | g_free(filename); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
763 | } |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
764 | else |
|
25359
ea172b7ea601
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <datallah@pidgin.im>
parents:
24672
diff
changeset
|
765 | msg = g_strdup(_("File transfer complete")); |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
766 | |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
767 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
768 | purple_xfer_get_account(xfer)); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
769 | |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
770 | if (conv != NULL) |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
771 | purple_conversation_write(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
772 | g_free(msg); |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
773 | } |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
774 | |
| 15884 | 775 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4656
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
776 | |
|
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
777 | if (ui_ops != NULL && ui_ops->update_progress != NULL) |
| 15884 | 778 | ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
| 4538 | 779 | } |
| 780 | ||
| 781 | void | |
| 15884 | 782 | purple_xfer_set_message(PurpleXfer *xfer, const char *message) |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
783 | { |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
784 | g_return_if_fail(xfer != NULL); |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
785 | |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
786 | g_free(xfer->message); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13838
diff
changeset
|
787 | xfer->message = g_strdup(message); |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
788 | } |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
789 | |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
790 | void |
| 15884 | 791 | purple_xfer_set_filename(PurpleXfer *xfer, const char *filename) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
792 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
793 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
794 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13838
diff
changeset
|
795 | g_free(xfer->filename); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13838
diff
changeset
|
796 | xfer->filename = g_strdup(filename); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
797 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
798 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
799 | void |
| 15884 | 800 | purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
801 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
802 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
803 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13838
diff
changeset
|
804 | g_free(xfer->local_filename); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13838
diff
changeset
|
805 | xfer->local_filename = g_strdup(filename); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
806 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
807 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
808 | void |
| 15884 | 809 | purple_xfer_set_size(PurpleXfer *xfer, size_t size) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
810 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
811 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
812 | |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
813 | xfer->size = size; |
| 15884 | 814 | xfer->bytes_remaining = xfer->size - purple_xfer_get_bytes_sent(xfer); |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
815 | } |
| 4538 | 816 | |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
817 | void |
| 15884 | 818 | purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent) |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
819 | { |
|
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
820 | g_return_if_fail(xfer != NULL); |
|
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
821 | |
|
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
822 | xfer->bytes_sent = bytes_sent; |
| 15884 | 823 | xfer->bytes_remaining = purple_xfer_get_size(xfer) - bytes_sent; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
824 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
825 | |
| 15884 | 826 | PurpleXferUiOps * |
| 827 | purple_xfer_get_ui_ops(const PurpleXfer *xfer) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
828 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
829 | g_return_val_if_fail(xfer != NULL, NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
830 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
831 | return xfer->ui_ops; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
832 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
833 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
834 | void |
| 15884 | 835 | purple_xfer_set_init_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
836 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
837 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
838 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
839 | xfer->ops.init = fnc; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
840 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
841 | |
| 15884 | 842 | void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
| 7805 | 843 | { |
| 844 | g_return_if_fail(xfer != NULL); | |
| 845 | ||
| 846 | xfer->ops.request_denied = fnc; | |
| 847 | } | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
848 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
849 | void |
| 15884 | 850 | purple_xfer_set_read_fnc(PurpleXfer *xfer, gssize (*fnc)(guchar **, PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
851 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
852 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
853 | |
|
5495
c4527631aea4
[gaim-migrate @ 5891]
Herman Bloggs <herman@bluedigits.com>
parents:
5494
diff
changeset
|
854 | xfer->ops.read = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
855 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
856 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
857 | void |
| 15884 | 858 | purple_xfer_set_write_fnc(PurpleXfer *xfer, |
| 859 | gssize (*fnc)(const guchar *, size_t, PurpleXfer *)) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
860 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
861 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
862 | |
|
5495
c4527631aea4
[gaim-migrate @ 5891]
Herman Bloggs <herman@bluedigits.com>
parents:
5494
diff
changeset
|
863 | xfer->ops.write = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
864 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
865 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
866 | void |
| 15884 | 867 | purple_xfer_set_ack_fnc(PurpleXfer *xfer, |
| 868 | void (*fnc)(PurpleXfer *, const guchar *, size_t)) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
869 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
870 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
871 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
872 | xfer->ops.ack = fnc; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
873 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
874 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
875 | void |
| 15884 | 876 | purple_xfer_set_start_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
877 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
878 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
879 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
880 | xfer->ops.start = fnc; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
881 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
882 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
883 | void |
| 15884 | 884 | purple_xfer_set_end_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
885 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
886 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
887 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
888 | xfer->ops.end = fnc; |
| 3609 | 889 | } |
| 890 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
891 | void |
| 15884 | 892 | purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
| 3609 | 893 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
894 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
895 | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
896 | xfer->ops.cancel_send = fnc; |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
897 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
898 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
899 | void |
| 15884 | 900 | purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
901 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
902 | g_return_if_fail(xfer != NULL); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
903 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
904 | xfer->ops.cancel_recv = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
905 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
906 | |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
907 | static void |
| 15884 | 908 | purple_xfer_increase_buffer_size(PurpleXfer *xfer) |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
909 | { |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
910 | xfer->current_buffer_size = MIN(xfer->current_buffer_size * 1.5, |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
911 | FT_MAX_BUFFER_SIZE); |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
912 | } |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
913 | |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
914 | gssize |
| 15884 | 915 | purple_xfer_read(PurpleXfer *xfer, guchar **buffer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
916 | { |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
917 | gssize s, r; |
| 3609 | 918 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
919 | g_return_val_if_fail(xfer != NULL, 0); |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
920 | g_return_val_if_fail(buffer != NULL, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
921 | |
| 15884 | 922 | if (purple_xfer_get_size(xfer) == 0) |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
923 | s = xfer->current_buffer_size; |
|
4517
998c580f7f56
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
924 | else |
| 15884 | 925 | s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); |
| 3609 | 926 | |
|
26373
105e5b66e8da
fix a bug in libpurple that prevented receiving file transfers to be marked completed (in case the protocol uses an xfer->ops.read function)
Sulabh Mahajan <sulabh@pidgin.im>
parents:
25359
diff
changeset
|
927 | if (xfer->ops.read != NULL) { |
|
5495
c4527631aea4
[gaim-migrate @ 5891]
Herman Bloggs <herman@bluedigits.com>
parents:
5494
diff
changeset
|
928 | r = (xfer->ops.read)(buffer, xfer); |
|
26373
105e5b66e8da
fix a bug in libpurple that prevented receiving file transfers to be marked completed (in case the protocol uses an xfer->ops.read function)
Sulabh Mahajan <sulabh@pidgin.im>
parents:
25359
diff
changeset
|
929 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
930 | else { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
931 | *buffer = g_malloc0(s); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
932 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
933 | r = read(xfer->fd, *buffer, s); |
|
13011
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
934 | if (r < 0 && errno == EAGAIN) |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
935 | r = 0; |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
936 | else if (r < 0) |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
937 | r = -1; |
|
13788
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13729
diff
changeset
|
938 | else if (r == 0) |
|
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13729
diff
changeset
|
939 | r = -1; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
940 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
941 | |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
942 | if (r == xfer->current_buffer_size) |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
943 | /* |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
944 | * We managed to read the entire buffer. This means our this |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
945 | * network is fast and our buffer is too small, so make it |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
946 | * bigger. |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
947 | */ |
| 15884 | 948 | purple_xfer_increase_buffer_size(xfer); |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
949 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
950 | return r; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
951 | } |
| 3609 | 952 | |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
953 | gssize |
| 15884 | 954 | purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
955 | { |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
956 | gssize r, s; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
957 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
958 | g_return_val_if_fail(xfer != NULL, 0); |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
959 | g_return_val_if_fail(buffer != NULL, 0); |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
960 | g_return_val_if_fail(size != 0, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
961 | |
| 15884 | 962 | s = MIN(purple_xfer_get_bytes_remaining(xfer), size); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
963 | |
| 8231 | 964 | if (xfer->ops.write != NULL) { |
|
5495
c4527631aea4
[gaim-migrate @ 5891]
Herman Bloggs <herman@bluedigits.com>
parents:
5494
diff
changeset
|
965 | r = (xfer->ops.write)(buffer, s, xfer); |
| 8231 | 966 | } else { |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
967 | r = write(xfer->fd, buffer, s); |
|
13011
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
968 | if (r < 0 && errno == EAGAIN) |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
969 | r = 0; |
| 15884 | 970 | if ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer)) |
| 971 | purple_xfer_set_completed(xfer, TRUE); | |
| 8231 | 972 | } |
| 3609 | 973 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
974 | return r; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
975 | } |
| 3609 | 976 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
977 | static void |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
978 | do_transfer(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
979 | { |
| 15884 | 980 | PurpleXferUiOps *ui_ops; |
|
11159
76ef02141bcb
[gaim-migrate @ 13246]
Mark Doliner <markdoliner@pidgin.im>
parents:
11084
diff
changeset
|
981 | guchar *buffer = NULL; |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
982 | gssize r = 0; |
| 3609 | 983 | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
984 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
985 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
986 | if (xfer->type == PURPLE_XFER_RECEIVE) { |
| 15884 | 987 | r = purple_xfer_read(xfer, &buffer); |
| 8316 | 988 | if (r > 0) { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
989 | size_t wc; |
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
990 | if (ui_ops && ui_ops->ui_write) |
|
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
991 | wc = ui_ops->ui_write(xfer, buffer, r); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
992 | else |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
993 | wc = fwrite(buffer, 1, r, xfer->dest_fp); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
994 | |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
995 | if (wc != r) { |
|
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
996 | purple_debug_error("filetransfer", "Unable to write whole buffer.\n"); |
|
27944
e71e3e3134b3
ft: fwrite failing is a local error. Pointed out by kenshin.
Paul Aurich <darkrain42@pidgin.im>
parents:
27942
diff
changeset
|
997 | purple_xfer_cancel_local(xfer); |
|
28076
796f5a14f70b
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27993
diff
changeset
|
998 | g_free(buffer); |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
999 | return; |
|
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
1000 | } |
|
28180
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1001 | |
|
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1002 | if ((purple_xfer_get_size(xfer) > 0) && |
|
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1003 | ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer))) |
|
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1004 | purple_xfer_set_completed(xfer, TRUE); |
|
17293
2b7fbca58d92
Fix file transfers aborting and mistakenly being marked as cancelled when they are actually complete. Fixes #814
Daniel Atallah <datallah@pidgin.im>
parents:
17089
diff
changeset
|
1005 | } else if(r < 0) { |
| 15884 | 1006 | purple_xfer_cancel_remote(xfer); |
|
28076
796f5a14f70b
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27993
diff
changeset
|
1007 | g_free(buffer); |
| 8316 | 1008 | return; |
|
13109
c5801934af5c
[gaim-migrate @ 15470]
Daniel Atallah <datallah@pidgin.im>
parents:
13108
diff
changeset
|
1009 | } |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1010 | } else if (xfer->type == PURPLE_XFER_SEND) { |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
1011 | size_t result; |
| 15884 | 1012 | size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1013 | |
| 8351 | 1014 | /* this is so the prpl can keep the connection open |
| 1015 | if it needs to for some odd reason. */ | |
| 1016 | if (s == 0) { | |
| 9798 | 1017 | if (xfer->watcher) { |
| 15884 | 1018 | purple_input_remove(xfer->watcher); |
| 8351 | 1019 | xfer->watcher = 0; |
| 1020 | } | |
| 1021 | return; | |
| 1022 | } | |
| 1023 | ||
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
1024 | if (ui_ops && ui_ops->ui_read) { |
|
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
1025 | gssize tmp = ui_ops->ui_read(xfer, &buffer, s); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1026 | if (tmp == 0) { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1027 | /* |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1028 | * UI isn't ready to send data. It will call |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1029 | * purple_xfer_ui_ready when ready, which sets back up this |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1030 | * watcher. |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1031 | */ |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1032 | if (xfer->watcher != 0) { |
|
28659
5bca2ccc0646
Use the appropriate function to remove an input watcher.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
1033 | purple_input_remove(xfer->watcher); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1034 | xfer->watcher = 0; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1035 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1036 | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1037 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1038 | } else if (tmp < 0) { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1039 | purple_debug_error("filetransfer", "Unable to read whole buffer.\n"); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1040 | purple_xfer_cancel_local(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1041 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1042 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1043 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1044 | result = tmp; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1045 | } else { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1046 | buffer = g_malloc0(s); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1047 | result = fread(buffer, 1, s, xfer->dest_fp); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1048 | if (result != s) { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1049 | purple_debug_error("filetransfer", "Unable to read whole buffer.\n"); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1050 | purple_xfer_cancel_local(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1051 | g_free(buffer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1052 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1053 | } |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
1054 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1055 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1056 | /* Write as much as we're allowed to. */ |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1057 | r = purple_xfer_write(xfer, buffer, result); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1058 | |
| 8231 | 1059 | if (r == -1) { |
| 15884 | 1060 | purple_xfer_cancel_remote(xfer); |
| 8231 | 1061 | g_free(buffer); |
| 1062 | return; | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1063 | } else if (r < result) { |
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
1064 | if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1065 | /* We have to seek back in the file now. */ |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1066 | fseek(xfer->dest_fp, r - s, SEEK_CUR); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1067 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1068 | else { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1069 | ui_ops->data_not_sent(xfer, buffer + r, result - r); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1070 | } |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1071 | } else { |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1072 | /* |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1073 | * We managed to write the entire buffer. This means our |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1074 | * network is fast and our buffer is too small, so make it |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1075 | * bigger. |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1076 | */ |
| 15884 | 1077 | purple_xfer_increase_buffer_size(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1078 | } |
| 3609 | 1079 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1080 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1081 | if (r > 0) { |
| 15884 | 1082 | if (purple_xfer_get_size(xfer) > 0) |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1083 | xfer->bytes_remaining -= r; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1084 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1085 | xfer->bytes_sent += r; |
|
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1086 | |
|
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1087 | if (xfer->ops.ack != NULL) |
|
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1088 | xfer->ops.ack(xfer, buffer, r); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1089 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1090 | g_free(buffer); |
|
4594
a96954344300
[gaim-migrate @ 4879]
Mark Doliner <markdoliner@pidgin.im>
parents:
4582
diff
changeset
|
1091 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1092 | if (ui_ops != NULL && ui_ops->update_progress != NULL) |
|
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1093 | ui_ops->update_progress(xfer, |
| 15884 | 1094 | purple_xfer_get_progress(xfer)); |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1095 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1096 | |
| 15884 | 1097 | if (purple_xfer_is_completed(xfer)) |
| 1098 | purple_xfer_end(xfer); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1099 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1100 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1101 | static void |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1102 | transfer_cb(gpointer data, gint source, PurpleInputCondition condition) |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1103 | { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1104 | PurpleXfer *xfer = data; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1105 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1106 | if (xfer->dest_fp == NULL) { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1107 | /* The UI is moderating its side manually */ |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1108 | PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1109 | if (0 == (priv->ready & PURPLE_XFER_READY_UI)) { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1110 | priv->ready |= PURPLE_XFER_READY_PRPL; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1111 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1112 | purple_input_remove(xfer->watcher); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1113 | xfer->watcher = 0; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1114 | return; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1115 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1116 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1117 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1118 | do_transfer(xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1119 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1120 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1121 | static void |
| 15884 | 1122 | begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1123 | { |
| 15884 | 1124 | PurpleXferType type = purple_xfer_get_type(xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1125 | PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1126 | |
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
1127 | if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1128 | xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1129 | type == PURPLE_XFER_RECEIVE ? "wb" : "rb"); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1130 | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1131 | if (xfer->dest_fp == NULL) { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1132 | purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer)); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1133 | purple_xfer_cancel_local(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1134 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1135 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1136 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1137 | fseek(xfer->dest_fp, xfer->bytes_sent, SEEK_SET); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1138 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1139 | |
|
28152
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1140 | if (xfer->fd != -1) |
|
17089
b27c8579750b
Patch from sourceforge tracker 1652005 from wabz to fix displaying file
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16490
diff
changeset
|
1141 | xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1142 | |
|
13599
b6369e541654
[gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents:
13595
diff
changeset
|
1143 | xfer->start_time = time(NULL); |
|
b6369e541654
[gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents:
13595
diff
changeset
|
1144 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1145 | if (xfer->ops.start != NULL) |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1146 | xfer->ops.start(xfer); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1147 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1148 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1149 | static void |
|
14183
bdde840e984c
[gaim-migrate @ 16755]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
1150 | connect_cb(gpointer data, gint source, const gchar *error_message) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1151 | { |
| 15884 | 1152 | PurpleXfer *xfer = (PurpleXfer *)data; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1153 | |
|
21676
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1154 | if (source < 0) { |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1155 | purple_xfer_cancel_local(xfer); |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1156 | return; |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1157 | } |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1158 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1159 | xfer->fd = source; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1160 | |
| 15884 | 1161 | begin_transfer(xfer, PURPLE_INPUT_READ); |
| 3609 | 1162 | } |
| 1163 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1164 | void |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1165 | purple_xfer_ui_ready(PurpleXfer *xfer) |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1166 | { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1167 | PurpleInputCondition cond; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1168 | PurpleXferType type; |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1169 | PurpleXferPrivData *priv; |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1170 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1171 | g_return_if_fail(xfer != NULL); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1172 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1173 | priv = g_hash_table_lookup(xfers_data, xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1174 | priv->ready |= PURPLE_XFER_READY_UI; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1175 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1176 | if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1177 | return; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1178 | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1179 | type = purple_xfer_get_type(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1180 | if (type == PURPLE_XFER_SEND) |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1181 | cond = PURPLE_INPUT_WRITE; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1182 | else /* if (type == PURPLE_XFER_RECEIVE) */ |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1183 | cond = PURPLE_INPUT_READ; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1184 | |
|
28153
d90df2a6bcd5
ft: Fix an issue with re-setting xfer->watcher when there is no fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28152
diff
changeset
|
1185 | if (xfer->watcher == 0 && xfer->fd != -1) |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1186 | xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1187 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1188 | priv->ready = PURPLE_XFER_READY_NONE; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1189 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1190 | do_transfer(xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1191 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1192 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1193 | void |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1194 | purple_xfer_prpl_ready(PurpleXfer *xfer) |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1195 | { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1196 | PurpleXferPrivData *priv; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1197 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1198 | g_return_if_fail(xfer != NULL); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1199 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1200 | priv = g_hash_table_lookup(xfers_data, xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1201 | priv->ready |= PURPLE_XFER_READY_PRPL; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1202 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1203 | /* I don't think fwrite/fread are ever *not* ready */ |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1204 | if (xfer->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI)) |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1205 | return; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1206 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1207 | priv->ready = PURPLE_XFER_READY_NONE; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1208 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1209 | do_transfer(xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1210 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1211 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1212 | void |
| 15884 | 1213 | purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1214 | unsigned int port) |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1215 | { |
| 15884 | 1216 | PurpleInputCondition cond; |
| 1217 | PurpleXferType type; | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1218 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1219 | g_return_if_fail(xfer != NULL); |
| 15884 | 1220 | g_return_if_fail(purple_xfer_get_type(xfer) != PURPLE_XFER_UNKNOWN); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1221 | |
| 15884 | 1222 | type = purple_xfer_get_type(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1223 | |
| 15884 | 1224 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_STARTED); |
| 7805 | 1225 | |
|
28152
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1226 | /* |
|
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1227 | * FIXME 3.0.0 -- there's too much broken code depending on fd == 0 |
|
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1228 | * meaning "don't use a real fd" |
|
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1229 | */ |
|
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1230 | if (fd == 0) |
|
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1231 | fd = -1; |
|
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1232 | |
| 15884 | 1233 | if (type == PURPLE_XFER_RECEIVE) { |
| 1234 | cond = PURPLE_INPUT_READ; | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1235 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1236 | if (ip != NULL) { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1237 | xfer->remote_ip = g_strdup(ip); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1238 | xfer->remote_port = port; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1239 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1240 | /* Establish a file descriptor. */ |
| 15884 | 1241 | purple_proxy_connect(NULL, xfer->account, xfer->remote_ip, |
|
14170
f611621bc8a0
[gaim-migrate @ 16742]
Mark Doliner <markdoliner@pidgin.im>
parents:
14151
diff
changeset
|
1242 | xfer->remote_port, connect_cb, xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1243 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1244 | return; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1245 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1246 | else { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1247 | xfer->fd = fd; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1248 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1249 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1250 | else { |
| 15884 | 1251 | cond = PURPLE_INPUT_WRITE; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1252 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1253 | xfer->fd = fd; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1254 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1255 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1256 | begin_transfer(xfer, cond); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1257 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1258 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1259 | void |
| 15884 | 1260 | purple_xfer_end(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1261 | { |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1262 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1263 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1264 | /* See if we are actually trying to cancel this. */ |
| 15884 | 1265 | if (!purple_xfer_is_completed(xfer)) { |
| 1266 | purple_xfer_cancel_local(xfer); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1267 | return; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1268 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1269 | |
|
13599
b6369e541654
[gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents:
13595
diff
changeset
|
1270 | xfer->end_time = time(NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1271 | if (xfer->ops.end != NULL) |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1272 | xfer->ops.end(xfer); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1273 | |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1274 | if (xfer->watcher != 0) { |
| 15884 | 1275 | purple_input_remove(xfer->watcher); |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1276 | xfer->watcher = 0; |
|
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1277 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1278 | |
|
28152
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1279 | if (xfer->fd != -1) |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1280 | close(xfer->fd); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1281 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1282 | if (xfer->dest_fp != NULL) { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1283 | fclose(xfer->dest_fp); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1284 | xfer->dest_fp = NULL; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1285 | } |
| 7805 | 1286 | |
| 15884 | 1287 | purple_xfer_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1288 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1289 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1290 | void |
| 15884 | 1291 | purple_xfer_add(PurpleXfer *xfer) |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1292 | { |
| 15884 | 1293 | PurpleXferUiOps *ui_ops; |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1294 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1295 | g_return_if_fail(xfer != NULL); |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1296 | |
| 15884 | 1297 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1298 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1299 | if (ui_ops != NULL && ui_ops->add_xfer != NULL) |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1300 | ui_ops->add_xfer(xfer); |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1301 | } |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1302 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1303 | void |
| 15884 | 1304 | purple_xfer_cancel_local(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1305 | { |
| 15884 | 1306 | PurpleXferUiOps *ui_ops; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
1307 | char *msg = NULL; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1308 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1309 | g_return_if_fail(xfer != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1310 | |
| 15884 | 1311 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
|
13599
b6369e541654
[gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents:
13595
diff
changeset
|
1312 | xfer->end_time = time(NULL); |
| 7738 | 1313 | |
| 15884 | 1314 | if (purple_xfer_get_filename(xfer) != NULL) |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1315 | { |
|
27797
10f6bc89044b
Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
1316 | msg = g_strdup_printf(_("You cancelled the transfer of %s"), |
| 15884 | 1317 | purple_xfer_get_filename(xfer)); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1318 | } |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1319 | else |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1320 | { |
|
25359
ea172b7ea601
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <datallah@pidgin.im>
parents:
24672
diff
changeset
|
1321 | msg = g_strdup(_("File transfer cancelled")); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1322 | } |
| 15884 | 1323 | purple_xfer_conversation_write(xfer, msg, FALSE); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
1324 | g_free(msg); |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
1325 | |
| 15884 | 1326 | if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1327 | { |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1328 | if (xfer->ops.cancel_send != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1329 | xfer->ops.cancel_send(xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1330 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1331 | else |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1332 | { |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1333 | if (xfer->ops.cancel_recv != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1334 | xfer->ops.cancel_recv(xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1335 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1336 | |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1337 | if (xfer->watcher != 0) { |
| 15884 | 1338 | purple_input_remove(xfer->watcher); |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1339 | xfer->watcher = 0; |
|
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1340 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1341 | |
|
28152
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1342 | if (xfer->fd != -1) |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1343 | close(xfer->fd); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1344 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1345 | if (xfer->dest_fp != NULL) { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1346 | fclose(xfer->dest_fp); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1347 | xfer->dest_fp = NULL; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1348 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1349 | |
| 15884 | 1350 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1351 | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1352 | if (ui_ops != NULL && ui_ops->cancel_local != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1353 | ui_ops->cancel_local(xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1354 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1355 | xfer->bytes_remaining = 0; |
| 7805 | 1356 | |
| 15884 | 1357 | purple_xfer_unref(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1358 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1359 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1360 | void |
| 15884 | 1361 | purple_xfer_cancel_remote(PurpleXfer *xfer) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1362 | { |
| 15884 | 1363 | PurpleXferUiOps *ui_ops; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
1364 | gchar *msg; |
| 15884 | 1365 | PurpleAccount *account; |
| 1366 | PurpleBuddy *buddy; | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1367 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1368 | g_return_if_fail(xfer != NULL); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1369 | |
| 15884 | 1370 | purple_request_close_with_handle(xfer); |
| 1371 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE); | |
|
13599
b6369e541654
[gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents:
13595
diff
changeset
|
1372 | xfer->end_time = time(NULL); |
|
9771
42bd06e5b1b3
[gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents:
9523
diff
changeset
|
1373 | |
| 15884 | 1374 | account = purple_xfer_get_account(xfer); |
| 1375 | buddy = purple_find_buddy(account, xfer->who); | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1376 | |
| 15884 | 1377 | if (purple_xfer_get_filename(xfer) != NULL) |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1378 | { |
|
27797
10f6bc89044b
Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
1379 | msg = g_strdup_printf(_("%s cancelled the transfer of %s"), |
| 15884 | 1380 | buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer)); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1381 | } |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1382 | else |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1383 | { |
|
27797
10f6bc89044b
Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
1384 | msg = g_strdup_printf(_("%s cancelled the file transfer"), |
| 15884 | 1385 | buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1386 | } |
| 15884 | 1387 | purple_xfer_conversation_write(xfer, msg, TRUE); |
| 1388 | purple_xfer_error(purple_xfer_get_type(xfer), account, xfer->who, msg); | |
|
9771
42bd06e5b1b3
[gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents:
9523
diff
changeset
|
1389 | g_free(msg); |
|
42bd06e5b1b3
[gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents:
9523
diff
changeset
|
1390 | |
| 15884 | 1391 | if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1392 | { |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1393 | if (xfer->ops.cancel_send != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1394 | xfer->ops.cancel_send(xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1395 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1396 | else |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1397 | { |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1398 | if (xfer->ops.cancel_recv != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1399 | xfer->ops.cancel_recv(xfer); |
|
7272
f8335b8f1f1c
[gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1400 | } |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1401 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1402 | if (xfer->watcher != 0) { |
| 15884 | 1403 | purple_input_remove(xfer->watcher); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1404 | xfer->watcher = 0; |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1405 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1406 | |
|
28152
e9800c07eb5b
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents:
28150
diff
changeset
|
1407 | if (xfer->fd != -1) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1408 | close(xfer->fd); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1409 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1410 | if (xfer->dest_fp != NULL) { |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1411 | fclose(xfer->dest_fp); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1412 | xfer->dest_fp = NULL; |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1413 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1414 | |
| 15884 | 1415 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1416 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1417 | if (ui_ops != NULL && ui_ops->cancel_remote != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1418 | ui_ops->cancel_remote(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1419 | |
|
4528
5efe7af8195d
[gaim-migrate @ 4806]
Christian Hammond <chipx86@chipx86.com>
parents:
4521
diff
changeset
|
1420 | xfer->bytes_remaining = 0; |
| 7805 | 1421 | |
| 15884 | 1422 | purple_xfer_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1423 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1424 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1425 | void |
| 15884 | 1426 | purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1427 | { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1428 | char *title; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1429 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1430 | g_return_if_fail(msg != NULL); |
| 15884 | 1431 | g_return_if_fail(type != PURPLE_XFER_UNKNOWN); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1432 | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1433 | if (account) { |
| 15884 | 1434 | PurpleBuddy *buddy; |
| 1435 | buddy = purple_find_buddy(account, who); | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1436 | if (buddy) |
| 15884 | 1437 | who = purple_buddy_get_alias(buddy); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1438 | } |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1439 | |
| 15884 | 1440 | if (type == PURPLE_XFER_SEND) |
|
11231
1c5968418ca4
[gaim-migrate @ 13371]
Richard Laager <rlaager@pidgin.im>
parents:
11159
diff
changeset
|
1441 | title = g_strdup_printf(_("File transfer to %s failed."), who); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1442 | else |
|
11231
1c5968418ca4
[gaim-migrate @ 13371]
Richard Laager <rlaager@pidgin.im>
parents:
11159
diff
changeset
|
1443 | title = g_strdup_printf(_("File transfer from %s failed."), who); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1444 | |
| 15884 | 1445 | purple_notify_error(NULL, NULL, title, msg); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1446 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1447 | g_free(title); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1448 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1449 | |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1450 | void |
| 15884 | 1451 | purple_xfer_update_progress(PurpleXfer *xfer) |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1452 | { |
| 15884 | 1453 | PurpleXferUiOps *ui_ops; |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1454 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1455 | g_return_if_fail(xfer != NULL); |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1456 | |
| 15884 | 1457 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1458 | if (ui_ops != NULL && ui_ops->update_progress != NULL) |
| 15884 | 1459 | ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1460 | } |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1461 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1462 | |
|
6263
6fec763a314c
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
1463 | /************************************************************************** |
|
6fec763a314c
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
1464 | * File Transfer Subsystem API |
|
6fec763a314c
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
1465 | **************************************************************************/ |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1466 | void * |
| 15884 | 1467 | purple_xfers_get_handle(void) { |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1468 | static int handle = 0; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1469 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1470 | return &handle; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1471 | } |
|
6241
34d166a31152
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
1472 | |
|
34d166a31152
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
1473 | void |
| 15884 | 1474 | purple_xfers_init(void) { |
| 1475 | void *handle = purple_xfers_get_handle(); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1476 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1477 | xfers_data = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1478 | NULL, purple_xfer_priv_data_destroy); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1479 | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1480 | /* register signals */ |
| 15884 | 1481 | purple_signal_register(handle, "file-recv-accept", |
| 1482 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1483 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1484 | PURPLE_SUBTYPE_XFER)); | |
| 1485 | purple_signal_register(handle, "file-send-accept", | |
| 1486 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1487 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1488 | PURPLE_SUBTYPE_XFER)); | |
| 1489 | purple_signal_register(handle, "file-recv-start", | |
| 1490 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1491 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1492 | PURPLE_SUBTYPE_XFER)); | |
| 1493 | purple_signal_register(handle, "file-send-start", | |
| 1494 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1495 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1496 | PURPLE_SUBTYPE_XFER)); | |
| 1497 | purple_signal_register(handle, "file-send-cancel", | |
| 1498 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1499 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1500 | PURPLE_SUBTYPE_XFER)); | |
| 1501 | purple_signal_register(handle, "file-recv-cancel", | |
| 1502 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1503 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1504 | PURPLE_SUBTYPE_XFER)); | |
| 1505 | purple_signal_register(handle, "file-send-complete", | |
| 1506 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1507 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1508 | PURPLE_SUBTYPE_XFER)); | |
| 1509 | purple_signal_register(handle, "file-recv-complete", | |
| 1510 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1511 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1512 | PURPLE_SUBTYPE_XFER)); | |
| 1513 | purple_signal_register(handle, "file-recv-request", | |
| 1514 | purple_marshal_VOID__POINTER, NULL, 1, | |
| 1515 | purple_value_new(PURPLE_TYPE_SUBTYPE, | |
| 1516 | PURPLE_SUBTYPE_XFER)); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1517 | } |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1518 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1519 | void |
|
21143
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
1520 | purple_xfers_uninit(void) |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
1521 | { |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
1522 | void *handle = purple_xfers_get_handle(); |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
1523 | |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
1524 | purple_signals_disconnect_by_handle(handle); |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
1525 | purple_signals_unregister_by_instance(handle); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1526 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1527 | g_hash_table_destroy(xfers_data); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1528 | xfers_data = NULL; |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1529 | } |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1530 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
1531 | void |
| 15884 | 1532 | purple_xfers_set_ui_ops(PurpleXferUiOps *ops) { |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1533 | xfer_ui_ops = ops; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1534 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1535 | |
| 15884 | 1536 | PurpleXferUiOps * |
| 1537 | purple_xfers_get_ui_ops(void) { | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1538 | return xfer_ui_ops; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1539 | } |