Mercurial > pidgin
annotate libpurple/ft.c @ 29815:3175b89c5156
Add support for recieving and sending MSN file transfer previews.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 28 Feb 2010 04:14:15 +0000 |
parents | 1e8dc177415e |
children | 10bf97a36be0 |
rev | line source |
---|---|
15373
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:
19681
diff
changeset
|
3 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 /* purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * |
15822 | 7 * Purple is the legal property of its developers, whose names are too numerous |
15373
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 |
19681
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 * |
15373
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" |
17811
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
27 #include "dbus-maybe.h" |
15373
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" |
15373
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 |
15822 | 40 static PurpleXferUiOps *xfer_ui_ops = NULL; |
15640
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
41 static GList *xfers; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
43 /* |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
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:
27875
diff
changeset
|
45 * easily. |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
46 */ |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
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:
27875
diff
changeset
|
48 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
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:
27875
diff
changeset
|
50 /* |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
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:
27875
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:
27875
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:
27875
diff
changeset
|
54 */ |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
55 enum { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
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:
27875
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:
27875
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:
27875
diff
changeset
|
59 } ready; |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
60 GByteArray *buffer; |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
61 } PurpleXferPrivData; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
62 |
15822 | 63 static int purple_xfer_choose_file(PurpleXfer *xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
65 static void |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
66 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:
27875
diff
changeset
|
67 { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
68 PurpleXferPrivData *priv = data; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
69 |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
70 if (priv->buffer) |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
71 g_byte_array_free(priv->buffer, TRUE); |
29348
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
72 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
73 g_free(priv); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
74 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
75 |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
76 static const gchar * |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
77 purple_xfer_status_type_to_string(PurpleXferStatusType type) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
78 { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
79 static const struct { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
80 PurpleXferStatusType type; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
81 const char *name; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
82 } type_names[] = { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
83 { PURPLE_XFER_STATUS_UNKNOWN, "unknown" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
84 { PURPLE_XFER_STATUS_NOT_STARTED, "not started" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
85 { PURPLE_XFER_STATUS_ACCEPTED, "accepted" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
86 { PURPLE_XFER_STATUS_STARTED, "started" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
87 { PURPLE_XFER_STATUS_DONE, "done" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
88 { PURPLE_XFER_STATUS_CANCEL_LOCAL, "cancelled locally" }, |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
89 { PURPLE_XFER_STATUS_CANCEL_REMOTE, "cancelled remotely" } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
90 }; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
91 int i; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
92 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
93 for (i = 0; i < G_N_ELEMENTS(type_names); ++i) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
94 if (type_names[i].type == type) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
95 return type_names[i].name; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
96 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
97 return "invalid state"; |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
98 } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
99 |
15640
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
100 GList * |
15822 | 101 purple_xfers_get_all() |
15640
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
102 { |
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
103 return xfers; |
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
104 } |
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
105 |
15822 | 106 PurpleXfer * |
107 purple_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 { |
15822 | 109 PurpleXfer *xfer; |
110 PurpleXferUiOps *ui_ops; | |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
111 PurpleXferPrivData *priv; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 |
15822 | 113 g_return_val_if_fail(type != PURPLE_XFER_UNKNOWN, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 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
|
115 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
|
116 |
15822 | 117 xfer = g_new0(PurpleXfer, 1); |
17811
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
118 PURPLE_DBUS_REGISTER_POINTER(xfer, PurpleXfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 xfer->ref = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 xfer->type = type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 xfer->account = account; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 xfer->who = g_strdup(who); |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
124 xfer->ui_ops = ui_ops = purple_xfers_get_ui_ops(); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 xfer->message = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 xfer->current_buffer_size = FT_INITIAL_BUFFER_SIZE; |
20221
89e5492bcea4
applied changes from 307f0cff97539b1c6ddc0114500677abfe42aaa6
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
127 xfer->fd = -1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
129 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:
27875
diff
changeset
|
130 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:
27875
diff
changeset
|
131 |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
132 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:
28359
diff
changeset
|
133 /* 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:
28359
diff
changeset
|
134 priv->buffer = NULL; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
135 } else { |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
136 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:
28359
diff
changeset
|
137 } |
29348
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
138 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
139 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:
27875
diff
changeset
|
140 |
15822 | 141 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 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
|
144 ui_ops->new_xfer(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 |
15640
35fa1d1c4ef2
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15373
diff
changeset
|
146 xfers = g_list_prepend(xfers, xfer); |
28821
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
147 |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
148 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
149 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:
28820
diff
changeset
|
150 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 return xfer; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 static void |
15822 | 155 purple_xfer_destroy(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 { |
15822 | 157 PurpleXferUiOps *ui_ops; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
28821
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
161 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
162 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:
28820
diff
changeset
|
163 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 /* Close the file browser, if it's open */ |
15822 | 165 purple_request_close_with_handle(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 |
15822 | 167 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) |
168 purple_xfer_cancel_local(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 |
15822 | 170 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 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
|
173 ui_ops->destroy(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 g_free(xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 g_free(xfer->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 g_free(xfer->remote_ip); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 g_free(xfer->local_filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
180 g_hash_table_remove(xfers_data, xfer); |
29782
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
181 g_free(xfer->thumbnail_data); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
182 |
17811
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
183 PURPLE_DBUS_UNREGISTER_POINTER(xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
184 xfers = g_list_remove(xfers, xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 g_free(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 void |
15822 | 189 purple_xfer_ref(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 xfer->ref++; |
28821
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
194 |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
195 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
196 purple_debug_info("xfer", "ref'd %p [%d]\n", xfer, xfer->ref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 void |
15822 | 200 purple_xfer_unref(PurpleXfer *xfer) |
15373
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 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 g_return_if_fail(xfer->ref > 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 xfer->ref--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 |
28821
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
207 if (purple_debug_is_verbose()) |
edea24b65db9
Add some verbose ref-count debugging for PurpleXfer's.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28820
diff
changeset
|
208 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:
28820
diff
changeset
|
209 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 if (xfer->ref == 0) |
15822 | 211 purple_xfer_destroy(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 } |
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 static void |
15822 | 215 purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatusType status) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
219 if (purple_debug_is_verbose()) |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
220 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:
28823
diff
changeset
|
221 xfer, purple_xfer_status_type_to_string(xfer->status), |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
222 purple_xfer_status_type_to_string(status)); |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
223 |
27725
36d5e7690ad6
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <paul@darkrain42.org>
parents:
27679
diff
changeset
|
224 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:
27679
diff
changeset
|
225 return; |
36d5e7690ad6
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <paul@darkrain42.org>
parents:
27679
diff
changeset
|
226 |
27677
fd4415c0595f
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <paul@darkrain42.org>
parents:
27396
diff
changeset
|
227 xfer->status = status; |
fd4415c0595f
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <paul@darkrain42.org>
parents:
27396
diff
changeset
|
228 |
15822 | 229 if(xfer->type == PURPLE_XFER_SEND) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 switch(status) { |
15822 | 231 case PURPLE_XFER_STATUS_ACCEPTED: |
232 purple_signal_emit(purple_xfers_get_handle(), "file-send-accept", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 break; |
15822 | 234 case PURPLE_XFER_STATUS_STARTED: |
235 purple_signal_emit(purple_xfers_get_handle(), "file-send-start", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 break; |
15822 | 237 case PURPLE_XFER_STATUS_DONE: |
238 purple_signal_emit(purple_xfers_get_handle(), "file-send-complete", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 break; |
15822 | 240 case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
241 case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
242 purple_signal_emit(purple_xfers_get_handle(), "file-send-cancel", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 } |
15822 | 247 } else if(xfer->type == PURPLE_XFER_RECEIVE) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 switch(status) { |
15822 | 249 case PURPLE_XFER_STATUS_ACCEPTED: |
250 purple_signal_emit(purple_xfers_get_handle(), "file-recv-accept", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 break; |
15822 | 252 case PURPLE_XFER_STATUS_STARTED: |
253 purple_signal_emit(purple_xfers_get_handle(), "file-recv-start", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 break; |
15822 | 255 case PURPLE_XFER_STATUS_DONE: |
256 purple_signal_emit(purple_xfers_get_handle(), "file-recv-complete", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 break; |
15822 | 258 case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
259 case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
260 purple_signal_emit(purple_xfers_get_handle(), "file-recv-cancel", xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
29806
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
268 static void |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
269 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:
29804
diff
changeset
|
270 const char *message, gboolean is_error, gboolean print_thumbnail) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 { |
15822 | 272 PurpleConversation *conv = NULL; |
273 PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 char *escaped; |
29806
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
275 const gpointer *thumbnail_data = purple_xfer_get_thumbnail_data(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 g_return_if_fail(message != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
15822 | 280 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, |
281 purple_xfer_get_account(xfer)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 if (conv == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 escaped = g_markup_escape_text(message, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 if (is_error) |
28675
52dc24a5069f
ft: Properly set a bitmask field (so it includes PURPLE_MESSAGE_SYSTEM like
Florian Quèze <florian@instantbird.org>
parents:
28359
diff
changeset
|
289 flags |= PURPLE_MESSAGE_ERROR; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 |
29806
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
291 if (print_thumbnail && thumbnail_data) { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
292 gchar *message_with_img; |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
293 gsize size = purple_xfer_get_thumbnail_size(xfer); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
294 gpointer data = g_memdup(thumbnail_data, size); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
295 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:
29804
diff
changeset
|
296 |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
297 message_with_img = |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
298 g_strdup_printf("<img id='%d'/> %s", id, escaped); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
299 purple_conversation_write(conv, NULL, message_with_img, flags, |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
300 time(NULL)); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
301 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:
29804
diff
changeset
|
302 g_free(message_with_img); |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
303 } else { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
304 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:
29804
diff
changeset
|
305 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 g_free(escaped); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 |
29806
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
309 void |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
310 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:
29804
diff
changeset
|
311 gboolean is_error) |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
312 { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
313 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:
29804
diff
changeset
|
314 } |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
315 |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
316 /* maybe this one should be exported puplically? */ |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
317 static void |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
318 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:
29804
diff
changeset
|
319 const gchar *message) |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
320 { |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
321 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:
29804
diff
changeset
|
322 } |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
323 |
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
324 |
15822 | 325 static void purple_xfer_show_file_error(PurpleXfer *xfer, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 int err = errno; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 gchar *msg = NULL, *utf8; |
15822 | 329 PurpleXferType xfer_type = purple_xfer_get_type(xfer); |
330 PurpleAccount *account = purple_xfer_get_account(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 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
|
333 switch(xfer_type) { |
15822 | 334 case PURPLE_XFER_SEND: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 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
|
336 utf8, g_strerror(err)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 break; |
15822 | 338 case PURPLE_XFER_RECEIVE: |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 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
|
340 utf8, g_strerror(err)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 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
|
344 utf8, g_strerror(err)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 |
15822 | 349 purple_xfer_conversation_write(xfer, msg, TRUE); |
350 purple_xfer_error(xfer_type, account, xfer->who, msg); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 static void |
15822 | 355 purple_xfer_choose_file_ok_cb(void *user_data, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 { |
15822 | 357 PurpleXfer *xfer; |
28819
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28675
diff
changeset
|
358 PurpleXferType type; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 struct stat st; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 gchar *dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 |
15822 | 362 xfer = (PurpleXfer *)user_data; |
28819
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28675
diff
changeset
|
363 type = purple_xfer_get_type(xfer); |
15373
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 if (g_stat(filename, &st) != 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 /* File not found. */ |
28819
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28675
diff
changeset
|
367 if (type == PURPLE_XFER_RECEIVE) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 int mode = W_OK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 int mode = F_OK; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 dir = g_path_get_dirname(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 if (g_access(dir, mode) == 0) { |
15822 | 376 purple_xfer_request_accepted(xfer, filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 } else { |
15822 | 378 purple_xfer_ref(xfer); |
379 purple_notify_message( | |
380 NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 _("Directory is not writable."), NULL, |
15822 | 382 (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 g_free(dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 else { |
15822 | 388 purple_xfer_show_file_error(xfer, filename); |
28823
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28822
diff
changeset
|
389 purple_xfer_cancel_local(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 } |
28819
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28675
diff
changeset
|
392 else if ((type == PURPLE_XFER_SEND) && (st.st_size == 0)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 |
15822 | 394 purple_notify_error(NULL, NULL, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 _("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
|
396 |
28823
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28822
diff
changeset
|
397 purple_xfer_cancel_local(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 } |
28819
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28675
diff
changeset
|
399 else if ((type == PURPLE_XFER_SEND) && S_ISDIR(st.st_mode)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 * 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
|
402 */ |
15822 | 403 purple_notify_error(NULL, NULL, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 _("Cannot send a directory."), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 |
28823
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28822
diff
changeset
|
406 purple_xfer_cancel_local(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 } |
28819
811c12e6d965
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28675
diff
changeset
|
408 else if ((type == PURPLE_XFER_RECEIVE) && S_ISDIR(st.st_mode)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 char *msg, *utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 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
|
411 msg = g_strdup_printf( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 _("%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
|
413 g_free(utf8); |
15822 | 414 purple_notify_error(NULL, NULL, msg, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 g_free(msg); |
15822 | 416 purple_xfer_request_denied(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 } |
28820
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
418 else if (type == PURPLE_XFER_SEND) { |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
419 #ifndef _WIN32 |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
420 int mode = R_OK; |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
421 #else |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
422 int mode = F_OK; |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
423 #endif |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
424 |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
425 if (g_access(filename, mode) == 0) { |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
426 purple_xfer_request_accepted(xfer, filename); |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
427 } else { |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
428 purple_xfer_ref(xfer); |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
429 purple_notify_message( |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
430 NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
431 _("File is not readable."), NULL, |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
432 (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
433 } |
32f356585aed
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28819
diff
changeset
|
434 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 else { |
15822 | 436 purple_xfer_request_accepted(xfer, filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 |
15822 | 439 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 static void |
15822 | 443 purple_xfer_choose_file_cancel_cb(void *user_data, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 { |
15822 | 445 PurpleXfer *xfer = (PurpleXfer *)user_data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 |
15822 | 447 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
28823
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28822
diff
changeset
|
448 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:
28822
diff
changeset
|
449 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:
28822
diff
changeset
|
450 else |
16dfa8df7dd1
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28822
diff
changeset
|
451 purple_xfer_request_denied(xfer); |
28822
df5808d7e669
The PurpleXfer should be unref'd if the file selection dialog was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28821
diff
changeset
|
452 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 static int |
15822 | 456 purple_xfer_choose_file(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 { |
15822 | 458 purple_request_file(xfer, NULL, purple_xfer_get_filename(xfer), |
459 (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE), | |
460 G_CALLBACK(purple_xfer_choose_file_ok_cb), | |
16439
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:
15822
diff
changeset
|
461 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:
15822
diff
changeset
|
462 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:
15822
diff
changeset
|
463 xfer); |
15373
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 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 static int |
15822 | 469 cancel_recv_cb(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 { |
15822 | 471 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
472 purple_xfer_request_denied(xfer); | |
473 purple_xfer_unref(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 } |
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 static void |
15822 | 479 purple_xfer_ask_recv(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 char *buf, *size_buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 size_t size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 /* 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
|
485 name directly */ |
15822 | 486 if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_ACCEPTED) { |
487 PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 |
15822 | 489 if (purple_xfer_get_filename(xfer) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
490 { |
15822 | 491 size = purple_xfer_get_size(xfer); |
492 size_buf = purple_str_size_to_units(size); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 buf = g_strdup_printf(_("%s wants to send you %s (%s)"), |
15822 | 494 buddy ? purple_buddy_get_alias(buddy) : xfer->who, |
495 purple_xfer_get_filename(xfer), size_buf); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 g_free(size_buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 buf = g_strdup_printf(_("%s wants to send you a file"), |
15822 | 501 buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 if (xfer->message != NULL) |
15822 | 505 serv_got_im(purple_account_get_connection(xfer->account), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 xfer->who, xfer->message, 0, time(NULL)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 |
29790
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
508 if (purple_xfer_get_thumbnail_data(xfer)) { |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
509 purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
510 PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
511 purple_xfer_get_thumbnail_data(xfer), |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
512 purple_xfer_get_thumbnail_size(xfer), xfer, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
513 G_CALLBACK(purple_xfer_choose_file), |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
514 G_CALLBACK(cancel_recv_cb)); |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
515 } else { |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
516 purple_request_accept_cancel(xfer, NULL, buf, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
517 PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL, |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
518 xfer, G_CALLBACK(purple_xfer_choose_file), |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
519 G_CALLBACK(cancel_recv_cb)); |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
520 } |
d0588e403877
Show thumbnail in ft request dialog
Marcus Lundblad <ml@update.uu.se>
parents:
29782
diff
changeset
|
521 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 } else |
15822 | 524 purple_xfer_choose_file(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 static int |
15822 | 528 ask_accept_ok(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 { |
15822 | 530 purple_xfer_request_accepted(xfer, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 static int |
15822 | 536 ask_accept_cancel(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 { |
15822 | 538 purple_xfer_request_denied(xfer); |
539 purple_xfer_unref(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 } |
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 static void |
15822 | 545 purple_xfer_ask_accept(PurpleXfer *xfer) |
15373
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 char *buf, *buf2 = NULL; |
15822 | 548 PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 buf = g_strdup_printf(_("Accept file transfer request from %s?"), |
15822 | 551 buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
552 if (purple_xfer_get_remote_ip(xfer) && | |
553 purple_xfer_get_remote_port(xfer)) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 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
|
555 "Remote host: %s\nRemote port: %d"), |
15822 | 556 purple_xfer_get_remote_ip(xfer), |
557 purple_xfer_get_remote_port(xfer)); | |
558 purple_request_accept_cancel(xfer, NULL, buf, buf2, | |
16439
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:
15822
diff
changeset
|
559 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:
15822
diff
changeset
|
560 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:
15822
diff
changeset
|
561 xfer, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 G_CALLBACK(ask_accept_ok), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 G_CALLBACK(ask_accept_cancel)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 g_free(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 g_free(buf2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 void |
15822 | 569 purple_xfer_request(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 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
|
573 |
15822 | 574 purple_xfer_ref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 |
15822 | 576 if (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 { |
15822 | 578 purple_signal_emit(purple_xfers_get_handle(), "file-recv-request", xfer); |
579 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 /* The file-transfer was cancelled by a plugin */ |
15822 | 582 purple_xfer_cancel_local(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 } |
15822 | 584 else if (purple_xfer_get_filename(xfer) || |
585 purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_ACCEPTED) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 gchar* message = NULL; |
15822 | 588 PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who); |
29804
cb09d358d777
Make it work again, after some new xfer UI ops where added... :)
Marcus Lundblad <ml@update.uu.se>
parents:
29801
diff
changeset
|
589 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 message = g_strdup_printf(_("%s is offering to send file %s"), |
15822 | 591 buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer)); |
29806
56b67321b7c6
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <ml@update.uu.se>
parents:
29804
diff
changeset
|
592 purple_xfer_conversation_write_with_thumbnail(xfer, message); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 g_free(message); |
29804
cb09d358d777
Make it work again, after some new xfer UI ops where added... :)
Marcus Lundblad <ml@update.uu.se>
parents:
29801
diff
changeset
|
594 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 /* 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
|
596 if (xfer->local_filename == NULL) |
15822 | 597 purple_xfer_ask_recv(xfer); |
15373
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 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 { |
15822 | 601 purple_xfer_ask_accept(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 { |
15822 | 606 purple_xfer_choose_file(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 void |
15822 | 611 purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 { |
15822 | 613 PurpleXferType type; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 struct stat st; |
26505
0c796a1950b7
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26167
diff
changeset
|
615 char *msg, *utf8, *base; |
15822 | 616 PurpleAccount *account; |
617 PurpleBuddy *buddy; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 if (xfer == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 |
15822 | 622 type = purple_xfer_get_type(xfer); |
623 account = purple_xfer_get_account(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
625 purple_debug_misc("xfer", "request accepted for %p\n", xfer); |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
626 |
15822 | 627 if (!filename && type == PURPLE_XFER_RECEIVE) { |
628 xfer->status = PURPLE_XFER_STATUS_ACCEPTED; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 xfer->ops.init(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 |
15822 | 633 buddy = purple_find_buddy(account, xfer->who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 |
15822 | 635 if (type == PURPLE_XFER_SEND) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 /* Sending a file */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 /* Check the filename. */ |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
638 PurpleXferUiOps *ui_ops; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
639 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:
27799
diff
changeset
|
640 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 #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
|
642 if (g_strrstr(filename, "../") || g_strrstr(filename, "..\\")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 #else |
21866
03c950701fac
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <stu@nosnilmot.com>
parents:
21597
diff
changeset
|
644 if (g_strrstr(filename, "../")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 #endif |
21866
03c950701fac
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <stu@nosnilmot.com>
parents:
21597
diff
changeset
|
646 { |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
647 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 msg = g_strdup_printf(_("%s is not a valid filename.\n"), utf8); |
15822 | 650 purple_xfer_error(type, account, xfer->who, msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 |
15822 | 654 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 |
27881
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
27878
diff
changeset
|
658 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
659 if (g_stat(filename, &st) == -1) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
660 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:
27799
diff
changeset
|
661 purple_xfer_unref(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
662 return; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
663 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
664 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
665 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:
27799
diff
changeset
|
666 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:
27799
diff
changeset
|
667 } else { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
668 utf8 = g_strdup(filename); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
669 purple_xfer_set_local_filename(xfer, filename); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 |
26505
0c796a1950b7
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26167
diff
changeset
|
672 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:
26167
diff
changeset
|
673 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:
26167
diff
changeset
|
674 g_free(base); |
15822 | 675 purple_xfer_set_filename(xfer, utf8); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 msg = g_strdup_printf(_("Offering to send %s to %s"), |
15822 | 678 utf8, buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 g_free(utf8); |
15822 | 680 purple_xfer_conversation_write(xfer, msg, FALSE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 /* Receiving a file */ |
15822 | 685 xfer->status = PURPLE_XFER_STATUS_ACCEPTED; |
686 purple_xfer_set_local_filename(xfer, filename); | |
15373
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(_("Starting transfer of %s from %s"), |
15822 | 689 xfer->filename, buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
690 purple_xfer_conversation_write(xfer, msg, FALSE); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 |
15822 | 694 purple_xfer_add(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 xfer->ops.init(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 } |
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 void |
15822 | 700 purple_xfer_request_denied(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
704 purple_debug_misc("xfer", "xfer %p denied\n", xfer); |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
705 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 if (xfer->ops.request_denied != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 xfer->ops.request_denied(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 |
15822 | 709 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 |
15822 | 712 PurpleXferType |
713 purple_xfer_get_type(const PurpleXfer *xfer) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 { |
15822 | 715 g_return_val_if_fail(xfer != NULL, PURPLE_XFER_UNKNOWN); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 return xfer->type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 |
15822 | 720 PurpleAccount * |
721 purple_xfer_get_account(const PurpleXfer *xfer) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 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
|
724 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 return xfer->account; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 |
17811
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
728 const char * |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
729 purple_xfer_get_remote_user(const PurpleXfer *xfer) |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
730 { |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
731 g_return_val_if_fail(xfer != NULL, NULL); |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
732 return xfer->who; |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
733 } |
e62095e99db0
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17201
diff
changeset
|
734 |
15822 | 735 PurpleXferStatusType |
736 purple_xfer_get_status(const PurpleXfer *xfer) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 { |
15822 | 738 g_return_val_if_fail(xfer != NULL, PURPLE_XFER_STATUS_UNKNOWN); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 return xfer->status; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 gboolean |
15822 | 744 purple_xfer_is_canceled(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 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
|
747 |
15822 | 748 if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) || |
749 (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE)) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 gboolean |
15822 | 756 purple_xfer_is_completed(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
758 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
|
759 |
15822 | 760 return (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_DONE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
761 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 const char * |
15822 | 764 purple_xfer_get_filename(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 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
|
767 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 return xfer->filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 const char * |
15822 | 772 purple_xfer_get_local_filename(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 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
|
775 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 return xfer->local_filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 size_t |
15822 | 780 purple_xfer_get_bytes_sent(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 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
|
783 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 return xfer->bytes_sent; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 size_t |
15822 | 788 purple_xfer_get_bytes_remaining(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 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
|
791 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 return xfer->bytes_remaining; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 size_t |
15822 | 796 purple_xfer_get_size(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 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
|
799 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 return xfer->size; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 double |
15822 | 804 purple_xfer_get_progress(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 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
|
807 |
15822 | 808 if (purple_xfer_get_size(xfer) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 return 0.0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 |
15822 | 811 return ((double)purple_xfer_get_bytes_sent(xfer) / |
812 (double)purple_xfer_get_size(xfer)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 unsigned int |
15822 | 816 purple_xfer_get_local_port(const PurpleXfer *xfer) |
15373
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 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
|
819 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 return xfer->local_port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 const char * |
15822 | 824 purple_xfer_get_remote_ip(const PurpleXfer *xfer) |
15373
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 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
|
827 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 return xfer->remote_ip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 unsigned int |
15822 | 832 purple_xfer_get_remote_port(const PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 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
|
835 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 return xfer->remote_port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 |
22216
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
839 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
|
840 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
|
841 { |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
842 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
|
843 |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
844 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
|
845 } |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
846 |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
847 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
|
848 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
|
849 { |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
850 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
|
851 |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
852 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
|
853 } |
b99d6d21cd79
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22073
diff
changeset
|
854 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 void |
15822 | 856 purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 { |
15822 | 858 PurpleXferUiOps *ui_ops; |
15373
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_if_fail(xfer != NULL); |
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 if (completed == TRUE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 char *msg = NULL; |
27396
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
864 PurpleConversation *conv; |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
865 |
15822 | 866 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 |
15822 | 868 if (purple_xfer_get_filename(xfer) != NULL) |
27396
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
869 { |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
870 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:
26505
diff
changeset
|
871 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:
26505
diff
changeset
|
872 && 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:
26505
diff
changeset
|
873 { |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
874 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:
26505
diff
changeset
|
875 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:
26505
diff
changeset
|
876 local, filename); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
877 g_free(local); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
878 } |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
879 else |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
880 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:
26505
diff
changeset
|
881 filename); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
882 g_free(filename); |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
883 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
884 else |
24915
568b786c36f9
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24451
diff
changeset
|
885 msg = g_strdup(_("File transfer complete")); |
27396
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
886 |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
887 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:
26505
diff
changeset
|
888 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:
26505
diff
changeset
|
889 |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
890 if (conv != NULL) |
740760605cc1
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26505
diff
changeset
|
891 purple_conversation_write(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 |
15822 | 895 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
896 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 if (ui_ops != NULL && ui_ops->update_progress != NULL) |
15822 | 898 ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 void |
15822 | 902 purple_xfer_set_message(PurpleXfer *xfer, const char *message) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 g_free(xfer->message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 xfer->message = g_strdup(message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 void |
15822 | 911 purple_xfer_set_filename(PurpleXfer *xfer, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 g_free(xfer->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
916 xfer->filename = g_strdup(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
917 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 void |
15822 | 920 purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 g_free(xfer->local_filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 xfer->local_filename = g_strdup(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
926 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
927 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
928 void |
15822 | 929 purple_xfer_set_size(PurpleXfer *xfer, size_t size) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 xfer->size = size; |
15822 | 934 xfer->bytes_remaining = xfer->size - purple_xfer_get_bytes_sent(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
935 } |
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 void |
15822 | 938 purple_xfer_set_bytes_sent(PurpleXfer *xfer, size_t bytes_sent) |
15373
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 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 xfer->bytes_sent = bytes_sent; |
15822 | 943 xfer->bytes_remaining = purple_xfer_get_size(xfer) - bytes_sent; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 |
15822 | 946 PurpleXferUiOps * |
947 purple_xfer_get_ui_ops(const PurpleXfer *xfer) | |
15373
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 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
|
950 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 return xfer->ui_ops; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 void |
15822 | 955 purple_xfer_set_init_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 g_return_if_fail(xfer != NULL); |
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 xfer->ops.init = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 |
15822 | 962 void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15373
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_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 xfer->ops.request_denied = fnc; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 void |
15822 | 970 purple_xfer_set_read_fnc(PurpleXfer *xfer, gssize (*fnc)(guchar **, PurpleXfer *)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 xfer->ops.read = fnc; |
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 |
15822 | 978 purple_xfer_set_write_fnc(PurpleXfer *xfer, |
979 gssize (*fnc)(const guchar *, size_t, PurpleXfer *)) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 xfer->ops.write = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 void |
15822 | 987 purple_xfer_set_ack_fnc(PurpleXfer *xfer, |
988 void (*fnc)(PurpleXfer *, const guchar *, size_t)) | |
15373
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 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 xfer->ops.ack = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 void |
15822 | 996 purple_xfer_set_start_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 xfer->ops.start = fnc; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1003 void |
15822 | 1004 purple_xfer_set_end_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1005 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 xfer->ops.end = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1009 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1010 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1011 void |
15822 | 1012 purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15373
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 g_return_if_fail(xfer != NULL); |
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 xfer->ops.cancel_send = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1018 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 void |
15822 | 1020 purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
15373
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 g_return_if_fail(xfer != NULL); |
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 xfer->ops.cancel_recv = fnc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1025 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1026 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1027 static void |
15822 | 1028 purple_xfer_increase_buffer_size(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1029 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1030 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
|
1031 FT_MAX_BUFFER_SIZE); |
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 gssize |
15822 | 1035 purple_xfer_read(PurpleXfer *xfer, guchar **buffer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1036 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1037 gssize s, r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1038 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1039 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
|
1040 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
|
1041 |
15822 | 1042 if (purple_xfer_get_size(xfer) == 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 s = xfer->current_buffer_size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 else |
15822 | 1045 s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 |
26167
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:
24915
diff
changeset
|
1047 if (xfer->ops.read != NULL) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 r = (xfer->ops.read)(buffer, xfer); |
26167
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:
24915
diff
changeset
|
1049 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 *buffer = g_malloc0(s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1052 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 r = read(xfer->fd, *buffer, s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 if (r < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1055 r = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 else if (r < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 r = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 else if (r == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 r = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 } |
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 if (r == xfer->current_buffer_size) |
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 * 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
|
1065 * 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
|
1066 * bigger. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 */ |
15822 | 1068 purple_xfer_increase_buffer_size(xfer); |
15373
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 return r; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 gssize |
15822 | 1074 purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 gssize r, s; |
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 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
|
1079 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
|
1080 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
|
1081 |
15822 | 1082 s = MIN(purple_xfer_get_bytes_remaining(xfer), size); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 if (xfer->ops.write != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 r = (xfer->ops.write)(buffer, s, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 r = write(xfer->fd, buffer, s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 if (r < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 r = 0; |
15822 | 1090 if ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer)) |
1091 purple_xfer_set_completed(xfer, TRUE); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 return r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 static void |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1098 do_transfer(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 { |
15822 | 1100 PurpleXferUiOps *ui_ops; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 guchar *buffer = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 gssize r = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1104 ui_ops = purple_xfer_get_ui_ops(xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1105 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1106 if (xfer->type == PURPLE_XFER_RECEIVE) { |
15822 | 1107 r = purple_xfer_read(xfer, &buffer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 if (r > 0) { |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1109 size_t wc; |
27881
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
27878
diff
changeset
|
1110 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:
27878
diff
changeset
|
1111 wc = ui_ops->ui_write(xfer, buffer, r); |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1112 else |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1113 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:
27799
diff
changeset
|
1114 |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1115 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
|
1116 purple_debug_error("filetransfer", "Unable to write whole buffer.\n"); |
27679
ed3184cc557d
ft: fwrite failing is a local error. Pointed out by kenshin.
Paul Aurich <paul@darkrain42.org>
parents:
27677
diff
changeset
|
1117 purple_xfer_cancel_local(xfer); |
27799
da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27725
diff
changeset
|
1118 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
|
1119 return; |
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1120 } |
27902
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
27881
diff
changeset
|
1121 |
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
27881
diff
changeset
|
1122 if ((purple_xfer_get_size(xfer) > 0) && |
e30de9ebfa69
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <paul@darkrain42.org>
parents:
27881
diff
changeset
|
1123 ((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:
27881
diff
changeset
|
1124 purple_xfer_set_completed(xfer, TRUE); |
17201
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:
17054
diff
changeset
|
1125 } else if(r < 0) { |
15822 | 1126 purple_xfer_cancel_remote(xfer); |
27799
da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27725
diff
changeset
|
1127 g_free(buffer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 } |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1130 } else if (xfer->type == PURPLE_XFER_SEND) { |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1131 size_t result; |
15822 | 1132 size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size); |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1133 PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 /* 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
|
1136 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
|
1137 if (s == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 if (xfer->watcher) { |
15822 | 1139 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1142 return; |
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 |
27881
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
27878
diff
changeset
|
1145 if (ui_ops && ui_ops->ui_read) { |
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
27878
diff
changeset
|
1146 gssize tmp = ui_ops->ui_read(xfer, &buffer, s); |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1147 if (tmp == 0) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1148 /* |
28911
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1149 * The UI claimed it was ready, but didn't have any data for |
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1150 * us... It will call purple_xfer_ui_ready when ready, which |
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1151 * sets back up this watcher. |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1152 */ |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1153 if (xfer->watcher != 0) { |
28359
53aab96e61a9
Use the appropriate function to remove an input watcher.
Paul Aurich <paul@darkrain42.org>
parents:
27999
diff
changeset
|
1154 purple_input_remove(xfer->watcher); |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1155 xfer->watcher = 0; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1156 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 |
28911
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1158 /* Need to indicate the prpl is still ready... */ |
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1159 priv->ready |= PURPLE_XFER_READY_PRPL; |
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1160 |
29348
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
1161 /* |
29344
10eaca0bf01a
propagate from branch 'im.pidgin.pidgin' (head 8f0a3e68547fbc66188357edbf6694bd8dd2d557)
John Bailey <rekkanoryo@rekkanoryo.org>
diff
changeset
|
1162 * if we requested 0 bytes it's only normal that end up here |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1163 * we shouldn't return as we still have something to |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1164 * write in priv->buffer |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1165 */ |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1166 if (s != 0) |
29348
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
1167 g_return_if_reached(); |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1168 } else if (tmp < 0) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1169 purple_debug_error("filetransfer", "Unable to read whole buffer.\n"); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1170 purple_xfer_cancel_local(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1171 return; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1172 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1173 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1174 result = tmp; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1175 } else { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1176 buffer = g_malloc0(s); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1177 result = fread(buffer, 1, s, xfer->dest_fp); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1178 if (result != s) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1179 purple_debug_error("filetransfer", "Unable to read whole buffer.\n"); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1180 purple_xfer_cancel_local(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1181 g_free(buffer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1182 return; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1183 } |
22073
f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@wiktel.com>
parents:
21866
diff
changeset
|
1184 } |
29348
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
1185 |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1186 if (priv->buffer) { |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1187 priv->buffer = g_byte_array_append(priv->buffer, buffer, result); |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1188 g_free(buffer); |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1189 buffer = priv->buffer->data; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1190 result = priv->buffer->len; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1191 } |
29348
422889fb57e0
propagate from branch 'im.pidgin.pidgin' (head 9028ac0daaa1f7e565726fa39aca22ce7d3ecc49)
Paul Aurich <paul@darkrain42.org>
diff
changeset
|
1192 |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1193 r = purple_xfer_write(xfer, buffer, result); |
15373
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 if (r == -1) { |
15822 | 1196 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 g_free(buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 return; |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1199 } else if (r == result) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 * 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
|
1202 * 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
|
1203 * bigger. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 */ |
15822 | 1205 purple_xfer_increase_buffer_size(xfer); |
29124
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1206 } else { |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1207 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:
28359
diff
changeset
|
1208 ui_ops->data_not_sent(xfer, buffer + r, result -r); |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1209 } |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1210 |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1211 if (priv->buffer) { |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1212 /* |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1213 * Remove what we wrote |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1214 * If we wrote the whole buffer the byte array will be empty |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1215 * Otherwise we'll kee what wasn't sent for next time. |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1216 */ |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1217 buffer = NULL; |
51c5cbc0d325
Kill off the use of fseek for non-seekable streams in file transfers.
foufou33@gmail.com
parents:
28359
diff
changeset
|
1218 priv->buffer = g_byte_array_remove_range(priv->buffer, 0, r); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1221 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 if (r > 0) { |
15822 | 1223 if (purple_xfer_get_size(xfer) > 0) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1224 xfer->bytes_remaining -= r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1225 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 xfer->bytes_sent += r; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1227 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 if (xfer->ops.ack != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 xfer->ops.ack(xfer, buffer, r); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1231 g_free(buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 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
|
1234 ui_ops->update_progress(xfer, |
15822 | 1235 purple_xfer_get_progress(xfer)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 |
15822 | 1238 if (purple_xfer_is_completed(xfer)) |
1239 purple_xfer_end(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1240 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1241 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1242 static void |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1243 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:
27875
diff
changeset
|
1244 { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1245 PurpleXfer *xfer = data; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1246 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1247 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:
27875
diff
changeset
|
1248 /* 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:
27875
diff
changeset
|
1249 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:
27875
diff
changeset
|
1250 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:
27875
diff
changeset
|
1251 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:
27875
diff
changeset
|
1252 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1253 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:
27875
diff
changeset
|
1254 xfer->watcher = 0; |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1255 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1256 purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1257 return; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1258 } |
28911
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1259 |
a41724547756
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <paul@darkrain42.org>
parents:
28831
diff
changeset
|
1260 priv->ready = PURPLE_XFER_READY_NONE; |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1261 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1262 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1263 do_transfer(xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1264 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1265 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1266 static void |
15822 | 1267 begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1268 { |
15822 | 1269 PurpleXferType type = purple_xfer_get_type(xfer); |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1270 PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1271 |
27881
dad4cb8f81df
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <paul@darkrain42.org>
parents:
27878
diff
changeset
|
1272 if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1273 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:
27799
diff
changeset
|
1274 type == PURPLE_XFER_RECEIVE ? "wb" : "rb"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1275 |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1276 if (xfer->dest_fp == NULL) { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1277 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:
27799
diff
changeset
|
1278 purple_xfer_cancel_local(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1279 return; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1280 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1281 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1282 fseek(xfer->dest_fp, xfer->bytes_sent, SEEK_SET); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1283 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1285 if (xfer->fd != -1) |
17054
21830d70709b
Patch from sourceforge tracker 1652005 from wabz to fix displaying file
Stu Tomlinson <stu@nosnilmot.com>
parents:
16439
diff
changeset
|
1286 xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 xfer->start_time = time(NULL); |
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 if (xfer->ops.start != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 xfer->ops.start(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1292 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1293 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1294 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1295 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
|
1296 { |
15822 | 1297 PurpleXfer *xfer = (PurpleXfer *)data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1298 |
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
|
1299 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
|
1300 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
|
1301 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
|
1302 } |
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
|
1303 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1304 xfer->fd = source; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1305 |
15822 | 1306 begin_transfer(xfer, PURPLE_INPUT_READ); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1307 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1308 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1309 void |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1310 purple_xfer_ui_ready(PurpleXfer *xfer) |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1311 { |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1312 PurpleInputCondition cond; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1313 PurpleXferType type; |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1314 PurpleXferPrivData *priv; |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1315 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1316 g_return_if_fail(xfer != NULL); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1317 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1318 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:
27875
diff
changeset
|
1319 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:
27875
diff
changeset
|
1320 |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1321 if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) { |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1322 purple_debug_misc("xfer", "UI is ready on ft %p, waiting for prpl\n", xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1323 return; |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1324 } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1325 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1326 purple_debug_misc("xfer", "UI (and prpl) ready on ft %p, so proceeding\n", xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1327 |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1328 type = purple_xfer_get_type(xfer); |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1329 if (type == PURPLE_XFER_SEND) |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1330 cond = PURPLE_INPUT_WRITE; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1331 else /* if (type == PURPLE_XFER_RECEIVE) */ |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1332 cond = PURPLE_INPUT_READ; |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1333 |
27875
7754717d574c
ft: Fix an issue with re-setting xfer->watcher when there is no fd.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1334 if (xfer->watcher == 0 && xfer->fd != -1) |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1335 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:
27799
diff
changeset
|
1336 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1337 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:
27875
diff
changeset
|
1338 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1339 do_transfer(xfer); |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1340 } |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1341 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1342 void |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1343 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:
27875
diff
changeset
|
1344 { |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1345 PurpleXferPrivData *priv; |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1346 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1347 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:
27875
diff
changeset
|
1348 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1349 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:
27875
diff
changeset
|
1350 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:
27875
diff
changeset
|
1351 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1352 /* I don't think fwrite/fread are ever *not* ready */ |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1353 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:
28823
diff
changeset
|
1354 purple_debug_misc("xfer", "prpl is ready on ft %p, waiting for UI\n", xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1355 return; |
28831
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1356 } |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1357 |
07ec4a569da1
ft: Add some useful debug logging.
Paul Aurich <paul@darkrain42.org>
parents:
28823
diff
changeset
|
1358 purple_debug_misc("xfer", "Prpl (and UI) ready on ft %p, so proceeding\n", xfer); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1359 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1360 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:
27875
diff
changeset
|
1361 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1362 do_transfer(xfer); |
27872
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1363 } |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1364 |
4a4e9d309fc0
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
hanzz@soc.pidgin.im
parents:
27799
diff
changeset
|
1365 void |
15822 | 1366 purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1367 unsigned int port) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1368 { |
15822 | 1369 PurpleInputCondition cond; |
1370 PurpleXferType type; | |
15373
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 g_return_if_fail(xfer != NULL); |
15822 | 1373 g_return_if_fail(purple_xfer_get_type(xfer) != PURPLE_XFER_UNKNOWN); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1374 |
15822 | 1375 type = purple_xfer_get_type(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1376 |
15822 | 1377 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_STARTED); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1378 |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1379 /* |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1380 * 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:
27872
diff
changeset
|
1381 * 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:
27872
diff
changeset
|
1382 */ |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1383 if (fd == 0) |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1384 fd = -1; |
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1385 |
15822 | 1386 if (type == PURPLE_XFER_RECEIVE) { |
1387 cond = PURPLE_INPUT_READ; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1388 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1389 if (ip != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1390 xfer->remote_ip = g_strdup(ip); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1391 xfer->remote_port = port; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1392 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1393 /* Establish a file descriptor. */ |
15822 | 1394 purple_proxy_connect(NULL, xfer->account, xfer->remote_ip, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1395 xfer->remote_port, connect_cb, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1396 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1397 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1398 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1399 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1400 xfer->fd = fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1401 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1402 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1403 else { |
15822 | 1404 cond = PURPLE_INPUT_WRITE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1405 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1406 xfer->fd = fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1407 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1408 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1409 begin_transfer(xfer, cond); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1410 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1411 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1412 void |
15822 | 1413 purple_xfer_end(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1414 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1415 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1416 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1417 /* See if we are actually trying to cancel this. */ |
15822 | 1418 if (!purple_xfer_is_completed(xfer)) { |
1419 purple_xfer_cancel_local(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1420 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1423 xfer->end_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1424 if (xfer->ops.end != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1425 xfer->ops.end(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1427 if (xfer->watcher != 0) { |
15822 | 1428 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1429 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1430 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1431 |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1432 if (xfer->fd != -1) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1433 close(xfer->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1434 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1435 if (xfer->dest_fp != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1436 fclose(xfer->dest_fp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1437 xfer->dest_fp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1438 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1439 |
15822 | 1440 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1441 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1442 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1443 void |
15822 | 1444 purple_xfer_add(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1445 { |
15822 | 1446 PurpleXferUiOps *ui_ops; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1447 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1448 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1449 |
15822 | 1450 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1451 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1452 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
|
1453 ui_ops->add_xfer(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1454 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1455 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1456 void |
15822 | 1457 purple_xfer_cancel_local(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1458 { |
15822 | 1459 PurpleXferUiOps *ui_ops; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1460 char *msg = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1461 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1462 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1463 |
15822 | 1464 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1465 xfer->end_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1466 |
15822 | 1467 if (purple_xfer_get_filename(xfer) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1468 { |
27960
a7eac81575e7
Normalize on 'cancelled'
Paul Aurich <paul@darkrain42.org>
parents:
27396
diff
changeset
|
1469 msg = g_strdup_printf(_("You cancelled the transfer of %s"), |
15822 | 1470 purple_xfer_get_filename(xfer)); |
15373
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 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1473 { |
24915
568b786c36f9
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24451
diff
changeset
|
1474 msg = g_strdup(_("File transfer cancelled")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1475 } |
15822 | 1476 purple_xfer_conversation_write(xfer, msg, FALSE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1477 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1478 |
15822 | 1479 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
15373
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 if (xfer->ops.cancel_send != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1482 xfer->ops.cancel_send(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1483 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1484 else |
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 if (xfer->ops.cancel_recv != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1487 xfer->ops.cancel_recv(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1488 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1489 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1490 if (xfer->watcher != 0) { |
15822 | 1491 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1492 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1493 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1494 |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1495 if (xfer->fd != -1) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1496 close(xfer->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1497 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1498 if (xfer->dest_fp != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1499 fclose(xfer->dest_fp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1500 xfer->dest_fp = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1501 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1502 |
15822 | 1503 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1504 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1505 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
|
1506 ui_ops->cancel_local(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1507 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1508 xfer->bytes_remaining = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1509 |
15822 | 1510 purple_xfer_unref(xfer); |
15373
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1513 void |
15822 | 1514 purple_xfer_cancel_remote(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1515 { |
15822 | 1516 PurpleXferUiOps *ui_ops; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1517 gchar *msg; |
15822 | 1518 PurpleAccount *account; |
1519 PurpleBuddy *buddy; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1521 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1522 |
15822 | 1523 purple_request_close_with_handle(xfer); |
1524 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1525 xfer->end_time = time(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1526 |
15822 | 1527 account = purple_xfer_get_account(xfer); |
1528 buddy = purple_find_buddy(account, xfer->who); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1529 |
15822 | 1530 if (purple_xfer_get_filename(xfer) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1531 { |
27960
a7eac81575e7
Normalize on 'cancelled'
Paul Aurich <paul@darkrain42.org>
parents:
27396
diff
changeset
|
1532 msg = g_strdup_printf(_("%s cancelled the transfer of %s"), |
15822 | 1533 buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1534 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1535 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1536 { |
27960
a7eac81575e7
Normalize on 'cancelled'
Paul Aurich <paul@darkrain42.org>
parents:
27396
diff
changeset
|
1537 msg = g_strdup_printf(_("%s cancelled the file transfer"), |
15822 | 1538 buddy ? purple_buddy_get_alias(buddy) : xfer->who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1539 } |
15822 | 1540 purple_xfer_conversation_write(xfer, msg, TRUE); |
1541 purple_xfer_error(purple_xfer_get_type(xfer), account, xfer->who, msg); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1542 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1543 |
15822 | 1544 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1545 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1546 if (xfer->ops.cancel_send != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1547 xfer->ops.cancel_send(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1548 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1549 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1550 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1551 if (xfer->ops.cancel_recv != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1552 xfer->ops.cancel_recv(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1553 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1554 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1555 if (xfer->watcher != 0) { |
15822 | 1556 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1557 xfer->watcher = 0; |
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 |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27872
diff
changeset
|
1560 if (xfer->fd != -1) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1561 close(xfer->fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1562 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1563 if (xfer->dest_fp != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1564 fclose(xfer->dest_fp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1565 xfer->dest_fp = NULL; |
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 |
15822 | 1568 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1569 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1570 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
|
1571 ui_ops->cancel_remote(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1572 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1573 xfer->bytes_remaining = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1574 |
15822 | 1575 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1576 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1577 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1578 void |
15822 | 1579 purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1580 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1581 char *title; |
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 g_return_if_fail(msg != NULL); |
15822 | 1584 g_return_if_fail(type != PURPLE_XFER_UNKNOWN); |
15373
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 if (account) { |
15822 | 1587 PurpleBuddy *buddy; |
1588 buddy = purple_find_buddy(account, who); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1589 if (buddy) |
15822 | 1590 who = purple_buddy_get_alias(buddy); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1591 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1592 |
15822 | 1593 if (type == PURPLE_XFER_SEND) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1594 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
|
1595 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1596 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
|
1597 |
15822 | 1598 purple_notify_error(NULL, NULL, title, msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1599 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1600 g_free(title); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1601 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1602 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1603 void |
15822 | 1604 purple_xfer_update_progress(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1605 { |
15822 | 1606 PurpleXferUiOps *ui_ops; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1607 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1608 g_return_if_fail(xfer != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1609 |
15822 | 1610 ui_ops = purple_xfer_get_ui_ops(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1611 if (ui_ops != NULL && ui_ops->update_progress != NULL) |
15822 | 1612 ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1613 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1614 |
29782
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1615 const void * |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1616 purple_xfer_get_thumbnail_data(const PurpleXfer *xfer) |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1617 { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1618 return xfer->thumbnail_data; |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1619 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1620 |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1621 gsize |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1622 purple_xfer_get_thumbnail_size(const PurpleXfer *xfer) |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1623 { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1624 return xfer->thumbnail_size; |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1625 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1626 |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1627 void |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1628 purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail, |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1629 gsize size) |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1630 { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1631 if (thumbnail && size > 0) { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1632 xfer->thumbnail_data = g_memdup(thumbnail, size); |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1633 xfer->thumbnail_size = size; |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1634 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1635 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1636 |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1637 void |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1638 purple_xfer_prepare_thumbnail(PurpleXfer *xfer) |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1639 { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1640 if (xfer->ui_ops->add_thumbnail) { |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1641 xfer->ui_ops->add_thumbnail(xfer); |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1642 } |
3882d419e628
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <ml@update.uu.se>
parents:
26505
diff
changeset
|
1643 } |
15373
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 /************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1646 * File Transfer Subsystem API |
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 void * |
15822 | 1649 purple_xfers_get_handle(void) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1650 static int handle = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1651 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1652 return &handle; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1653 } |
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 void |
15822 | 1656 purple_xfers_init(void) { |
1657 void *handle = purple_xfers_get_handle(); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1658 |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1659 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:
27875
diff
changeset
|
1660 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:
27875
diff
changeset
|
1661 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1662 /* register signals */ |
15822 | 1663 purple_signal_register(handle, "file-recv-accept", |
1664 purple_marshal_VOID__POINTER, NULL, 1, | |
1665 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1666 PURPLE_SUBTYPE_XFER)); | |
1667 purple_signal_register(handle, "file-send-accept", | |
1668 purple_marshal_VOID__POINTER, NULL, 1, | |
1669 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1670 PURPLE_SUBTYPE_XFER)); | |
1671 purple_signal_register(handle, "file-recv-start", | |
1672 purple_marshal_VOID__POINTER, NULL, 1, | |
1673 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1674 PURPLE_SUBTYPE_XFER)); | |
1675 purple_signal_register(handle, "file-send-start", | |
1676 purple_marshal_VOID__POINTER, NULL, 1, | |
1677 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1678 PURPLE_SUBTYPE_XFER)); | |
1679 purple_signal_register(handle, "file-send-cancel", | |
1680 purple_marshal_VOID__POINTER, NULL, 1, | |
1681 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1682 PURPLE_SUBTYPE_XFER)); | |
1683 purple_signal_register(handle, "file-recv-cancel", | |
1684 purple_marshal_VOID__POINTER, NULL, 1, | |
1685 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1686 PURPLE_SUBTYPE_XFER)); | |
1687 purple_signal_register(handle, "file-send-complete", | |
1688 purple_marshal_VOID__POINTER, NULL, 1, | |
1689 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1690 PURPLE_SUBTYPE_XFER)); | |
1691 purple_signal_register(handle, "file-recv-complete", | |
1692 purple_marshal_VOID__POINTER, NULL, 1, | |
1693 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1694 PURPLE_SUBTYPE_XFER)); | |
1695 purple_signal_register(handle, "file-recv-request", | |
1696 purple_marshal_VOID__POINTER, NULL, 1, | |
1697 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
1698 PURPLE_SUBTYPE_XFER)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1699 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1700 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1701 void |
21067
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1702 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
|
1703 { |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1704 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
|
1705 |
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20592
diff
changeset
|
1706 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
|
1707 purple_signals_unregister_by_instance(handle); |
27878
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1708 |
b7b25f580637
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <paul@darkrain42.org>
parents:
27875
diff
changeset
|
1709 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:
27875
diff
changeset
|
1710 xfers_data = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1711 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1712 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1713 void |
15822 | 1714 purple_xfers_set_ui_ops(PurpleXferUiOps *ops) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1715 xfer_ui_ops = ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1716 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1717 |
15822 | 1718 PurpleXferUiOps * |
1719 purple_xfers_get_ui_ops(void) { | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1720 return xfer_ui_ops; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1721 } |