Mercurial > pidgin.yaz
annotate libpurple/ft.c @ 32468:9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
author | masca@cpw.pidgin.im |
---|---|
date | Thu, 01 Sep 2011 06:00:21 +0000 |
parents | e5e81ce9c564 |
children | 48bc3f9f2115 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file ft.c File Transfer API |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
3 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 /* purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * |
15823 | 7 * Purple is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19567
diff
changeset
|
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
19567
b99a158ea85e
disapproval of revision 'c672802b647f1230fbd9b0edf383fb3d558cf719'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19566
diff
changeset
|
24 * |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "internal.h" |
17527
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
27 #include "dbus-maybe.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "ft.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "network.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "proxy.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include "request.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "util.h" |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
35 #include "debug.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #define FT_INITIAL_BUFFER_SIZE 4096 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 #define FT_MAX_BUFFER_SIZE 65535 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 |
15823 | 40 static PurpleXferUiOps *xfer_ui_ops = NULL; |
15641
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
41 static GList *xfers; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
43 /* |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
44 * A hack to store more data since we can't extend the size of PurpleXfer |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
45 * easily. |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
46 */ |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
47 static GHashTable *xfers_data = NULL; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
48 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
49 typedef struct _PurpleXferPrivData { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
50 /* |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
51 * Used to moderate the file transfer when either the read/write ui_ops are |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
52 * set or fd is not set. In those cases, the UI/prpl call the respective |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
53 * function, which is somewhat akin to a fd watch being triggered. |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
54 */ |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
55 enum { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
56 PURPLE_XFER_READY_NONE = 0x0, |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
57 PURPLE_XFER_READY_UI = 0x1, |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
58 PURPLE_XFER_READY_PRPL = 0x2, |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
59 } ready; |
30094
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
60 |
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
61 /* TODO: Should really use a PurpleCircBuffer for this. */ |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
62 GByteArray *buffer; |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
63 |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
64 gpointer thumbnail_data; /**< thumbnail image */ |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
65 gsize thumbnail_size; |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
66 gchar *thumbnail_mimetype; |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
67 } PurpleXferPrivData; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
68 |
15823 | 69 static int purple_xfer_choose_file(PurpleXfer *xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
71 static void |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
72 purple_xfer_priv_data_destroy(gpointer data) |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
73 { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
74 PurpleXferPrivData *priv = data; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
75 |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
76 if (priv->buffer) |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
77 g_byte_array_free(priv->buffer, TRUE); |
29742
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
78 |
30248
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
79 g_free(priv->thumbnail_data); |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
80 |
30248
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
81 g_free(priv->thumbnail_mimetype); |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
82 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
83 g_free(priv); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
84 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
85 |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
86 static const gchar * |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
87 purple_xfer_status_type_to_string(PurpleXferStatusType type) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
88 { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
89 static const struct { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
90 PurpleXferStatusType type; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
91 const char *name; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
92 } type_names[] = { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
93 { PURPLE_XFER_STATUS_UNKNOWN, "unknown" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
94 { PURPLE_XFER_STATUS_NOT_STARTED, "not started" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
95 { PURPLE_XFER_STATUS_ACCEPTED, "accepted" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
96 { PURPLE_XFER_STATUS_STARTED, "started" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
97 { PURPLE_XFER_STATUS_DONE, "done" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
98 { PURPLE_XFER_STATUS_CANCEL_LOCAL, "cancelled locally" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
99 { PURPLE_XFER_STATUS_CANCEL_REMOTE, "cancelled remotely" } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
100 }; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
101 int i; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
102 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
103 for (i = 0; i < G_N_ELEMENTS(type_names); ++i) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
104 if (type_names[i].type == type) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
105 return type_names[i].name; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
106 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
107 return "invalid state"; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
108 } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
109 |
15641
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
110 GList * |
15823 | 111 purple_xfers_get_all() |
15641
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
112 { |
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
113 return xfers; |
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
114 } |
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
115 |
15823 | 116 PurpleXfer * |
117 purple_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 { |
15823 | 119 PurpleXfer *xfer; |
120 PurpleXferUiOps *ui_ops; | |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
121 PurpleXferPrivData *priv; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 |
15823 | 123 g_return_val_if_fail(type != PURPLE_XFER_UNKNOWN, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 g_return_val_if_fail(account != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 g_return_val_if_fail(who != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 |
15823 | 127 xfer = g_new0(PurpleXfer, 1); |
17527
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
128 PURPLE_DBUS_REGISTER_POINTER(xfer, PurpleXfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 xfer->ref = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 xfer->type = type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 xfer->account = account; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 xfer->who = g_strdup(who); |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
134 xfer->ui_ops = ui_ops = purple_xfers_get_ui_ops(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 xfer->message = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 xfer->current_buffer_size = FT_INITIAL_BUFFER_SIZE; |
20221
89e5492bcea4
applied changes from 307f0cff97539b1c6ddc0114500677abfe42aaa6
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
137 xfer->fd = -1; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
139 priv = g_new0(PurpleXferPrivData, 1); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
140 priv->ready = PURPLE_XFER_READY_NONE; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
141 |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
142 if (ui_ops && ui_ops->data_not_sent) { |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
143 /* If the ui will handle unsent data no need for buffer */ |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
144 priv->buffer = NULL; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
145 } else { |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
146 priv->buffer = g_byte_array_sized_new(FT_INITIAL_BUFFER_SIZE); |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
147 } |
29742
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
148 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
149 g_hash_table_insert(xfers_data, xfer, priv); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
150 |
15823 | 151 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 if (ui_ops != NULL && ui_ops->new_xfer != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 ui_ops->new_xfer(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 |
15641
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15374
diff
changeset
|
156 xfers = g_list_prepend(xfers, xfer); |
29204
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
157 |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
158 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
159 purple_debug_info("xfer", "new %p [%d]\n", xfer, xfer->ref); |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
160 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 return xfer; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 static void |
15823 | 165 purple_xfer_destroy(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 { |
15823 | 167 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
29204
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
171 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
172 purple_debug_info("xfer", "destroyed %p [%d]\n", xfer, xfer->ref); |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
173 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 /* Close the file browser, if it's open */ |
15823 | 175 purple_request_close_with_handle(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 |
15823 | 177 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) |
178 purple_xfer_cancel_local(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
15823 | 180 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 if (ui_ops != NULL && ui_ops->destroy != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 ui_ops->destroy(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 g_free(xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 g_free(xfer->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 g_free(xfer->remote_ip); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 g_free(xfer->local_filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
190 g_hash_table_remove(xfers_data, xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
191 |
17527
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
192 PURPLE_DBUS_UNREGISTER_POINTER(xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
193 xfers = g_list_remove(xfers, xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 g_free(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 void |
15823 | 198 purple_xfer_ref(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 xfer->ref++; |
29204
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
203 |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
204 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
205 purple_debug_info("xfer", "ref'd %p [%d]\n", xfer, xfer->ref); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 void |
15823 | 209 purple_xfer_unref(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 g_return_if_fail(xfer->ref > 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 xfer->ref--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 |
29204
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
216 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
217 purple_debug_info("xfer", "unref'd %p [%d]\n", xfer, xfer->ref); |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29203
diff
changeset
|
218 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 if (xfer->ref == 0) |
15823 | 220 purple_xfer_destroy(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 |
32468
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
223 void |
15823 | 224 purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatusType status) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
228 if (purple_debug_is_verbose()) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
229 purple_debug_info("xfer", "Changing status of xfer %p from %s to %s\n", |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
230 xfer, purple_xfer_status_type_to_string(xfer->status), |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
231 purple_xfer_status_type_to_string(status)); |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
232 |
28059
36d5e7690ad6
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <paul@darkrain42.org>
parents:
28007
diff
changeset
|
233 if (xfer->status == status) |
36d5e7690ad6
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <paul@darkrain42.org>
parents:
28007
diff
changeset
|
234 return; |
36d5e7690ad6
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <paul@darkrain42.org>
parents:
28007
diff
changeset
|
235 |
28005
fd4415c0595f
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <paul@darkrain42.org>
parents:
27478
diff
changeset
|
236 xfer->status = status; |
fd4415c0595f
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <paul@darkrain42.org>
parents:
27478
diff
changeset
|
237 |
15823 | 238 if(xfer->type == PURPLE_XFER_SEND) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 switch(status) { |
15823 | 240 case PURPLE_XFER_STATUS_ACCEPTED: |
241 purple_signal_emit(purple_xfers_get_handle(), "file-send-accept", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 break; |
15823 | 243 case PURPLE_XFER_STATUS_STARTED: |
244 purple_signal_emit(purple_xfers_get_handle(), "file-send-start", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 break; |
15823 | 246 case PURPLE_XFER_STATUS_DONE: |
247 purple_signal_emit(purple_xfers_get_handle(), "file-send-complete", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 break; |
15823 | 249 case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
250 case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
251 purple_signal_emit(purple_xfers_get_handle(), "file-send-cancel", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 } |
15823 | 256 } else if(xfer->type == PURPLE_XFER_RECEIVE) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 switch(status) { |
15823 | 258 case PURPLE_XFER_STATUS_ACCEPTED: |
259 purple_signal_emit(purple_xfers_get_handle(), "file-recv-accept", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 break; |
15823 | 261 case PURPLE_XFER_STATUS_STARTED: |
262 purple_signal_emit(purple_xfers_get_handle(), "file-recv-start", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 break; |
15823 | 264 case PURPLE_XFER_STATUS_DONE: |
265 purple_signal_emit(purple_xfers_get_handle(), "file-recv-complete", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 break; |
15823 | 267 case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
268 case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
269 purple_signal_emit(purple_xfers_get_handle(), "file-recv-cancel", xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31395
diff
changeset
|
277 static void |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
278 purple_xfer_conversation_write_internal(PurpleXfer *xfer, |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
279 const char *message, gboolean is_error, gboolean print_thumbnail) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 { |
15823 | 281 PurpleConversation *conv = NULL; |
282 PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 char *escaped; |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
284 gconstpointer thumbnail_data; |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
285 gsize size; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 g_return_if_fail(message != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
290 thumbnail_data = purple_xfer_get_thumbnail(xfer, &size); |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
291 |
15823 | 292 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, |
293 purple_xfer_get_account(xfer)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 if (conv == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 escaped = g_markup_escape_text(message, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 if (is_error) |
29056
52dc24a5069f
ft: Properly set a bitmask field (so it includes PURPLE_MESSAGE_SYSTEM like
Florian Quèze <florian@instantbird.org>
parents:
28727
diff
changeset
|
301 flags |= PURPLE_MESSAGE_ERROR; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
303 if (print_thumbnail && thumbnail_data) { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
304 gchar *message_with_img; |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31395
diff
changeset
|
305 gpointer data = g_memdup(thumbnail_data, size); |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
306 int id = purple_imgstore_add_with_id(data, size, NULL); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
307 |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31395
diff
changeset
|
308 message_with_img = |
30248
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
309 g_strdup_printf("<img id='%d'> %s", id, escaped); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31395
diff
changeset
|
310 purple_conversation_write(conv, NULL, message_with_img, flags, |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
311 time(NULL)); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
312 purple_imgstore_unref_by_id(id); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
313 g_free(message_with_img); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
314 } else { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
315 purple_conversation_write(conv, NULL, escaped, flags, time(NULL)); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
316 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 g_free(escaped); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
320 void |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
321 purple_xfer_conversation_write(PurpleXfer *xfer, gchar *message, |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
322 gboolean is_error) |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
323 { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
324 purple_xfer_conversation_write_internal(xfer, message, is_error, FALSE); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
325 } |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
326 |
30248
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
327 /* maybe this one should be exported publically? */ |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
328 static void |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
329 purple_xfer_conversation_write_with_thumbnail(PurpleXfer *xfer, |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
330 const gchar *message) |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
331 { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
332 purple_xfer_conversation_write_internal(xfer, message, FALSE, TRUE); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
333 } |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
334 |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
335 |
15823 | 336 static void purple_xfer_show_file_error(PurpleXfer *xfer, const char *filename) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 int err = errno; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 gchar *msg = NULL, *utf8; |
15823 | 340 PurpleXferType xfer_type = purple_xfer_get_type(xfer); |
341 PurpleAccount *account = purple_xfer_get_account(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 switch(xfer_type) { |
15823 | 345 case PURPLE_XFER_SEND: |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20251
diff
changeset
|
347 utf8, g_strerror(err)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 break; |
15823 | 349 case PURPLE_XFER_RECEIVE: |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 msg = g_strdup_printf(_("Error writing %s: \n%s.\n"), |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20251
diff
changeset
|
351 utf8, g_strerror(err)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 msg = g_strdup_printf(_("Error accessing %s: \n%s.\n"), |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20251
diff
changeset
|
355 utf8, g_strerror(err)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 |
15823 | 360 purple_xfer_conversation_write(xfer, msg, TRUE); |
361 purple_xfer_error(xfer_type, account, xfer->who, msg); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 static void |
15823 | 366 purple_xfer_choose_file_ok_cb(void *user_data, const char *filename) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 { |
15823 | 368 PurpleXfer *xfer; |
29202
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29056
diff
changeset
|
369 PurpleXferType type; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 struct stat st; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 gchar *dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 |
15823 | 373 xfer = (PurpleXfer *)user_data; |
29202
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29056
diff
changeset
|
374 type = purple_xfer_get_type(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 if (g_stat(filename, &st) != 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 /* File not found. */ |
29202
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29056
diff
changeset
|
378 if (type == PURPLE_XFER_RECEIVE) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 int mode = W_OK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 int mode = F_OK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 dir = g_path_get_dirname(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 if (g_access(dir, mode) == 0) { |
15823 | 387 purple_xfer_request_accepted(xfer, filename); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 } else { |
15823 | 389 purple_xfer_ref(xfer); |
390 purple_notify_message( | |
391 NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 _("Directory is not writable."), NULL, |
15823 | 393 (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 g_free(dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 else { |
15823 | 399 purple_xfer_show_file_error(xfer, filename); |
29206
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
400 purple_xfer_cancel_local(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 } |
29202
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29056
diff
changeset
|
403 else if ((type == PURPLE_XFER_SEND) && (st.st_size == 0)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 |
15823 | 405 purple_notify_error(NULL, NULL, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 _("Cannot send a file of 0 bytes."), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 |
29206
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
408 purple_xfer_cancel_local(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 } |
29202
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29056
diff
changeset
|
410 else if ((type == PURPLE_XFER_SEND) && S_ISDIR(st.st_mode)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 * XXX - Sending a directory should be valid for some protocols. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 */ |
15823 | 414 purple_notify_error(NULL, NULL, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 _("Cannot send a directory."), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 |
29206
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
417 purple_xfer_cancel_local(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 } |
29202
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29056
diff
changeset
|
419 else if ((type == PURPLE_XFER_RECEIVE) && S_ISDIR(st.st_mode)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 char *msg, *utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 msg = g_strdup_printf( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 _("%s is not a regular file. Cowardly refusing to overwrite it.\n"), utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 g_free(utf8); |
15823 | 425 purple_notify_error(NULL, NULL, msg, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 g_free(msg); |
15823 | 427 purple_xfer_request_denied(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 } |
29203
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
429 else if (type == PURPLE_XFER_SEND) { |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
430 #ifndef _WIN32 |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
431 int mode = R_OK; |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
432 #else |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
433 int mode = F_OK; |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
434 #endif |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
435 |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
436 if (g_access(filename, mode) == 0) { |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
437 purple_xfer_request_accepted(xfer, filename); |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
438 } else { |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
439 purple_xfer_ref(xfer); |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
440 purple_notify_message( |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
441 NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
442 _("File is not readable."), NULL, |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
443 (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
444 } |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29202
diff
changeset
|
445 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 else { |
15823 | 447 purple_xfer_request_accepted(xfer, filename); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 |
15823 | 450 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 static void |
15823 | 454 purple_xfer_choose_file_cancel_cb(void *user_data, const char *filename) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 { |
15823 | 456 PurpleXfer *xfer = (PurpleXfer *)user_data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 |
15823 | 458 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
29206
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
459 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
460 purple_xfer_cancel_local(xfer); |
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
461 else |
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29205
diff
changeset
|
462 purple_xfer_request_denied(xfer); |
29205
df5808d7e669
The PurpleXfer should be unref'd if the file selection dialog was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29204
diff
changeset
|
463 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 static int |
15823 | 467 purple_xfer_choose_file(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 { |
15823 | 469 purple_request_file(xfer, NULL, purple_xfer_get_filename(xfer), |
470 (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE), | |
471 G_CALLBACK(purple_xfer_choose_file_ok_cb), | |
16442
08db93bbd798
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 <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
472 G_CALLBACK(purple_xfer_choose_file_cancel_cb), |
08db93bbd798
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 <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
473 purple_xfer_get_account(xfer), xfer->who, NULL, |
08db93bbd798
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 <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
474 xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 static int |
15823 | 480 cancel_recv_cb(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 { |
15823 | 482 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
483 purple_xfer_request_denied(xfer); | |
484 purple_xfer_unref(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 static void |
15823 | 490 purple_xfer_ask_recv(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 char *buf, *size_buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 size_t size; |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
494 gconstpointer thumb; |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
495 gsize thumb_size; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 /* If we have already accepted the request, ask the destination file |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 name directly */ |
15823 | 499 if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_ACCEPTED) { |
500 PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 |
15823 | 502 if (purple_xfer_get_filename(xfer) != NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 { |
15823 | 504 size = purple_xfer_get_size(xfer); |
505 size_buf = purple_str_size_to_units(size); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), |
15823 | 507 buddy ? purple_buddy_get_alias(buddy) : xfer->who, |
508 purple_xfer_get_filename(xfer), size_buf); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 g_free(size_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 buf = g_strdup_printf(_("%s wants to send you a file"), |
15823 | 514 buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 if (xfer->message != NULL) |
15823 | 518 serv_got_im(purple_account_get_connection(xfer->account), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 xfer->who, xfer->message, 0, time(NULL)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
521 if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) { |
30205
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
522 purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
523 PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, |
30286
ce52e101844a
Scale incoming thumbnails in the request dialog if they are overly large
Marcus Lundblad <ml@update.uu.se>
parents:
30250
diff
changeset
|
524 thumb, thumb_size, xfer, |
30205
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
525 G_CALLBACK(purple_xfer_choose_file), |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
526 G_CALLBACK(cancel_recv_cb)); |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
527 } else { |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
528 purple_request_accept_cancel(xfer, NULL, buf, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
529 PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
530 xfer, G_CALLBACK(purple_xfer_choose_file), |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
531 G_CALLBACK(cancel_recv_cb)); |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
30197
diff
changeset
|
532 } |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31395
diff
changeset
|
533 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 } else |
15823 | 536 purple_xfer_choose_file(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 static int |
15823 | 540 ask_accept_ok(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 { |
15823 | 542 purple_xfer_request_accepted(xfer, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 static int |
15823 | 548 ask_accept_cancel(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 { |
15823 | 550 purple_xfer_request_denied(xfer); |
551 purple_xfer_unref(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 static void |
15823 | 557 purple_xfer_ask_accept(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 char *buf, *buf2 = NULL; |
15823 | 560 PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 buf = g_strdup_printf(_("Accept file transfer request from %s?"), |
15823 | 563 buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
564 if (purple_xfer_get_remote_ip(xfer) && | |
565 purple_xfer_get_remote_port(xfer)) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 buf2 = g_strdup_printf(_("A file is available for download from:\n" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 "Remote host: %s\nRemote port: %d"), |
15823 | 568 purple_xfer_get_remote_ip(xfer), |
569 purple_xfer_get_remote_port(xfer)); | |
570 purple_request_accept_cancel(xfer, NULL, buf, buf2, | |
16442
08db93bbd798
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 <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
571 PURPLE_DEFAULT_ACTION_NONE, |
08db93bbd798
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 <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
572 xfer->account, xfer->who, NULL, |
08db93bbd798
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 <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
573 xfer, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 G_CALLBACK(ask_accept_ok), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 G_CALLBACK(ask_accept_cancel)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 g_free(buf2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 void |
15823 | 581 purple_xfer_request(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 g_return_if_fail(xfer->ops.init != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 |
15823 | 586 purple_xfer_ref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 |
15823 | 588 if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 { |
15823 | 590 purple_signal_emit(purple_xfers_get_handle(), "file-recv-request", xfer); |
591 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 /* The file-transfer was cancelled by a plugin */ |
15823 | 594 purple_xfer_cancel_local(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 } |
15823 | 596 else if (purple_xfer_get_filename(xfer) || |
597 purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_ACCEPTED) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 gchar* message = NULL; |
15823 | 600 PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); |
30219
cb09d358d777
Make it work again, after some new xfer UI ops where added... :)
Marcus Lundblad <ml@update.uu.se>
parents:
30216
diff
changeset
|
601 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 message = g_strdup_printf(_("%s is offering to send file %s"), |
15823 | 603 buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer)); |
30221
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
30219
diff
changeset
|
604 purple_xfer_conversation_write_with_thumbnail(xfer, message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 g_free(message); |
30219
cb09d358d777
Make it work again, after some new xfer UI ops where added... :)
Marcus Lundblad <ml@update.uu.se>
parents:
30216
diff
changeset
|
606 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 /* Ask for a filename to save to if it's not already given by a plugin */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 if (xfer->local_filename == NULL) |
15823 | 609 purple_xfer_ask_recv(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 { |
15823 | 613 purple_xfer_ask_accept(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 { |
15823 | 618 purple_xfer_choose_file(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 void |
15823 | 623 purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 { |
15823 | 625 PurpleXferType type; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 struct stat st; |
26587
0c796a1950b7
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26249
diff
changeset
|
627 char *msg, *utf8, *base; |
15823 | 628 PurpleAccount *account; |
629 PurpleBuddy *buddy; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 if (xfer == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 |
15823 | 634 type = purple_xfer_get_type(xfer); |
635 account = purple_xfer_get_account(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 |
29937 | 637 purple_debug_misc("xfer", "request accepted for %p\n", xfer); |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
638 |
15823 | 639 if (!filename && type == PURPLE_XFER_RECEIVE) { |
640 xfer->status = PURPLE_XFER_STATUS_ACCEPTED; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 xfer->ops.init(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 |
15823 | 645 buddy = purple_find_buddy(account, xfer->who); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 |
15823 | 647 if (type == PURPLE_XFER_SEND) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 /* Sending a file */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 /* Check the filename. */ |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
650 PurpleXferUiOps *ui_ops; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
651 ui_ops = purple_xfer_get_ui_ops(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
652 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 #ifdef _WIN32 |
21866
03c950701fac
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <stu@nosnilmot.com>
parents:
21597
diff
changeset
|
654 if (g_strrstr(filename, "../") || g_strrstr(filename, "..\\")) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 #else |
21866
03c950701fac
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <stu@nosnilmot.com>
parents:
21597
diff
changeset
|
656 if (g_strrstr(filename, "../")) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 #endif |
21866
03c950701fac
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <stu@nosnilmot.com>
parents:
21597
diff
changeset
|
658 { |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
659 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 msg = g_strdup_printf(_("%s is not a valid filename.\n"), utf8); |
15823 | 662 purple_xfer_error(type, account, xfer->who, msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 |
15823 | 666 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 |
28226
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
28223
diff
changeset
|
670 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
671 if (g_stat(filename, &st) == -1) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
672 purple_xfer_show_file_error(xfer, filename); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
673 purple_xfer_unref(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
674 return; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
675 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
676 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
677 purple_xfer_set_local_filename(xfer, filename); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
678 purple_xfer_set_size(xfer, st.st_size); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
679 } else { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
680 purple_xfer_set_local_filename(xfer, filename); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 |
26587
0c796a1950b7
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26249
diff
changeset
|
683 base = g_path_get_basename(filename); |
0c796a1950b7
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26249
diff
changeset
|
684 utf8 = g_filename_to_utf8(base, -1, NULL, NULL, NULL); |
0c796a1950b7
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26249
diff
changeset
|
685 g_free(base); |
15823 | 686 purple_xfer_set_filename(xfer, utf8); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 msg = g_strdup_printf(_("Offering to send %s to %s"), |
15823 | 689 utf8, buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 g_free(utf8); |
15823 | 691 purple_xfer_conversation_write(xfer, msg, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 /* Receiving a file */ |
15823 | 696 xfer->status = PURPLE_XFER_STATUS_ACCEPTED; |
697 purple_xfer_set_local_filename(xfer, filename); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 msg = g_strdup_printf(_("Starting transfer of %s from %s"), |
15823 | 700 xfer->filename, buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
701 purple_xfer_conversation_write(xfer, msg, FALSE); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 |
15823 | 705 purple_xfer_add(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 xfer->ops.init(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 void |
15823 | 711 purple_xfer_request_denied(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
715 purple_debug_misc("xfer", "xfer %p denied\n", xfer); |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
716 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 if (xfer->ops.request_denied != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 xfer->ops.request_denied(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 |
15823 | 720 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 |
32468
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
723 int purple_xfer_get_fd(PurpleXfer *xfer) |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
724 { |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
725 g_return_val_if_fail(xfer != NULL, 0); |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
726 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
727 return xfer->fd; |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
728 } |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
729 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
730 int purple_xfer_get_watcher(PurpleXfer *xfer) |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
731 { |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
732 g_return_val_if_fail(xfer != NULL, 0); |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
733 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
734 return xfer->watcher; |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
735 } |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
736 |
15823 | 737 PurpleXferType |
738 purple_xfer_get_type(const PurpleXfer *xfer) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 { |
15823 | 740 g_return_val_if_fail(xfer != NULL, PURPLE_XFER_UNKNOWN); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 return xfer->type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 |
15823 | 745 PurpleAccount * |
746 purple_xfer_get_account(const PurpleXfer *xfer) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 g_return_val_if_fail(xfer != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 return xfer->account; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 |
17527
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
753 const char * |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
754 purple_xfer_get_remote_user(const PurpleXfer *xfer) |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
755 { |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
756 g_return_val_if_fail(xfer != NULL, NULL); |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
757 return xfer->who; |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
758 } |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17252
diff
changeset
|
759 |
15823 | 760 PurpleXferStatusType |
761 purple_xfer_get_status(const PurpleXfer *xfer) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 { |
15823 | 763 g_return_val_if_fail(xfer != NULL, PURPLE_XFER_STATUS_UNKNOWN); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 return xfer->status; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 |
30865
1cdae196aac8
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30286
diff
changeset
|
768 /* FIXME: Rename with cancelled for 3.0.0. */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 gboolean |
15823 | 770 purple_xfer_is_canceled(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 g_return_val_if_fail(xfer != NULL, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 |
15823 | 774 if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) || |
775 (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE)) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 gboolean |
15823 | 782 purple_xfer_is_completed(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 g_return_val_if_fail(xfer != NULL, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 |
15823 | 786 return (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_DONE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 const char * |
15823 | 790 purple_xfer_get_filename(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 g_return_val_if_fail(xfer != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
794 return xfer->filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 const char * |
15823 | 798 purple_xfer_get_local_filename(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 g_return_val_if_fail(xfer != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 return xfer->local_filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 size_t |
15823 | 806 purple_xfer_get_bytes_sent(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 g_return_val_if_fail(xfer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 return xfer->bytes_sent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 size_t |
15823 | 814 purple_xfer_get_bytes_remaining(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 g_return_val_if_fail(xfer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 return xfer->bytes_remaining; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 size_t |
15823 | 822 purple_xfer_get_size(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 g_return_val_if_fail(xfer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 return xfer->size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 double |
15823 | 830 purple_xfer_get_progress(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 g_return_val_if_fail(xfer != NULL, 0.0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 |
15823 | 834 if (purple_xfer_get_size(xfer) == 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
835 return 0.0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 |
15823 | 837 return ((double)purple_xfer_get_bytes_sent(xfer) / |
838 (double)purple_xfer_get_size(xfer)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 unsigned int |
15823 | 842 purple_xfer_get_local_port(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 g_return_val_if_fail(xfer != NULL, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 return xfer->local_port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 const char * |
15823 | 850 purple_xfer_get_remote_ip(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 g_return_val_if_fail(xfer != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 return xfer->remote_ip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
856 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 unsigned int |
15823 | 858 purple_xfer_get_remote_port(const PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
859 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 g_return_val_if_fail(xfer != NULL, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
862 return xfer->remote_port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 |
22216
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
865 time_t |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
866 purple_xfer_get_start_time(const PurpleXfer *xfer) |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
867 { |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
868 g_return_val_if_fail(xfer != NULL, 0); |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
869 |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
870 return xfer->start_time; |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
871 } |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
872 |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
873 time_t |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
874 purple_xfer_get_end_time(const PurpleXfer *xfer) |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
875 { |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
876 g_return_val_if_fail(xfer != NULL, 0); |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
877 |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
878 return xfer->end_time; |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
879 } |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
880 |
32468
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
881 void purple_xfer_set_fd(PurpleXfer *xfer, int fd) |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
882 { |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
883 g_return_if_fail(xfer != NULL); |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
884 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
885 xfer->fd = fd; |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
886 } |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
887 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
888 void purple_xfer_set_watcher(PurpleXfer *xfer, int watcher) |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
889 { |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
890 g_return_if_fail(xfer != NULL); |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
891 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
892 xfer->watcher = watcher; |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
893 } |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
894 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
895 void |
15823 | 896 purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 { |
15823 | 898 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 if (completed == TRUE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 char *msg = NULL; |
27478
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
904 PurpleConversation *conv; |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
905 |
15823 | 906 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 |
15823 | 908 if (purple_xfer_get_filename(xfer) != NULL) |
27478
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
909 { |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
910 char *filename = g_markup_escape_text(purple_xfer_get_filename(xfer), -1); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
911 if (purple_xfer_get_local_filename(xfer) |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
912 && purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
913 { |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
914 char *local = g_markup_escape_text(purple_xfer_get_local_filename(xfer), -1); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
915 msg = g_strdup_printf(_("Transfer of file <A HREF=\"file://%s\">%s</A> complete"), |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
916 local, filename); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
917 g_free(local); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
918 } |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
919 else |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
920 msg = g_strdup_printf(_("Transfer of file %s complete"), |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
921 filename); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
922 g_free(filename); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
923 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 else |
24884
568b786c36f9
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24394
diff
changeset
|
925 msg = g_strdup(_("File transfer complete")); |
27478
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
926 |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
927 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
928 purple_xfer_get_account(xfer)); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
929 |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
930 if (conv != NULL) |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26587
diff
changeset
|
931 purple_conversation_write(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
934 |
15823 | 935 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 if (ui_ops != NULL && ui_ops->update_progress != NULL) |
15823 | 938 ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 void |
15823 | 942 purple_xfer_set_message(PurpleXfer *xfer, const char *message) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 g_free(xfer->message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 xfer->message = g_strdup(message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 void |
15823 | 951 purple_xfer_set_filename(PurpleXfer *xfer, const char *filename) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 g_free(xfer->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 xfer->filename = g_strdup(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 void |
15823 | 960 purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 g_free(xfer->local_filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 xfer->local_filename = g_strdup(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 void |
15823 | 969 purple_xfer_set_size(PurpleXfer *xfer, size_t size) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 xfer->size = size; |
15823 | 974 xfer->bytes_remaining = xfer->size - purple_xfer_get_bytes_sent(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 void |
32468
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
978 purple_xfer_set_local_port(PurpleXfer *xfer, unsigned int local_port) |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
979 { |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
980 g_return_if_fail(xfer != NULL); |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
981 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
982 xfer->local_port = local_port; |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
983 } |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
984 |
9f9be9ab3383
Add some get/set functions to help hidding _PrupleXfer.
masca@cpw.pidgin.im
parents:
32434
diff
changeset
|
985 void |
15823 | 986 purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
987 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 xfer->bytes_sent = bytes_sent; |
15823 | 991 xfer->bytes_remaining = purple_xfer_get_size(xfer) - bytes_sent; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 |
15823 | 994 PurpleXferUiOps * |
995 purple_xfer_get_ui_ops(const PurpleXfer *xfer) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 g_return_val_if_fail(xfer != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 return xfer->ui_ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1001 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1002 void |
15823 | 1003 purple_xfer_set_init_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1005 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 xfer->ops.init = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1009 |
15823 | 1010 void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1011 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1012 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1013 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1014 xfer->ops.request_denied = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1015 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1016 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 void |
15823 | 1018 purple_xfer_set_read_fnc(PurpleXfer *xfer, gssize (*fnc)(guchar **, PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1020 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1021 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1022 xfer->ops.read = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1023 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1024 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1025 void |
15823 | 1026 purple_xfer_set_write_fnc(PurpleXfer *xfer, |
1027 gssize (*fnc)(const guchar *, size_t, PurpleXfer *)) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1028 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1029 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1030 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1031 xfer->ops.write = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1032 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1034 void |
15823 | 1035 purple_xfer_set_ack_fnc(PurpleXfer *xfer, |
1036 void (*fnc)(PurpleXfer *, const guchar *, size_t)) | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1037 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1038 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1039 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1040 xfer->ops.ack = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1041 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1042 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 void |
15823 | 1044 purple_xfer_set_start_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1047 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 xfer->ops.start = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1049 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 void |
15823 | 1052 purple_xfer_set_end_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1055 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 xfer->ops.end = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 void |
15823 | 1060 purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 xfer->ops.cancel_send = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 void |
15823 | 1068 purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1070 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 xfer->ops.cancel_recv = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 static void |
15823 | 1076 purple_xfer_increase_buffer_size(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 xfer->current_buffer_size = MIN(xfer->current_buffer_size * 1.5, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 FT_MAX_BUFFER_SIZE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 gssize |
15823 | 1083 purple_xfer_read(PurpleXfer *xfer, guchar **buffer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 gssize s, r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 g_return_val_if_fail(xfer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 g_return_val_if_fail(buffer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 |
15823 | 1090 if (purple_xfer_get_size(xfer) == 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 s = xfer->current_buffer_size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 else |
15823 | 1093 s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 |
26249
4cbe258db067
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@soc.pidgin.im>
parents:
24884
diff
changeset
|
1095 if (xfer->ops.read != NULL) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 r = (xfer->ops.read)(buffer, xfer); |
26249
4cbe258db067
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@soc.pidgin.im>
parents:
24884
diff
changeset
|
1097 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 *buffer = g_malloc0(s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 r = read(xfer->fd, *buffer, s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 if (r < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 r = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 else if (r < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 r = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 else if (r == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 r = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 if (r == xfer->current_buffer_size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 * We managed to read the entire buffer. This means our this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 * network is fast and our buffer is too small, so make it |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 * bigger. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1115 */ |
15823 | 1116 purple_xfer_increase_buffer_size(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1118 return r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1119 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 gssize |
15823 | 1122 purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 gssize r, s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 g_return_val_if_fail(xfer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 g_return_val_if_fail(buffer != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 g_return_val_if_fail(size != 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 |
15823 | 1130 s = MIN(purple_xfer_get_bytes_remaining(xfer), size); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 if (xfer->ops.write != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 r = (xfer->ops.write)(buffer, s, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 r = write(xfer->fd, buffer, s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 if (r < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 r = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 } |
31750
45496e1dfe5c
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31534
diff
changeset
|
1139 if (r >= 0 && (purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer) && |
45496e1dfe5c
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31534
diff
changeset
|
1140 !purple_xfer_is_completed(xfer)) |
45496e1dfe5c
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31534
diff
changeset
|
1141 purple_xfer_set_completed(xfer, TRUE); |
45496e1dfe5c
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31534
diff
changeset
|
1142 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 return r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 static void |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1148 do_transfer(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 { |
15823 | 1150 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 guchar *buffer = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1152 gssize r = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1154 ui_ops = purple_xfer_get_ui_ops(xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1155 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1156 if (xfer->type == PURPLE_XFER_RECEIVE) { |
15823 | 1157 r = purple_xfer_read(xfer, &buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 if (r > 0) { |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1159 size_t wc; |
28226
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
28223
diff
changeset
|
1160 if (ui_ops && ui_ops->ui_write) |
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
28223
diff
changeset
|
1161 wc = ui_ops->ui_write(xfer, buffer, r); |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1162 else |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1163 wc = fwrite(buffer, 1, r, xfer->dest_fp); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1164 |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1165 if (wc != r) { |
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1166 purple_debug_error("filetransfer", "Unable to write whole buffer.\n"); |
28007
ed3184cc557d
ft: fwrite failing is a local error. Pointed out by kenshin.
Paul Aurich <paul@darkrain42.org>
parents:
28005
diff
changeset
|
1167 purple_xfer_cancel_local(xfer); |
28137
da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents:
28059
diff
changeset
|
1168 g_free(buffer); |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1169 return; |
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1170 } |
28247
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
28226
diff
changeset
|
1171 |
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
28226
diff
changeset
|
1172 if ((purple_xfer_get_size(xfer) > 0) && |
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
28226
diff
changeset
|
1173 ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer))) |
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
28226
diff
changeset
|
1174 purple_xfer_set_completed(xfer, TRUE); |
17252
9235189117c0
Fix file transfers aborting and mistakenly being marked as cancelled when they are actually complete. Fixes #814
Daniel Atallah <daniel.atallah@gmail.com>
parents:
17065
diff
changeset
|
1175 } else if(r < 0) { |
15823 | 1176 purple_xfer_cancel_remote(xfer); |
28137
da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents:
28059
diff
changeset
|
1177 g_free(buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 } |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1180 } else if (xfer->type == PURPLE_XFER_SEND) { |
29895
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1181 size_t result = 0; |
15823 | 1182 size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1183 PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
29936
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1184 gboolean read = TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 /* this is so the prpl can keep the connection open |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 if it needs to for some odd reason. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 if (s == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 if (xfer->watcher) { |
15823 | 1190 purple_input_remove(xfer->watcher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 |
29936
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1196 if (priv->buffer) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1197 if (priv->buffer->len < s) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1198 s -= priv->buffer->len; |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1199 read = TRUE; |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1200 } else { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1201 read = FALSE; |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1202 } |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1203 } |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1204 |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1205 if (read) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1206 if (ui_ops && ui_ops->ui_read) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1207 gssize tmp = ui_ops->ui_read(xfer, &buffer, s); |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1208 if (tmp == 0) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1209 /* |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1210 * The UI claimed it was ready, but didn't have any data for |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1211 * us... It will call purple_xfer_ui_ready when ready, which |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1212 * sets back up this watcher. |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1213 */ |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1214 if (xfer->watcher != 0) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1215 purple_input_remove(xfer->watcher); |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1216 xfer->watcher = 0; |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1217 } |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1218 |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1219 /* Need to indicate the prpl is still ready... */ |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1220 priv->ready |= PURPLE_XFER_READY_PRPL; |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1221 |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1222 g_return_if_reached(); |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1223 } else if (tmp < 0) { |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1224 purple_debug_error("filetransfer", "Unable to read whole buffer.\n"); |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1225 purple_xfer_cancel_local(xfer); |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1226 return; |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1227 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 |
29936
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1229 result = tmp; |
75780bc426d0
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <paul@darkrain42.org>
parents:
29935
diff
changeset
|
1230 } else { |
29895
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1231 buffer = g_malloc(s); |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1232 result = fread(buffer, 1, s, xfer->dest_fp); |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1233 if (result != s) { |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1234 purple_debug_error("filetransfer", "Unable to read whole buffer.\n"); |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1235 purple_xfer_cancel_local(xfer); |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1236 g_free(buffer); |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1237 return; |
1326fd4dfdc9
ft: Don't try to read from the source file if the byte array already holds
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29742
diff
changeset
|
1238 } |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1239 } |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1240 } |
29937 | 1241 |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1242 if (priv->buffer) { |
30094
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1243 g_byte_array_append(priv->buffer, buffer, result); |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1244 g_free(buffer); |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1245 buffer = priv->buffer->data; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1246 result = priv->buffer->len; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1247 } |
29937 | 1248 |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1249 r = purple_xfer_write(xfer, buffer, result); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1251 if (r == -1) { |
15823 | 1252 purple_xfer_cancel_remote(xfer); |
30094
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1253 if (!priv->buffer) |
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1254 /* We don't free buffer if priv->buffer is set, because in |
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1255 that case buffer doesn't belong to us. */ |
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1256 g_free(buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1257 return; |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1258 } else if (r == result) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1259 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1260 * We managed to write the entire buffer. This means our |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1261 * network is fast and our buffer is too small, so make it |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1262 * bigger. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1263 */ |
15823 | 1264 purple_xfer_increase_buffer_size(xfer); |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1265 } else { |
29937 | 1266 if (ui_ops && ui_ops->data_not_sent) |
1267 ui_ops->data_not_sent(xfer, buffer + r, result - r); | |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1268 } |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1269 |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1270 if (priv->buffer) { |
29937 | 1271 /* |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1272 * Remove what we wrote |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1273 * If we wrote the whole buffer the byte array will be empty |
30094
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1274 * Otherwise we'll keep what wasn't sent for next time. |
29518
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1275 */ |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28727
diff
changeset
|
1276 buffer = NULL; |
30094
6797736dbe37
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <mark@kingant.net>
parents:
29937
diff
changeset
|
1277 g_byte_array_remove_range(priv->buffer, 0, r); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1278 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1279 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1281 if (r > 0) { |
15823 | 1282 if (purple_xfer_get_size(xfer) > 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1283 xfer->bytes_remaining -= r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1285 xfer->bytes_sent += r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1286 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 if (xfer->ops.ack != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 xfer->ops.ack(xfer, buffer, r); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1290 g_free(buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1292 if (ui_ops != NULL && ui_ops->update_progress != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1293 ui_ops->update_progress(xfer, |
15823 | 1294 purple_xfer_get_progress(xfer)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1295 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1296 |
15823 | 1297 if (purple_xfer_is_completed(xfer)) |
1298 purple_xfer_end(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1299 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1300 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1301 static void |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1302 transfer_cb(gpointer data, gint source, PurpleInputCondition condition) |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1303 { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1304 PurpleXfer *xfer = data; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1305 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1306 if (xfer->dest_fp == NULL) { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1307 /* The UI is moderating its side manually */ |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1308 PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1309 if (0 == (priv->ready & PURPLE_XFER_READY_UI)) { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1310 priv->ready |= PURPLE_XFER_READY_PRPL; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1311 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1312 purple_input_remove(xfer->watcher); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1313 xfer->watcher = 0; |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1314 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1315 purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1316 return; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1317 } |
29299
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
29215
diff
changeset
|
1318 |
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
29215
diff
changeset
|
1319 priv->ready = PURPLE_XFER_READY_NONE; |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1320 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1321 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1322 do_transfer(xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1323 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1324 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1325 static void |
15823 | 1326 begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1327 { |
15823 | 1328 PurpleXferType type = purple_xfer_get_type(xfer); |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1329 PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1330 |
31025
485eaf544bb0
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30865
diff
changeset
|
1331 if (xfer->start_time != 0) { |
485eaf544bb0
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30865
diff
changeset
|
1332 purple_debug_error("xfer", "Transfer is being started multiple times\n"); |
485eaf544bb0
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30865
diff
changeset
|
1333 g_return_if_reached(); |
485eaf544bb0
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30865
diff
changeset
|
1334 } |
485eaf544bb0
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30865
diff
changeset
|
1335 |
28226
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
28223
diff
changeset
|
1336 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1337 xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1338 type == PURPLE_XFER_RECEIVE ? "wb" : "rb"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1339 |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1340 if (xfer->dest_fp == NULL) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1341 purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer)); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1342 purple_xfer_cancel_local(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1343 return; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1344 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1345 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1346 fseek(xfer->dest_fp, xfer->bytes_sent, SEEK_SET); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1347 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1348 |
28218
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1349 if (xfer->fd != -1) |
17065
21830d70709b
Patch from sourceforge tracker 1652005 from wabz to fix displaying file
Stu Tomlinson <stu@nosnilmot.com>
parents:
16442
diff
changeset
|
1350 xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1351 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1352 xfer->start_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1354 if (xfer->ops.start != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1355 xfer->ops.start(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1356 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1357 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1358 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1359 connect_cb(gpointer data, gint source, const gchar *error_message) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1360 { |
15823 | 1361 PurpleXfer *xfer = (PurpleXfer *)data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1362 |
21587
fd87b254d3f3
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
1363 if (source < 0) { |
fd87b254d3f3
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
1364 purple_xfer_cancel_local(xfer); |
fd87b254d3f3
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
1365 return; |
fd87b254d3f3
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
1366 } |
fd87b254d3f3
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21560
diff
changeset
|
1367 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1368 xfer->fd = source; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1369 |
15823 | 1370 begin_transfer(xfer, PURPLE_INPUT_READ); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1371 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1372 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1373 void |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1374 purple_xfer_ui_ready(PurpleXfer *xfer) |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1375 { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1376 PurpleInputCondition cond; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1377 PurpleXferType type; |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1378 PurpleXferPrivData *priv; |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1379 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1380 g_return_if_fail(xfer != NULL); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1381 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1382 priv = g_hash_table_lookup(xfers_data, xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1383 priv->ready |= PURPLE_XFER_READY_UI; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1384 |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1385 if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1386 purple_debug_misc("xfer", "UI is ready on ft %p, waiting for prpl\n", xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1387 return; |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1388 } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1389 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1390 purple_debug_misc("xfer", "UI (and prpl) ready on ft %p, so proceeding\n", xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1391 |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1392 type = purple_xfer_get_type(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1393 if (type == PURPLE_XFER_SEND) |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1394 cond = PURPLE_INPUT_WRITE; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1395 else /* if (type == PURPLE_XFER_RECEIVE) */ |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1396 cond = PURPLE_INPUT_READ; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1397 |
28219
7754717d574c
ft: Fix an issue with re-setting xfer->watcher when there is no fd.
Paul Aurich <paul@darkrain42.org>
parents:
28218
diff
changeset
|
1398 if (xfer->watcher == 0 && xfer->fd != -1) |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1399 xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1400 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1401 priv->ready = PURPLE_XFER_READY_NONE; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1402 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1403 do_transfer(xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1404 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1405 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1406 void |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1407 purple_xfer_prpl_ready(PurpleXfer *xfer) |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1408 { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1409 PurpleXferPrivData *priv; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1410 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1411 g_return_if_fail(xfer != NULL); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1412 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1413 priv = g_hash_table_lookup(xfers_data, xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1414 priv->ready |= PURPLE_XFER_READY_PRPL; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1415 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1416 /* I don't think fwrite/fread are ever *not* ready */ |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1417 if (xfer->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI)) { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1418 purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1419 return; |
29215
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1420 } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1421 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
29206
diff
changeset
|
1422 purple_debug_misc("xfer", "Prpl (and UI) ready on ft %p, so proceeding\n", xfer); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1423 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1424 priv->ready = PURPLE_XFER_READY_NONE; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1425 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1426 do_transfer(xfer); |
28216
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1427 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1428 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
28137
diff
changeset
|
1429 void |
15823 | 1430 purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1431 unsigned int port) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1432 { |
15823 | 1433 PurpleInputCondition cond; |
1434 PurpleXferType type; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1435 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1436 g_return_if_fail(xfer != NULL); |
15823 | 1437 g_return_if_fail(purple_xfer_get_type(xfer) != PURPLE_XFER_UNKNOWN); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1438 |
15823 | 1439 type = purple_xfer_get_type(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1440 |
15823 | 1441 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_STARTED); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1442 |
28218
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1443 /* |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1444 * FIXME 3.0.0 -- there's too much broken code depending on fd == 0 |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1445 * meaning "don't use a real fd" |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1446 */ |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1447 if (fd == 0) |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1448 fd = -1; |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1449 |
15823 | 1450 if (type == PURPLE_XFER_RECEIVE) { |
1451 cond = PURPLE_INPUT_READ; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1452 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1453 if (ip != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1454 xfer->remote_ip = g_strdup(ip); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1455 xfer->remote_port = port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1456 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1457 /* Establish a file descriptor. */ |
15823 | 1458 purple_proxy_connect(NULL, xfer->account, xfer->remote_ip, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1459 xfer->remote_port, connect_cb, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1460 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1461 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1462 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1463 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1464 xfer->fd = fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1465 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1466 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1467 else { |
15823 | 1468 cond = PURPLE_INPUT_WRITE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1469 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1470 xfer->fd = fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1471 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1473 begin_transfer(xfer, cond); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1474 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1475 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1476 void |
15823 | 1477 purple_xfer_end(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1478 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1479 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1480 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1481 /* See if we are actually trying to cancel this. */ |
15823 | 1482 if (!purple_xfer_is_completed(xfer)) { |
1483 purple_xfer_cancel_local(xfer); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1484 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1485 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1486 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1487 xfer->end_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1488 if (xfer->ops.end != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1489 xfer->ops.end(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1490 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1491 if (xfer->watcher != 0) { |
15823 | 1492 purple_input_remove(xfer->watcher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1493 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1494 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1495 |
28218
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1496 if (xfer->fd != -1) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1497 close(xfer->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1498 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1499 if (xfer->dest_fp != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1500 fclose(xfer->dest_fp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1501 xfer->dest_fp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1502 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1503 |
15823 | 1504 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1505 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1506 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1507 void |
15823 | 1508 purple_xfer_add(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1509 { |
15823 | 1510 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1511 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1512 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1513 |
15823 | 1514 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1515 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1516 if (ui_ops != NULL && ui_ops->add_xfer != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1517 ui_ops->add_xfer(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1518 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1519 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1520 void |
15823 | 1521 purple_xfer_cancel_local(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1522 { |
15823 | 1523 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1524 char *msg = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1525 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1526 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1527 |
31395
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1528 /* TODO: We definitely want to close any open request dialogs associated |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1529 with this transfer. However, in some cases the request dialog might |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1530 own a reference on the xfer. This happens at least with the "%s wants |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1531 to send you %s" dialog from purple_xfer_ask_recv(). In these cases |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1532 the ref count will not be decremented when the request dialog is |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1533 closed, so the ref count will never reach 0 and the xfer will never |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1534 be freed. This is a memleak and should be fixed. It's not clear what |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1535 the correct fix is. Probably requests should have a destroy function |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1536 that is called when the request is destroyed. But also, ref counting |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1537 xfer objects makes this code REALLY complicated. An alternate fix is |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1538 to not ref count and instead just make sure the object still exists |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1539 when we try to use it. */ |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1540 purple_request_close_with_handle(xfer); |
a76cf8ecb0c5
Close open requests related to this xfer when the request is canceled
Mark Doliner <mark@kingant.net>
parents:
31025
diff
changeset
|
1541 |
15823 | 1542 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1543 xfer->end_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1544 |
15823 | 1545 if (purple_xfer_get_filename(xfer) != NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1546 { |
28310
a7eac81575e7
Normalize on 'cancelled'
Paul Aurich <paul@darkrain42.org>
parents:
27478
diff
changeset
|
1547 msg = g_strdup_printf(_("You cancelled the transfer of %s"), |
15823 | 1548 purple_xfer_get_filename(xfer)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1549 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1550 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1551 { |
24884
568b786c36f9
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24394
diff
changeset
|
1552 msg = g_strdup(_("File transfer cancelled")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1553 } |
15823 | 1554 purple_xfer_conversation_write(xfer, msg, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1555 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1556 |
15823 | 1557 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1558 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1559 if (xfer->ops.cancel_send != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1560 xfer->ops.cancel_send(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1561 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1562 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1563 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1564 if (xfer->ops.cancel_recv != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1565 xfer->ops.cancel_recv(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1566 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1567 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1568 if (xfer->watcher != 0) { |
15823 | 1569 purple_input_remove(xfer->watcher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1570 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1571 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1572 |
28218
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1573 if (xfer->fd != -1) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1574 close(xfer->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1575 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1576 if (xfer->dest_fp != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1577 fclose(xfer->dest_fp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1578 xfer->dest_fp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1579 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1580 |
15823 | 1581 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1582 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1583 if (ui_ops != NULL && ui_ops->cancel_local != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1584 ui_ops->cancel_local(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1585 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1586 xfer->bytes_remaining = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1587 |
15823 | 1588 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1589 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1590 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1591 void |
15823 | 1592 purple_xfer_cancel_remote(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1593 { |
15823 | 1594 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1595 gchar *msg; |
15823 | 1596 PurpleAccount *account; |
1597 PurpleBuddy *buddy; | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1598 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1599 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1600 |
15823 | 1601 purple_request_close_with_handle(xfer); |
1602 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1603 xfer->end_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1604 |
15823 | 1605 account = purple_xfer_get_account(xfer); |
1606 buddy = purple_find_buddy(account, xfer->who); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1607 |
15823 | 1608 if (purple_xfer_get_filename(xfer) != NULL) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1609 { |
28310
a7eac81575e7
Normalize on 'cancelled'
Paul Aurich <paul@darkrain42.org>
parents:
27478
diff
changeset
|
1610 msg = g_strdup_printf(_("%s cancelled the transfer of %s"), |
15823 | 1611 buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1612 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1613 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1614 { |
28310
a7eac81575e7
Normalize on 'cancelled'
Paul Aurich <paul@darkrain42.org>
parents:
27478
diff
changeset
|
1615 msg = g_strdup_printf(_("%s cancelled the file transfer"), |
15823 | 1616 buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1617 } |
15823 | 1618 purple_xfer_conversation_write(xfer, msg, TRUE); |
1619 purple_xfer_error(purple_xfer_get_type(xfer), account, xfer->who, msg); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1620 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1621 |
15823 | 1622 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1623 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1624 if (xfer->ops.cancel_send != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1625 xfer->ops.cancel_send(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1626 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1627 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1628 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1629 if (xfer->ops.cancel_recv != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1630 xfer->ops.cancel_recv(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1631 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1632 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1633 if (xfer->watcher != 0) { |
15823 | 1634 purple_input_remove(xfer->watcher); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1635 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1636 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1637 |
28218
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
28216
diff
changeset
|
1638 if (xfer->fd != -1) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1639 close(xfer->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1640 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1641 if (xfer->dest_fp != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1642 fclose(xfer->dest_fp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1643 xfer->dest_fp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1644 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1645 |
15823 | 1646 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1647 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1648 if (ui_ops != NULL && ui_ops->cancel_remote != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1649 ui_ops->cancel_remote(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1650 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1651 xfer->bytes_remaining = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1652 |
15823 | 1653 purple_xfer_unref(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1654 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1655 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1656 void |
15823 | 1657 purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1658 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1659 char *title; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1660 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1661 g_return_if_fail(msg != NULL); |
15823 | 1662 g_return_if_fail(type != PURPLE_XFER_UNKNOWN); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1663 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1664 if (account) { |
15823 | 1665 PurpleBuddy *buddy; |
1666 buddy = purple_find_buddy(account, who); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1667 if (buddy) |
15823 | 1668 who = purple_buddy_get_alias(buddy); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1669 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1670 |
15823 | 1671 if (type == PURPLE_XFER_SEND) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1672 title = g_strdup_printf(_("File transfer to %s failed."), who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1673 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1674 title = g_strdup_printf(_("File transfer from %s failed."), who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1675 |
15823 | 1676 purple_notify_error(NULL, NULL, title, msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1677 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1678 g_free(title); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1679 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1680 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1681 void |
15823 | 1682 purple_xfer_update_progress(PurpleXfer *xfer) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1683 { |
15823 | 1684 PurpleXferUiOps *ui_ops; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1685 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1686 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1687 |
15823 | 1688 ui_ops = purple_xfer_get_ui_ops(xfer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1689 if (ui_ops != NULL && ui_ops->update_progress != NULL) |
15823 | 1690 ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1691 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1692 |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
1693 gconstpointer |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
1694 purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len) |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1695 { |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1696 PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1697 |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
1698 if (len) |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
1699 *len = priv->thumbnail_size; |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1700 |
30250
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30248
diff
changeset
|
1701 return priv->thumbnail_data; |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1702 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1703 |
30237
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
30234
diff
changeset
|
1704 const gchar * |
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
30234
diff
changeset
|
1705 purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer) |
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
30234
diff
changeset
|
1706 { |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1707 PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1708 |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1709 return priv->thumbnail_mimetype; |
30237
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
30234
diff
changeset
|
1710 } |
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
30234
diff
changeset
|
1711 |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1712 void |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1713 purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail, |
30237
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
30234
diff
changeset
|
1714 gsize size, const gchar *mimetype) |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1715 { |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1716 PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1717 |
30248
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1718 g_free(priv->thumbnail_data); |
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1719 g_free(priv->thumbnail_mimetype); |
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1720 |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1721 if (thumbnail && size > 0) { |
30239
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1722 priv->thumbnail_data = g_memdup(thumbnail, size); |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1723 priv->thumbnail_size = size; |
6671b5e92c28
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <ml@update.uu.se>
parents:
30238
diff
changeset
|
1724 priv->thumbnail_mimetype = g_strdup(mimetype); |
30248
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1725 } else { |
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1726 priv->thumbnail_data = NULL; |
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1727 priv->thumbnail_size = 0; |
834038426c38
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30247
diff
changeset
|
1728 priv->thumbnail_mimetype = NULL; |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1729 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1730 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1731 |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1732 void |
30238
79bb2804a19e
Set desired image formats for thumbnails as a parameter to
Marcus Lundblad <ml@update.uu.se>
parents:
30237
diff
changeset
|
1733 purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats) |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1734 { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1735 if (xfer->ui_ops->add_thumbnail) { |
30238
79bb2804a19e
Set desired image formats for thumbnails as a parameter to
Marcus Lundblad <ml@update.uu.se>
parents:
30237
diff
changeset
|
1736 xfer->ui_ops->add_thumbnail(xfer, formats); |
30197
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1737 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26587
diff
changeset
|
1738 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1739 |
32417
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1740 void |
32426 | 1741 purple_xfer_set_protocol_data(PurpleXfer *xfer, gpointer proto_data) |
32417
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1742 { |
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1743 g_return_if_fail(xfer != NULL); |
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1744 |
32426 | 1745 xfer->proto_data = proto_data; |
32417
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1746 } |
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1747 |
32426 | 1748 gpointer |
32434
e5e81ce9c564
These pointers should rather be marked const.
andrew.victor@mxit.com
parents:
32427
diff
changeset
|
1749 purple_xfer_get_protocol_data(const PurpleXfer *xfer) |
32417
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1750 { |
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1751 g_return_val_if_fail(xfer != NULL, NULL); |
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1752 |
32426 | 1753 return xfer->proto_data; |
32417
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1754 } |
d61170e263b4
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
andrew.victor@mxit.com
parents:
31996
diff
changeset
|
1755 |
32427
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1756 void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data) |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1757 { |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1758 g_return_if_fail(xfer != NULL); |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1759 |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1760 xfer->ui_data = ui_data; |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1761 } |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1762 |
32434
e5e81ce9c564
These pointers should rather be marked const.
andrew.victor@mxit.com
parents:
32427
diff
changeset
|
1763 gpointer purple_xfer_get_ui_data(const PurpleXfer *xfer) |
32427
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1764 { |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1765 g_return_val_if_fail(xfer != NULL, NULL); |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1766 |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1767 return xfer->ui_data; |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1768 } |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1769 |
ff051a32e1e8
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
andrew.victor@mxit.com
parents:
32426
diff
changeset
|
1770 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1771 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1772 * File Transfer Subsystem API |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1773 **************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1774 void * |
15823 | 1775 purple_xfers_get_handle(void) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1776 static int handle = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1777 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1778 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1779 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1780 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1781 void |
15823 | 1782 purple_xfers_init(void) { |
1783 void *handle = purple_xfers_get_handle(); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1784 |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1785 xfers_data = g_hash_table_new_full(g_direct_hash, g_direct_equal, |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1786 NULL, purple_xfer_priv_data_destroy); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1787 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1788 /* register signals */ |
15823 | 1789 purple_signal_register(handle, "file-recv-accept", |
1790 purple_marshal_VOID__POINTER, NULL, 1, | |
1791 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1792 PURPLE_SUBTYPE_XFER)); | |
1793 purple_signal_register(handle, "file-send-accept", | |
1794 purple_marshal_VOID__POINTER, NULL, 1, | |
1795 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1796 PURPLE_SUBTYPE_XFER)); | |
1797 purple_signal_register(handle, "file-recv-start", | |
1798 purple_marshal_VOID__POINTER, NULL, 1, | |
1799 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1800 PURPLE_SUBTYPE_XFER)); | |
1801 purple_signal_register(handle, "file-send-start", | |
1802 purple_marshal_VOID__POINTER, NULL, 1, | |
1803 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1804 PURPLE_SUBTYPE_XFER)); | |
1805 purple_signal_register(handle, "file-send-cancel", | |
1806 purple_marshal_VOID__POINTER, NULL, 1, | |
1807 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1808 PURPLE_SUBTYPE_XFER)); | |
1809 purple_signal_register(handle, "file-recv-cancel", | |
1810 purple_marshal_VOID__POINTER, NULL, 1, | |
1811 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1812 PURPLE_SUBTYPE_XFER)); | |
1813 purple_signal_register(handle, "file-send-complete", | |
1814 purple_marshal_VOID__POINTER, NULL, 1, | |
1815 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1816 PURPLE_SUBTYPE_XFER)); | |
1817 purple_signal_register(handle, "file-recv-complete", | |
1818 purple_marshal_VOID__POINTER, NULL, 1, | |
1819 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1820 PURPLE_SUBTYPE_XFER)); | |
1821 purple_signal_register(handle, "file-recv-request", | |
1822 purple_marshal_VOID__POINTER, NULL, 1, | |
1823 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1824 PURPLE_SUBTYPE_XFER)); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1825 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1826 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1827 void |
21067
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1828 purple_xfers_uninit(void) |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1829 { |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1830 void *handle = purple_xfers_get_handle(); |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1831 |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1832 purple_signals_disconnect_by_handle(handle); |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1833 purple_signals_unregister_by_instance(handle); |
28223
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1834 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1835 g_hash_table_destroy(xfers_data); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
28219
diff
changeset
|
1836 xfers_data = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1837 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1838 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1839 void |
15823 | 1840 purple_xfers_set_ui_ops(PurpleXferUiOps *ops) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1841 xfer_ui_ops = ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1842 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1843 |
15823 | 1844 PurpleXferUiOps * |
1845 purple_xfers_get_ui_ops(void) { | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1846 return xfer_ui_ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1847 } |