libpurple/xfer.c

Tue, 02 Mar 2021 23:22:34 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 02 Mar 2021 23:22:34 -0600
changeset 40804
5496016b3c00
parent 40756
3a58ef28ee44
child 40885
87f6241da196
permissions
-rw-r--r--

Port libpurple from purple_protocols_ to purple_protocol_manager_

Testing Done:
Compiled and ran locally.

Bugs closed: PIDGIN-17472

Reviewed at https://reviews.imfreedom.org/r/538/

20330
650a7af9c238 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents: 19859
diff changeset
1 /* purple
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7820
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7820
diff changeset
5 * source distribution.
4538
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
6 *
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * (at your option) any later version.
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 *
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * GNU General Public License for more details.
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 *
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * 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
19 * 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
20 *
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 */
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
22
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
23 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
25 #include "internal.h"
40195
fb4b0ae193c0 Remove glibcompat.h from all the files that don't actually need it.
Gary Kramlich <grim@reaperworld.com>
parents: 40146
diff changeset
26 #include "glibcompat.h" /* for purple_g_stat on win32 */
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
27
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40334
diff changeset
28 #include <glib/gstdio.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40334
diff changeset
29
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
30 #include "debug.h"
34927
cef809309dbf Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
31 #include "enums.h"
40756
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40648
diff changeset
32 #include "glibcompat.h"
35813
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
33 #include "image-store.h"
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8208
diff changeset
34 #include "network.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
35 #include "notify.h"
6241
34d166a31152 [gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
36 #include "prefs.h"
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #include "proxy.h"
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
38 #include "purple-gio.h"
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
39 #include "request.h"
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
40 #include "util.h"
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
41 #include "xfer.h"
5494
410d120ef10d [gaim-migrate @ 5890]
Herman Bloggs <herman@bluedigits.com>
parents: 5436
diff changeset
42
15280
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
43 #define FT_INITIAL_BUFFER_SIZE 4096
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
44 #define FT_MAX_BUFFER_SIZE 65535
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
45
34909
91be147083c6 Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents: 34892
diff changeset
46 typedef struct _PurpleXferPrivate PurpleXferPrivate;
91be147083c6 Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents: 34892
diff changeset
47
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
48 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
49 static GList *xfers;
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
35466
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
51 /* Private data for a file transfer */
34909
91be147083c6 Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents: 34892
diff changeset
52 struct _PurpleXferPrivate {
35466
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
53 PurpleXferType type; /* The type of transfer. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
54
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
55 PurpleAccount *account; /* The account. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
56
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
57 char *who; /* The person on the other end of the
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
58 transfer. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
59
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
60 char *message; /* A message sent with the request */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
61 char *filename; /* The name sent over the network. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
62 char *local_filename; /* The name on the local hard drive. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
63 goffset size; /* The size of the file. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
64
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
65 FILE *dest_fp; /* The destination file pointer. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
66
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
67 char *remote_ip; /* The remote IP address. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
68 guint16 local_port; /* The local port. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
69 guint16 remote_port; /* The remote port. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
70
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
71 GSocketConnection *conn; /* The socket connection. */
35466
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
72 int fd; /* The socket file descriptor. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
73 int watcher; /* Watcher. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
74
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
75 goffset bytes_sent; /* The number of bytes sent. */
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
76 gint64 start_time; /* When the transfer of data began. */
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
77 gint64 end_time; /* When the transfer of data ended. */
35466
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
78
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
79 size_t current_buffer_size; /* This gradually increases for fast
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
80 network connections. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
81
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
82 PurpleXferStatus status; /* File Transfer's status. */
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
83
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
84 gboolean visible; /* Hint the UI that the transfer should
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
85 be visible or not. */
35466
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
86 PurpleXferUiOps *ui_ops; /* UI-specific operations. */
34909
91be147083c6 Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents: 34892
diff changeset
87
28156
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
88 /*
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
89 * 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
90 * 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
91 * 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
92 */
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
93 enum {
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
94 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
95 PURPLE_XFER_READY_UI = 0x1,
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
96 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
97 } 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
98
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
99 /* 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
100 GByteArray *buffer;
30115
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
101
35466
e259e75f1c6f Fix some gtk-doc warnings till xmlnode.h
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
102 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
103 gsize thumbnail_size;
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
104 gchar *thumbnail_mimetype;
34909
91be147083c6 Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents: 34892
diff changeset
105 };
28156
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
106
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
107 /* GObject property enums */
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
108 enum
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
109 {
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
110 PROP_0,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
111 PROP_TYPE,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
112 PROP_ACCOUNT,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
113 PROP_REMOTE_USER,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
114 PROP_MESSAGE,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
115 PROP_FILENAME,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
116 PROP_LOCAL_FILENAME,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
117 PROP_FILE_SIZE,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
118 PROP_REMOTE_IP,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
119 PROP_LOCAL_PORT,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
120 PROP_REMOTE_PORT,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
121 PROP_FD,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
122 PROP_WATCHER,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
123 PROP_BYTES_SENT,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
124 PROP_START_TIME,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
125 PROP_END_TIME,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
126 PROP_STATUS,
40255
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
127 PROP_PROGRESS,
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
128 PROP_VISIBLE,
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
129 PROP_LAST
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
130 };
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
131
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
132 static GParamSpec *properties[PROP_LAST];
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
133
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
134 /* GObject signal enums */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
135 enum
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
136 {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
137 SIG_OPEN_LOCAL,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
138 SIG_QUERY_LOCAL,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
139 SIG_READ_LOCAL,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
140 SIG_WRITE_LOCAL,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
141 SIG_DATA_NOT_SENT,
40257
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
142 SIG_ADD_THUMBNAIL,
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
143 SIG_LAST
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
144 };
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
145 static guint signals[SIG_LAST] = {0};
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
146
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
147 G_DEFINE_TYPE_WITH_PRIVATE(PurpleXfer, purple_xfer, G_TYPE_OBJECT);
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
148
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
149 static int purple_xfer_choose_file(PurpleXfer *xfer);
14967
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
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 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
178 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
179
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
180 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
181
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
182 priv = purple_xfer_get_instance_private(xfer);
9788
ca43717a431b [gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents: 9785
diff changeset
183
29168
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
184 if (purple_debug_is_verbose())
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
185 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
186 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
187 purple_xfer_status_type_to_string(status));
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
188
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
189 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
190 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
191
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
192 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
193
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
194 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_STATUS]);
9788
ca43717a431b [gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents: 9785
diff changeset
195 }
ca43717a431b [gaim-migrate @ 10656]
Dave West <kat@users.sourceforge.net>
parents: 9785
diff changeset
196
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
197 void
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
198 purple_xfer_set_visible(PurpleXfer *xfer, gboolean visible)
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
199 {
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
200 PurpleXferPrivate *priv = NULL;
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
201
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
202 g_return_if_fail(PURPLE_IS_XFER(xfer));
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
203
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
204 priv = purple_xfer_get_instance_private(xfer);
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
205 priv->visible = visible;
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
206
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
207 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_VISIBLE]);
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
208 }
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
209
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31154
diff changeset
210 static void
28722
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
211 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
212 const char *message, gboolean is_error, gboolean print_thumbnail)
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
213 {
34656
adbcbe04077c Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
214 PurpleIMConversation *im = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
215 PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM;
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10654
diff changeset
216 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
217 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
218 gsize size;
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
219 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
220
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
221 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
222
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
223 im = purple_conversations_find_im_with_account(priv->who,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
224 purple_xfer_get_account(xfer));
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
225
34656
adbcbe04077c Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
226 if (im == NULL)
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
227 return;
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
228
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10654
diff changeset
229 escaped = g_markup_escape_text(message, -1);
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
230
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
231 if (is_error)
29019
9cb4fa62242d ft: Properly set a bitmask field (so it includes PURPLE_MESSAGE_SYSTEM like
Florian Quèze <florian@instantbird.org>
parents: 28659
diff changeset
232 flags |= PURPLE_MESSAGE_ERROR;
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
233
28722
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
234 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
235 gchar *message_with_img;
35813
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
236 PurpleImage *img;
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
237 guint id;
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
238
40146
66604f791698 Fix some possible leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39892
diff changeset
239 img = purple_image_new_from_data(thumbnail_data, size);
35813
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
240 id = purple_image_store_add(img);
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
241 g_object_unref(img);
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
242
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
243 message_with_img = g_strdup_printf("<img src=\""
a5b71a95a42a imgstore: remove references from libpurple (not prpls yet)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35812
diff changeset
244 PURPLE_IMAGE_STORE_PROTOCOL "%u\"> %s", id, escaped);
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
245 purple_conversation_write_system_message(
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
246 PURPLE_CONVERSATION(im), message_with_img, flags);
28722
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
247 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
248 } else {
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
249 purple_conversation_write_system_message(
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
250 PURPLE_CONVERSATION(im), escaped, flags);
28722
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
251 }
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10654
diff changeset
252 g_free(escaped);
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
253 }
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
254
28722
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
255 void
33465
215bec3b763a Add const to the API, where needed
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33052
diff changeset
256 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
257 gboolean is_error)
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
258 {
39775
a203f2974c98 Move extraneous NULL-checks in xfer to public function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39670
diff changeset
259 g_return_if_fail(PURPLE_IS_XFER(xfer));
a203f2974c98 Move extraneous NULL-checks in xfer to public function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39670
diff changeset
260 g_return_if_fail(message != NULL);
a203f2974c98 Move extraneous NULL-checks in xfer to public function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39670
diff changeset
261
28722
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
262 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
263 }
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
264
30124
e84a06d70326 Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30123
diff changeset
265 /* 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
266 static void
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
267 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
268 const gchar *message)
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
269 {
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
270 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
271 }
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
272
d53c7b4cf1d2 Print the thumbnail along with the offer message in the conversation
Marcus Lundblad <malu@pidgin.im>
parents: 28720
diff changeset
273
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
274 static void purple_xfer_show_file_error(PurpleXfer *xfer, const char *filename)
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
275 {
10919
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
276 int err = errno;
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
277 gchar *msg = NULL, *utf8;
34910
60502558e400 Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents: 34909
diff changeset
278 PurpleXferType xfer_type = purple_xfer_get_xfer_type(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
279 PurpleAccount *account = purple_xfer_get_account(xfer);
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
280 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
281
10919
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
282 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
283 switch(xfer_type) {
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
284 case PURPLE_XFER_TYPE_SEND:
9796
dd7499147bed [gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents: 9795
diff changeset
285 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
286 utf8, g_strerror(err));
9795
80d4d3be52d7 [gaim-migrate @ 10663]
Luke Schierer <lschiere@pidgin.im>
parents: 9789
diff changeset
287 break;
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
288 case PURPLE_XFER_TYPE_RECEIVE:
9796
dd7499147bed [gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents: 9795
diff changeset
289 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
290 utf8, g_strerror(err));
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
291 break;
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
292 default:
9796
dd7499147bed [gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents: 9795
diff changeset
293 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
294 utf8, g_strerror(err));
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
295 break;
10919
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
296 }
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
297 g_free(utf8);
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
298
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
299 purple_xfer_conversation_write(xfer, msg, TRUE);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
300 purple_xfer_error(xfer_type, account, priv->who, msg);
9796
dd7499147bed [gaim-migrate @ 10664]
Dave West <kat@users.sourceforge.net>
parents: 9795
diff changeset
301 g_free(msg);
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
302 }
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
303
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
304 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
305 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
306 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
307 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
308 PurpleXferType type;
33940
b44d15793c83 Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33661
diff changeset
309 GStatBuf st;
14967
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
310 gchar *dir;
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
311
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
312 xfer = (PurpleXfer *)user_data;
34910
60502558e400 Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents: 34909
diff changeset
313 type = purple_xfer_get_xfer_type(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
314
10589
4e10236e06d4 [gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents: 10504
diff changeset
315 if (g_stat(filename, &st) != 0) {
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
316 /* File not found. */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
317 if (type == PURPLE_XFER_TYPE_RECEIVE) {
15161
7a392764f0b8 [gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents: 14967
diff changeset
318 #ifndef _WIN32
7a392764f0b8 [gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents: 14967
diff changeset
319 int mode = W_OK;
7a392764f0b8 [gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents: 14967
diff changeset
320 #else
7a392764f0b8 [gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents: 14967
diff changeset
321 int mode = F_OK;
7a392764f0b8 [gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents: 14967
diff changeset
322 #endif
14967
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
323 dir = g_path_get_dirname(filename);
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
324
15161
7a392764f0b8 [gaim-migrate @ 17885]
Daniel Atallah <datallah@pidgin.im>
parents: 14967
diff changeset
325 if (g_access(dir, mode) == 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
326 purple_xfer_request_accepted(xfer, filename);
14967
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
327 } else {
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
328 g_object_ref(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
329 purple_notify_message(
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
330 NULL, PURPLE_NOTIFY_MSG_ERROR, NULL,
14967
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
331 _("Directory is not writable."), NULL,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
332 purple_request_cpar_from_account(
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
333 purple_xfer_get_account(xfer)),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
334 (PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer);
14967
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
335 }
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
336
6a418583bf2d [gaim-migrate @ 17677]
Ka-Hing Cheung <khc@pidgin.im>
parents: 14899
diff changeset
337 g_free(dir);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
338 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
339 else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
340 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
341 purple_xfer_cancel_local(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
342 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
343 }
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
344 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
345
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
346 purple_notify_error(NULL, NULL,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
347 _("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
348 purple_request_cpar_from_account(
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
349 purple_xfer_get_account(xfer)));
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
350
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
351 purple_xfer_cancel_local(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
352 }
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
353 else if ((type == PURPLE_XFER_TYPE_SEND) && S_ISDIR(st.st_mode)) {
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
354 /*
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
355 * XXX - Sending a directory should be valid for some protocols.
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
356 */
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
357 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
358 NULL, purple_request_cpar_from_account(
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
359 purple_xfer_get_account(xfer)));
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
360
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
361 purple_xfer_cancel_local(xfer);
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
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_RECEIVE) && S_ISDIR(st.st_mode)) {
10919
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
364 char *msg, *utf8;
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
365 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
366 msg = g_strdup_printf(
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
367 _("%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
368 g_free(utf8);
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
369 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
370 purple_request_cpar_from_account(
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
371 purple_xfer_get_account(xfer)));
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
372 g_free(msg);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
373 purple_xfer_request_denied(xfer);
9785
14fe4689ff01 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
374 }
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
375 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
376 #ifndef _WIN32
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
377 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
378 #else
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
379 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
380 #endif
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
381
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
382 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
383 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
384 } else {
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
385 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
386 purple_notify_message(
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
387 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
388 _("File is not readable."), NULL,
34449
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)),
29156
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
391 (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
392 }
816cd92683eb Check file permissions before sending a file transfer request.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29155
diff changeset
393 }
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
394 else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
395 purple_xfer_request_accepted(xfer, filename);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
396 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
397
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
398 g_object_unref(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
399 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
400
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
401 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
402 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
403 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
404 PurpleXfer *xfer = (PurpleXfer *)user_data;
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
405
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
406 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
407 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
408 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
409 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
410 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
411 g_object_unref(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
412 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
413
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
414 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
415 purple_xfer_choose_file(PurpleXfer *xfer)
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
416 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
417 purple_request_file(xfer, NULL, purple_xfer_get_filename(xfer),
34945
54af0dd9faa5 Fixed build errors
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
418 (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
419 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
420 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
421 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
422 xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
423
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
424 return 0;
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
425 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
426
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
427 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
428 cancel_recv_cb(PurpleXfer *xfer)
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
429 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
430 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
431 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
432 g_object_unref(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
433
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
434 return 0;
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
435 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
436
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
437 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
438 purple_xfer_ask_recv(PurpleXfer *xfer)
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
439 {
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
440 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10654
diff changeset
441 char *buf, *size_buf;
32663
1b87b3e98b0a Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32608
diff changeset
442 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
443 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
444 gsize thumb_size;
9511
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 /* If we have already accepted the request, ask the destination file
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
447 name directly */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
448 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
449 PurpleRequestCommonParameters *cpar;
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
450 PurpleBuddy *buddy = purple_blist_find_buddy(priv->account, priv->who);
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
451
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
452 if (purple_xfer_get_filename(xfer) != NULL)
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
453 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
454 size = purple_xfer_get_size(xfer);
39824
aefdb7ab2475 Replace purple_str_size_to_units by g_format_size.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39823
diff changeset
455 size_buf = g_format_size_full(size, G_FORMAT_SIZE_LONG_FORMAT);
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
456 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
457 buddy ? purple_buddy_get_alias(buddy) : priv->who,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
458 purple_xfer_get_filename(xfer), size_buf);
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
459 g_free(size_buf);
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
460 }
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
461 else
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
462 {
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
463 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
464 buddy ? purple_buddy_get_alias(buddy) : priv->who);
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
465 }
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
466
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
467 if (priv->message != NULL)
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35489
diff changeset
468 purple_serv_got_im(purple_account_get_connection(priv->account),
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
469 priv->who, priv->message, 0, time(NULL));
9933
61bd3fadbfe6 [gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents: 9932
diff changeset
470
34945
54af0dd9faa5 Fixed build errors
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
471 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
472 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
473 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
474 thumb_size);
27427
00f91afbd4d9 Show thumbnail in ft request dialog
Marcus Lundblad <malu@pidgin.im>
parents: 27419
diff changeset
475 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31154
diff changeset
476
34331
c8486462bb63 Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34305
diff changeset
477 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
478 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
479 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
480 G_CALLBACK(cancel_recv_cb));
c8486462bb63 Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34305
diff changeset
481
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
482 g_free(buf);
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
483 } else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
484 purple_xfer_choose_file(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
485 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
486
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
487 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
488 ask_accept_ok(PurpleXfer *xfer)
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
489 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
490 purple_xfer_request_accepted(xfer, NULL);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
491
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
492 return 0;
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
493 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
494
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
495 static int
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
496 ask_accept_cancel(PurpleXfer *xfer)
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
497 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
498 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
499 g_object_unref(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
500
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
501 return 0;
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
502 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
503
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
504 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
505 purple_xfer_ask_accept(PurpleXfer *xfer)
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
506 {
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
507 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
508 char *buf, *buf2 = NULL;
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
509 PurpleBuddy *buddy = purple_blist_find_buddy(priv->account, priv->who);
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 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
512 buddy ? purple_buddy_get_alias(buddy) : priv->who);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
513 if (purple_xfer_get_remote_ip(xfer) &&
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
514 purple_xfer_get_remote_port(xfer))
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
515 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
516 "Remote host: %s\nRemote port: %d"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
517 purple_xfer_get_remote_ip(xfer),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
518 purple_xfer_get_remote_port(xfer));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
519 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
520 PURPLE_DEFAULT_ACTION_NONE,
34945
54af0dd9faa5 Fixed build errors
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
521 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
522 G_CALLBACK(ask_accept_ok), G_CALLBACK(ask_accept_cancel));
9511
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
523 g_free(buf);
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
524 g_free(buf2);
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
525 }
d68f99136f26 [gaim-migrate @ 10338]
Mark Doliner <markdoliner@pidgin.im>
parents: 8585
diff changeset
526
7805
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
527 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
528 purple_xfer_request(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
529 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
530 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
531
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
532 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
533
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
534 /* this is unref'd in the finishers, like cancel and stop */
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
535 g_object_ref(xfer);
4247
a77b46afa096 [gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents: 4245
diff changeset
536
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
537 priv = purple_xfer_get_instance_private(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
538
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
539 if (priv->type == PURPLE_XFER_TYPE_RECEIVE)
13220
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
540 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
541 purple_signal_emit(purple_xfers_get_handle(), "file-recv-request", xfer);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
542 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
543 {
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
544 /* The file-transfer was cancelled by a plugin */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
545 purple_xfer_cancel_local(xfer);
13220
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
546 }
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
547 else if (priv->filename || priv->status == PURPLE_XFER_STATUS_ACCEPTED)
13220
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
548 {
11084
b6acee973833 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents: 10919
diff changeset
549 gchar* message = NULL;
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
550 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
551
11084
b6acee973833 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents: 10919
diff changeset
552 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
553 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
554 purple_xfer_conversation_write_with_thumbnail(xfer, message);
11084
b6acee973833 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents: 10919
diff changeset
555 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
556
13220
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
557 /* 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
558 if (priv->local_filename == NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
559 purple_xfer_ask_recv(xfer);
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 else
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
562 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
563 purple_xfer_ask_accept(xfer);
11084
b6acee973833 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly@users.sourceforge.net>
parents: 10919
diff changeset
564 }
13220
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
565 }
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
566 else
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
567 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
568 purple_xfer_choose_file(xfer);
13220
4eca54b95034 [gaim-migrate @ 15583]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13109
diff changeset
569 }
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570 }
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
572 static gboolean
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
573 do_query_local(PurpleXfer *xfer, const gchar *filename)
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
574 {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
575 GStatBuf st;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
576
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
577 if (g_stat(filename, &st) == -1) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
578 purple_xfer_show_file_error(xfer, filename);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
579 return FALSE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
580 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
581
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
582 purple_xfer_set_size(xfer, st.st_size);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
583 return TRUE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
584 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
585
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
586 void
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
587 purple_xfer_request_accepted(PurpleXfer *xfer, const gchar *filename)
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
588 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
589 PurpleXferClass *klass = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
590 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
591 gchar *msg, *utf8, *base;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
592 PurpleBuddy *buddy;
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
594 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
595
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
596 klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
597 priv = purple_xfer_get_instance_private(xfer);
8585
23db71a2d432 [gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents: 8351
diff changeset
598
29822
7c6c2df6f9a2 whitespace trimming
Paul Aurich <darkrain42@pidgin.im>
parents: 29821
diff changeset
599 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
600
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
601 if(filename == NULL) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
602 if(priv->type == PURPLE_XFER_TYPE_RECEIVE) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
603 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_ACCEPTED);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
604 klass->init(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
605 } else {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
606 purple_debug_warning(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
607 "xfer",
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
608 "can not set file transfer without a file name"
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
609 );
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
610 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
611
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 return;
4150
fd30caf1a296 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
613 }
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
615 buddy = purple_blist_find_buddy(priv->account, priv->who);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
616
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
617 if (priv->type == PURPLE_XFER_TYPE_SEND) {
13595
191c2d12a00c [gaim-migrate @ 15980]
Mark Doliner <markdoliner@pidgin.im>
parents: 13220
diff changeset
618 /* Sending a file */
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
619 /* Check the filename. */
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
620 gboolean query_status;
28150
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
97486eeddc1a [gaim-migrate @ 14225]
Richard Gobeille
parents: 11338
diff changeset
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
97486eeddc1a [gaim-migrate @ 14225]
Richard Gobeille
parents: 11338
diff changeset
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
97486eeddc1a [gaim-migrate @ 14225]
Richard Gobeille
parents: 11338
diff changeset
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
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
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);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
631 purple_xfer_error(priv->type, priv->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
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
638
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
639 g_signal_emit(xfer, signals[SIG_QUERY_LOCAL], 0, filename,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
640 &query_status);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
641 if (!query_status) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
642 g_object_unref(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
643 return;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
644 }
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
645 purple_xfer_set_local_filename(xfer, filename);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
646
26726
b81bcec8f359 Updates for GTK+ 3.0. Remove some deprecated functions (someone should
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26373
diff changeset
647 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
648 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
649 g_free(base);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
650 purple_xfer_set_filename(xfer, utf8);
10919
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
651
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
652 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
653 utf8, buddy ? purple_buddy_get_alias(buddy) : priv->who);
10919
22fba24cd16e [gaim-migrate @ 12683]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10774
diff changeset
654 g_free(utf8);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
655 purple_xfer_conversation_write(xfer, msg, FALSE);
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
656 g_free(msg);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
657 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
658 else {
13595
191c2d12a00c [gaim-migrate @ 15980]
Mark Doliner <markdoliner@pidgin.im>
parents: 13220
diff changeset
659 /* Receiving a file */
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
660 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_ACCEPTED);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
661 purple_xfer_set_local_filename(xfer, filename);
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
662
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
663 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
664 priv->filename, buddy ? purple_buddy_get_alias(buddy) : priv->who);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
665 purple_xfer_conversation_write(xfer, msg, FALSE);
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
666 g_free(msg);
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
667 }
4150
fd30caf1a296 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
668
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
669 purple_xfer_set_visible(xfer, TRUE);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
670
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
671 klass->init(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
672 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
673
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
674 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
675 purple_xfer_request_denied(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
676 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
677 PurpleXferClass *klass = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
678
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
679 g_return_if_fail(PURPLE_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
680
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
681 klass = PURPLE_XFER_GET_CLASS(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
682
29168
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
683 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
684
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
685 if(klass && klass->request_denied) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
686 klass->request_denied(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
687 }
5164
dda3bf92f195 [gaim-migrate @ 5528]
Mark Doliner <markdoliner@pidgin.im>
parents: 5146
diff changeset
688
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
689 g_object_unref(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
690 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
691
32289
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
692 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
693 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
694 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
695
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
696 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
697
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
698 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
699 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
700 }
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 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
703 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
704 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
705
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
706 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
707
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
708 priv = purple_xfer_get_instance_private(xfer);
34922
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
712 PurpleXferType
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
713 purple_xfer_get_xfer_type(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
714 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
715 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
716
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
717 g_return_val_if_fail(PURPLE_IS_XFER(xfer), PURPLE_XFER_TYPE_UNKNOWN);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
718
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
719 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
720 return priv->type;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
721 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
722
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
723 PurpleAccount *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
724 purple_xfer_get_account(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
725 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
726 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
727
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
728 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
729
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
730 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
731 return priv->account;
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
732 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
733
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
734 void
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
735 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
736 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
737 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
738
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
739 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
740
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
741 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
742 g_free(priv->who);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
743 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
744
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
745 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_REMOTE_USER]);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
746 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
747
17852
174c0d122a79 Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17293
diff changeset
748 const char *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
749 purple_xfer_get_remote_user(PurpleXfer *xfer)
17852
174c0d122a79 Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17293
diff changeset
750 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
751 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
752
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
753 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
754
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
755 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
756 return priv->who;
17852
174c0d122a79 Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17293
diff changeset
757 }
174c0d122a79 Add new function purple_xfer_get_remote_user.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17293
diff changeset
758
34909
91be147083c6 Started GObjectification of PurpleXfer.
Ankit Vani <a@nevitus.org>
parents: 34892
diff changeset
759 PurpleXferStatus
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
760 purple_xfer_get_status(PurpleXfer *xfer)
7805
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
761 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
762 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
763
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
764 g_return_val_if_fail(PURPLE_IS_XFER(xfer), PURPLE_XFER_STATUS_UNKNOWN);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
765
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
766 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
767 return priv->status;
7805
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
768 }
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
769
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
770 gboolean
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
771 purple_xfer_get_visible(PurpleXfer *xfer)
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
772 {
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
773 PurpleXferPrivate *priv = NULL;
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
774
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
775 g_return_val_if_fail(PURPLE_IS_XFER(xfer), FALSE);
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
776
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
777 priv = purple_xfer_get_instance_private(xfer);
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
778 return priv->visible;
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
779 }
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
780
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
781 gboolean
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
782 purple_xfer_is_cancelled(PurpleXfer *xfer)
7738
ebb766ef2146 [gaim-migrate @ 8383]
Tim Ringenbach <marv@pidgin.im>
parents: 7272
diff changeset
783 {
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34955
diff changeset
784 g_return_val_if_fail(PURPLE_IS_XFER(xfer), TRUE);
7738
ebb766ef2146 [gaim-migrate @ 8383]
Tim Ringenbach <marv@pidgin.im>
parents: 7272
diff changeset
785
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
786 if ((purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) ||
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
787 (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE))
7805
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
788 return TRUE;
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
789 else
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
790 return FALSE;
7738
ebb766ef2146 [gaim-migrate @ 8383]
Tim Ringenbach <marv@pidgin.im>
parents: 7272
diff changeset
791 }
ebb766ef2146 [gaim-migrate @ 8383]
Tim Ringenbach <marv@pidgin.im>
parents: 7272
diff changeset
792
4539
44671e1ce14e [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
793 gboolean
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
794 purple_xfer_is_completed(PurpleXfer *xfer)
4539
44671e1ce14e [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
795 {
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34955
diff changeset
796 g_return_val_if_fail(PURPLE_IS_XFER(xfer), TRUE);
4539
44671e1ce14e [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
797
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
798 return (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_DONE);
4539
44671e1ce14e [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
799 }
44671e1ce14e [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
800
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
801 const char *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
802 purple_xfer_get_filename(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
803 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
804 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
805
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
806 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
807
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
808 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
809 return priv->filename;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
810 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
811
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
812 const char *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
813 purple_xfer_get_local_filename(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
814 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
815 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
816
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
817 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
818
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
819 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
820 return priv->local_filename;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
821 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
822
32663
1b87b3e98b0a Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32608
diff changeset
823 goffset
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
824 purple_xfer_get_bytes_sent(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
825 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
826 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
827
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
828 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
829
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
830 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
831 return priv->bytes_sent;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
832 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
833
32663
1b87b3e98b0a Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32608
diff changeset
834 goffset
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
835 purple_xfer_get_bytes_remaining(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
836 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
837 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
838
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
839 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
840
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
841 priv = purple_xfer_get_instance_private(xfer);
37210
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
842 return priv->size - priv->bytes_sent;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
843 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
844
32663
1b87b3e98b0a Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32608
diff changeset
845 goffset
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
846 purple_xfer_get_size(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
847 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
848 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
849
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
850 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
851
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
852 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
853 return priv->size;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
854 }
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 double
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
857 purple_xfer_get_progress(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
858 {
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34955
diff changeset
859 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
860
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
861 if (purple_xfer_get_size(xfer) == 0)
4517
998c580f7f56 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
862 return 0.0;
998c580f7f56 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
863
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
864 return ((double)purple_xfer_get_bytes_sent(xfer) /
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
865 (double)purple_xfer_get_size(xfer));
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
866 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
867
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
868 guint16
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
869 purple_xfer_get_local_port(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
870 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
871 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
872
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
873 g_return_val_if_fail(PURPLE_IS_XFER(xfer), -1);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
874
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
875 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
876 return priv->local_port;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
877 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
878
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
879 const char *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
880 purple_xfer_get_remote_ip(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
881 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
882 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
883
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
884 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
885
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
886 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
887 return priv->remote_ip;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
888 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
889
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
890 guint16
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
891 purple_xfer_get_remote_port(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
892 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
893 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
894
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
895 g_return_val_if_fail(PURPLE_IS_XFER(xfer), -1);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
896
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
897 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
898 return priv->remote_port;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
899 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
900
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
901 gint64
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
902 purple_xfer_get_start_time(PurpleXfer *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
903 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
904 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
905
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
906 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
907
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
908 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
909 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
910 }
d6a489105624 Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22194
diff changeset
911
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
912 gint64
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
913 purple_xfer_get_end_time(PurpleXfer *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
914 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
915 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
916
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
917 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
918
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
919 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
920 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
921 }
d6a489105624 Add accessor and update finch to not touch the internals of PurpleXfer.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22194
diff changeset
922
32289
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
923 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
924 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
925 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
926
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
927 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
928
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
929 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
930 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
931
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
932 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_FD]);
32289
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
933 }
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
934
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
935 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
936 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
937 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
938
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
939 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
940
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
941 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
942 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
943
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
944 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_WATCHER]);
32289
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
945 }
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
946
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
947 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
948 purple_xfer_set_completed(PurpleXfer *xfer, gboolean completed)
4538
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
949 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
950 PurpleXferPrivate *priv = NULL;
4656
b676f986e7e3 [gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents: 4634
diff changeset
951
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
952 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
953
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
954 priv = purple_xfer_get_instance_private(xfer);
4538
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
955
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
956 if (completed == TRUE) {
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
957 char *msg = NULL;
34656
adbcbe04077c Refactored remaining libpurple to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents: 34625
diff changeset
958 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
959
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
960 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_DONE);
4656
b676f986e7e3 [gaim-migrate @ 4967]
Mark Doliner <markdoliner@pidgin.im>
parents: 4634
diff changeset
961
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
962 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
963 {
162b561fad5e Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26726
diff changeset
964 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
965 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
966 && 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
967 {
162b561fad5e Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26726
diff changeset
968 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
969 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
970 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
971 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
972 }
162b561fad5e Link-ify the filename when writing the "Transfer is complete" message to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26726
diff changeset
973 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
974 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
975 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
976 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
977 }
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
978 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
979 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
980
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
981 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
982 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
983
36089
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
984 if (im != NULL) {
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
985 purple_conversation_write_system_message(
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
986 PURPLE_CONVERSATION(im), msg, 0);
c035b9a63457 Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 36002
diff changeset
987 }
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
988 g_free(msg);
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
989 }
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
990
40255
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
991 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_PROGRESS]);
4538
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
992 }
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
993
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
994 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
995 purple_xfer_set_message(PurpleXfer *xfer, const char *message)
9933
61bd3fadbfe6 [gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents: 9932
diff changeset
996 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
997 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
998
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
999 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1000
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1001 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1002
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1003 if (message != priv->message) {
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1004 g_free(priv->message);
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1005 priv->message = g_strdup(message);
38254
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1006 }
35013
4718438d053b Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents: 35001
diff changeset
1007
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1008 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_MESSAGE]);
9933
61bd3fadbfe6 [gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents: 9932
diff changeset
1009 }
61bd3fadbfe6 [gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents: 9932
diff changeset
1010
34927
cef809309dbf Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1011 const char *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1012 purple_xfer_get_message(PurpleXfer *xfer)
34927
cef809309dbf Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1013 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1014 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1015
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1016 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1017
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1018 priv = purple_xfer_get_instance_private(xfer);
34927
cef809309dbf Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1019 return priv->message;
cef809309dbf Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1020 }
cef809309dbf Fixed libpurple build errors, and added purple_xfer_get_message()
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1021
9933
61bd3fadbfe6 [gaim-migrate @ 10825]
Dave West <kat@users.sourceforge.net>
parents: 9932
diff changeset
1022 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1023 purple_xfer_set_filename(PurpleXfer *xfer, const char *filename)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1024 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1025 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1026
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1027 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1028
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1029 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1030
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1031 if (filename != priv->filename) {
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1032 g_free(priv->filename);
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1033 priv->filename = g_strdup(filename);
38254
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1034 }
35013
4718438d053b Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents: 35001
diff changeset
1035
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1036 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_FILENAME]);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1037 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1038
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1039 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1040 purple_xfer_set_local_filename(PurpleXfer *xfer, const char *filename)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1041 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1042 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1043
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1044 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1045
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1046 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1047
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1048 if (filename != priv->local_filename) {
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1049 g_free(priv->local_filename);
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38254 37644
diff changeset
1050 priv->local_filename = g_strdup(filename);
38254
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1051 }
35013
4718438d053b Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents: 35001
diff changeset
1052
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1053 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_LOCAL_FILENAME]);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1054 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1055
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1056 void
32663
1b87b3e98b0a Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32608
diff changeset
1057 purple_xfer_set_size(PurpleXfer *xfer, goffset size)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1058 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1059 PurpleXferPrivate *priv = NULL;
40262
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1060 GObject *obj;
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1061
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1062 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1063
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1064 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1065 priv->size = size;
35013
4718438d053b Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents: 35001
diff changeset
1066
40262
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1067 obj = G_OBJECT(xfer);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1068 g_object_freeze_notify(obj);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1069 g_object_notify_by_pspec(obj, properties[PROP_FILE_SIZE]);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1070 g_object_notify_by_pspec(obj, properties[PROP_PROGRESS]);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1071 g_object_thaw_notify(obj);
15322
cd268e368bc1 [gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents: 15280
diff changeset
1072 }
4538
929fb97f4e7f [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
1073
15322
cd268e368bc1 [gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents: 15280
diff changeset
1074 void
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
1075 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
1076 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1077 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1078
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1079 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1080
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1081 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1082 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
1083
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1084 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_LOCAL_PORT]);
32289
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
1085 }
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
1086
8c121b654972 Add some get/set functions to help hidding _PrupleXfer.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32256
diff changeset
1087 void
32663
1b87b3e98b0a Upgrade PurpleXfer for a 64-bit world.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32608
diff changeset
1088 purple_xfer_set_bytes_sent(PurpleXfer *xfer, goffset bytes_sent)
15322
cd268e368bc1 [gaim-migrate @ 18050]
Mark Doliner <markdoliner@pidgin.im>
parents: 15280
diff changeset
1089 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1090 PurpleXferPrivate *priv = NULL;
40262
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1091 GObject *obj;
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1092
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1093 g_return_if_fail(PURPLE_IS_XFER(xfer));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1094
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1095 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1096 priv->bytes_sent = bytes_sent;
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1097
40262
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1098 obj = G_OBJECT(xfer);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1099 g_object_freeze_notify(obj);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1100 g_object_notify_by_pspec(obj, properties[PROP_BYTES_SENT]);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1101 g_object_notify_by_pspec(obj, properties[PROP_PROGRESS]);
47129af2bd5e Add freezes around multi-notifies in xfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40261
diff changeset
1102 g_object_thaw_notify(obj);
4514
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
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1105 PurpleXferUiOps *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1106 purple_xfer_get_ui_ops(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1107 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1108 PurpleXferPrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1109
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1110 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1111
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39775
diff changeset
1112 priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1113 return priv->ui_ops;
4514
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
15280
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1116 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1117 purple_xfer_increase_buffer_size(PurpleXfer *xfer)
15280
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1118 {
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1119 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1120
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1121 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
1122 FT_MAX_BUFFER_SIZE);
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1123 }
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1124
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1125 static gssize
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1126 do_read(PurpleXfer *xfer, guchar **buffer, gsize size)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1127 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1128 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1129 gssize r;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1130
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1131 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
6240
0390b27fe09d [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1132 g_return_val_if_fail(buffer != NULL, 0);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1133
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1134 priv = purple_xfer_get_instance_private(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1135
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1136 *buffer = g_malloc0(size);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1137
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1138 r = read(priv->fd, *buffer, size);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1139 if (r < 0 && errno == EAGAIN) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1140 r = 0;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1141 } else if (r < 0) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1142 r = -1;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1143 } else if (r == 0) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1144 r = -1;
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
1145 }
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1146
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1147 return r;
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1148 }
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1149
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1150 gssize
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1151 purple_xfer_read(PurpleXfer *xfer, guchar **buffer)
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1152 {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1153 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1154 PurpleXferClass *klass = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1155 gsize s;
39670
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1156 gssize r;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1157
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1158 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1159 g_return_val_if_fail(buffer != NULL, 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1160
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1161 priv = purple_xfer_get_instance_private(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1162
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1163 if (purple_xfer_get_size(xfer) == 0) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1164 s = priv->current_buffer_size;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1165 } else {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1166 s = MIN(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1167 (gssize)purple_xfer_get_bytes_remaining(xfer),
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1168 (gssize)priv->current_buffer_size
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1169 );
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1170 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1171
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1172 klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1173 if(klass && klass->read) {
39670
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1174 r = klass->read(xfer, buffer, s);
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1175 } else {
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1176 r = do_read(xfer, buffer, s);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1177 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1178
39670
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1179 if (r >= 0 && (gsize)r == priv->current_buffer_size) {
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1180 /*
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1181 * We managed to read the entire buffer. This means our
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1182 * network is fast and our buffer is too small, so make it
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1183 * bigger.
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1184 */
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1185 purple_xfer_increase_buffer_size(xfer);
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1186 }
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1187
8d95b195ce69 Cleanups from review
Gary Kramlich <grim@reaperworld.com>
parents: 39669
diff changeset
1188 return r;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1189 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1190
37644
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1191 static gssize
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1192 do_write(PurpleXfer *xfer, const guchar *buffer, gsize size)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1193 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1194 PurpleXferPrivate *priv = NULL;
37644
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1195 gssize r;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1196
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1197 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
6240
0390b27fe09d [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1198 g_return_val_if_fail(buffer != NULL, 0);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1199 g_return_val_if_fail(size != 0, 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1200
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1201 priv = purple_xfer_get_instance_private(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1202
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1203 r = write(priv->fd, buffer, size);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1204 if (r < 0 && errno == EAGAIN)
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1205 r = 0;
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1206
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1207 return r;
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1208 }
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1209
37644
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1210 gssize
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1211 purple_xfer_write(PurpleXfer *xfer, const guchar *buffer, gsize size)
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1212 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1213 PurpleXferClass *klass = NULL;
37644
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1214 gssize s;
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1215
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1216 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1217
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1218 s = MIN(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1219 (gssize)purple_xfer_get_bytes_remaining(xfer),
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1220 (gssize)size
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1221 );
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1222
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1223 klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1224 if(klass && klass->write) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1225 return klass->write(xfer, buffer, s);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1226 }
37644
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1227
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1228 return do_write(xfer, buffer, s);
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1229 }
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1230
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1231 static gssize
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1232 do_write_local(PurpleXfer *xfer, const guchar *buffer, gssize size)
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1233 {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1234 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1235
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1236 if (priv->dest_fp == NULL) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1237 purple_debug_error("xfer", "File is not opened for writing");
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1238 return -1;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1239 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1240
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1241 return fwrite(buffer, 1, size, priv->dest_fp);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1242 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1243
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1244 gboolean
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1245 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
1246 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1247 PurpleXferPrivate *priv = NULL;
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1248 gsize wc;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1249 goffset remaining;
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1250 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
1251
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1252 g_return_val_if_fail(PURPLE_IS_XFER(xfer), FALSE);
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1253 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
1254
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1255 priv = purple_xfer_get_instance_private(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1256
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1257 fs_known = (priv->size > 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1258
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1259 remaining = purple_xfer_get_bytes_remaining(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1260 if (fs_known && (goffset)size > remaining) {
35176
b0659f31989d Update debug categories for new filenames
Ankit Vani <a@nevitus.org>
parents: 35115
diff changeset
1261 purple_debug_warning("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
1262 "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
1263 ").\n", purple_xfer_get_size(xfer));
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1264 size = remaining;
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1265 }
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1266
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1267 g_signal_emit(xfer, signals[SIG_WRITE_LOCAL], 0, buffer, size, &wc);
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1268
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1269 if (wc != size) {
35176
b0659f31989d Update debug categories for new filenames
Ankit Vani <a@nevitus.org>
parents: 35115
diff changeset
1270 purple_debug_error("xfer",
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1271 "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
1272 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
1273 return FALSE;
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1274 }
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1275
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1276 purple_xfer_set_bytes_sent(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1277 xfer,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1278 purple_xfer_get_bytes_sent(xfer) + size
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1279 );
34272
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1280
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1281 return TRUE;
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1282 }
8df870b218ca HTTP: chop off another HTTP implementation (for xmpp oob file transfers)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33940
diff changeset
1283
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1284 static gssize
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1285 do_read_local(PurpleXfer *xfer, guchar *buffer, gssize size)
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1286 {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1287 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1288 gssize got_len;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1289
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1290 if (priv->dest_fp == NULL) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1291 purple_debug_error("xfer", "File is not opened for reading");
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1292 return -1;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1293 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1294
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1295 got_len = fread(buffer, 1, size, priv->dest_fp);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1296 if ((got_len < 0 || got_len != size) && ferror(priv->dest_fp)) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1297 purple_debug_error("xfer", "Unable to read file.");
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1298 return -1;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1299 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1300
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1301 return got_len;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1302 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1303
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
1304 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
1305 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
1306 {
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 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
1308
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1309 g_return_val_if_fail(PURPLE_IS_XFER(xfer), 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1310 g_return_val_if_fail(buffer != NULL, 0);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1311
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1312 g_signal_emit(xfer, signals[SIG_READ_LOCAL], 0, buffer, size, &got_len);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1313 if (got_len < 0 || got_len > size) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1314 purple_debug_error("xfer", "Unable to read file.");
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1315 purple_xfer_cancel_local(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1316 return -1;
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
1317 }
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
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 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
1320 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
1321 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
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
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 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
1325 }
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
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1327 static gboolean
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1328 do_data_not_sent(PurpleXfer *xfer, const guchar *buffer, gsize size)
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1329 {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1330 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1331
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1332 if (priv->buffer == NULL) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1333 priv->buffer = g_byte_array_sized_new(FT_INITIAL_BUFFER_SIZE);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1334 g_byte_array_append(priv->buffer, buffer, size);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1335 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1336
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1337 return TRUE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1338 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1339
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1340 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
1341 do_transfer(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1342 {
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1343 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
11159
76ef02141bcb [gaim-migrate @ 13246]
Mark Doliner <markdoliner@pidgin.im>
parents: 11084
diff changeset
1344 guchar *buffer = NULL;
12151
8002bb57756b [gaim-migrate @ 14452]
Richard Laager <rlaager@pidgin.im>
parents: 11934
diff changeset
1345 gssize r = 0;
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1346
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
1347 if (priv->type == PURPLE_XFER_TYPE_RECEIVE) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1348 r = purple_xfer_read(xfer, &buffer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1349 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
1350 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
1351 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
1352 return;
3e48f2d3d083 Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents: 21985
diff changeset
1353 }
28180
782b27dceaf7 ft: Set completion (for receiving) *after* writing the file.
Paul Aurich <darkrain42@pidgin.im>
parents: 28159
diff changeset
1354
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
1355 } else if(r < 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1356 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
1357 g_free(buffer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1358 return;
13109
c5801934af5c [gaim-migrate @ 15470]
Daniel Atallah <datallah@pidgin.im>
parents: 13108
diff changeset
1359 }
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34925
diff changeset
1360 } 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
1361 gssize result = 0;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1362 gsize s = MIN(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1363 (gsize)purple_xfer_get_bytes_remaining(xfer),
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1364 (gsize)priv->current_buffer_size
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1365 );
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1366 gboolean read_more = TRUE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1367 gboolean existing_buffer = FALSE;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1368
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36577
diff changeset
1369 /* this is so the protocol can keep the connection open
8351
216d9836e839 [gaim-migrate @ 9075]
Tim Ringenbach <marv@pidgin.im>
parents: 8316
diff changeset
1370 if it needs to for some odd reason. */
216d9836e839 [gaim-migrate @ 9075]
Tim Ringenbach <marv@pidgin.im>
parents: 8316
diff changeset
1371 if (s == 0) {
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1372 if (priv->watcher) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1373 purple_input_remove(priv->watcher);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1374 purple_xfer_set_watcher(xfer, 0);
8351
216d9836e839 [gaim-migrate @ 9075]
Tim Ringenbach <marv@pidgin.im>
parents: 8316
diff changeset
1375 }
216d9836e839 [gaim-migrate @ 9075]
Tim Ringenbach <marv@pidgin.im>
parents: 8316
diff changeset
1376 return;
216d9836e839 [gaim-migrate @ 9075]
Tim Ringenbach <marv@pidgin.im>
parents: 8316
diff changeset
1377 }
216d9836e839 [gaim-migrate @ 9075]
Tim Ringenbach <marv@pidgin.im>
parents: 8316
diff changeset
1378
29821
8c85f494737a ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29820
diff changeset
1379 if (priv->buffer) {
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1380 existing_buffer = TRUE;
29821
8c85f494737a ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29820
diff changeset
1381 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
1382 s -= priv->buffer->len;
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1383 read_more = TRUE;
29821
8c85f494737a ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29820
diff changeset
1384 } else {
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1385 read_more = FALSE;
29821
8c85f494737a ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29820
diff changeset
1386 }
8c85f494737a ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29820
diff changeset
1387 }
8c85f494737a ft: Apply QuLogic's fix from d6b03d30f4 to the UI side too.
Paul Aurich <darkrain42@pidgin.im>
parents: 29820
diff changeset
1388
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1389 if (read_more) {
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
1390 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
1391 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
1392 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
1393 /*
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
1394 * 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
1395 * 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
1396 * 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
1397 */
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1398 if (priv->watcher != 0) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1399 purple_input_remove(priv->watcher);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1400 purple_xfer_set_watcher(xfer, 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
1401 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1402
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36577
diff changeset
1403 /* 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
1404 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
1405
39892
4fb59abd727e Fix some static analysis warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1406 g_free(buffer);
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
1407 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
1408 }
39892
4fb59abd727e Fix some static analysis warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1409 if (result < 0) {
4fb59abd727e Fix some static analysis warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1410 g_free(buffer);
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
1411 return;
39892
4fb59abd727e Fix some static analysis warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1412 }
22194
3e48f2d3d083 Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents: 21985
diff changeset
1413 }
29822
7c6c2df6f9a2 whitespace trimming
Paul Aurich <darkrain42@pidgin.im>
parents: 29821
diff changeset
1414
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
1415 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
1416 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
1417 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
1418 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
1419 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
1420 }
29822
7c6c2df6f9a2 whitespace trimming
Paul Aurich <darkrain42@pidgin.im>
parents: 29821
diff changeset
1421
37644
451ed08be0b9 Fix purple_xfer_write() during do_transfer()
Jakub Adam <jakub.adam@ktknet.cz>
parents: 37210
diff changeset
1422 r = do_write(xfer, buffer, result);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1423
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8208
diff changeset
1424 if (r == -1) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1425 purple_debug_error("xfer", "do_write failed! %s\n", g_strerror(errno));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1426 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
1427 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
1428 /* 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
1429 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
1430 g_free(buffer);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8208
diff changeset
1431 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
1432 } else if (r == result) {
15280
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1433 /*
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1434 * We managed to write the entire buffer. This means our
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1435 * 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
1436 * bigger.
9df6112da532 [gaim-migrate @ 18008]
Mark Doliner <markdoliner@pidgin.im>
parents: 15161
diff changeset
1437 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1438 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
1439 } else {
40334
3123ce0bafa7 Fix some issues that scanbuild had identified
Gary Kramlich <grim@reaperworld.com>
parents: 40262
diff changeset
1440 gboolean handler_result = FALSE;
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1441 g_signal_emit(xfer, signals[SIG_DATA_NOT_SENT], 0, buffer + r,
40334
3123ce0bafa7 Fix some issues that scanbuild had identified
Gary Kramlich <grim@reaperworld.com>
parents: 40262
diff changeset
1442 result - r, &handler_result);
3123ce0bafa7 Fix some issues that scanbuild had identified
Gary Kramlich <grim@reaperworld.com>
parents: 40262
diff changeset
1443 if (!handler_result) {
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1444 purple_xfer_cancel_local(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1445 }
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
1446 }
ca223fea0a1e Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents: 28659
diff changeset
1447
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1448 if (existing_buffer && priv->buffer) {
29822
7c6c2df6f9a2 whitespace trimming
Paul Aurich <darkrain42@pidgin.im>
parents: 29821
diff changeset
1449 /*
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
1450 * 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
1451 * 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
1452 * 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
1453 */
ca223fea0a1e Kill off the use of fseek for non-seekable streams in file transfers.
Raouf M. Bencheraiet <foufou33@gmail.com>
parents: 28659
diff changeset
1454 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
1455 g_byte_array_remove_range(priv->buffer, 0, r);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1456 }
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1457 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1458
13108
9a5cd09fd9cb [gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents: 13011
diff changeset
1459 if (r > 0) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1460 PurpleXferClass *klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1461
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1462 if (klass && klass->ack)
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1463 klass->ack(xfer, buffer, r);
13108
9a5cd09fd9cb [gaim-migrate @ 15469]
Daniel Atallah <datallah@pidgin.im>
parents: 13011
diff changeset
1464 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1465
39892
4fb59abd727e Fix some static analysis warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1466 g_free(buffer);
4fb59abd727e Fix some static analysis warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1467
37210
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1468 if (purple_xfer_get_bytes_sent(xfer) >= purple_xfer_get_size(xfer) &&
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1469 !purple_xfer_is_completed(xfer)) {
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1470 purple_xfer_set_completed(xfer, TRUE);
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1471 }
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1472
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1473 /* TODO: Check if above is the only place xfers are marked completed.
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1474 * If so, merge these conditions.
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1475 */
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1476 if (purple_xfer_is_completed(xfer)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1477 purple_xfer_end(xfer);
37210
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1478 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1479 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1480
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1481 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
1482 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
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 PurpleXfer *xfer = data;
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1485 PurpleXferPrivate *priv = purple_xfer_get_instance_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
1486
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1487 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
1488 /* 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
1489 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
1490 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
1491
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1492 purple_input_remove(priv->watcher);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1493 purple_xfer_set_watcher(xfer, 0);
29168
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
1494
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36577
diff changeset
1495 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
1496 return;
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1497 }
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
1498
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
1499 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
1500 }
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1501
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1502 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
1503 }
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1504
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1505 static gboolean
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1506 do_open_local(PurpleXfer *xfer)
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1507 {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1508 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1509
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1510 priv->dest_fp =
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1511 g_fopen(purple_xfer_get_local_filename(xfer),
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1512 priv->type == PURPLE_XFER_TYPE_RECEIVE ? "wb" : "rb");
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1513
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1514 if (priv->dest_fp == NULL) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1515 purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer));
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1516 return FALSE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1517 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1518
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1519 if (fseek(priv->dest_fp, priv->bytes_sent, SEEK_SET) != 0) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1520 purple_debug_error("xfer", "couldn't seek");
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1521 purple_xfer_show_file_error(xfer, purple_xfer_get_local_filename(xfer));
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1522 return FALSE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1523 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1524
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1525 return TRUE;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1526 }
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1527
28156
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1528 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1529 begin_transfer(PurpleXfer *xfer, PurpleInputCondition cond)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1530 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1531 PurpleXferClass *klass = PURPLE_XFER_GET_CLASS(xfer);
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1532 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1533 gboolean open_status = FALSE;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1534
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1535 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
1536 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
1537 g_return_if_reached();
e5075db65f9a Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <datallah@pidgin.im>
parents: 30708
diff changeset
1538 }
e5075db65f9a Beginning a file transfer multiple times leaks file handles.
Daniel Atallah <datallah@pidgin.im>
parents: 30708
diff changeset
1539
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1540 g_signal_emit(xfer, signals[SIG_OPEN_LOCAL], 0, &open_status);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1541 if (!open_status) {
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
1542 purple_xfer_cancel_local(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1543 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1544
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1545 if (priv->fd != -1) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1546 purple_xfer_set_watcher(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1547 xfer,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1548 purple_input_add(priv->fd, cond, transfer_cb, xfer)
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1549 );
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1550 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1551
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
1552 priv->start_time = g_get_monotonic_time();
13599
b6369e541654 [gaim-migrate @ 15984]
Mark Doliner <markdoliner@pidgin.im>
parents: 13595
diff changeset
1553
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1554 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_START_TIME]);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1555
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1556 if (klass && klass->start) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1557 klass->start(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1558 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1559 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1560
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1561 static void
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1562 connect_cb(GObject *source, GAsyncResult *result, gpointer user_data)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1563 {
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1564 PurpleXfer *xfer = PURPLE_XFER(user_data);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1565 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1566 GSocket *socket;
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1567 GError *error = NULL;
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1568
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1569 priv->conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source),
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1570 result, &error);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1571 if (priv->conn == NULL) {
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1572 purple_debug_error("xfer", "Unable to connect to destination host: %s",
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1573 error ? error->message : "unknown error");
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
1574 purple_xfer_cancel_local(xfer);
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1575 g_clear_error(&error);
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
1576 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
1577 }
dabfb5216949 Fix #3983 by canceling the file transfer when connecting to the remote host fails.
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
1578
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1579 socket = g_socket_connection_get_socket(priv->conn);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1580 purple_xfer_set_fd(xfer, g_socket_get_fd(socket));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1581 begin_transfer(xfer, PURPLE_INPUT_READ);
3609
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1582 }
6ca2fef0003e [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1583
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1584 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
1585 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
1586 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1587 PurpleXferPrivate *priv = NULL;
39858
0f2be88d88e4 Fix some minor warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39824
diff changeset
1588 PurpleInputCondition cond = 0;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1589
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1590 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1591
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1592 priv = purple_xfer_get_instance_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
1593
28156
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1594 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
1595
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
1596 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
1597 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
1598 return;
29168
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
1599 }
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
1600
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36577
diff changeset
1601 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
1602
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1603 if (priv->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
1604 cond = PURPLE_INPUT_WRITE;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1605 } else if (priv->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
1606 cond = PURPLE_INPUT_READ;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1607 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1608
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1609 if (priv->watcher == 0 && priv->fd != -1) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1610 purple_xfer_set_watcher(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1611 xfer,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1612 purple_input_add(priv->fd, cond, transfer_cb, xfer)
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1613 );
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1614 }
28150
1213ec1efcf8 ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents: 28076
diff changeset
1615
28156
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1616 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
1617
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1618 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
1619 }
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1620
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1621 void
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
1622 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
1623 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1624 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1625
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1626 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1627
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1628 priv = purple_xfer_get_instance_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
1629
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34878
diff changeset
1630 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
1631
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1632 /* 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
1633 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
1634 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
1635 return;
29168
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
1636 }
585ce277cad3 ft: Add some useful debug logging.
Paul Aurich <darkrain42@pidgin.im>
parents: 29159
diff changeset
1637
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36577
diff changeset
1638 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
1639
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1640 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
1641
0a75e2463576 ft: Add infrastructure to allow a prpl to moderate when to send packets.
Paul Aurich <darkrain42@pidgin.im>
parents: 28153
diff changeset
1642 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
1643 }
1213ec1efcf8 ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents: 28076
diff changeset
1644
1213ec1efcf8 ft: Allow the UI to overloadthe use of fread/fwrite. Closes #9844.
Jan Kaluza <hanzz.k@gmail.com>
parents: 28076
diff changeset
1645 void
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
1646 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
1647 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1648 PurpleXferPrivate *priv = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1649 PurpleInputCondition cond;
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1650 GObject *obj;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1651
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1652 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1653
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1654 priv = purple_xfer_get_instance_private(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1655
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1656 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_STARTED);
7805
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
1657
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1658 if (priv->type == PURPLE_XFER_TYPE_RECEIVE) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1659 cond = PURPLE_INPUT_READ;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1660
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1661 if (ip != NULL) {
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1662 GSocketClient *client;
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1663 GError *error = NULL;
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1664
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1665 priv->remote_ip = g_strdup(ip);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1666 priv->remote_port = port;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1667
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1668 obj = G_OBJECT(xfer);
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1669 g_object_freeze_notify(obj);
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1670 g_object_notify_by_pspec(obj, properties[PROP_REMOTE_IP]);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1671 g_object_notify_by_pspec(obj, properties[PROP_REMOTE_PORT]);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1672 g_object_thaw_notify(obj);
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1673
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1674 client = purple_gio_socket_client_new(priv->account, &error);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1675 if (client == NULL) {
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1676 /* Assume it's a proxy error */
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1677 purple_notify_error(
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1678 NULL, NULL, _("Invalid proxy settings"), error->message,
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1679 purple_request_cpar_from_account(priv->account));
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1680 g_clear_error(&error);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1681 return;
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1682 }
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1683
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1684 purple_debug_info("xfer", "Attempting connection to %s:%u\n", ip,
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1685 port);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1686
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1687 g_socket_client_connect_to_host_async(client, ip, port, NULL,
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1688 connect_cb, xfer);
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
1689 g_object_unref(client);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1690
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1691 return;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1692 } else {
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1693 purple_xfer_set_fd(xfer, fd);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1694 }
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1695 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1696 cond = PURPLE_INPUT_WRITE;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1697
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1698 purple_xfer_set_fd(xfer, fd);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1699 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1700
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1701 begin_transfer(xfer, cond);
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1702 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1703
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1704 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1705 purple_xfer_end(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1706 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1707 PurpleXferClass *klass = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1708 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1709
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1710 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1711
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1712 klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1713 priv = purple_xfer_get_instance_private(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1714
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1715 /* See if we are actually trying to cancel this. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1716 if (!purple_xfer_is_completed(xfer)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1717 purple_xfer_cancel_local(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1718 return;
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1719 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1720
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
1721 priv->end_time = g_get_monotonic_time();
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1722
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1723 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_END_TIME]);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1724
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1725 if (klass && klass->end != NULL) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1726 klass->end(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1727 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1728
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1729 if (priv->watcher != 0) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1730 purple_input_remove(priv->watcher);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1731 purple_xfer_set_watcher(xfer, 0);
4521
c67f31cc18f4 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1732 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1733
37210
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1734 if (priv->fd != -1) {
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1735 if (close(priv->fd)) {
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1736 purple_debug_error("xfer", "closing file descr in purple_xfer_end() failed: %s",
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1737 g_strerror(errno));
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1738 }
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1739 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1740
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1741 if (priv->dest_fp != NULL) {
37210
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1742 if (fclose(priv->dest_fp)) {
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1743 purple_debug_error("xfer", "closing dest file in purple_xfer_end() failed: %s",
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1744 g_strerror(errno));
68004413f6e7 Initial fix of file transfer by removing extra calls to purple_xfer_set_bytes_sent() and purple_xfer_set_completed(). Also, remove needless member bytes_remaining from PurpleXferPrivate. Works reliably for me on XMPP. However, the redundant purple_xfer_set_completed() calls may be relied upon by other protocols. This needs to be tested. Ok'd by elb. Refs #16001
Michael McConville <mmcconville@mykolab.com>
parents: 37193
diff changeset
1745 }
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1746 priv->dest_fp = NULL;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1747 }
7805
6045c467441e [gaim-migrate @ 8452]
Tim Ringenbach <marv@pidgin.im>
parents: 7738
diff changeset
1748
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
1749 g_object_unref(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1750 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1751
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1752 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1753 purple_xfer_cancel_local(PurpleXfer *xfer)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1754 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1755 PurpleXferClass *klass = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1756 PurpleXferPrivate *priv = NULL;
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10654
diff changeset
1757 char *msg = NULL;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1758
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1759 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1760
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1761 klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1762 priv = purple_xfer_get_instance_private(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1763
31154
d285b9000fbe Apply Mark's specific changes listed below to the 2.7.7 branch.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 30832
diff changeset
1764 /* 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
1765 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
1766 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
1767 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
1768 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
1769 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
1770 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
1771 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
1772 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
1773 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
1774 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
1775 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
1776 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
1777
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1778 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_LOCAL);
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
1779 priv->end_time = g_get_monotonic_time();
7738
ebb766ef2146 [gaim-migrate @ 8383]
Tim Ringenbach <marv@pidgin.im>
parents: 7272
diff changeset
1780
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1781 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_END_TIME]);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1782
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1783 if (purple_xfer_get_filename(xfer) != NULL)
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1784 {
27797
10f6bc89044b Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents: 27655
diff changeset
1785 msg = g_strdup_printf(_("You cancelled the transfer of %s"),
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1786 purple_xfer_get_filename(xfer));
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1787 }
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1788 else
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1789 {
25359
ea172b7ea601 The remainder of a patch from fqueze to fix some incorrect *printf() function
Daniel Atallah <datallah@pidgin.im>
parents: 24672
diff changeset
1790 msg = g_strdup(_("File transfer cancelled"));
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1791 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1792 purple_xfer_conversation_write(xfer, msg, FALSE);
9932
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
1793 g_free(msg);
5e7cc9975595 [gaim-migrate @ 10824]
Dave West <kat@users.sourceforge.net>
parents: 9805
diff changeset
1794
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1795 if (priv->type == PURPLE_XFER_TYPE_SEND)
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1796 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1797 if (klass && klass->cancel_send) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1798 klass->cancel_send(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1799 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1800 } else {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1801 if (klass && klass->cancel_recv) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1802 klass->cancel_recv(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1803 }
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1804 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1805
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1806 if (priv->watcher != 0) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1807 purple_input_remove(priv->watcher);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1808 purple_xfer_set_watcher(xfer, 0);
4521
c67f31cc18f4 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1809 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1810
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1811 if (priv->fd != -1) {
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1812 close(priv->fd);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1813 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1814
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1815 if (priv->dest_fp != NULL) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1816 fclose(priv->dest_fp);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1817 priv->dest_fp = NULL;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1818 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1819
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
1820 g_object_unref(xfer);
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1821 }
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1822
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1823 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1824 purple_xfer_cancel_remote(PurpleXfer *xfer)
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1825 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1826 PurpleXferClass *klass = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1827 PurpleXferPrivate *priv = NULL;
10774
f4238d6312ff [gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10654
diff changeset
1828 gchar *msg;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1829 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1830 PurpleBuddy *buddy;
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1831
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1832 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1833
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1834 klass = PURPLE_XFER_GET_CLASS(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1835 priv = purple_xfer_get_instance_private(xfer);
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1836
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1837 purple_request_close_with_handle(xfer);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1838 purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_CANCEL_REMOTE);
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
1839 priv->end_time = g_get_monotonic_time();
9771
42bd06e5b1b3 [gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents: 9523
diff changeset
1840
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
1841 g_object_notify_by_pspec(G_OBJECT(xfer), properties[PROP_END_TIME]);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1842
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1843 account = purple_xfer_get_account(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1844 buddy = purple_blist_find_buddy(account, priv->who);
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
1845
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1846 if (purple_xfer_get_filename(xfer) != NULL)
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1847 {
27797
10f6bc89044b Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents: 27655
diff changeset
1848 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
1849 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
1850 }
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1851 else
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1852 {
27797
10f6bc89044b Normalize on 'cancelled'
Paul Aurich <darkrain42@pidgin.im>
parents: 27655
diff changeset
1853 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
1854 buddy ? purple_buddy_get_alias(buddy) : priv->who);
10470
1a070302fa8c [gaim-migrate @ 11752]
Evan Schoenberg <evands@pidgin.im>
parents: 10259
diff changeset
1855 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1856 purple_xfer_conversation_write(xfer, msg, TRUE);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1857 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
1858 g_free(msg);
42bd06e5b1b3 [gaim-migrate @ 10639]
Dave West <kat@users.sourceforge.net>
parents: 9523
diff changeset
1859
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1860 if (priv->type == PURPLE_XFER_TYPE_SEND) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1861 if (klass && klass->cancel_send) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1862 klass->cancel_send(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1863 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1864 } else if(priv->type == PURPLE_XFER_TYPE_RECEIVE) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1865 if (klass && klass->cancel_recv) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1866 klass->cancel_recv(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1867 }
7272
f8335b8f1f1c [gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
1868 }
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1869
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1870 if (priv->watcher != 0) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1871 purple_input_remove(priv->watcher);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
1872 purple_xfer_set_watcher(xfer, 0);
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1873 }
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1874
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1875 if (priv->fd != -1)
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1876 close(priv->fd);
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1877
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1878 if (priv->dest_fp != NULL) {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1879 fclose(priv->dest_fp);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1880 priv->dest_fp = NULL;
4675
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1881 }
8e0a7b537ca2 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1882
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
1883 g_object_unref(xfer);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1884 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1885
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1886 void
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1887 purple_xfer_error(PurpleXferType type, PurpleAccount *account, const gchar *who, const gchar *msg)
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1888 {
39858
0f2be88d88e4 Fix some minor warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39824
diff changeset
1889 gchar *title = NULL;
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1890
6240
0390b27fe09d [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1891 g_return_if_fail(msg != NULL);
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1892
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
1893 if (account) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1894 PurpleBuddy *buddy;
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34656
diff changeset
1895 buddy = purple_blist_find_buddy(account, who);
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
1896 if (buddy)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
1897 who = purple_buddy_get_alias(buddy);
10654
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
1898 }
b2dd3be1b087 [gaim-migrate @ 12182]
Richard Laager <rlaager@pidgin.im>
parents: 10589
diff changeset
1899
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1900 if (type == PURPLE_XFER_TYPE_SEND) {
11231
1c5968418ca4 [gaim-migrate @ 13371]
Richard Laager <rlaager@pidgin.im>
parents: 11159
diff changeset
1901 title = g_strdup_printf(_("File transfer to %s failed."), who);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1902 } else if (type == PURPLE_XFER_TYPE_RECEIVE) {
11231
1c5968418ca4 [gaim-migrate @ 13371]
Richard Laager <rlaager@pidgin.im>
parents: 11159
diff changeset
1903 title = g_strdup_printf(_("File transfer from %s failed."), who);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1904 }
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1905
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34333
diff changeset
1906 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
1907 purple_request_cpar_from_account(account));
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1908
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1909 g_free(title);
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1910 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1911
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
1912 gconstpointer
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1913 purple_xfer_get_thumbnail(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
1914 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1915 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1916
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1917 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1918
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1919 priv = purple_xfer_get_instance_private(xfer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1920
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1921 if (len) {
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
1922 *len = priv->thumbnail_size;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1923 }
27419
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1924
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
1925 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
1926 }
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1927
30113
f60cbf3b3ca9 Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents: 29846
diff changeset
1928 const gchar *
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1929 purple_xfer_get_thumbnail_mimetype(PurpleXfer *xfer)
30113
f60cbf3b3ca9 Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents: 29846
diff changeset
1930 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1931 PurpleXferPrivate *priv = NULL;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1932
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1933 g_return_val_if_fail(PURPLE_IS_XFER(xfer), NULL);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1934
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1935 priv = purple_xfer_get_instance_private(xfer);
30115
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
1936
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
1937 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
1938 }
f60cbf3b3ca9 Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents: 29846
diff changeset
1939
27419
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1940 void
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1941 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
1942 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
1943 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1944 PurpleXferPrivate *priv = NULL;
38368
61f85dabe64e libpurple/xfer.c: Silence warnings in purple_xfer_set_thumbnail()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
1945 gpointer old_thumbnail_data;
61f85dabe64e libpurple/xfer.c: Silence warnings in purple_xfer_set_thumbnail()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
1946 gchar *old_mimetype;
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1947
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1948 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1949
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1950 priv = purple_xfer_get_instance_private(xfer);
30115
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
1951
38254
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1952 /* Hold onto these in case they are equal to passed-in pointers */
38368
61f85dabe64e libpurple/xfer.c: Silence warnings in purple_xfer_set_thumbnail()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
1953 old_thumbnail_data = priv->thumbnail_data;
61f85dabe64e libpurple/xfer.c: Silence warnings in purple_xfer_set_thumbnail()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
1954 old_mimetype = priv->thumbnail_mimetype;
30124
e84a06d70326 Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30123
diff changeset
1955
27419
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1956 if (thumbnail && size > 0) {
40756
3a58ef28ee44 Implement mitigation for GHSL-2021-045
Gary Kramlich <grim@reaperworld.com>
parents: 40648
diff changeset
1957 priv->thumbnail_data = g_memdup2(thumbnail, size);
30115
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
1958 priv->thumbnail_size = size;
619d2b5758c0 Hide the thumbnail-related stuff from the PurpleXfer struct to
Marcus Lundblad <malu@pidgin.im>
parents: 30114
diff changeset
1959 priv->thumbnail_mimetype = g_strdup(mimetype);
30124
e84a06d70326 Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30123
diff changeset
1960 } else {
e84a06d70326 Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30123
diff changeset
1961 priv->thumbnail_data = NULL;
e84a06d70326 Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30123
diff changeset
1962 priv->thumbnail_size = 0;
e84a06d70326 Minor cleanup.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30123
diff changeset
1963 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
1964 }
38254
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1965
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1966 /* Now it's safe to free the pointers */
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1967 g_free(old_thumbnail_data);
41ce9e8bd35f Applying fain's patch which fixes 15755
fain
parents: 37188
diff changeset
1968 g_free(old_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
1969 }
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1970
5cdc131e86a2 Added a skeleton for functions to set and get a thumbnail image associated
Marcus Lundblad <malu@pidgin.im>
parents: 26726
diff changeset
1971 void
30114
8472e53fbbfc Set desired image formats for thumbnails as a parameter to
Marcus Lundblad <malu@pidgin.im>
parents: 30113
diff changeset
1972 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
1973 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1974 g_return_if_fail(PURPLE_IS_XFER(xfer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
1975
40257
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
1976 g_signal_emit(xfer, signals[SIG_ADD_THUMBNAIL], 0, formats, 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
1977 }
8585
23db71a2d432 [gaim-migrate @ 9335]
Pekka Riikonen <priikone@silcnet.org>
parents: 8351
diff changeset
1978
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1979 /**************************************************************************
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1980 * GObject code
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
1981 **************************************************************************/
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1982 static void
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1983 purple_xfer_set_property(GObject *obj, guint param_id, const GValue *value,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1984 GParamSpec *pspec)
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1985 {
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1986 PurpleXfer *xfer = PURPLE_XFER(obj);
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
1987 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1988
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1989 switch (param_id) {
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1990 case PROP_TYPE:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1991 priv->type = g_value_get_enum(value);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1992 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1993 case PROP_ACCOUNT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1994 priv->account = g_value_get_object(value);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1995 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1996 case PROP_REMOTE_USER:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1997 purple_xfer_set_remote_user(xfer, g_value_get_string(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1998 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
1999 case PROP_MESSAGE:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2000 purple_xfer_set_message(xfer, g_value_get_string(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2001 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2002 case PROP_FILENAME:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2003 purple_xfer_set_filename(xfer, g_value_get_string(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2004 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2005 case PROP_LOCAL_FILENAME:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2006 purple_xfer_set_local_filename(xfer, g_value_get_string(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2007 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2008 case PROP_FILE_SIZE:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2009 purple_xfer_set_size(xfer, g_value_get_int64(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2010 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2011 case PROP_LOCAL_PORT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2012 purple_xfer_set_local_port(xfer, g_value_get_int(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2013 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2014 case PROP_FD:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2015 purple_xfer_set_fd(xfer, g_value_get_int(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2016 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2017 case PROP_WATCHER:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2018 purple_xfer_set_watcher(xfer, g_value_get_int(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2019 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2020 case PROP_BYTES_SENT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2021 purple_xfer_set_bytes_sent(xfer, g_value_get_int64(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2022 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2023 case PROP_STATUS:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2024 purple_xfer_set_status(xfer, g_value_get_enum(value));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2025 break;
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2026 case PROP_VISIBLE:
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2027 purple_xfer_set_visible(xfer, g_value_get_boolean(value));
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2028 break;
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2029 default:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2030 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2031 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2032 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2033 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2034
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2035 static void
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2036 purple_xfer_get_property(GObject *obj, guint param_id, GValue *value,
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2037 GParamSpec *pspec)
34792
09228ea79272 Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
2038 {
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2039 PurpleXfer *xfer = PURPLE_XFER(obj);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2040
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2041 switch (param_id) {
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2042 case PROP_TYPE:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2043 g_value_set_enum(value, purple_xfer_get_xfer_type(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2044 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2045 case PROP_ACCOUNT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2046 g_value_set_object(value, purple_xfer_get_account(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2047 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2048 case PROP_REMOTE_USER:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2049 g_value_set_string(value, purple_xfer_get_remote_user(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2050 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2051 case PROP_MESSAGE:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2052 g_value_set_string(value, purple_xfer_get_message(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2053 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2054 case PROP_FILENAME:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2055 g_value_set_string(value, purple_xfer_get_filename(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2056 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2057 case PROP_LOCAL_FILENAME:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2058 g_value_set_string(value, purple_xfer_get_local_filename(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2059 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2060 case PROP_FILE_SIZE:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2061 g_value_set_int64(value, purple_xfer_get_size(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2062 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2063 case PROP_REMOTE_IP:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2064 g_value_set_string(value, purple_xfer_get_remote_ip(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2065 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2066 case PROP_LOCAL_PORT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2067 g_value_set_int(value, purple_xfer_get_local_port(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2068 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2069 case PROP_REMOTE_PORT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2070 g_value_set_int(value, purple_xfer_get_remote_port(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2071 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2072 case PROP_FD:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2073 g_value_set_int(value, purple_xfer_get_fd(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2074 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2075 case PROP_WATCHER:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2076 g_value_set_int(value, purple_xfer_get_watcher(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2077 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2078 case PROP_BYTES_SENT:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2079 g_value_set_int64(value, purple_xfer_get_bytes_sent(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2080 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2081 case PROP_START_TIME:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2082 g_value_set_int64(value, purple_xfer_get_start_time(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2083 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2084 case PROP_END_TIME:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2085 g_value_set_int64(value, purple_xfer_get_end_time(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2086 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2087 case PROP_STATUS:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2088 g_value_set_enum(value, purple_xfer_get_status(xfer));
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2089 break;
40255
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2090 case PROP_PROGRESS:
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2091 g_value_set_double(value, purple_xfer_get_progress(xfer));
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2092 break;
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2093 case PROP_VISIBLE:
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2094 g_value_set_boolean(value, purple_xfer_get_visible(xfer));
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2095 break;
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2096 default:
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2097 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2098 break;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2099 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2100 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2101
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2102 static void
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
2103 purple_xfer_init(PurpleXfer *xfer)
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2104 {
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
2105 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2106
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2107 priv->ui_ops = purple_xfers_get_ui_ops();
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2108 priv->current_buffer_size = FT_INITIAL_BUFFER_SIZE;
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2109 priv->fd = -1;
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2110 priv->ready = PURPLE_XFER_READY_NONE;
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2111 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2112
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2113 static void
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2114 purple_xfer_constructed(GObject *object)
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2115 {
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2116 PurpleXfer *xfer = PURPLE_XFER(object);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2117 PurpleXferUiOps *ui_ops;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2118
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
2119 G_OBJECT_CLASS(purple_xfer_parent_class)->constructed(object);
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2120
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2121 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
2122
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2123 if (ui_ops != NULL && ui_ops->new_xfer != NULL) {
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2124 ui_ops->new_xfer(xfer);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2125 }
34922
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 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
2128 }
09228ea79272 Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
2129
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2130 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
2131 purple_xfer_finalize(GObject *object)
34792
09228ea79272 Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
2132 {
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2133 PurpleXfer *xfer = PURPLE_XFER(object);
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
2134 PurpleXferPrivate *priv = purple_xfer_get_instance_private(xfer);
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2135
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2136 /* Close the file browser, if it's open */
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2137 purple_request_close_with_handle(xfer);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2138
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2139 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_STARTED) {
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2140 purple_xfer_cancel_local(xfer);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2141 }
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2142
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2143 xfers = g_list_remove(xfers, xfer);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2144
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2145 g_free(priv->who);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2146 g_free(priv->filename);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2147 g_free(priv->remote_ip);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2148 g_free(priv->local_filename);
40648
d575d71dcc56 Convert proxy code in xfer to gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
2149 g_clear_object(&priv->conn);
34792
09228ea79272 Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
2150
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2151 if (priv->buffer) {
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2152 g_byte_array_free(priv->buffer, TRUE);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2153 }
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2154
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2155 g_free(priv->thumbnail_data);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2156 g_free(priv->thumbnail_mimetype);
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2157
39380
3088866c22f4 libpurple: Port almost self-contained code from g_type_class_add_private()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39352
diff changeset
2158 G_OBJECT_CLASS(purple_xfer_parent_class)->finalize(object);
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2159 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2160
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2161 /* Class initializer function */
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2162 static void
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2163 purple_xfer_class_init(PurpleXferClass *klass)
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2164 {
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2165 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2166
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2167 obj_class->finalize = purple_xfer_finalize;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2168 obj_class->constructed = purple_xfer_constructed;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2169 obj_class->get_property = purple_xfer_get_property;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2170 obj_class->set_property = purple_xfer_set_property;
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2171
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2172 klass->write = do_write;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2173 klass->read = do_read;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2174
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2175 klass->open_local = do_open_local;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2176 klass->query_local = do_query_local;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2177 klass->read_local = do_read_local;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2178 klass->write_local = do_write_local;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2179 klass->data_not_sent = do_data_not_sent;
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2180
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2181 /* Properties */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2182
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2183 properties[PROP_TYPE] = g_param_spec_enum("type", "Transfer type",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2184 "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
2185 PURPLE_XFER_TYPE_UNKNOWN,
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
2186 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2187 G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2188
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2189 properties[PROP_ACCOUNT] = g_param_spec_object("account", "Account",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2190 "The account sending or receiving the file.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2191 PURPLE_TYPE_ACCOUNT,
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
2192 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2193 G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2194
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2195 properties[PROP_REMOTE_USER] = g_param_spec_string("remote-user",
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2196 "Remote user",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2197 "The name of the remote user.", NULL,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2198 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2199
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2200 properties[PROP_MESSAGE] = g_param_spec_string("message", "Message",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2201 "The message for the file transfer.", NULL,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2202 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2203
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2204 properties[PROP_FILENAME] = g_param_spec_string("filename", "Filename",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2205 "The filename for the file transfer.", NULL,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2206 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2207
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2208 properties[PROP_LOCAL_FILENAME] = g_param_spec_string("local-filename",
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2209 "Local filename",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2210 "The local filename for the file transfer.", NULL,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2211 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2212
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2213 properties[PROP_FILE_SIZE] = g_param_spec_int64("file-size", "File size",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2214 "Size of the file in a file transfer.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2215 G_MININT64, G_MAXINT64, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2216 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2217
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2218 properties[PROP_REMOTE_IP] = g_param_spec_string("remote-ip", "Remote IP",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2219 "The remote IP address in the file transfer.", NULL,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2220 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2221
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2222 properties[PROP_LOCAL_PORT] = g_param_spec_int("local-port", "Local port",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2223 "The local port number in the file transfer.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2224 G_MININT, G_MAXINT, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2225 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2226
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2227 properties[PROP_REMOTE_PORT] = g_param_spec_int("remote-port",
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2228 "Remote port",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2229 "The remote port number in the file transfer.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2230 G_MININT, G_MAXINT, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2231 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2232
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2233 properties[PROP_FD] = g_param_spec_int("fd", "Socket FD",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2234 "The socket file descriptor.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2235 G_MININT, G_MAXINT, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2236 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2237
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2238 properties[PROP_WATCHER] = g_param_spec_int("watcher", "Watcher",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2239 "The watcher for the file transfer.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2240 G_MININT, G_MAXINT, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2241 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2242
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2243 properties[PROP_BYTES_SENT] = g_param_spec_int64("bytes-sent", "Bytes sent",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2244 "The number of bytes sent (or received) so far.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2245 G_MININT64, G_MAXINT64, 0,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2246 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2247
39823
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2248 properties[PROP_START_TIME] = g_param_spec_int64(
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2249 "start-time", "Start time",
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2250 "The monotonic time the transfer of a file started.",
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2251 G_MININT64, G_MAXINT64, 0,
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2252 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2253
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2254 properties[PROP_END_TIME] = g_param_spec_int64(
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2255 "end-time", "End time",
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2256 "The monotonic time the transfer of a file ended.", G_MININT64,
36acf9e724a5 Convert file transfer times to monotonic clock.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39782
diff changeset
2257 G_MAXINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2258
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2259 properties[PROP_STATUS] = g_param_spec_enum("status", "Status",
35058
506740af931c Unmark property names and blurbs from translatable to non-translatable
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
2260 "The current status for the file transfer.",
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2261 PURPLE_TYPE_XFER_STATUS, PURPLE_XFER_STATUS_UNKNOWN,
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
2262 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
35085
abab0adfa0ec libpurple: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents: 35080
diff changeset
2263
40255
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2264 properties[PROP_PROGRESS] = g_param_spec_double(
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2265 "progress", "Progress",
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2266 "The current progress of the file transfer.", -1.0, 1.0, -1.0,
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2267 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
42922708e18e Replace PurpleXferUiOps.update_progress by PurpleXfer.progress.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40254
diff changeset
2268
40260
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2269 properties[PROP_VISIBLE] = g_param_spec_boolean(
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2270 "visible", "Visible",
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2271 "Hint for UIs whether this transfer should be visible.", FALSE,
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2272 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
663b8a40dad5 Change PurpleXferUiOps.add_xfer to PurpleXfer:visible property.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40258
diff changeset
2273
35085
abab0adfa0ec libpurple: use g_object_class_install_properties instead of repeated g_object_class_install_property
Ankit Vani <a@nevitus.org>
parents: 35080
diff changeset
2274 g_object_class_install_properties(obj_class, PROP_LAST, properties);
40253
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2275
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2276 /* Signals */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2277
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2278 /**
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2279 * PurpleXfer::open-local:
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2280 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2281 * Open a file locally for a file transfer.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2282 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2283 * The default class handler will open a file using standard library
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2284 * functions. If you connect to this signal, you should connect to
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2285 * PurpleXfer::query-local, PurpleXfer::read-local, PurpleXfer::write-local
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2286 * and PurpleXfer::data-not-sent as well.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2287 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2288 * Returns: %TRUE if the file was opened successfully, or %FALSE otherwise,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2289 * and the transfer should be cancelled (libpurple will cancel).
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2290 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2291 * Since: 3.0.0
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2292 */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2293 signals[SIG_OPEN_LOCAL] = g_signal_new(
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2294 "open-local", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2295 G_STRUCT_OFFSET(PurpleXferClass, open_local),
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2296 g_signal_accumulator_first_wins, NULL, NULL, G_TYPE_BOOLEAN, 0);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2297
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2298 /**
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2299 * PurpleXfer::query-local:
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2300 * @filename: The filename of the transfer.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2301 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2302 * Query a file's properties locally.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2303 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2304 * The default class handler will query a file using standard library
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2305 * functions, and set the transfer's size. If you connect to this signal,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2306 * you should try to do the same, but it is not necessarily an error if you
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2307 * cannot. If you connect to this signal, you must connect to
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2308 * PurpleXfer::open-local, PurpleXfer::read-local, PurpleXfer::write-local
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2309 * and PurpleXfer::data-not-sent as well.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2310 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2311 * Returns: %TRUE if the properties were queried successfully, or %FALSE
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2312 * otherwise, and the transfer should be cancelled (libpurple will
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2313 * cancel).
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2314 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2315 * Since: 3.0.0
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2316 */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2317 signals[SIG_QUERY_LOCAL] = g_signal_new(
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2318 "query-local", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2319 G_STRUCT_OFFSET(PurpleXferClass, query_local),
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2320 g_signal_accumulator_first_wins, NULL, NULL, G_TYPE_BOOLEAN, 1,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2321 G_TYPE_STRING);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2322
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2323 /**
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2324 * PurpleXfer::read-local:
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2325 * @buffer: (out): A pointer to a buffer to fill.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2326 * @size: The maximum amount of data to put in the buffer.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2327 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2328 * Read data locally to send to the protocol for a file transfer.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2329 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2330 * The default class handler will read from a file using standard library
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2331 * functions. If you connect to this signal, you must connect to
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2332 * PurpleXfer::open-local, PurpleXfer::query-local, PurpleXfer::write-local
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2333 * and PurpleXfer::data-not-sent as well.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2334 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2335 * Returns: The amount of data in the buffer, 0 if nothing is available,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2336 * and a negative value if an error occurred and the transfer
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2337 * should be cancelled (libpurple will cancel).
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2338 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2339 * Since: 3.0.0
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2340 */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2341 signals[SIG_READ_LOCAL] = g_signal_new(
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2342 "read-local", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2343 G_STRUCT_OFFSET(PurpleXferClass, read_local),
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2344 g_signal_accumulator_first_wins, NULL, NULL, G_TYPE_LONG, 2,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2345 G_TYPE_POINTER, G_TYPE_LONG);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2346
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2347 /**
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2348 * PurpleXfer::write-local:
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2349 * @buffer: The buffer to write.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2350 * @size: The size of the buffer.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2351 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2352 * Write data received from the protocol locally. The signal handler must
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2353 * deal with the entire buffer and return size, or it is treated as an
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2354 * error.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2355 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2356 * The default class handler will write to a file using standard library
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2357 * functions. If you connect to this signal, you must connect to
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2358 * PurpleXfer::open-local, PurpleXfer::query-local, PurpleXfer::read-local
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2359 * and PurpleXfer::data-not-sent as well.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2360 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2361 * Returns: @size if the write was successful, or a value between 0 and
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2362 * @size on error.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2363 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2364 * Since: 3.0.0
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2365 */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2366 signals[SIG_WRITE_LOCAL] = g_signal_new(
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2367 "write-local", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2368 G_STRUCT_OFFSET(PurpleXferClass, write_local),
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2369 g_signal_accumulator_first_wins, NULL, NULL, G_TYPE_LONG, 2,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2370 G_TYPE_POINTER, G_TYPE_LONG);
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2371
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2372 /**
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2373 * PurpleXfer::data-not-sent:
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2374 * @buffer: A pointer to the beginning of the unwritten data.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2375 * @size: The amount of unwritten data.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2376 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2377 * Notify the UI that not all the data read in was written. The UI should
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2378 * re-enqueue this data and return it the next time read is called.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2379 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2380 * If you connect to this signal, you must connect to
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2381 * PurpleXfer::open-local, PurpleXfer::query-local, PurpleXfer::read-local
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2382 * and PurpleXfer::write-local as well.
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2383 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2384 * Returns: %TRUE if the data was re-enqueued successfully, or %FALSE
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2385 * otherwise, and the transfer should be cancelled (libpurple
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2386 * will cancel).
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2387 *
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2388 * Since: 3.0.0
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2389 */
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2390 signals[SIG_DATA_NOT_SENT] = g_signal_new(
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2391 "data-not-sent", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2392 G_STRUCT_OFFSET(PurpleXferClass, data_not_sent),
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2393 g_signal_accumulator_first_wins, NULL, NULL, G_TYPE_BOOLEAN, 2,
7f38c3cc5c91 Convert xfer I/O operations from UI ops to signals.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40195
diff changeset
2394 G_TYPE_POINTER, G_TYPE_ULONG);
40257
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2395
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2396 /**
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2397 * PurpleXfer::add-thumbnail:
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2398 * @formats: A comma-separated string of allowed image formats.
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2399 *
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2400 * Request that a thumbnail be added to a file transfer.
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2401 *
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2402 * Since: 3.0.0
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2403 */
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2404 signals[SIG_ADD_THUMBNAIL] = g_signal_new(
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2405 "add-thumbnail", G_TYPE_FROM_CLASS(klass), G_SIGNAL_ACTION, 0, NULL,
e6692de3b4de Convert PurpleXferUiOps.add_thumbnail to a signal.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40256
diff changeset
2406 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2407 }
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2408
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2409 PurpleXfer *
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2410 purple_xfer_new(PurpleAccount *account, PurpleXferType type, const char *who)
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2411 {
36728
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2412 PurpleXfer *xfer;
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2413 PurpleProtocol *protocol;
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2414
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34955
diff changeset
2415 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
2416 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
2417 g_return_val_if_fail(who != NULL, NULL);
34925
6196ea6ef237 Added GObject code to xfer.c
Ankit Vani <a@nevitus.org>
parents: 34922
diff changeset
2418
40804
5496016b3c00 Port libpurple from purple_protocols_ to purple_protocol_manager_
Gary Kramlich <grim@reaperworld.com>
parents: 40756
diff changeset
2419 protocol = purple_account_get_protocol(account);
38842
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2420 if (PURPLE_IS_PROTOCOL_XFER(protocol)) {
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2421 PurpleConnection *connection = purple_account_get_connection(account);
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2422
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2423 xfer = purple_protocol_xfer_new_xfer(
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2424 PURPLE_PROTOCOL_XFER(protocol),
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2425 connection,
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2426 /* TODO: this should support the type */
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2427 who
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2428 );
38847
6b3d5359cb93 Remove some trailing whitespace and commented code
Gary Kramlich <grim@reaperworld.com>
parents: 38842
diff changeset
2429 } else {
36728
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2430 xfer = g_object_new(PURPLE_TYPE_XFER,
36872
c0099fc27ace Merged soc.2013.gobjectification branch
Ankit Vani <a@nevitus.org>
parents: 36858 35013
diff changeset
2431 "account", account,
c0099fc27ace Merged soc.2013.gobjectification branch
Ankit Vani <a@nevitus.org>
parents: 36858 35013
diff changeset
2432 "type", type,
c0099fc27ace Merged soc.2013.gobjectification branch
Ankit Vani <a@nevitus.org>
parents: 36858 35013
diff changeset
2433 "remote-user", who,
36728
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2434 NULL
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2435 );
38842
98227c37cd17 start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents: 38840
diff changeset
2436 }
36728
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2437
313d07370a7b Use the protocol factory interface functions
Ankit Vani <a@nevitus.org>
parents: 36715
diff changeset
2438 return xfer;
34792
09228ea79272 Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
2439 }
09228ea79272 Added GBoxed to certificate, certificate pool, xfer, log
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
2440
6263
6fec763a314c [gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents: 6242
diff changeset
2441 /**************************************************************************
6fec763a314c [gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents: 6242
diff changeset
2442 * File Transfer Subsystem API
6fec763a314c [gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents: 6242
diff changeset
2443 **************************************************************************/
34922
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2444 GList *
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2445 purple_xfers_get_all()
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2446 {
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2447 return xfers;
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2448 }
6043d2b7f55a Started GObjectification of xfer.c
Ankit Vani <a@nevitus.org>
parents: 34919
diff changeset
2449
11281
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2450 void *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2451 purple_xfers_get_handle(void) {
11281
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2452 static int handle = 0;
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2453
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2454 return &handle;
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2455 }
6241
34d166a31152 [gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
2456
34d166a31152 [gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
2457 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2458 purple_xfers_init(void) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2459 void *handle = purple_xfers_get_handle();
11281
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2460
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2461 /* register signals */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2462 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
2463 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
2464 PURPLE_TYPE_XFER);
11281
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2465 }
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2466
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2467 void
21143
239b2f43bef5 Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents: 20661
diff changeset
2468 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
2469 {
239b2f43bef5 Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents: 20661
diff changeset
2470 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
2471
239b2f43bef5 Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents: 20661
diff changeset
2472 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
2473 purple_signals_unregister_by_instance(handle);
11281
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2474 }
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2475
a5cda37a16be [gaim-migrate @ 13478]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11231
diff changeset
2476 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2477 purple_xfers_set_ui_ops(PurpleXferUiOps *ops) {
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2478 xfer_ui_ops = ops;
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2479 }
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2480
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2481 PurpleXferUiOps *
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15702
diff changeset
2482 purple_xfers_get_ui_ops(void) {
4514
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2483 return xfer_ui_ops;
40e3588a280f [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
2484 }
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2485
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2486 /**************************************************************************
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2487 * GBoxed code
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2488 **************************************************************************/
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2489 static PurpleXferUiOps *
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2490 purple_xfer_ui_ops_copy(PurpleXferUiOps *ops)
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2491 {
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2492 PurpleXferUiOps *ops_new;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2493
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2494 g_return_val_if_fail(ops != NULL, NULL);
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2495
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2496 ops_new = g_new(PurpleXferUiOps, 1);
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2497 *ops_new = *ops;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2498
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2499 return ops_new;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2500 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2501
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2502 GType
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2503 purple_xfer_ui_ops_get_type(void)
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2504 {
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2505 static GType type = 0;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2506
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2507 if (type == 0) {
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2508 type = g_boxed_type_register_static("PurpleXferUiOps",
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2509 (GBoxedCopyFunc)purple_xfer_ui_ops_copy,
35597
7fcfcf147b99 Use g_free as UiOps structures GBoxed free function
Ankit Vani <a@nevitus.org>
parents: 35574
diff changeset
2510 (GBoxedFreeFunc)g_free);
35572
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2511 }
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2512
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2513 return type;
5c4846317f2f Box the *UiOps structures
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
2514 }
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2515
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2516 /**************************************************************************
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2517 * PurpleXferProtocolInterface
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2518 **************************************************************************/
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2519 G_DEFINE_INTERFACE(PurpleProtocolXfer, purple_protocol_xfer, G_TYPE_INVALID);
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2520
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2521 static void
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2522 purple_protocol_xfer_default_init(PurpleProtocolXferInterface *face) {
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2523 }
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2524
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2525 gboolean
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2526 purple_protocol_xfer_can_receive(PurpleProtocolXfer *prplxfer,
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2527 PurpleConnection *connection,
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2528 const gchar *who
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2529 ) {
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2530 PurpleProtocolXferInterface *iface = NULL;
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2531
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2532 g_return_val_if_fail(PURPLE_IS_PROTOCOL_XFER(prplxfer), FALSE);
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2533 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2534 g_return_val_if_fail(who, FALSE);
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2535
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2536 iface = PURPLE_PROTOCOL_XFER_GET_IFACE(prplxfer);
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2537 if(iface && iface->can_receive)
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2538 return iface->can_receive(prplxfer, connection, who);
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2539
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2540 /* If the PurpleProtocolXfer doesn't implement this function, we assume
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2541 * there are no conditions where we can't send a file to the given user.
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2542 */
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39380
diff changeset
2543 return TRUE;
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2544 }
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2545
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2546 void
39005
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38847
diff changeset
2547 purple_protocol_xfer_send_file(PurpleProtocolXfer *prplxfer,
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38847
diff changeset
2548 PurpleConnection *connection,
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38847
diff changeset
2549 const gchar *who,
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38847
diff changeset
2550 const gchar *filename
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2551 ) {
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2552 PurpleProtocolXferInterface *iface = NULL;
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2553
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2554 g_return_if_fail(PURPLE_IS_PROTOCOL_XFER(prplxfer));
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2555 g_return_if_fail(PURPLE_IS_CONNECTION(connection));
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2556 g_return_if_fail(who);
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2557
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2558 iface = PURPLE_PROTOCOL_XFER_GET_IFACE(prplxfer);
39005
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38847
diff changeset
2559 if(iface && iface->send_file)
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38847
diff changeset
2560 iface->send_file(prplxfer, connection, who, filename);
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2561 }
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2562
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2563 PurpleXfer *
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2564 purple_protocol_xfer_new_xfer(PurpleProtocolXfer *prplxfer,
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2565 PurpleConnection *connection,
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2566 const gchar *who
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2567 ) {
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2568 PurpleProtocolXferInterface *iface = NULL;
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2569
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2570 g_return_val_if_fail(PURPLE_IS_PROTOCOL_XFER(prplxfer), FALSE);
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2571 g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), FALSE);
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2572 g_return_val_if_fail(who, FALSE);
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2573
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2574 iface = PURPLE_PROTOCOL_XFER_GET_IFACE(prplxfer);
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2575 if(iface && iface->new_xfer)
38840
33326576c72b Fix the argument names so there's no confusion
Gary Kramlich <grim@reaperworld.com>
parents: 38834
diff changeset
2576 return iface->new_xfer(prplxfer, connection, who);
38834
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2577
e4144efa975e Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents: 38828
diff changeset
2578 return NULL;
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38368
diff changeset
2579 }

mercurial