Fri, 11 Oct 2013 15:54:01 +0530
Merged soc.2013.gobjectification branch
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1 | /** |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
2 | * @file xfer.c File Transfer API |
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
3 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
4 | /* purple |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
5 | * |
| 15884 | 6 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 7 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 8 | * source distribution. | |
| 4538 | 9 | * |
| 3609 | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by | |
| 12 | * the Free Software Foundation; either version 2 of the License, or | |
| 13 | * (at your option) any later version. | |
| 14 | * | |
| 15 | * This program is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19733
diff
changeset
|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
19733
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
23 | * |
| 3609 | 24 | */ |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
25 | #include "internal.h" |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
26 | #include "dbus-maybe.h" |
|
34927
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
27 | #include "enums.h" |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
28 | #include "xfer.h" |
| 8231 | 29 | #include "network.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
30 | #include "notify.h" |
|
6241
34d166a31152
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
31 | #include "prefs.h" |
| 3609 | 32 | #include "proxy.h" |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
33 | #include "request.h" |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
34 | #include "util.h" |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
35 | #include "debug.h" |
|
5494
410d120ef10d
[gaim-migrate @ 5890]
Herman Bloggs <herman@bluedigits.com>
parents:
5436
diff
changeset
|
36 | |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
37 | #define FT_INITIAL_BUFFER_SIZE 4096 |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
38 | #define FT_MAX_BUFFER_SIZE 65535 |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
39 | |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
40 | #define PURPLE_XFER_GET_PRIVATE(obj) \ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
41 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_XFER, PurpleXferPrivate)) |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
42 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
43 | /** @copydoc _PurpleXferPrivate */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
44 | typedef struct _PurpleXferPrivate PurpleXferPrivate; |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
45 | |
| 15884 | 46 | static PurpleXferUiOps *xfer_ui_ops = NULL; |
|
15702
111fdd9108cc
Patch from Richard 'wabz' Nelson to add file-transfer ui. Amazing stuff\!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15435
diff
changeset
|
47 | static GList *xfers; |
| 3609 | 48 | |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
49 | /** Private data for a file transfer */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
50 | struct _PurpleXferPrivate { |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
51 | PurpleXferType type; /**< The type of transfer. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
52 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
53 | PurpleAccount *account; /**< The account. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
54 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
55 | char *who; /**< The person on the other end of the |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
56 | transfer. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
57 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
58 | char *message; /**< A message sent with the request */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
59 | char *filename; /**< The name sent over the network. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
60 | char *local_filename; /**< The name on the local hard drive. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
61 | goffset size; /**< The size of the file. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
62 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
63 | FILE *dest_fp; /**< The destination file pointer. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
64 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
65 | char *remote_ip; /**< The remote IP address. */ |
| 35001 | 66 | guint16 local_port; /**< The local port. */ |
| 67 | guint16 remote_port; /**< The remote port. */ | |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
68 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
69 | int fd; /**< The socket file descriptor. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
70 | int watcher; /**< Watcher. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
71 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
72 | goffset bytes_sent; /**< The number of bytes sent. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
73 | goffset bytes_remaining; /**< The number of bytes remaining. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
74 | time_t start_time; /**< When the transfer of data began. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
75 | time_t end_time; /**< When the transfer of data ended. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
76 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
77 | size_t current_buffer_size; /**< This gradually increases for fast |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
78 | network connections. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
79 | |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
80 | PurpleXferStatus status; /**< File Transfer's status. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
81 | |
|
36798
21af2b190cfa
Various fixes for protocol ids, functions and documentation
Ankit Vani <a@nevitus.org>
parents:
36782
diff
changeset
|
82 | /** I/O operations, which should be set by the protocol using |
| 34919 | 83 | * purple_xfer_set_init_fnc() and friends. Setting #init is |
| 84 | * mandatory; all others are optional. | |
| 85 | */ | |
| 86 | struct | |
| 87 | { | |
| 88 | void (*init)(PurpleXfer *xfer); | |
| 89 | void (*request_denied)(PurpleXfer *xfer); | |
| 90 | void (*start)(PurpleXfer *xfer); | |
| 91 | void (*end)(PurpleXfer *xfer); | |
| 92 | void (*cancel_send)(PurpleXfer *xfer); | |
| 93 | void (*cancel_recv)(PurpleXfer *xfer); | |
| 94 | gssize (*read)(guchar **buffer, PurpleXfer *xfer); | |
| 95 | gssize (*write)(const guchar *buffer, size_t size, PurpleXfer *xfer); | |
| 96 | void (*ack)(PurpleXfer *xfer, const guchar *buffer, size_t size); | |
| 97 | } ops; | |
| 98 | ||
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
99 | PurpleXferUiOps *ui_ops; /**< UI-specific operations. */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
100 | |
|
36798
21af2b190cfa
Various fixes for protocol ids, functions and documentation
Ankit Vani <a@nevitus.org>
parents:
36782
diff
changeset
|
101 | void *proto_data; /**< Protocol-specific data. |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
102 | TODO Remove this, and use |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
103 | protocol-specific subclasses */ |
|
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
104 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
105 | /* |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
106 | * Used to moderate the file transfer when either the read/write ui_ops are |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
107 | * set or fd is not set. In those cases, the UI/protocol call the respective |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
108 | * function, which is somewhat akin to a fd watch being triggered. |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
109 | */ |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
110 | enum { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
111 | PURPLE_XFER_READY_NONE = 0x0, |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
112 | PURPLE_XFER_READY_UI = 0x1, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
113 | PURPLE_XFER_READY_PROTOCOL = 0x2, |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
114 | } ready; |
|
29968
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
115 | |
|
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
116 | /* TODO: Should really use a PurpleCircBuffer for this. */ |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
117 | GByteArray *buffer; |
|
30115
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
118 | |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
119 | gpointer thumbnail_data; /**< thumbnail image */ |
|
30115
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
120 | gsize thumbnail_size; |
|
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
121 | gchar *thumbnail_mimetype; |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
122 | }; |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
123 | |
| 34925 | 124 | /* GObject property enums */ |
| 125 | enum | |
| 126 | { | |
| 127 | PROP_0, | |
| 128 | PROP_TYPE, | |
| 129 | PROP_ACCOUNT, | |
| 130 | PROP_REMOTE_USER, | |
| 131 | PROP_MESSAGE, | |
| 132 | PROP_FILENAME, | |
| 133 | PROP_LOCAL_FILENAME, | |
| 134 | PROP_FILE_SIZE, | |
| 135 | PROP_REMOTE_IP, | |
| 136 | PROP_LOCAL_PORT, | |
| 137 | PROP_REMOTE_PORT, | |
| 138 | PROP_FD, | |
| 139 | PROP_WATCHER, | |
| 140 | PROP_BYTES_SENT, | |
| 141 | PROP_START_TIME, | |
| 142 | PROP_END_TIME, | |
| 143 | PROP_STATUS, | |
| 144 | PROP_LAST | |
| 145 | }; | |
| 146 | ||
| 147 | static GObjectClass *parent_class; | |
| 148 | ||
| 15884 | 149 | static int purple_xfer_choose_file(PurpleXfer *xfer); |
| 14967 | 150 | |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
151 | static const gchar * |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
152 | purple_xfer_status_type_to_string(PurpleXferStatus type) |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
153 | { |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
154 | static const struct { |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
155 | PurpleXferStatus type; |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
156 | const char *name; |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
157 | } type_names[] = { |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
158 | { PURPLE_XFER_STATUS_UNKNOWN, "unknown" }, |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
159 | { PURPLE_XFER_STATUS_NOT_STARTED, "not started" }, |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
160 | { PURPLE_XFER_STATUS_ACCEPTED, "accepted" }, |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
161 | { PURPLE_XFER_STATUS_STARTED, "started" }, |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
162 | { PURPLE_XFER_STATUS_DONE, "done" }, |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
163 | { PURPLE_XFER_STATUS_CANCEL_LOCAL, "cancelled locally" }, |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
164 | { PURPLE_XFER_STATUS_CANCEL_REMOTE, "cancelled remotely" } |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
165 | }; |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
166 | gsize i; |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
167 | |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
168 | for (i = 0; i < G_N_ELEMENTS(type_names); ++i) |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
169 | if (type_names[i].type == type) |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
170 | return type_names[i].name; |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
171 | |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
172 | return "invalid state"; |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
173 | } |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
174 | |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
175 | void |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
176 | purple_xfer_set_status(PurpleXfer *xfer, PurpleXferStatus status) |
|
9788
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
177 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
178 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
179 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
180 | g_return_if_fail(priv != NULL); |
|
9788
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
181 | |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
182 | if (purple_debug_is_verbose()) |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
183 | purple_debug_info("xfer", "Changing status of xfer %p from %s to %s\n", |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
184 | xfer, purple_xfer_status_type_to_string(priv->status), |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
185 | purple_xfer_status_type_to_string(status)); |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
186 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
187 | if (priv->status == status) |
|
27993
857add008895
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <darkrain42@pidgin.im>
parents:
27944
diff
changeset
|
188 | return; |
|
857add008895
ft: Don't emit a changed-status signal for something that isn't a change.
Paul Aurich <darkrain42@pidgin.im>
parents:
27944
diff
changeset
|
189 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
190 | priv->status = status; |
|
27942
ace850ade78d
Set xfer->status before emitting signals in purple_xfer_set_status.
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
191 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
192 | if(priv->type == PURPLE_XFER_TYPE_SEND) { |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
193 | switch(status) { |
| 15884 | 194 | case PURPLE_XFER_STATUS_ACCEPTED: |
| 195 | purple_signal_emit(purple_xfers_get_handle(), "file-send-accept", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
196 | break; |
| 15884 | 197 | case PURPLE_XFER_STATUS_STARTED: |
| 198 | purple_signal_emit(purple_xfers_get_handle(), "file-send-start", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
199 | break; |
| 15884 | 200 | case PURPLE_XFER_STATUS_DONE: |
| 201 | purple_signal_emit(purple_xfers_get_handle(), "file-send-complete", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
202 | break; |
| 15884 | 203 | case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
| 204 | case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
| 205 | purple_signal_emit(purple_xfers_get_handle(), "file-send-cancel", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
206 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
207 | default: |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
208 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
209 | } |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
210 | } else if(priv->type == PURPLE_XFER_TYPE_RECEIVE) { |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
211 | switch(status) { |
| 15884 | 212 | case PURPLE_XFER_STATUS_ACCEPTED: |
| 213 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-accept", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
214 | break; |
| 15884 | 215 | case PURPLE_XFER_STATUS_STARTED: |
| 216 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-start", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
217 | break; |
| 15884 | 218 | case PURPLE_XFER_STATUS_DONE: |
| 219 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-complete", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
220 | break; |
| 15884 | 221 | case PURPLE_XFER_STATUS_CANCEL_LOCAL: |
| 222 | case PURPLE_XFER_STATUS_CANCEL_REMOTE: | |
| 223 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-cancel", xfer); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
224 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
225 | default: |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
226 | break; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
227 | } |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
228 | } |
|
9788
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
229 | } |
|
ca43717a431b
[gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents:
9785
diff
changeset
|
230 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31154
diff
changeset
|
231 | static void |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
232 | purple_xfer_conversation_write_internal(PurpleXfer *xfer, |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
233 | const char *message, gboolean is_error, gboolean print_thumbnail) |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
234 | { |
|
34656
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
235 | PurpleIMConversation *im = NULL; |
| 15884 | 236 | PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
237 | char *escaped; |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
238 | gconstpointer thumbnail_data; |
|
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
239 | gsize size; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
240 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
241 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
242 | g_return_if_fail(priv != NULL); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
243 | g_return_if_fail(message != NULL); |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
244 | |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
245 | thumbnail_data = purple_xfer_get_thumbnail(xfer, &size); |
|
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
246 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
247 | im = purple_conversations_find_im_with_account(priv->who, |
| 15884 | 248 | purple_xfer_get_account(xfer)); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
249 | |
|
34656
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
250 | if (im == NULL) |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
251 | return; |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
252 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
253 | escaped = g_markup_escape_text(message, -1); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
254 | |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
255 | if (is_error) |
|
29019
9cb4fa62242d
ft: Properly set a bitmask field (so it includes PURPLE_MESSAGE_SYSTEM like
Florian Quèze <florian@instantbird.org>
parents:
28659
diff
changeset
|
256 | flags |= PURPLE_MESSAGE_ERROR; |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
257 | |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
258 | if (print_thumbnail && thumbnail_data) { |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
259 | gchar *message_with_img; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31154
diff
changeset
|
260 | gpointer data = g_memdup(thumbnail_data, size); |
| 33661 | 261 | int id = purple_imgstore_new_with_id(data, size, NULL); |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
262 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31154
diff
changeset
|
263 | message_with_img = |
|
33052
df92c3d93904
From now on, prpls must specify images using SRC instead of ID.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32663
diff
changeset
|
264 | g_strdup_printf("<img src='" PURPLE_STORED_IMAGE_PROTOCOL "%d'> %s", |
|
df92c3d93904
From now on, prpls must specify images using SRC instead of ID.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32663
diff
changeset
|
265 | id, escaped); |
|
34656
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
266 | purple_conversation_write(PURPLE_CONVERSATION(im), NULL, |
|
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
267 | message_with_img, flags, time(NULL)); |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
268 | purple_imgstore_unref_by_id(id); |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
269 | g_free(message_with_img); |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
270 | } else { |
|
34656
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
271 | purple_conversation_write(PURPLE_CONVERSATION(im), NULL, escaped, flags, |
|
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
272 | time(NULL)); |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
273 | } |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
274 | g_free(escaped); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
275 | } |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
276 | |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
277 | void |
|
33465
215bec3b763a
Add const to the API, where needed
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33052
diff
changeset
|
278 | purple_xfer_conversation_write(PurpleXfer *xfer, const gchar *message, |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
279 | gboolean is_error) |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
280 | { |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
281 | purple_xfer_conversation_write_internal(xfer, message, is_error, FALSE); |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
282 | } |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
283 | |
|
30124
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
284 | /* maybe this one should be exported publically? */ |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
285 | static void |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
286 | purple_xfer_conversation_write_with_thumbnail(PurpleXfer *xfer, |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
287 | const gchar *message) |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
288 | { |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
289 | purple_xfer_conversation_write_internal(xfer, message, FALSE, TRUE); |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
290 | } |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
291 | |
|
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
292 | |
| 15884 | 293 | static void purple_xfer_show_file_error(PurpleXfer *xfer, const char *filename) |
| 9785 | 294 | { |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
295 | int err = errno; |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
296 | gchar *msg = NULL, *utf8; |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
297 | PurpleXferType xfer_type = purple_xfer_get_xfer_type(xfer); |
| 15884 | 298 | PurpleAccount *account = purple_xfer_get_account(xfer); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
299 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 9785 | 300 | |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
301 | utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
302 | switch(xfer_type) { |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
303 | case PURPLE_XFER_TYPE_SEND: |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
304 | msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20147
diff
changeset
|
305 | utf8, g_strerror(err)); |
| 9795 | 306 | break; |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
307 | case PURPLE_XFER_TYPE_RECEIVE: |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
308 | msg = g_strdup_printf(_("Error writing %s: \n%s.\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20147
diff
changeset
|
309 | utf8, g_strerror(err)); |
| 9785 | 310 | break; |
| 311 | default: | |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
312 | msg = g_strdup_printf(_("Error accessing %s: \n%s.\n"), |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20147
diff
changeset
|
313 | utf8, g_strerror(err)); |
| 9785 | 314 | break; |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
315 | } |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
316 | g_free(utf8); |
| 9785 | 317 | |
| 15884 | 318 | purple_xfer_conversation_write(xfer, msg, TRUE); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
319 | purple_xfer_error(xfer_type, account, priv->who, msg); |
|
9796
dd7499147bed
[gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents:
9795
diff
changeset
|
320 | g_free(msg); |
| 9785 | 321 | } |
| 322 | ||
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
323 | static void |
| 15884 | 324 | purple_xfer_choose_file_ok_cb(void *user_data, const char *filename) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
325 | { |
| 15884 | 326 | PurpleXfer *xfer; |
|
29155
365ee5da3b06
There's no need to call purple_xfer_get_type() repeatedly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29019
diff
changeset
|
327 | PurpleXferType type; |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33661
diff
changeset
|
328 | GStatBuf st; |
| 14967 | 329 | gchar *dir; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
330 | |
| 15884 | 331 | xfer = (PurpleXfer *)user_data; |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
332 | type = purple_xfer_get_xfer_type(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
333 | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10504
diff
changeset
|
334 | if (g_stat(filename, &st) != 0) { |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
335 | /* File not found. */ |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
336 | if (type == PURPLE_XFER_TYPE_RECEIVE) { |
|
15161
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
337 | #ifndef _WIN32 |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
338 | int mode = W_OK; |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
339 | #else |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
340 | int mode = F_OK; |
|
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
341 | #endif |
| 14967 | 342 | dir = g_path_get_dirname(filename); |
| 343 | ||
|
15161
7a392764f0b8
[gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents:
14967
diff
changeset
|
344 | if (g_access(dir, mode) == 0) { |
| 15884 | 345 | purple_xfer_request_accepted(xfer, filename); |
| 14967 | 346 | } else { |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
347 | g_object_ref(xfer); |
| 15884 | 348 | purple_notify_message( |
| 349 | NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, | |
| 14967 | 350 | _("Directory is not writable."), NULL, |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
351 | purple_request_cpar_from_account( |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
352 | purple_xfer_get_account(xfer)), |
| 15884 | 353 | (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
| 14967 | 354 | } |
| 355 | ||
| 356 | g_free(dir); | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
357 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
358 | else { |
| 15884 | 359 | purple_xfer_show_file_error(xfer, filename); |
|
29159
742ae16831fa
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29158
diff
changeset
|
360 | purple_xfer_cancel_local(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
361 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
362 | } |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
363 | else if ((type == PURPLE_XFER_TYPE_SEND) && (st.st_size == 0)) { |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
364 | |
| 15884 | 365 | purple_notify_error(NULL, NULL, |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
366 | _("Cannot send a file of 0 bytes."), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
367 | purple_request_cpar_from_account( |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
368 | purple_xfer_get_account(xfer))); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
369 | |
|
29159
742ae16831fa
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29158
diff
changeset
|
370 | purple_xfer_cancel_local(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
371 | } |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
372 | else if ((type == PURPLE_XFER_TYPE_SEND) && S_ISDIR(st.st_mode)) { |
| 9785 | 373 | /* |
| 374 | * XXX - Sending a directory should be valid for some protocols. | |
| 375 | */ | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
376 | purple_notify_error(NULL, NULL, _("Cannot send a directory."), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
377 | NULL, purple_request_cpar_from_account( |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
378 | purple_xfer_get_account(xfer))); |
| 9785 | 379 | |
|
29159
742ae16831fa
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29158
diff
changeset
|
380 | purple_xfer_cancel_local(xfer); |
| 9785 | 381 | } |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
382 | else if ((type == PURPLE_XFER_TYPE_RECEIVE) && S_ISDIR(st.st_mode)) { |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
383 | char *msg, *utf8; |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
384 | utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
385 | msg = g_strdup_printf( |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
386 | _("%s is not a regular file. Cowardly refusing to overwrite it.\n"), utf8); |
|
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
387 | g_free(utf8); |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
388 | purple_notify_error(NULL, NULL, msg, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
389 | purple_request_cpar_from_account( |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
390 | purple_xfer_get_account(xfer))); |
| 9785 | 391 | g_free(msg); |
| 15884 | 392 | purple_xfer_request_denied(xfer); |
| 9785 | 393 | } |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
394 | else if (type == PURPLE_XFER_TYPE_SEND) { |
|
29156
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
395 | #ifndef _WIN32 |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
396 | int mode = R_OK; |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
397 | #else |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
398 | int mode = F_OK; |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
399 | #endif |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
400 | |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
401 | if (g_access(filename, mode) == 0) { |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
402 | purple_xfer_request_accepted(xfer, filename); |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
403 | } else { |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
404 | g_object_ref(xfer); |
|
29156
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
405 | purple_notify_message( |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
406 | NULL, PURPLE_NOTIFY_MSG_ERROR, NULL, |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
407 | _("File is not readable."), NULL, |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
408 | purple_request_cpar_from_account( |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
409 | purple_xfer_get_account(xfer)), |
|
29156
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
410 | (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer); |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
411 | } |
|
816cd92683eb
Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29155
diff
changeset
|
412 | } |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
413 | else { |
| 15884 | 414 | purple_xfer_request_accepted(xfer, filename); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
415 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
416 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
417 | g_object_unref(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
418 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
419 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
420 | static void |
| 15884 | 421 | purple_xfer_choose_file_cancel_cb(void *user_data, const char *filename) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
422 | { |
| 15884 | 423 | PurpleXfer *xfer = (PurpleXfer *)user_data; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
424 | |
| 15884 | 425 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
426 | if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) |
|
29159
742ae16831fa
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29158
diff
changeset
|
427 | purple_xfer_cancel_local(xfer); |
|
742ae16831fa
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29158
diff
changeset
|
428 | else |
|
742ae16831fa
Call purple_xfer_cancel_local instead of purple_xfer_request_denied when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29158
diff
changeset
|
429 | purple_xfer_request_denied(xfer); |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
430 | g_object_unref(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
431 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
432 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
433 | static int |
| 15884 | 434 | purple_xfer_choose_file(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
435 | { |
| 15884 | 436 | purple_request_file(xfer, NULL, purple_xfer_get_filename(xfer), |
| 34945 | 437 | (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_RECEIVE), |
|
34333
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
438 | G_CALLBACK(purple_xfer_choose_file_ok_cb), |
|
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
439 | G_CALLBACK(purple_xfer_choose_file_cancel_cb), |
|
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
440 | purple_request_cpar_from_account(purple_xfer_get_account(xfer)), |
|
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
441 | xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
442 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
443 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
444 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
445 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
446 | static int |
| 15884 | 447 | cancel_recv_cb(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
448 | { |
| 15884 | 449 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
| 450 | purple_xfer_request_denied(xfer); | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
451 | g_object_unref(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
452 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
453 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
454 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
455 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
456 | static void |
| 15884 | 457 | purple_xfer_ask_recv(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
458 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
459 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
460 | char *buf, *size_buf; |
|
32663
1b87b3e98b0a
Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32608
diff
changeset
|
461 | goffset size; |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
462 | gconstpointer thumb; |
|
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
463 | gsize thumb_size; |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
464 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
465 | /* If we have already accepted the request, ask the destination file |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
466 | name directly */ |
| 15884 | 467 | if (purple_xfer_get_status(xfer) != PURPLE_XFER_STATUS_ACCEPTED) { |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
468 | PurpleRequestCommonParameters *cpar; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
469 | PurpleBuddy *buddy = purple_blist_find_buddy(priv->account, priv->who); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
470 | |
| 15884 | 471 | if (purple_xfer_get_filename(xfer) != NULL) |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
472 | { |
| 15884 | 473 | size = purple_xfer_get_size(xfer); |
| 474 | size_buf = purple_str_size_to_units(size); | |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
475 | buf = g_strdup_printf(_("%s wants to send you %s (%s)"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
476 | buddy ? purple_buddy_get_alias(buddy) : priv->who, |
| 15884 | 477 | purple_xfer_get_filename(xfer), size_buf); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
478 | g_free(size_buf); |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
479 | } |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
480 | else |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
481 | { |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
482 | buf = g_strdup_printf(_("%s wants to send you a file"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
483 | buddy ? purple_buddy_get_alias(buddy) : priv->who); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
484 | } |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
485 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
486 | if (priv->message != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
487 | serv_got_im(purple_account_get_connection(priv->account), |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
488 | priv->who, priv->message, 0, time(NULL)); |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
489 | |
| 34945 | 490 | cpar = purple_request_cpar_from_account(priv->account); |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
491 | if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) { |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
492 | purple_request_cpar_set_custom_icon(cpar, thumb, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
493 | thumb_size); |
|
27427
00f91afbd4d9
Show thumbnail in ft request dialog
Marcus Lundblad <malu@pidgin.im>
parents:
27419
diff
changeset
|
494 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31154
diff
changeset
|
495 | |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
496 | purple_request_accept_cancel(xfer, NULL, buf, NULL, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
497 | PURPLE_DEFAULT_ACTION_NONE, cpar, xfer, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
498 | G_CALLBACK(purple_xfer_choose_file), |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
499 | G_CALLBACK(cancel_recv_cb)); |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
500 | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
501 | g_free(buf); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
502 | } else |
| 15884 | 503 | purple_xfer_choose_file(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
504 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
505 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
506 | static int |
| 15884 | 507 | ask_accept_ok(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
508 | { |
| 15884 | 509 | purple_xfer_request_accepted(xfer, NULL); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
510 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
511 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
512 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
513 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
514 | static int |
| 15884 | 515 | ask_accept_cancel(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
516 | { |
| 15884 | 517 | purple_xfer_request_denied(xfer); |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
518 | g_object_unref(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
519 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
520 | return 0; |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
521 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
522 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
523 | static void |
| 15884 | 524 | purple_xfer_ask_accept(PurpleXfer *xfer) |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
525 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
526 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
527 | char *buf, *buf2 = NULL; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
528 | PurpleBuddy *buddy = purple_blist_find_buddy(priv->account, priv->who); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
529 | |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
530 | buf = g_strdup_printf(_("Accept file transfer request from %s?"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
531 | buddy ? purple_buddy_get_alias(buddy) : priv->who); |
| 15884 | 532 | if (purple_xfer_get_remote_ip(xfer) && |
| 533 | purple_xfer_get_remote_port(xfer)) | |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
534 | buf2 = g_strdup_printf(_("A file is available for download from:\n" |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
535 | "Remote host: %s\nRemote port: %d"), |
| 15884 | 536 | purple_xfer_get_remote_ip(xfer), |
| 537 | purple_xfer_get_remote_port(xfer)); | |
| 538 | purple_request_accept_cancel(xfer, NULL, buf, buf2, | |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
539 | PURPLE_DEFAULT_ACTION_NONE, |
| 34945 | 540 | purple_request_cpar_from_account(priv->account), xfer, |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34305
diff
changeset
|
541 | G_CALLBACK(ask_accept_ok), G_CALLBACK(ask_accept_cancel)); |
|
9511
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
542 | g_free(buf); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
543 | g_free(buf2); |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
544 | } |
|
d68f99136f26
[gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents:
8585
diff
changeset
|
545 | |
| 7805 | 546 | void |
| 15884 | 547 | purple_xfer_request(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
548 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
549 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
550 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
551 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
552 | g_return_if_fail(priv->ops.init != NULL); |
| 3609 | 553 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
554 | g_object_ref(xfer); |
|
4247
a77b46afa096
[gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents:
4245
diff
changeset
|
555 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
556 | if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_RECEIVE) |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
557 | { |
| 15884 | 558 | purple_signal_emit(purple_xfers_get_handle(), "file-recv-request", xfer); |
| 559 | if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) | |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
560 | { |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
561 | /* The file-transfer was cancelled by a plugin */ |
| 15884 | 562 | purple_xfer_cancel_local(xfer); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
563 | } |
| 15884 | 564 | else if (purple_xfer_get_filename(xfer) || |
| 565 | purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_ACCEPTED) | |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
566 | { |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
567 | gchar* message = NULL; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
568 | PurpleBuddy *buddy = purple_blist_find_buddy(priv->account, priv->who); |
|
28720
4b63cf19f159
Make it work again, after some new xfer UI ops where added... :)
Marcus Lundblad <malu@pidgin.im>
parents:
28682
diff
changeset
|
569 | |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
570 | message = g_strdup_printf(_("%s is offering to send file %s"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
571 | buddy ? purple_buddy_get_alias(buddy) : priv->who, purple_xfer_get_filename(xfer)); |
|
28722
d53c7b4cf1d2
Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents:
28720
diff
changeset
|
572 | purple_xfer_conversation_write_with_thumbnail(xfer, message); |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
573 | g_free(message); |
|
28720
4b63cf19f159
Make it work again, after some new xfer UI ops where added... :)
Marcus Lundblad <malu@pidgin.im>
parents:
28682
diff
changeset
|
574 | |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
575 | /* Ask for a filename to save to if it's not already given by a plugin */ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
576 | if (priv->local_filename == NULL) |
| 15884 | 577 | purple_xfer_ask_recv(xfer); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
578 | } |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
579 | else |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
580 | { |
| 15884 | 581 | purple_xfer_ask_accept(xfer); |
|
11084
b6acee973833
[gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents:
10919
diff
changeset
|
582 | } |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
583 | } |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
584 | else |
|
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
585 | { |
| 15884 | 586 | purple_xfer_choose_file(xfer); |
|
13220
4eca54b95034
[gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13109
diff
changeset
|
587 | } |
| 3609 | 588 | } |
| 589 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
590 | void |
| 15884 | 591 | purple_xfer_request_accepted(PurpleXfer *xfer, const char *filename) |
| 3609 | 592 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
593 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 15884 | 594 | PurpleXferType type; |
|
33940
b44d15793c83
Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33661
diff
changeset
|
595 | GStatBuf st; |
|
26726
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
596 | char *msg, *utf8, *base; |
| 15884 | 597 | PurpleAccount *account; |
| 598 | PurpleBuddy *buddy; | |
| 3609 | 599 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
600 | if (priv == NULL) |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
601 | return; |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
602 | |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
603 | type = purple_xfer_get_xfer_type(xfer); |
| 15884 | 604 | account = purple_xfer_get_account(xfer); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
605 | |
| 29822 | 606 | purple_debug_misc("xfer", "request accepted for %p\n", xfer); |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
607 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
608 | if (!filename && type == PURPLE_XFER_TYPE_RECEIVE) { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
609 | priv->status = PURPLE_XFER_STATUS_ACCEPTED; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
610 | priv->ops.init(xfer); |
| 3609 | 611 | return; |
| 4150 | 612 | } |
| 3609 | 613 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
614 | buddy = purple_blist_find_buddy(account, priv->who); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
615 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
616 | if (type == PURPLE_XFER_TYPE_SEND) { |
|
13595
191c2d12a00c
[gaim-migrate @ 15980]
Mark Doliner <markdoliner@pidgin.im>
parents:
13220
diff
changeset
|
617 | /* Sending a file */ |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
618 | /* Check the filename. */ |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
619 | PurpleXferUiOps *ui_ops; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
620 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
621 | |
| 11934 | 622 | #ifdef _WIN32 |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21682
diff
changeset
|
623 | if (g_strrstr(filename, "../") || g_strrstr(filename, "..\\")) |
| 11934 | 624 | #else |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21682
diff
changeset
|
625 | if (g_strrstr(filename, "../")) |
| 11934 | 626 | #endif |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21682
diff
changeset
|
627 | { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
628 | utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
| 3609 | 629 | |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
630 | msg = g_strdup_printf(_("%s is not a valid filename.\n"), utf8); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
631 | purple_xfer_error(type, account, priv->who, msg); |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
632 | g_free(utf8); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
633 | g_free(msg); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
634 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
635 | g_object_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
636 | return; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
637 | } |
| 3609 | 638 | |
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
639 | if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
640 | if (g_stat(filename, &st) == -1) { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
641 | purple_xfer_show_file_error(xfer, filename); |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
642 | g_object_unref(xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
643 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
644 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
645 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
646 | purple_xfer_set_local_filename(xfer, filename); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
647 | purple_xfer_set_size(xfer, st.st_size); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
648 | } else { |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
649 | purple_xfer_set_local_filename(xfer, filename); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
650 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
651 | |
|
26726
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
652 | base = g_path_get_basename(filename); |
|
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
653 | utf8 = g_filename_to_utf8(base, -1, NULL, NULL, NULL); |
|
b81bcec8f359
Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26373
diff
changeset
|
654 | g_free(base); |
| 15884 | 655 | purple_xfer_set_filename(xfer, utf8); |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
656 | |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
657 | msg = g_strdup_printf(_("Offering to send %s to %s"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
658 | utf8, buddy ? purple_buddy_get_alias(buddy) : priv->who); |
|
10919
22fba24cd16e
[gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10774
diff
changeset
|
659 | g_free(utf8); |
| 15884 | 660 | purple_xfer_conversation_write(xfer, msg, FALSE); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
661 | g_free(msg); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
662 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
663 | else { |
|
13595
191c2d12a00c
[gaim-migrate @ 15980]
Mark Doliner <markdoliner@pidgin.im>
parents:
13220
diff
changeset
|
664 | /* Receiving a file */ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
665 | priv->status = PURPLE_XFER_STATUS_ACCEPTED; |
| 15884 | 666 | purple_xfer_set_local_filename(xfer, filename); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
667 | |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
668 | msg = g_strdup_printf(_("Starting transfer of %s from %s"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
669 | priv->filename, buddy ? purple_buddy_get_alias(buddy) : priv->who); |
| 15884 | 670 | purple_xfer_conversation_write(xfer, msg, FALSE); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
671 | g_free(msg); |
| 3609 | 672 | } |
| 4150 | 673 | |
| 15884 | 674 | purple_xfer_add(xfer); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
675 | priv->ops.init(xfer); |
| 10259 | 676 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
677 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
678 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
679 | void |
| 15884 | 680 | purple_xfer_request_denied(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
681 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
682 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
683 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
684 | g_return_if_fail(priv != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
685 | |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
686 | purple_debug_misc("xfer", "xfer %p denied\n", xfer); |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
687 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
688 | if (priv->ops.request_denied != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
689 | priv->ops.request_denied(xfer); |
|
5164
dda3bf92f195
[gaim-migrate @ 5528]
Mark Doliner <markdoliner@pidgin.im>
parents:
5146
diff
changeset
|
690 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
691 | g_object_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
692 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
693 | |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
694 | int purple_xfer_get_fd(PurpleXfer *xfer) |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
695 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
696 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
697 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
698 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
699 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
700 | return priv->fd; |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
701 | } |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
702 | |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
703 | int purple_xfer_get_watcher(PurpleXfer *xfer) |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
704 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
705 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
706 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
707 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
708 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
709 | return priv->watcher; |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
710 | } |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
711 | |
| 15884 | 712 | PurpleXferType |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
713 | purple_xfer_get_xfer_type(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
714 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
715 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
716 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
717 | g_return_val_if_fail(priv != NULL, PURPLE_XFER_TYPE_UNKNOWN); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
718 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
719 | return priv->type; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
720 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
721 | |
| 15884 | 722 | PurpleAccount * |
| 723 | purple_xfer_get_account(const PurpleXfer *xfer) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
724 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
725 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
726 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
727 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
728 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
729 | return priv->account; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
730 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
731 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
732 | void |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
733 | purple_xfer_set_remote_user(PurpleXfer *xfer, const char *who) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
734 | { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
735 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
736 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
737 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
738 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
739 | g_free(priv->who); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
740 | priv->who = g_strdup(who); |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
741 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
742 | g_object_notify(G_OBJECT(xfer), "remote-user"); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
743 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
744 | |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
745 | const char * |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
746 | purple_xfer_get_remote_user(const PurpleXfer *xfer) |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
747 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
748 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
749 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
750 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
751 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
752 | return priv->who; |
|
17852
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
753 | } |
|
174c0d122a79
Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17293
diff
changeset
|
754 | |
|
34909
91be147083c6
Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents:
34892
diff
changeset
|
755 | PurpleXferStatus |
| 15884 | 756 | purple_xfer_get_status(const PurpleXfer *xfer) |
| 7805 | 757 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
758 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 7805 | 759 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
760 | g_return_val_if_fail(priv != NULL, PURPLE_XFER_STATUS_UNKNOWN); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
761 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
762 | return priv->status; |
| 7805 | 763 | } |
| 764 | ||
| 765 | gboolean | |
|
32607
3d50780413f8
purple_xfer_is_canceled() renamed to purple_xfer_is_cancelled()
Andrew Victor <andrew.victor@mxit.com>
parents:
32289
diff
changeset
|
766 | purple_xfer_is_cancelled(const PurpleXfer *xfer) |
| 7738 | 767 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
768 | g_return_val_if_fail(PURPLE_IS_XFER(xfer), TRUE); |
| 7738 | 769 | |
| 15884 | 770 | if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) || |
| 771 | (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE)) | |
| 7805 | 772 | return TRUE; |
| 773 | else | |
| 774 | return FALSE; | |
| 7738 | 775 | } |
| 776 | ||
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
777 | gboolean |
| 15884 | 778 | purple_xfer_is_completed(const PurpleXfer *xfer) |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
779 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
780 | g_return_val_if_fail(PURPLE_IS_XFER(xfer), TRUE); |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
781 | |
| 15884 | 782 | return (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_DONE); |
|
4539
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
783 | } |
|
44671e1ce14e
[gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents:
4538
diff
changeset
|
784 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
785 | const char * |
| 15884 | 786 | purple_xfer_get_filename(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
787 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
788 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
789 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
790 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
791 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
792 | return priv->filename; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
793 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
794 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
795 | const char * |
| 15884 | 796 | purple_xfer_get_local_filename(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
797 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
798 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
799 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
800 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
801 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
802 | return priv->local_filename; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
803 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
804 | |
|
32663
1b87b3e98b0a
Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32608
diff
changeset
|
805 | goffset |
| 15884 | 806 | purple_xfer_get_bytes_sent(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
807 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
808 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
809 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
810 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
811 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
812 | return priv->bytes_sent; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
813 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
814 | |
|
32663
1b87b3e98b0a
Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32608
diff
changeset
|
815 | goffset |
| 15884 | 816 | purple_xfer_get_bytes_remaining(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
817 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
818 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
819 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
820 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
821 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
822 | return priv->bytes_remaining; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
823 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
824 | |
|
32663
1b87b3e98b0a
Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32608
diff
changeset
|
825 | goffset |
| 15884 | 826 | purple_xfer_get_size(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
827 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
828 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
829 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
830 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
831 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
832 | return priv->size; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
833 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
834 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
835 | double |
| 15884 | 836 | purple_xfer_get_progress(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
837 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
838 | g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0.0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
839 | |
| 15884 | 840 | if (purple_xfer_get_size(xfer) == 0) |
|
4517
998c580f7f56
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
841 | return 0.0; |
|
998c580f7f56
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
842 | |
| 15884 | 843 | return ((double)purple_xfer_get_bytes_sent(xfer) / |
| 844 | (double)purple_xfer_get_size(xfer)); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
845 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
846 | |
|
34457
a9d3726c3a8f
Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34449
diff
changeset
|
847 | guint16 |
| 15884 | 848 | purple_xfer_get_local_port(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
849 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
850 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
851 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
852 | g_return_val_if_fail(priv != NULL, -1); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
853 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
854 | return priv->local_port; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
855 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
856 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
857 | const char * |
| 15884 | 858 | purple_xfer_get_remote_ip(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
859 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
860 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
861 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
862 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
863 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
864 | return priv->remote_ip; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
865 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
866 | |
|
34457
a9d3726c3a8f
Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34449
diff
changeset
|
867 | guint16 |
| 15884 | 868 | purple_xfer_get_remote_port(const PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
869 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
870 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
871 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
872 | g_return_val_if_fail(priv != NULL, -1); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
873 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
874 | return priv->remote_port; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
875 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
876 | |
|
22338
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
877 | time_t |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
878 | purple_xfer_get_start_time(const PurpleXfer *xfer) |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
879 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
880 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
22338
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
881 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
882 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
883 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
884 | return priv->start_time; |
|
22338
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
885 | } |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
886 | |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
887 | time_t |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
888 | purple_xfer_get_end_time(const PurpleXfer *xfer) |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
889 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
890 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
22338
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
891 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
892 | g_return_val_if_fail(priv != NULL, 0); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
893 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
894 | return priv->end_time; |
|
22338
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
895 | } |
|
d6a489105624
Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22194
diff
changeset
|
896 | |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
897 | void purple_xfer_set_fd(PurpleXfer *xfer, int fd) |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
898 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
899 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
900 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
901 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
902 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
903 | priv->fd = fd; |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
904 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
905 | g_object_notify(G_OBJECT(xfer), "fd"); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
906 | } |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
907 | |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
908 | void purple_xfer_set_watcher(PurpleXfer *xfer, int watcher) |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
909 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
910 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
911 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
912 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
913 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
914 | priv->watcher = watcher; |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
915 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
916 | g_object_notify(G_OBJECT(xfer), "watcher"); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
917 | } |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
918 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
919 | void |
| 15884 | 920 | purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed) |
| 4538 | 921 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
922 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 15884 | 923 | PurpleXferUiOps *ui_ops; |
|
4656
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
924 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
925 | g_return_if_fail(priv != NULL); |
| 4538 | 926 | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
927 | if (completed == TRUE) { |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
928 | char *msg = NULL; |
|
34656
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
929 | PurpleIMConversation *im; |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
930 | |
| 15884 | 931 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE); |
|
4656
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
932 | |
| 15884 | 933 | if (purple_xfer_get_filename(xfer) != NULL) |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
934 | { |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
935 | char *filename = g_markup_escape_text(purple_xfer_get_filename(xfer), -1); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
936 | if (purple_xfer_get_local_filename(xfer) |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
937 | && purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_RECEIVE) |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
938 | { |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
939 | char *local = g_markup_escape_text(purple_xfer_get_local_filename(xfer), -1); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
940 | msg = g_strdup_printf(_("Transfer of file <A HREF=\"file://%s\">%s</A> complete"), |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
941 | local, filename); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
942 | g_free(local); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
943 | } |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
944 | else |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
945 | msg = g_strdup_printf(_("Transfer of file %s complete"), |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
946 | filename); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
947 | g_free(filename); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
948 | } |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
949 | else |
|
25359
ea172b7ea601
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <datallah@pidgin.im>
parents:
24672
diff
changeset
|
950 | msg = g_strdup(_("File transfer complete")); |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
951 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
952 | im = purple_conversations_find_im_with_account(priv->who, |
|
27655
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
953 | purple_xfer_get_account(xfer)); |
|
162b561fad5e
Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26726
diff
changeset
|
954 | |
|
34656
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
955 | if (im != NULL) |
|
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
956 | purple_conversation_write(PURPLE_CONVERSATION(im), NULL, msg, |
|
adbcbe04077c
Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
957 | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
958 | g_free(msg); |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
959 | } |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
960 | |
| 15884 | 961 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4656
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
962 | |
|
b676f986e7e3
[gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents:
4634
diff
changeset
|
963 | if (ui_ops != NULL && ui_ops->update_progress != NULL) |
| 15884 | 964 | ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
| 4538 | 965 | } |
| 966 | ||
| 967 | void | |
| 15884 | 968 | purple_xfer_set_message(PurpleXfer *xfer, const char *message) |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
969 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
970 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
971 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
972 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
973 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
974 | g_free(priv->message); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
975 | priv->message = g_strdup(message); |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
976 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
977 | g_object_notify(G_OBJECT(xfer), "message"); |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
978 | } |
|
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
979 | |
|
34927
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
980 | const char * |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
981 | purple_xfer_get_message(const PurpleXfer *xfer) |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
982 | { |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
983 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
984 | |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
985 | g_return_val_if_fail(priv != NULL, NULL); |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
986 | |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
987 | return priv->message; |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
988 | } |
|
cef809309dbf
Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents:
34926
diff
changeset
|
989 | |
|
9933
61bd3fadbfe6
[gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents:
9932
diff
changeset
|
990 | void |
| 15884 | 991 | purple_xfer_set_filename(PurpleXfer *xfer, const char *filename) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
992 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
993 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
994 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
995 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
996 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
997 | g_free(priv->filename); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
998 | priv->filename = g_strdup(filename); |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
999 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1000 | g_object_notify(G_OBJECT(xfer), "filename"); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1001 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1002 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1003 | void |
| 15884 | 1004 | purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1005 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1006 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1007 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1008 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1009 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1010 | g_free(priv->local_filename); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1011 | priv->local_filename = g_strdup(filename); |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1012 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1013 | g_object_notify(G_OBJECT(xfer), "local-filename"); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1014 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1015 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1016 | void |
|
32663
1b87b3e98b0a
Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32608
diff
changeset
|
1017 | purple_xfer_set_size(PurpleXfer *xfer, goffset size) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1018 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1019 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1020 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1021 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1022 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1023 | priv->size = size; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1024 | priv->bytes_remaining = priv->size - purple_xfer_get_bytes_sent(xfer); |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1025 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1026 | g_object_notify(G_OBJECT(xfer), "file-size"); |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
1027 | } |
| 4538 | 1028 | |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
1029 | void |
|
34457
a9d3726c3a8f
Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34449
diff
changeset
|
1030 | purple_xfer_set_local_port(PurpleXfer *xfer, guint16 local_port) |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
1031 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1032 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
1033 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1034 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1035 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1036 | priv->local_port = local_port; |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1037 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1038 | g_object_notify(G_OBJECT(xfer), "local-port"); |
|
32289
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
1039 | } |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
1040 | |
|
8c121b654972
Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32256
diff
changeset
|
1041 | void |
|
32663
1b87b3e98b0a
Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32608
diff
changeset
|
1042 | purple_xfer_set_bytes_sent(PurpleXfer *xfer, goffset bytes_sent) |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
1043 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1044 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
15322
cd268e368bc1
[gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents:
15280
diff
changeset
|
1045 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1046 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1047 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1048 | priv->bytes_sent = bytes_sent; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1049 | priv->bytes_remaining = purple_xfer_get_size(xfer) - bytes_sent; |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1050 | |
|
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
1051 | g_object_notify(G_OBJECT(xfer), "bytes-sent"); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1052 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1053 | |
| 15884 | 1054 | PurpleXferUiOps * |
| 1055 | purple_xfer_get_ui_ops(const PurpleXfer *xfer) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1056 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1057 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1058 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1059 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1060 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1061 | return priv->ui_ops; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1062 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1063 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1064 | void |
| 15884 | 1065 | purple_xfer_set_init_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1066 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1067 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1068 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1069 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1070 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1071 | priv->ops.init = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1072 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1073 | |
| 15884 | 1074 | void purple_xfer_set_request_denied_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
| 7805 | 1075 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1076 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 7805 | 1077 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1078 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1079 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1080 | priv->ops.request_denied = fnc; |
| 7805 | 1081 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1082 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1083 | void |
| 15884 | 1084 | purple_xfer_set_read_fnc(PurpleXfer *xfer, gssize (*fnc)(guchar **, PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1085 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1086 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1087 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1088 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1089 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1090 | priv->ops.read = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1091 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1092 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1093 | void |
| 15884 | 1094 | purple_xfer_set_write_fnc(PurpleXfer *xfer, |
| 1095 | gssize (*fnc)(const guchar *, size_t, PurpleXfer *)) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1096 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1097 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1098 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1099 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1100 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1101 | priv->ops.write = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1102 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1103 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1104 | void |
| 15884 | 1105 | purple_xfer_set_ack_fnc(PurpleXfer *xfer, |
| 1106 | void (*fnc)(PurpleXfer *, const guchar *, size_t)) | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1107 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1108 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1109 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1110 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1111 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1112 | priv->ops.ack = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1113 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1114 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1115 | void |
| 15884 | 1116 | purple_xfer_set_start_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1117 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1118 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1119 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1120 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1121 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1122 | priv->ops.start = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1123 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1124 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1125 | void |
| 15884 | 1126 | purple_xfer_set_end_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1127 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1128 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1129 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1130 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1131 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1132 | priv->ops.end = fnc; |
| 3609 | 1133 | } |
| 1134 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1135 | void |
| 15884 | 1136 | purple_xfer_set_cancel_send_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
| 3609 | 1137 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1138 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1139 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1140 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1141 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1142 | priv->ops.cancel_send = fnc; |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1143 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1144 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1145 | void |
| 15884 | 1146 | purple_xfer_set_cancel_recv_fnc(PurpleXfer *xfer, void (*fnc)(PurpleXfer *)) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1147 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1148 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1149 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1150 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1151 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1152 | priv->ops.cancel_recv = fnc; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1153 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1154 | |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1155 | static void |
| 15884 | 1156 | purple_xfer_increase_buffer_size(PurpleXfer *xfer) |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1157 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1158 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1159 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1160 | priv->current_buffer_size = MIN(priv->current_buffer_size * 1.5, |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1161 | FT_MAX_BUFFER_SIZE); |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1162 | } |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1163 | |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
1164 | gssize |
| 15884 | 1165 | purple_xfer_read(PurpleXfer *xfer, guchar **buffer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1166 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1167 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
1168 | gssize s, r; |
| 3609 | 1169 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1170 | g_return_val_if_fail(priv != NULL, 0); |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1171 | g_return_val_if_fail(buffer != NULL, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1172 | |
| 15884 | 1173 | if (purple_xfer_get_size(xfer) == 0) |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1174 | s = priv->current_buffer_size; |
|
4517
998c580f7f56
[gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents:
4514
diff
changeset
|
1175 | else |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1176 | s = MIN(purple_xfer_get_bytes_remaining(xfer), priv->current_buffer_size); |
| 3609 | 1177 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1178 | if (priv->ops.read != NULL) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1179 | r = (priv->ops.read)(buffer, xfer); |
|
26373
105e5b66e8da
fix a bug in libpurple that prevented receiving file transfers to be marked completed (in case the protocol uses an xfer->ops.read function)
Sulabh Mahajan <sulabh@pidgin.im>
parents:
25359
diff
changeset
|
1180 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1181 | else { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1182 | *buffer = g_malloc0(s); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1183 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1184 | r = read(priv->fd, *buffer, s); |
|
13011
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
1185 | if (r < 0 && errno == EAGAIN) |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
1186 | r = 0; |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
1187 | else if (r < 0) |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
1188 | r = -1; |
|
13788
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13729
diff
changeset
|
1189 | else if (r == 0) |
|
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13729
diff
changeset
|
1190 | r = -1; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1191 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1192 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1193 | if (r >= 0 && (gsize)r == priv->current_buffer_size) |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1194 | /* |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1195 | * We managed to read the entire buffer. This means our this |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1196 | * network is fast and our buffer is too small, so make it |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1197 | * bigger. |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1198 | */ |
| 15884 | 1199 | purple_xfer_increase_buffer_size(xfer); |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1200 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1201 | return r; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1202 | } |
| 3609 | 1203 | |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
1204 | gssize |
| 15884 | 1205 | purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1206 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1207 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
1208 | gssize r, s; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1209 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1210 | g_return_val_if_fail(priv != NULL, 0); |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1211 | g_return_val_if_fail(buffer != NULL, 0); |
|
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1212 | g_return_val_if_fail(size != 0, 0); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1213 | |
| 15884 | 1214 | s = MIN(purple_xfer_get_bytes_remaining(xfer), size); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1215 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1216 | if (priv->ops.write != NULL) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1217 | r = (priv->ops.write)(buffer, s, xfer); |
| 8231 | 1218 | } else { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1219 | r = write(priv->fd, buffer, s); |
|
13011
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
1220 | if (r < 0 && errno == EAGAIN) |
|
b41d13bd682d
[gaim-migrate @ 15364]
Daniel Atallah <datallah@pidgin.im>
parents:
12250
diff
changeset
|
1221 | r = 0; |
| 8231 | 1222 | } |
|
31504
b0452e7fc9f9
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31294
diff
changeset
|
1223 | if (r >= 0 && (purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer) && |
|
b0452e7fc9f9
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31294
diff
changeset
|
1224 | !purple_xfer_is_completed(xfer)) |
|
b0452e7fc9f9
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31294
diff
changeset
|
1225 | purple_xfer_set_completed(xfer, TRUE); |
|
b0452e7fc9f9
Fix up some cases of file transfers never finishing. This will help certain
Cristi Posoiu
parents:
31294
diff
changeset
|
1226 | |
| 3609 | 1227 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1228 | return r; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1229 | } |
| 3609 | 1230 | |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1231 | gboolean |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1232 | purple_xfer_write_file(PurpleXfer *xfer, const guchar *buffer, gsize size) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1233 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1234 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1235 | PurpleXferUiOps *ui_ops; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1236 | gsize wc; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1237 | gboolean fs_known; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1238 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1239 | g_return_val_if_fail(priv != NULL, FALSE); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1240 | g_return_val_if_fail(buffer != NULL, FALSE); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1241 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1242 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1243 | fs_known = (purple_xfer_get_size(xfer) > 0); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1244 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1245 | if (fs_known && size > purple_xfer_get_bytes_remaining(xfer)) { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1246 | purple_debug_warning("filetransfer", |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1247 | "Got too much data (truncating at %" G_GOFFSET_FORMAT |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1248 | ").\n", purple_xfer_get_size(xfer)); |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1249 | size = purple_xfer_get_bytes_remaining(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1250 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1251 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1252 | if (ui_ops && ui_ops->ui_write) |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1253 | wc = ui_ops->ui_write(xfer, buffer, size); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1254 | else { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1255 | if (priv->dest_fp == NULL) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1256 | purple_debug_error("filetransfer", |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1257 | "File is not opened for writing\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1258 | purple_xfer_cancel_local(xfer); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1259 | return FALSE; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1260 | } |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1261 | wc = fwrite(buffer, size, 1, priv->dest_fp); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1262 | } |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1263 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1264 | if (wc != size) { |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1265 | purple_debug_error("filetransfer", |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1266 | "Unable to write whole buffer.\n"); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1267 | purple_xfer_cancel_local(xfer); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1268 | return FALSE; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1269 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1270 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1271 | purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1272 | size); |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1273 | |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1274 | return TRUE; |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1275 | } |
|
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1276 | |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1277 | gssize |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1278 | purple_xfer_read_file(PurpleXfer *xfer, guchar *buffer, gsize size) |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1279 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1280 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1281 | PurpleXferUiOps *ui_ops; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1282 | gssize got_len; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1283 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1284 | g_return_val_if_fail(priv != NULL, FALSE); |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1285 | g_return_val_if_fail(buffer != NULL, FALSE); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1286 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1287 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1288 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1289 | if (ui_ops && ui_ops->ui_read) { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1290 | guchar *buffer_got = NULL; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1291 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1292 | got_len = ui_ops->ui_read(xfer, &buffer_got, size); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1293 | |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
1294 | if (got_len >= 0 && (gsize)got_len > size) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1295 | g_free(buffer_got); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1296 | purple_debug_error("filetransfer", |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1297 | "Got too much data from UI.\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1298 | purple_xfer_cancel_local(xfer); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1299 | return -1; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1300 | } |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1301 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1302 | if (got_len > 0) |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1303 | memcpy(buffer, buffer_got, got_len); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1304 | g_free(buffer_got); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1305 | } else { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1306 | if (priv->dest_fp == NULL) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1307 | purple_debug_error("filetransfer", |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1308 | "File is not opened for reading\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1309 | purple_xfer_cancel_local(xfer); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1310 | return -1; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1311 | } |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1312 | got_len = fread(buffer, size, 1, priv->dest_fp); |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
1313 | if ((got_len < 0 || (gsize)got_len != size) && |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1314 | ferror(priv->dest_fp)) |
|
34305
5804117fb298
Fix the rest of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34286
diff
changeset
|
1315 | { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1316 | purple_debug_error("filetransfer", |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1317 | "Unable to read file.\n"); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1318 | purple_xfer_cancel_local(xfer); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1319 | return -1; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1320 | } |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1321 | } |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1322 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1323 | if (got_len > 0) { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1324 | purple_xfer_set_bytes_sent(xfer, |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1325 | purple_xfer_get_bytes_sent(xfer) + got_len); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1326 | } |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1327 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1328 | return got_len; |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1329 | } |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1330 | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1331 | static void |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1332 | do_transfer(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1333 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1334 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 15884 | 1335 | PurpleXferUiOps *ui_ops; |
|
11159
76ef02141bcb
[gaim-migrate @ 13246]
Mark Doliner <markdoliner@pidgin.im>
parents:
11084
diff
changeset
|
1336 | guchar *buffer = NULL; |
|
12151
8002bb57756b
[gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents:
11934
diff
changeset
|
1337 | gssize r = 0; |
| 3609 | 1338 | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1339 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1340 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1341 | if (priv->type == PURPLE_XFER_TYPE_RECEIVE) { |
| 15884 | 1342 | r = purple_xfer_read(xfer, &buffer); |
| 8316 | 1343 | if (r > 0) { |
|
34272
8df870b218ca
HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33940
diff
changeset
|
1344 | if (!purple_xfer_write_file(xfer, buffer, r)) { |
|
28076
796f5a14f70b
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27993
diff
changeset
|
1345 | g_free(buffer); |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
1346 | return; |
|
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
1347 | } |
|
28180
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1348 | |
|
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1349 | if ((purple_xfer_get_size(xfer) > 0) && |
|
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1350 | ((purple_xfer_get_bytes_sent(xfer)+r) >= purple_xfer_get_size(xfer))) |
|
782b27dceaf7
ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents:
28159
diff
changeset
|
1351 | purple_xfer_set_completed(xfer, TRUE); |
|
17293
2b7fbca58d92
Fix file transfers aborting and mistakenly being marked as cancelled when they are actually complete. Fixes #814
Daniel Atallah <datallah@pidgin.im>
parents:
17089
diff
changeset
|
1352 | } else if(r < 0) { |
| 15884 | 1353 | purple_xfer_cancel_remote(xfer); |
|
28076
796f5a14f70b
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27993
diff
changeset
|
1354 | g_free(buffer); |
| 8316 | 1355 | return; |
|
13109
c5801934af5c
[gaim-migrate @ 15470]
Daniel Atallah <datallah@pidgin.im>
parents:
13108
diff
changeset
|
1356 | } |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1357 | } else if (priv->type == PURPLE_XFER_TYPE_SEND) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1358 | gssize result = 0; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1359 | size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), priv->current_buffer_size); |
|
29821
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1360 | gboolean read = TRUE; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1361 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1362 | /* this is so the protocol can keep the connection open |
| 8351 | 1363 | if it needs to for some odd reason. */ |
| 1364 | if (s == 0) { | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1365 | if (priv->watcher) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1366 | purple_input_remove(priv->watcher); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1367 | priv->watcher = 0; |
| 8351 | 1368 | } |
| 1369 | return; | |
| 1370 | } | |
| 1371 | ||
|
29821
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1372 | if (priv->buffer) { |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1373 | if (priv->buffer->len < s) { |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1374 | s -= priv->buffer->len; |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1375 | read = TRUE; |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1376 | } else { |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1377 | read = FALSE; |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1378 | } |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1379 | } |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1380 | |
|
8c85f494737a
ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents:
29820
diff
changeset
|
1381 | if (read) { |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1382 | buffer = g_new(guchar, s); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1383 | result = purple_xfer_read_file(xfer, buffer, s); |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1384 | if (result == 0) { |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1385 | /* |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1386 | * The UI claimed it was ready, but didn't have any data for |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1387 | * us... It will call purple_xfer_ui_ready when ready, which |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1388 | * sets back up this watcher. |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1389 | */ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1390 | if (priv->watcher != 0) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1391 | purple_input_remove(priv->watcher); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1392 | priv->watcher = 0; |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1393 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1394 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1395 | /* Need to indicate the protocol is still ready... */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
1396 | priv->ready |= PURPLE_XFER_READY_PROTOCOL; |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1397 | |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1398 | g_return_if_reached(); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1399 | } |
|
34286
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1400 | if (result < 0) |
|
8d0979967d05
HTTP: removing extra yahoo HTTP implementations - file transfer (and small improvements to libpurple http and ft code)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34272
diff
changeset
|
1401 | return; |
|
22194
3e48f2d3d083
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
21985
diff
changeset
|
1402 | } |
| 29822 | 1403 | |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1404 | if (priv->buffer) { |
|
29968
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1405 | g_byte_array_append(priv->buffer, buffer, result); |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1406 | g_free(buffer); |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1407 | buffer = priv->buffer->data; |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1408 | result = priv->buffer->len; |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1409 | } |
| 29822 | 1410 | |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1411 | r = purple_xfer_write(xfer, buffer, result); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1412 | |
| 8231 | 1413 | if (r == -1) { |
| 15884 | 1414 | purple_xfer_cancel_remote(xfer); |
|
29968
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1415 | if (!priv->buffer) |
|
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1416 | /* We don't free buffer if priv->buffer is set, because in |
|
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1417 | that case buffer doesn't belong to us. */ |
|
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1418 | g_free(buffer); |
| 8231 | 1419 | return; |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1420 | } else if (r == result) { |
|
15280
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1421 | /* |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1422 | * We managed to write the entire buffer. This means our |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1423 | * network is fast and our buffer is too small, so make it |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1424 | * bigger. |
|
9df6112da532
[gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents:
15161
diff
changeset
|
1425 | */ |
| 15884 | 1426 | purple_xfer_increase_buffer_size(xfer); |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1427 | } else { |
| 29822 | 1428 | if (ui_ops && ui_ops->data_not_sent) |
| 1429 | ui_ops->data_not_sent(xfer, buffer + r, result - r); | |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1430 | } |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1431 | |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1432 | if (priv->buffer) { |
| 29822 | 1433 | /* |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1434 | * Remove what we wrote |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1435 | * If we wrote the whole buffer the byte array will be empty |
|
29968
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1436 | * Otherwise we'll keep what wasn't sent for next time. |
|
29533
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1437 | */ |
|
ca223fea0a1e
Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents:
28659
diff
changeset
|
1438 | buffer = NULL; |
|
29968
1bab736e15da
Does anyone know the purpose of the ui_write, ui_read and data_not_sent
Mark Doliner <markdoliner@pidgin.im>
parents:
29822
diff
changeset
|
1439 | g_byte_array_remove_range(priv->buffer, 0, r); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1440 | } |
| 3609 | 1441 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1442 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1443 | if (r > 0) { |
| 15884 | 1444 | if (purple_xfer_get_size(xfer) > 0) |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1445 | priv->bytes_remaining -= r; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1446 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1447 | priv->bytes_sent += r; |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1448 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1449 | if (priv->ops.ack != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1450 | priv->ops.ack(xfer, buffer, r); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1451 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1452 | g_free(buffer); |
|
4594
a96954344300
[gaim-migrate @ 4879]
Mark Doliner <markdoliner@pidgin.im>
parents:
4582
diff
changeset
|
1453 | |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1454 | if (ui_ops != NULL && ui_ops->update_progress != NULL) |
|
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1455 | ui_ops->update_progress(xfer, |
| 15884 | 1456 | purple_xfer_get_progress(xfer)); |
|
13108
9a5cd09fd9cb
[gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents:
13011
diff
changeset
|
1457 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1458 | |
| 15884 | 1459 | if (purple_xfer_is_completed(xfer)) |
| 1460 | purple_xfer_end(xfer); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1461 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1462 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1463 | static void |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1464 | transfer_cb(gpointer data, gint source, PurpleInputCondition condition) |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1465 | { |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1466 | PurpleXfer *xfer = data; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1467 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1468 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1469 | if (priv->dest_fp == NULL) { |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1470 | /* The UI is moderating its side manually */ |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1471 | if (0 == (priv->ready & PURPLE_XFER_READY_UI)) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
1472 | priv->ready |= PURPLE_XFER_READY_PROTOCOL; |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1473 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1474 | purple_input_remove(priv->watcher); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1475 | priv->watcher = 0; |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
1476 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1477 | purple_debug_misc("xfer", "Protocol is ready on ft %p, waiting for UI\n", xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1478 | return; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1479 | } |
|
29232
a94f1f9cdcd2
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <darkrain42@pidgin.im>
parents:
29168
diff
changeset
|
1480 | |
|
a94f1f9cdcd2
ft: Fix ui_ops->ui_read being called too often (when it's not ready).
Paul Aurich <darkrain42@pidgin.im>
parents:
29168
diff
changeset
|
1481 | priv->ready = PURPLE_XFER_READY_NONE; |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1482 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1483 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1484 | do_transfer(xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1485 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1486 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1487 | static void |
| 15884 | 1488 | begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1489 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1490 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
1491 | PurpleXferType type = purple_xfer_get_xfer_type(xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1492 | PurpleXferUiOps *ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1493 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1494 | if (priv->start_time != 0) { |
|
30832
e5075db65f9a
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <datallah@pidgin.im>
parents:
30708
diff
changeset
|
1495 | purple_debug_error("xfer", "Transfer is being started multiple times\n"); |
|
e5075db65f9a
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <datallah@pidgin.im>
parents:
30708
diff
changeset
|
1496 | g_return_if_reached(); |
|
e5075db65f9a
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <datallah@pidgin.im>
parents:
30708
diff
changeset
|
1497 | } |
|
e5075db65f9a
Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <datallah@pidgin.im>
parents:
30708
diff
changeset
|
1498 | |
|
28159
567c6a03a6ea
Fix building on win32, which has #define write wpurple_write (and similar for read).
Paul Aurich <darkrain42@pidgin.im>
parents:
28156
diff
changeset
|
1499 | if (ui_ops == NULL || (ui_ops->ui_read == NULL && ui_ops->ui_write == NULL)) { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1500 | priv->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1501 | type == PURPLE_XFER_TYPE_RECEIVE ? "wb" : "rb"); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1502 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1503 | if (priv->dest_fp == NULL) { |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1504 | purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer)); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1505 | purple_xfer_cancel_local(xfer); |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1506 | return; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1507 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1508 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1509 | fseek(priv->dest_fp, priv->bytes_sent, SEEK_SET); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1510 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1511 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1512 | if (priv->fd != -1) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1513 | priv->watcher = purple_input_add(priv->fd, cond, transfer_cb, xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1514 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1515 | priv->start_time = time(NULL); |
|
13599
b6369e541654
[gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents:
13595
diff
changeset
|
1516 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1517 | if (priv->ops.start != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1518 | priv->ops.start(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1519 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1520 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1521 | static void |
|
14183
bdde840e984c
[gaim-migrate @ 16755]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
1522 | connect_cb(gpointer data, gint source, const gchar *error_message) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1523 | { |
| 15884 | 1524 | PurpleXfer *xfer = (PurpleXfer *)data; |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1525 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1526 | |
|
21676
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1527 | if (source < 0) { |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1528 | purple_xfer_cancel_local(xfer); |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1529 | return; |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1530 | } |
|
dabfb5216949
Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
1531 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1532 | priv->fd = source; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1533 | |
| 15884 | 1534 | begin_transfer(xfer, PURPLE_INPUT_READ); |
| 3609 | 1535 | } |
| 1536 | ||
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1537 | void |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1538 | purple_xfer_ui_ready(PurpleXfer *xfer) |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1539 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1540 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1541 | PurpleInputCondition cond; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1542 | PurpleXferType type; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1543 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1544 | g_return_if_fail(priv != NULL); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1545 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1546 | priv->ready |= PURPLE_XFER_READY_UI; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1547 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
1548 | if (0 == (priv->ready & PURPLE_XFER_READY_PROTOCOL)) { |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1549 | purple_debug_misc("xfer", "UI is ready on ft %p, waiting for protocol\n", xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1550 | return; |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
1551 | } |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
1552 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1553 | purple_debug_misc("xfer", "UI (and protocol) ready on ft %p, so proceeding\n", xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1554 | |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
1555 | type = purple_xfer_get_xfer_type(xfer); |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1556 | if (type == PURPLE_XFER_TYPE_SEND) |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1557 | cond = PURPLE_INPUT_WRITE; |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1558 | else /* if (type == PURPLE_XFER_TYPE_RECEIVE) */ |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1559 | cond = PURPLE_INPUT_READ; |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1560 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1561 | if (priv->watcher == 0 && priv->fd != -1) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1562 | priv->watcher = purple_input_add(priv->fd, cond, transfer_cb, xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1563 | |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1564 | priv->ready = PURPLE_XFER_READY_NONE; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1565 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1566 | do_transfer(xfer); |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1567 | } |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1568 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1569 | void |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
1570 | purple_xfer_protocol_ready(PurpleXfer *xfer) |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1571 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1572 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1573 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1574 | g_return_if_fail(priv != NULL); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1575 | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
1576 | priv->ready |= PURPLE_XFER_READY_PROTOCOL; |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1577 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1578 | /* I don't think fwrite/fread are ever *not* ready */ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1579 | if (priv->dest_fp == NULL && 0 == (priv->ready & PURPLE_XFER_READY_UI)) { |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1580 | purple_debug_misc("xfer", "Protocol is ready on ft %p, waiting for UI\n", xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1581 | return; |
|
29168
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
1582 | } |
|
585ce277cad3
ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents:
29159
diff
changeset
|
1583 | |
|
36637
9b0109ae118d
Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents:
36577
diff
changeset
|
1584 | purple_debug_misc("xfer", "Protocol (and UI) ready on ft %p, so proceeding\n", xfer); |
|
28156
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1585 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1586 | priv->ready = PURPLE_XFER_READY_NONE; |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1587 | |
|
0a75e2463576
ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents:
28153
diff
changeset
|
1588 | do_transfer(xfer); |
|
28150
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1589 | } |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1590 | |
|
1213ec1efcf8
ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents:
28076
diff
changeset
|
1591 | void |
|
34457
a9d3726c3a8f
Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34449
diff
changeset
|
1592 | purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, guint16 port) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1593 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1594 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 15884 | 1595 | PurpleInputCondition cond; |
| 1596 | PurpleXferType type; | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1597 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1598 | g_return_if_fail(priv != NULL); |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1599 | g_return_if_fail(purple_xfer_get_xfer_type(xfer) != PURPLE_XFER_TYPE_UNKNOWN); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1600 | |
|
34910
60502558e400
Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents:
34909
diff
changeset
|
1601 | type = purple_xfer_get_xfer_type(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1602 | |
| 15884 | 1603 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_STARTED); |
| 7805 | 1604 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1605 | if (type == PURPLE_XFER_TYPE_RECEIVE) { |
| 15884 | 1606 | cond = PURPLE_INPUT_READ; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1607 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1608 | if (ip != NULL) { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1609 | priv->remote_ip = g_strdup(ip); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1610 | priv->remote_port = port; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1611 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1612 | /* Establish a file descriptor. */ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1613 | purple_proxy_connect(NULL, priv->account, priv->remote_ip, |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1614 | priv->remote_port, connect_cb, xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1615 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1616 | return; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1617 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1618 | else { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1619 | priv->fd = fd; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1620 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1621 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1622 | else { |
| 15884 | 1623 | cond = PURPLE_INPUT_WRITE; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1624 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1625 | priv->fd = fd; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1626 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1627 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1628 | begin_transfer(xfer, cond); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1629 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1630 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1631 | void |
| 15884 | 1632 | purple_xfer_end(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1633 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1634 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1635 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1636 | g_return_if_fail(priv != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1637 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1638 | /* See if we are actually trying to cancel this. */ |
| 15884 | 1639 | if (!purple_xfer_is_completed(xfer)) { |
| 1640 | purple_xfer_cancel_local(xfer); | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1641 | return; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1642 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1643 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1644 | priv->end_time = time(NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1645 | if (priv->ops.end != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1646 | priv->ops.end(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1647 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1648 | if (priv->watcher != 0) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1649 | purple_input_remove(priv->watcher); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1650 | priv->watcher = 0; |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1651 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1652 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1653 | if (priv->fd != -1) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1654 | close(priv->fd); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1655 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1656 | if (priv->dest_fp != NULL) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1657 | fclose(priv->dest_fp); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1658 | priv->dest_fp = NULL; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1659 | } |
| 7805 | 1660 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
1661 | g_object_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1662 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1663 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1664 | void |
| 15884 | 1665 | purple_xfer_add(PurpleXfer *xfer) |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1666 | { |
| 15884 | 1667 | PurpleXferUiOps *ui_ops; |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1668 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1669 | g_return_if_fail(PURPLE_IS_XFER(xfer)); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1670 | |
| 15884 | 1671 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1672 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1673 | if (ui_ops != NULL && ui_ops->add_xfer != NULL) |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1674 | ui_ops->add_xfer(xfer); |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1675 | } |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1676 | |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1677 | void |
| 15884 | 1678 | purple_xfer_cancel_local(PurpleXfer *xfer) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1679 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1680 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 15884 | 1681 | PurpleXferUiOps *ui_ops; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
1682 | char *msg = NULL; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1683 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1684 | g_return_if_fail(priv != NULL); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1685 | |
|
31154
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1686 | /* TODO: We definitely want to close any open request dialogs associated |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1687 | with this transfer. However, in some cases the request dialog might |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1688 | own a reference on the xfer. This happens at least with the "%s wants |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1689 | to send you %s" dialog from purple_xfer_ask_recv(). In these cases |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1690 | the ref count will not be decremented when the request dialog is |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1691 | closed, so the ref count will never reach 0 and the xfer will never |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1692 | be freed. This is a memleak and should be fixed. It's not clear what |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1693 | the correct fix is. Probably requests should have a destroy function |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1694 | that is called when the request is destroyed. But also, ref counting |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1695 | xfer objects makes this code REALLY complicated. An alternate fix is |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1696 | to not ref count and instead just make sure the object still exists |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1697 | when we try to use it. */ |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1698 | purple_request_close_with_handle(xfer); |
|
d285b9000fbe
Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
30832
diff
changeset
|
1699 | |
| 15884 | 1700 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1701 | priv->end_time = time(NULL); |
| 7738 | 1702 | |
| 15884 | 1703 | if (purple_xfer_get_filename(xfer) != NULL) |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1704 | { |
|
27797
10f6bc89044b
Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
1705 | msg = g_strdup_printf(_("You cancelled the transfer of %s"), |
| 15884 | 1706 | purple_xfer_get_filename(xfer)); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1707 | } |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1708 | else |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1709 | { |
|
25359
ea172b7ea601
The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <datallah@pidgin.im>
parents:
24672
diff
changeset
|
1710 | msg = g_strdup(_("File transfer cancelled")); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1711 | } |
| 15884 | 1712 | purple_xfer_conversation_write(xfer, msg, FALSE); |
|
9932
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
1713 | g_free(msg); |
|
5e7cc9975595
[gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents:
9805
diff
changeset
|
1714 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1715 | if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1716 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1717 | if (priv->ops.cancel_send != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1718 | priv->ops.cancel_send(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1719 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1720 | else |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1721 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1722 | if (priv->ops.cancel_recv != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1723 | priv->ops.cancel_recv(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1724 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1725 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1726 | if (priv->watcher != 0) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1727 | purple_input_remove(priv->watcher); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1728 | priv->watcher = 0; |
|
4521
c67f31cc18f4
[gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents:
4518
diff
changeset
|
1729 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1730 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1731 | if (priv->fd != -1) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1732 | close(priv->fd); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1733 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1734 | if (priv->dest_fp != NULL) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1735 | fclose(priv->dest_fp); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1736 | priv->dest_fp = NULL; |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1737 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1738 | |
| 15884 | 1739 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1740 | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1741 | if (ui_ops != NULL && ui_ops->cancel_local != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1742 | ui_ops->cancel_local(xfer); |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1743 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1744 | priv->bytes_remaining = 0; |
| 7805 | 1745 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
1746 | g_object_unref(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1747 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1748 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1749 | void |
| 15884 | 1750 | purple_xfer_cancel_remote(PurpleXfer *xfer) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1751 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1752 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
| 15884 | 1753 | PurpleXferUiOps *ui_ops; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10654
diff
changeset
|
1754 | gchar *msg; |
| 15884 | 1755 | PurpleAccount *account; |
| 1756 | PurpleBuddy *buddy; | |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1757 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1758 | g_return_if_fail(priv != NULL); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1759 | |
| 15884 | 1760 | purple_request_close_with_handle(xfer); |
| 1761 | purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE); | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1762 | priv->end_time = time(NULL); |
|
9771
42bd06e5b1b3
[gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents:
9523
diff
changeset
|
1763 | |
| 15884 | 1764 | account = purple_xfer_get_account(xfer); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1765 | buddy = purple_blist_find_buddy(account, priv->who); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1766 | |
| 15884 | 1767 | if (purple_xfer_get_filename(xfer) != NULL) |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1768 | { |
|
27797
10f6bc89044b
Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
1769 | msg = g_strdup_printf(_("%s cancelled the transfer of %s"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1770 | buddy ? purple_buddy_get_alias(buddy) : priv->who, purple_xfer_get_filename(xfer)); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1771 | } |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1772 | else |
|
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1773 | { |
|
27797
10f6bc89044b
Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents:
27655
diff
changeset
|
1774 | msg = g_strdup_printf(_("%s cancelled the file transfer"), |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1775 | buddy ? purple_buddy_get_alias(buddy) : priv->who); |
|
10470
1a070302fa8c
[gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents:
10259
diff
changeset
|
1776 | } |
| 15884 | 1777 | purple_xfer_conversation_write(xfer, msg, TRUE); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1778 | purple_xfer_error(purple_xfer_get_xfer_type(xfer), account, priv->who, msg); |
|
9771
42bd06e5b1b3
[gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents:
9523
diff
changeset
|
1779 | g_free(msg); |
|
42bd06e5b1b3
[gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents:
9523
diff
changeset
|
1780 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1781 | if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1782 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1783 | if (priv->ops.cancel_send != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1784 | priv->ops.cancel_send(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1785 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1786 | else |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1787 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1788 | if (priv->ops.cancel_recv != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1789 | priv->ops.cancel_recv(xfer); |
|
7272
f8335b8f1f1c
[gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1790 | } |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1791 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1792 | if (priv->watcher != 0) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1793 | purple_input_remove(priv->watcher); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1794 | priv->watcher = 0; |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1795 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1796 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1797 | if (priv->fd != -1) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1798 | close(priv->fd); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1799 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1800 | if (priv->dest_fp != NULL) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1801 | fclose(priv->dest_fp); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1802 | priv->dest_fp = NULL; |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1803 | } |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1804 | |
| 15884 | 1805 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
4675
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1806 | |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1807 | if (ui_ops != NULL && ui_ops->cancel_remote != NULL) |
|
8e0a7b537ca2
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4656
diff
changeset
|
1808 | ui_ops->cancel_remote(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1809 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1810 | priv->bytes_remaining = 0; |
| 7805 | 1811 | |
|
34912
539b7b4d1949
Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34910
diff
changeset
|
1812 | g_object_unref(xfer); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1813 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1814 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1815 | void |
| 15884 | 1816 | purple_xfer_error(PurpleXferType type, PurpleAccount *account, const char *who, const char *msg) |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1817 | { |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1818 | char *title; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1819 | |
|
6240
0390b27fe09d
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1820 | g_return_if_fail(msg != NULL); |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1821 | g_return_if_fail(type != PURPLE_XFER_TYPE_UNKNOWN); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1822 | |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1823 | if (account) { |
| 15884 | 1824 | PurpleBuddy *buddy; |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34656
diff
changeset
|
1825 | buddy = purple_blist_find_buddy(account, who); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1826 | if (buddy) |
| 15884 | 1827 | who = purple_buddy_get_alias(buddy); |
|
10654
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1828 | } |
|
b2dd3be1b087
[gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents:
10589
diff
changeset
|
1829 | |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
1830 | if (type == PURPLE_XFER_TYPE_SEND) |
|
11231
1c5968418ca4
[gaim-migrate @ 13371]
Richard Laager <rlaager@pidgin.im>
parents:
11159
diff
changeset
|
1831 | title = g_strdup_printf(_("File transfer to %s failed."), who); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1832 | else |
|
11231
1c5968418ca4
[gaim-migrate @ 13371]
Richard Laager <rlaager@pidgin.im>
parents:
11159
diff
changeset
|
1833 | title = g_strdup_printf(_("File transfer from %s failed."), who); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1834 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1835 | purple_notify_error(NULL, NULL, title, msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1836 | purple_request_cpar_from_account(account)); |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1837 | |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1838 | g_free(title); |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1839 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
1840 | |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1841 | void |
| 15884 | 1842 | purple_xfer_update_progress(PurpleXfer *xfer) |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1843 | { |
| 15884 | 1844 | PurpleXferUiOps *ui_ops; |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1845 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1846 | g_return_if_fail(PURPLE_IS_XFER(xfer)); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1847 | |
| 15884 | 1848 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1849 | if (ui_ops != NULL && ui_ops->update_progress != NULL) |
| 15884 | 1850 | ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer)); |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1851 | } |
|
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1852 | |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
1853 | gconstpointer |
|
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
1854 | purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len) |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1855 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1856 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1857 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1858 | g_return_val_if_fail(priv != NULL, NULL); |
|
30115
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1859 | |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
1860 | if (len) |
|
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
1861 | *len = priv->thumbnail_size; |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1862 | |
|
30126
f09ecb81212c
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30124
diff
changeset
|
1863 | return priv->thumbnail_data; |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1864 | } |
|
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1865 | |
|
30113
f60cbf3b3ca9
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents:
29846
diff
changeset
|
1866 | const gchar * |
|
f60cbf3b3ca9
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents:
29846
diff
changeset
|
1867 | purple_xfer_get_thumbnail_mimetype(const PurpleXfer *xfer) |
|
f60cbf3b3ca9
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents:
29846
diff
changeset
|
1868 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1869 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1870 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1871 | g_return_val_if_fail(priv != NULL, NULL); |
|
30115
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1872 | |
|
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1873 | return priv->thumbnail_mimetype; |
|
30113
f60cbf3b3ca9
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents:
29846
diff
changeset
|
1874 | } |
|
f60cbf3b3ca9
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents:
29846
diff
changeset
|
1875 | |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1876 | void |
|
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1877 | purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail, |
|
30113
f60cbf3b3ca9
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents:
29846
diff
changeset
|
1878 | gsize size, const gchar *mimetype) |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1879 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1880 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1881 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1882 | g_return_if_fail(priv != NULL); |
|
30115
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1883 | |
|
30124
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1884 | g_free(priv->thumbnail_data); |
|
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1885 | g_free(priv->thumbnail_mimetype); |
|
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1886 | |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1887 | if (thumbnail && size > 0) { |
|
30115
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1888 | priv->thumbnail_data = g_memdup(thumbnail, size); |
|
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1889 | priv->thumbnail_size = size; |
|
619d2b5758c0
Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents:
30114
diff
changeset
|
1890 | priv->thumbnail_mimetype = g_strdup(mimetype); |
|
30124
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1891 | } else { |
|
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1892 | priv->thumbnail_data = NULL; |
|
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1893 | priv->thumbnail_size = 0; |
|
e84a06d70326
Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30123
diff
changeset
|
1894 | priv->thumbnail_mimetype = NULL; |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1895 | } |
|
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1896 | } |
|
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1897 | |
|
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1898 | void |
|
30114
8472e53fbbfc
Set desired image formats for thumbnails as a parameter to
Marcus Lundblad <malu@pidgin.im>
parents:
30113
diff
changeset
|
1899 | purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats) |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1900 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1901 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1902 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1903 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1904 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1905 | if (priv->ui_ops->add_thumbnail) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1906 | priv->ui_ops->add_thumbnail(xfer, formats); |
|
27419
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1907 | } |
|
5cdc131e86a2
Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents:
26726
diff
changeset
|
1908 | } |
|
8585
23db71a2d432
[gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents:
8351
diff
changeset
|
1909 | |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1910 | void |
|
32248
aa63f22a6e6a
Rename field for consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
32239
diff
changeset
|
1911 | purple_xfer_set_protocol_data(PurpleXfer *xfer, gpointer proto_data) |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1912 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1913 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1914 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1915 | g_return_if_fail(priv != NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1916 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1917 | priv->proto_data = proto_data; |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1918 | } |
|
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1919 | |
|
32248
aa63f22a6e6a
Rename field for consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
32239
diff
changeset
|
1920 | gpointer |
|
32256
620e4580252a
These pointers should rather be marked const.
Andrew Victor <andrew.victor@mxit.com>
parents:
32249
diff
changeset
|
1921 | purple_xfer_get_protocol_data(const PurpleXfer *xfer) |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1922 | { |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1923 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1924 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1925 | g_return_val_if_fail(priv != NULL, NULL); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1926 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1927 | return priv->proto_data; |
|
32239
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1928 | } |
|
3d93edd94500
Introduce API purple_xfer_get_protocol_data() and purple_xfer_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
31754
diff
changeset
|
1929 | |
|
32249
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1930 | void purple_xfer_set_ui_data(PurpleXfer *xfer, gpointer ui_data) |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1931 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1932 | g_return_if_fail(PURPLE_IS_XFER(xfer)); |
|
32249
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1933 | |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1934 | xfer->ui_data = ui_data; |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1935 | } |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1936 | |
|
32256
620e4580252a
These pointers should rather be marked const.
Andrew Victor <andrew.victor@mxit.com>
parents:
32249
diff
changeset
|
1937 | gpointer purple_xfer_get_ui_data(const PurpleXfer *xfer) |
|
32249
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1938 | { |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1939 | g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL); |
|
32249
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1940 | |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1941 | return xfer->ui_data; |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1942 | } |
|
b636d2273c64
Added accessor functions purple_xfer_get_ui_data() and purple_xfer_set_ui_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32248
diff
changeset
|
1943 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1944 | /************************************************************************** |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1945 | * GObject code |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
1946 | **************************************************************************/ |
| 34925 | 1947 | /* Set method for GObject properties */ |
| 1948 | static void | |
| 1949 | purple_xfer_set_property(GObject *obj, guint param_id, const GValue *value, | |
| 1950 | GParamSpec *pspec) | |
| 1951 | { | |
| 1952 | PurpleXfer *xfer = PURPLE_XFER(obj); | |
| 1953 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); | |
| 1954 | ||
| 1955 | switch (param_id) { | |
| 1956 | case PROP_TYPE: | |
| 1957 | priv->type = g_value_get_enum(value); | |
| 1958 | break; | |
| 1959 | case PROP_ACCOUNT: | |
| 1960 | priv->account = g_value_get_object(value); | |
| 1961 | break; | |
| 1962 | case PROP_REMOTE_USER: | |
| 1963 | purple_xfer_set_remote_user(xfer, g_value_get_string(value)); | |
| 1964 | break; | |
| 1965 | case PROP_MESSAGE: | |
| 1966 | purple_xfer_set_message(xfer, g_value_get_string(value)); | |
| 1967 | break; | |
| 1968 | case PROP_FILENAME: | |
| 1969 | purple_xfer_set_filename(xfer, g_value_get_string(value)); | |
| 1970 | break; | |
| 1971 | case PROP_LOCAL_FILENAME: | |
| 1972 | purple_xfer_set_local_filename(xfer, g_value_get_string(value)); | |
| 1973 | break; | |
| 1974 | case PROP_FILE_SIZE: | |
| 1975 | purple_xfer_set_size(xfer, g_value_get_int64(value)); | |
| 1976 | break; | |
| 1977 | case PROP_LOCAL_PORT: | |
| 1978 | purple_xfer_set_local_port(xfer, g_value_get_int(value)); | |
| 1979 | break; | |
| 1980 | case PROP_FD: | |
| 1981 | purple_xfer_set_fd(xfer, g_value_get_int(value)); | |
| 1982 | break; | |
| 1983 | case PROP_WATCHER: | |
| 1984 | purple_xfer_set_watcher(xfer, g_value_get_int(value)); | |
| 1985 | break; | |
| 1986 | case PROP_BYTES_SENT: | |
| 1987 | purple_xfer_set_bytes_sent(xfer, g_value_get_int64(value)); | |
| 1988 | break; | |
| 1989 | case PROP_STATUS: | |
| 1990 | purple_xfer_set_status(xfer, g_value_get_enum(value)); | |
| 1991 | break; | |
| 1992 | default: | |
| 1993 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); | |
| 1994 | break; | |
| 1995 | } | |
| 1996 | } | |
| 1997 | ||
| 1998 | /* Get method for GObject properties */ | |
| 1999 | static void | |
| 2000 | purple_xfer_get_property(GObject *obj, guint param_id, GValue *value, | |
| 2001 | GParamSpec *pspec) | |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2002 | { |
| 34925 | 2003 | PurpleXfer *xfer = PURPLE_XFER(obj); |
| 2004 | ||
| 2005 | switch (param_id) { | |
| 2006 | case PROP_TYPE: | |
| 2007 | g_value_set_enum(value, purple_xfer_get_xfer_type(xfer)); | |
| 2008 | break; | |
| 2009 | case PROP_ACCOUNT: | |
| 2010 | g_value_set_object(value, purple_xfer_get_account(xfer)); | |
| 2011 | break; | |
| 2012 | case PROP_REMOTE_USER: | |
| 2013 | g_value_set_string(value, purple_xfer_get_remote_user(xfer)); | |
| 2014 | break; | |
| 2015 | case PROP_MESSAGE: | |
| 2016 | g_value_set_string(value, purple_xfer_get_message(xfer)); | |
| 2017 | break; | |
| 2018 | case PROP_FILENAME: | |
| 2019 | g_value_set_string(value, purple_xfer_get_filename(xfer)); | |
| 2020 | break; | |
| 2021 | case PROP_LOCAL_FILENAME: | |
| 2022 | g_value_set_string(value, purple_xfer_get_local_filename(xfer)); | |
| 2023 | break; | |
| 2024 | case PROP_FILE_SIZE: | |
| 2025 | g_value_set_int64(value, purple_xfer_get_size(xfer)); | |
| 2026 | break; | |
| 2027 | case PROP_REMOTE_IP: | |
| 2028 | g_value_set_string(value, purple_xfer_get_remote_ip(xfer)); | |
| 2029 | break; | |
| 2030 | case PROP_LOCAL_PORT: | |
| 2031 | g_value_set_int(value, purple_xfer_get_local_port(xfer)); | |
| 2032 | break; | |
| 2033 | case PROP_REMOTE_PORT: | |
| 2034 | g_value_set_int(value, purple_xfer_get_remote_port(xfer)); | |
| 2035 | break; | |
| 2036 | case PROP_FD: | |
| 2037 | g_value_set_int(value, purple_xfer_get_fd(xfer)); | |
| 2038 | break; | |
| 2039 | case PROP_WATCHER: | |
| 2040 | g_value_set_int(value, purple_xfer_get_watcher(xfer)); | |
| 2041 | break; | |
| 2042 | case PROP_BYTES_SENT: | |
| 2043 | g_value_set_int64(value, purple_xfer_get_bytes_sent(xfer)); | |
| 2044 | break; | |
| 2045 | case PROP_START_TIME: | |
| 2046 | #if SIZEOF_TIME_T == 4 | |
| 2047 | g_value_set_int(value, purple_xfer_get_start_time(xfer)); | |
| 2048 | #elif SIZEOF_TIME_T == 8 | |
| 2049 | g_value_set_int64(value, purple_xfer_get_start_time(xfer)); | |
| 2050 | #else | |
| 2051 | #error Unknown size of time_t | |
| 2052 | #endif | |
| 2053 | break; | |
| 2054 | case PROP_END_TIME: | |
| 2055 | #if SIZEOF_TIME_T == 4 | |
| 2056 | g_value_set_int(value, purple_xfer_get_end_time(xfer)); | |
| 2057 | #elif SIZEOF_TIME_T == 8 | |
| 2058 | g_value_set_int64(value, purple_xfer_get_end_time(xfer)); | |
| 2059 | #else | |
| 2060 | #error Unknown size of time_t | |
| 2061 | #endif | |
| 2062 | break; | |
| 2063 | case PROP_STATUS: | |
| 2064 | g_value_set_enum(value, purple_xfer_get_status(xfer)); | |
| 2065 | break; | |
| 2066 | default: | |
| 2067 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); | |
| 2068 | break; | |
| 2069 | } | |
| 2070 | } | |
| 2071 | ||
| 2072 | /* GObject initialization function */ | |
| 2073 | static void | |
| 2074 | purple_xfer_init(GTypeInstance *instance, gpointer klass) | |
| 2075 | { | |
| 2076 | PurpleXfer *xfer = PURPLE_XFER(instance); | |
| 2077 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); | |
| 2078 | ||
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2079 | PURPLE_DBUS_REGISTER_POINTER(xfer, PurpleXfer); |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2080 | |
| 34925 | 2081 | priv->ui_ops = purple_xfers_get_ui_ops(); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2082 | priv->message = NULL; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2083 | priv->current_buffer_size = FT_INITIAL_BUFFER_SIZE; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2084 | priv->fd = -1; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2085 | priv->ready = PURPLE_XFER_READY_NONE; |
| 34925 | 2086 | } |
| 2087 | ||
| 2088 | /* Called when done constructing */ | |
| 2089 | static void | |
| 2090 | purple_xfer_constructed(GObject *object) | |
| 2091 | { | |
| 2092 | PurpleXfer *xfer = PURPLE_XFER(object); | |
| 2093 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); | |
| 2094 | PurpleXferUiOps *ui_ops; | |
| 2095 | ||
| 2096 | parent_class->constructed(object); | |
| 2097 | ||
| 2098 | ui_ops = purple_xfers_get_ui_ops(); | |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2099 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2100 | if (ui_ops && ui_ops->data_not_sent) { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2101 | /* If the ui will handle unsent data no need for buffer */ |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2102 | priv->buffer = NULL; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2103 | } else { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2104 | priv->buffer = g_byte_array_sized_new(FT_INITIAL_BUFFER_SIZE); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2105 | } |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2106 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2107 | if (ui_ops != NULL && ui_ops->new_xfer != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2108 | ui_ops->new_xfer(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2109 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2110 | xfers = g_list_prepend(xfers, xfer); |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2111 | } |
|
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2112 | |
|
34986
894c29e33300
Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents:
34983
diff
changeset
|
2113 | /* GObject finalize function */ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2114 | static void |
|
34986
894c29e33300
Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents:
34983
diff
changeset
|
2115 | purple_xfer_finalize(GObject *object) |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2116 | { |
| 34925 | 2117 | PurpleXfer *xfer = PURPLE_XFER(object); |
|
34986
894c29e33300
Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents:
34983
diff
changeset
|
2118 | PurpleXferPrivate *priv = PURPLE_XFER_GET_PRIVATE(xfer); |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2119 | PurpleXferUiOps *ui_ops; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2120 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2121 | /* Close the file browser, if it's open */ |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2122 | purple_request_close_with_handle(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2123 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2124 | if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2125 | purple_xfer_cancel_local(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2126 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2127 | ui_ops = purple_xfer_get_ui_ops(xfer); |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2128 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2129 | if (ui_ops != NULL && ui_ops->destroy != NULL) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2130 | ui_ops->destroy(xfer); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2131 | |
| 34925 | 2132 | xfers = g_list_remove(xfers, xfer); |
| 2133 | ||
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2134 | g_free(priv->who); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2135 | g_free(priv->filename); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2136 | g_free(priv->remote_ip); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2137 | g_free(priv->local_filename); |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2138 | |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2139 | if (priv->buffer) |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2140 | g_byte_array_free(priv->buffer, TRUE); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2141 | |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2142 | g_free(priv->thumbnail_data); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2143 | g_free(priv->thumbnail_mimetype); |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2144 | |
|
34986
894c29e33300
Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents:
34983
diff
changeset
|
2145 | PURPLE_DBUS_UNREGISTER_POINTER(xfer); |
|
894c29e33300
Move all object destruction code to finalize() methods and keep unrefs in dispose()
Ankit Vani <a@nevitus.org>
parents:
34983
diff
changeset
|
2146 | |
| 34925 | 2147 | parent_class->finalize(object); |
| 2148 | } | |
| 2149 | ||
| 2150 | /* Class initializer function */ | |
| 2151 | static void | |
| 2152 | purple_xfer_class_init(PurpleXferClass *klass) | |
| 2153 | { | |
| 2154 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); | |
| 2155 | ||
| 2156 | parent_class = g_type_class_peek_parent(klass); | |
| 2157 | ||
| 2158 | obj_class->finalize = purple_xfer_finalize; | |
| 2159 | obj_class->constructed = purple_xfer_constructed; | |
| 2160 | ||
| 2161 | /* Setup properties */ | |
| 2162 | obj_class->get_property = purple_xfer_get_property; | |
| 2163 | obj_class->set_property = purple_xfer_set_property; | |
| 2164 | ||
| 2165 | g_object_class_install_property(obj_class, PROP_TYPE, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2166 | g_param_spec_enum("type", _("Transfer type"), |
| 34925 | 2167 | _("The type of file transfer."), PURPLE_TYPE_XFER_TYPE, |
|
34926
c5b444d1447d
Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents:
34925
diff
changeset
|
2168 | PURPLE_XFER_TYPE_UNKNOWN, |
| 34925 | 2169 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY) |
| 2170 | ); | |
| 2171 | ||
| 2172 | g_object_class_install_property(obj_class, PROP_ACCOUNT, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2173 | g_param_spec_object("account", _("Account"), |
| 34925 | 2174 | _("The account sending or receiving the file."), |
| 2175 | PURPLE_TYPE_ACCOUNT, | |
| 2176 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY) | |
| 2177 | ); | |
| 2178 | ||
| 2179 | g_object_class_install_property(obj_class, PROP_REMOTE_USER, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2180 | g_param_spec_string("remote-user", _("Remote user"), |
| 34925 | 2181 | _("The name of the remote user."), NULL, |
| 2182 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT) | |
| 2183 | ); | |
| 2184 | ||
| 2185 | g_object_class_install_property(obj_class, PROP_MESSAGE, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2186 | g_param_spec_string("message", _("Message"), |
| 34925 | 2187 | _("The message for the file transfer."), NULL, |
| 2188 | G_PARAM_READWRITE) | |
| 2189 | ); | |
| 2190 | ||
| 2191 | g_object_class_install_property(obj_class, PROP_FILENAME, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2192 | g_param_spec_string("filename", _("Filename"), |
| 34925 | 2193 | _("The filename for the file transfer."), NULL, |
| 2194 | G_PARAM_READWRITE) | |
| 2195 | ); | |
| 2196 | ||
| 2197 | g_object_class_install_property(obj_class, PROP_LOCAL_FILENAME, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2198 | g_param_spec_string("local-filename", _("Local filename"), |
| 34925 | 2199 | _("The local filename for the file transfer."), NULL, |
| 2200 | G_PARAM_READWRITE) | |
| 2201 | ); | |
| 2202 | ||
| 2203 | g_object_class_install_property(obj_class, PROP_FILE_SIZE, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2204 | g_param_spec_int64("file-size", _("File size"), |
| 34925 | 2205 | _("Size of the file in a file transfer."), |
| 2206 | G_MININT64, G_MAXINT64, 0, | |
| 2207 | G_PARAM_READWRITE) | |
| 2208 | ); | |
| 2209 | ||
| 2210 | g_object_class_install_property(obj_class, PROP_REMOTE_IP, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2211 | g_param_spec_string("remote-ip", _("Remote IP"), |
| 34925 | 2212 | _("The remote IP address in the file transfer."), NULL, |
| 2213 | G_PARAM_READABLE) | |
| 2214 | ); | |
| 2215 | ||
| 2216 | g_object_class_install_property(obj_class, PROP_LOCAL_PORT, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2217 | g_param_spec_int("local-port", _("Local port"), |
| 34925 | 2218 | _("The local port number in the file transfer."), |
| 2219 | G_MININT, G_MAXINT, 0, | |
| 2220 | G_PARAM_READWRITE) | |
| 2221 | ); | |
| 2222 | ||
| 2223 | g_object_class_install_property(obj_class, PROP_REMOTE_PORT, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2224 | g_param_spec_int("remote-port", _("Remote port"), |
| 34925 | 2225 | _("The remote port number in the file transfer."), |
| 2226 | G_MININT, G_MAXINT, 0, | |
| 2227 | G_PARAM_READABLE) | |
| 2228 | ); | |
| 2229 | ||
| 2230 | g_object_class_install_property(obj_class, PROP_FD, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2231 | g_param_spec_int("fd", _("Socket FD"), |
| 34925 | 2232 | _("The socket file descriptor."), |
| 2233 | G_MININT, G_MAXINT, 0, | |
| 2234 | G_PARAM_READWRITE) | |
| 2235 | ); | |
| 2236 | ||
| 2237 | g_object_class_install_property(obj_class, PROP_WATCHER, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2238 | g_param_spec_int("watcher", _("Watcher"), |
| 34925 | 2239 | _("The watcher for the file transfer."), |
| 2240 | G_MININT, G_MAXINT, 0, | |
| 2241 | G_PARAM_READWRITE) | |
| 2242 | ); | |
| 2243 | ||
| 2244 | g_object_class_install_property(obj_class, PROP_BYTES_SENT, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2245 | g_param_spec_int64("bytes-sent", _("Bytes sent"), |
| 34925 | 2246 | _("The number of bytes sent (or received) so far."), |
| 2247 | G_MININT64, G_MAXINT64, 0, | |
| 2248 | G_PARAM_READWRITE) | |
| 2249 | ); | |
| 2250 | ||
| 2251 | g_object_class_install_property(obj_class, PROP_START_TIME, | |
| 2252 | #if SIZEOF_TIME_T == 4 | |
| 2253 | g_param_spec_int | |
| 2254 | #elif SIZEOF_TIME_T == 8 | |
| 2255 | g_param_spec_int64 | |
| 2256 | #else | |
| 2257 | #error Unknown size of time_t | |
| 2258 | #endif | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2259 | ("start-time", _("Start time"), |
| 34925 | 2260 | _("The time the transfer of a file started."), |
| 2261 | #if SIZEOF_TIME_T == 4 | |
| 2262 | G_MININT, G_MAXINT, 0, | |
| 2263 | #elif SIZEOF_TIME_T == 8 | |
| 2264 | G_MININT64, G_MAXINT64, 0, | |
| 2265 | #else | |
| 2266 | #error Unknown size of time_t | |
| 2267 | #endif | |
| 2268 | G_PARAM_READABLE) | |
| 2269 | ); | |
| 2270 | ||
| 2271 | g_object_class_install_property(obj_class, PROP_END_TIME, | |
| 2272 | #if SIZEOF_TIME_T == 4 | |
| 2273 | g_param_spec_int | |
| 2274 | #elif SIZEOF_TIME_T == 8 | |
| 2275 | g_param_spec_int64 | |
| 2276 | #else | |
| 2277 | #error Unknown size of time_t | |
| 2278 | #endif | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2279 | ("end-time", _("End time"), |
| 34925 | 2280 | _("The time the transfer of a file ended."), |
| 2281 | #if SIZEOF_TIME_T == 4 | |
| 2282 | G_MININT, G_MAXINT, 0, | |
| 2283 | #elif SIZEOF_TIME_T == 8 | |
| 2284 | G_MININT64, G_MAXINT64, 0, | |
| 2285 | #else | |
| 2286 | #error Unknown size of time_t | |
| 2287 | #endif | |
| 2288 | G_PARAM_READABLE) | |
| 2289 | ); | |
| 2290 | ||
| 2291 | g_object_class_install_property(obj_class, PROP_STATUS, | |
|
35013
4718438d053b
Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents:
35001
diff
changeset
|
2292 | g_param_spec_enum("status", _("Status"), |
| 34925 | 2293 | _("The current status for the file transfer."), |
| 2294 | PURPLE_TYPE_XFER_STATUS, PURPLE_XFER_STATUS_UNKNOWN, | |
| 2295 | G_PARAM_READWRITE) | |
| 2296 | ); | |
| 2297 | ||
| 2298 | g_type_class_add_private(klass, sizeof(PurpleXferPrivate)); | |
| 2299 | } | |
| 2300 | ||
| 2301 | GType | |
| 2302 | purple_xfer_get_type(void) | |
| 2303 | { | |
| 2304 | static GType type = 0; | |
| 2305 | ||
| 2306 | if(type == 0) { | |
| 2307 | static const GTypeInfo info = { | |
| 2308 | sizeof(PurpleXferClass), | |
| 2309 | NULL, | |
| 2310 | NULL, | |
| 2311 | (GClassInitFunc)purple_xfer_class_init, | |
| 2312 | NULL, | |
| 2313 | NULL, | |
| 2314 | sizeof(PurpleXfer), | |
| 2315 | 0, | |
| 2316 | (GInstanceInitFunc)purple_xfer_init, | |
| 2317 | NULL, | |
| 2318 | }; | |
| 2319 | ||
| 2320 | type = g_type_register_static(G_TYPE_OBJECT, "PurpleXfer", | |
| 2321 | &info, 0); | |
| 2322 | } | |
| 2323 | ||
| 2324 | return type; | |
| 2325 | } | |
| 2326 | ||
| 2327 | PurpleXfer * | |
| 2328 | purple_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who) | |
| 2329 | { | |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2330 | PurpleXfer *xfer; |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2331 | PurpleProtocol *protocol; |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2332 | |
|
34983
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
2333 | g_return_val_if_fail(type != PURPLE_XFER_TYPE_UNKNOWN, NULL); |
|
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
2334 | g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); |
|
81638be26f41
Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
2335 | g_return_val_if_fail(who != NULL, NULL); |
| 34925 | 2336 | |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2337 | protocol = purple_protocols_find(purple_account_get_protocol_id(account)); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2338 | |
|
36844
b62140058cd3
Check for valid PurpleProtocols
Ankit Vani <a@nevitus.org>
parents:
36843
diff
changeset
|
2339 | g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL); |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2340 | |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2341 | if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, FACTORY_IFACE, xfer_new)) |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2342 | xfer = purple_protocol_factory_iface_xfer_new(protocol, account, type, |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2343 | who); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2344 | else |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2345 | xfer = g_object_new(PURPLE_TYPE_XFER, |
| 36872 | 2346 | "account", account, |
| 2347 | "type", type, | |
| 2348 | "remote-user", who, | |
|
36728
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2349 | NULL |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2350 | ); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2351 | |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2352 | g_return_val_if_fail(xfer != NULL, NULL); |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2353 | |
|
313d07370a7b
Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents:
36715
diff
changeset
|
2354 | return xfer; |
|
34792
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2355 | } |
|
09228ea79272
Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
2356 | |
|
6263
6fec763a314c
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
2357 | /************************************************************************** |
|
6fec763a314c
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
2358 | * File Transfer Subsystem API |
|
6fec763a314c
[gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents:
6242
diff
changeset
|
2359 | **************************************************************************/ |
|
34922
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2360 | GList * |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2361 | purple_xfers_get_all() |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2362 | { |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2363 | return xfers; |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2364 | } |
|
6043d2b7f55a
Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents:
34919
diff
changeset
|
2365 | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2366 | void * |
| 15884 | 2367 | purple_xfers_get_handle(void) { |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2368 | static int handle = 0; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2369 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2370 | return &handle; |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2371 | } |
|
6241
34d166a31152
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
2372 | |
|
34d166a31152
[gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
2373 | void |
| 15884 | 2374 | purple_xfers_init(void) { |
| 2375 | void *handle = purple_xfers_get_handle(); | |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2376 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2377 | /* register signals */ |
| 15884 | 2378 | purple_signal_register(handle, "file-recv-accept", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2379 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2380 | PURPLE_TYPE_XFER); |
| 15884 | 2381 | purple_signal_register(handle, "file-send-accept", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2382 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2383 | PURPLE_TYPE_XFER); |
| 15884 | 2384 | purple_signal_register(handle, "file-recv-start", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2385 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2386 | PURPLE_TYPE_XFER); |
| 15884 | 2387 | purple_signal_register(handle, "file-send-start", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2388 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2389 | PURPLE_TYPE_XFER); |
| 15884 | 2390 | purple_signal_register(handle, "file-send-cancel", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2391 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2392 | PURPLE_TYPE_XFER); |
| 15884 | 2393 | purple_signal_register(handle, "file-recv-cancel", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2394 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2395 | PURPLE_TYPE_XFER); |
| 15884 | 2396 | purple_signal_register(handle, "file-send-complete", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2397 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2398 | PURPLE_TYPE_XFER); |
| 15884 | 2399 | purple_signal_register(handle, "file-recv-complete", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2400 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2401 | PURPLE_TYPE_XFER); |
| 15884 | 2402 | purple_signal_register(handle, "file-recv-request", |
|
34818
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2403 | purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, |
|
a65e961e1e29
Refactored core, ft, imgstore to use GType instead of PurpleValue
Ankit Vani <a@nevitus.org>
parents:
34798
diff
changeset
|
2404 | PURPLE_TYPE_XFER); |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2405 | } |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2406 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2407 | void |
|
21143
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
2408 | purple_xfers_uninit(void) |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
2409 | { |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
2410 | void *handle = purple_xfers_get_handle(); |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
2411 | |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
2412 | purple_signals_disconnect_by_handle(handle); |
|
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20661
diff
changeset
|
2413 | purple_signals_unregister_by_instance(handle); |
|
11281
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2414 | } |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2415 | |
|
a5cda37a16be
[gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11231
diff
changeset
|
2416 | void |
| 15884 | 2417 | purple_xfers_set_ui_ops(PurpleXferUiOps *ops) { |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
2418 | xfer_ui_ops = ops; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
2419 | } |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
2420 | |
| 15884 | 2421 | PurpleXferUiOps * |
| 2422 | purple_xfers_get_ui_ops(void) { | |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
2423 | return xfer_ui_ops; |
|
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4249
diff
changeset
|
2424 | } |