annotate src/ft.c @ 12595:3169cd6727ad

[gaim-migrate @ 14925] I've been meaning to spend the time to commit these changes separately, but it's been a couple days without me finding the time... 1. Allow the creation of GaimStatusTypes by passing NULL for the name and/or id. The core uses the default name and/or id. This eliminates quite a bit of duplication in the prpls. 2. Make statuses more consistent. For example, in some prpls, "Busy" was descended from the UNAVAILABLE primitive and on others it was a case of AWAY. Another example... "On Vacation" is definitely an EXTENDED_AWAY not an AWAY. 3. Rename some pixmaps to elminate some special cases. The names of the pixmaps should now match the primitive default IDs. 4. Rename the HIDDEN primitive to INVISIBLE, since we seem to be using that term everywhere. In conjunction with #1, more duplication was eliminated. 5. Add a MOBILE status primitive. It's not used now. It'll be needed in the (hopefully not-too-distant) future, so I'm planning ahead. 6. Shrink the status select for small blist folks. Now if someone can get rid of that stupid extra padding, we'll be set (well, after we deal with imhtml space issues). I've fought with this for many many hours over several days and I can't get it. It's clear that the combo box is requesting more space than is really necessary, but I don't know why. This is really my first go at anything significant status-related. Everyone should check their favorite prpls carefully to make sure I didn't break anything. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 21 Dec 2005 08:24:17 +0000
parents 5e2a365af01b
children 5e14039d0415
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1 /**
7820
8e60ddc28a22 [gaim-migrate @ 8472]
Mark Doliner <mark@kingant.net>
parents: 7805
diff changeset
2 * @file ft.c File Transfer API
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
4 * gaim
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
5 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7820
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7820
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7820
diff changeset
8 * source distribution.
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
9 *
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * (at your option) any later version.
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 *
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * GNU General Public License for more details.
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23 *
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
25 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
26 #include "ft.h"
8231
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
27 #include "network.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
28 #include "notify.h"
6241
9ce44a7f9ae7 [gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
29 #include "prefs.h"
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include "proxy.h"
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
31 #include "request.h"
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
32 #include "util.h"
5494
d557a53e35c5 [gaim-migrate @ 5890]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5436
diff changeset
33
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
34 static GaimXferUiOps *xfer_ui_ops = NULL;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
36 GaimXfer *
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
37 gaim_xfer_new(GaimAccount *account, GaimXferType type, const char *who)
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
39 GaimXfer *xfer;
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
40 GaimXferUiOps *ui_ops;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
42 g_return_val_if_fail(type != GAIM_XFER_UNKNOWN, NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
43 g_return_val_if_fail(account != NULL, NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
44 g_return_val_if_fail(who != NULL, NULL);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
46 xfer = g_new0(GaimXfer, 1);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
48 xfer->ref = 1;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
49 xfer->type = type;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
50 xfer->account = account;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
51 xfer->who = g_strdup(who);
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6482
diff changeset
52 xfer->ui_ops = gaim_xfers_get_ui_ops();
9933
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
53 xfer->message = NULL;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
55 ui_ops = gaim_xfer_get_ui_ops(xfer);
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
56
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
57 if (ui_ops != NULL && ui_ops->new_xfer != NULL)
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
58 ui_ops->new_xfer(xfer);
5169
71927464a1db [gaim-migrate @ 5533]
Mark Doliner <mark@kingant.net>
parents: 5164
diff changeset
59
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 return xfer;
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
63 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
64 gaim_xfer_destroy(GaimXfer *xfer)
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
66 GaimXferUiOps *ui_ops;
4247
3ea14f99c35c [gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents: 4245
diff changeset
67
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
68 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
69
9512
3c79229259ba [gaim-migrate @ 10339]
Mark Doliner <mark@kingant.net>
parents: 9511
diff changeset
70 /* Close the file browser, if it's open */
3c79229259ba [gaim-migrate @ 10339]
Mark Doliner <mark@kingant.net>
parents: 9511
diff changeset
71 gaim_request_close_with_handle(xfer);
3c79229259ba [gaim-migrate @ 10339]
Mark Doliner <mark@kingant.net>
parents: 9511
diff changeset
72
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
73 if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_STARTED)
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
74 gaim_xfer_cancel_local(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
76 ui_ops = gaim_xfer_get_ui_ops(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
78 if (ui_ops != NULL && ui_ops->destroy != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
79 ui_ops->destroy(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80
9789
51a6a98d276b [gaim-migrate @ 10657]
Mark Doliner <mark@kingant.net>
parents: 9788
diff changeset
81 g_free(xfer->who);
51a6a98d276b [gaim-migrate @ 10657]
Mark Doliner <mark@kingant.net>
parents: 9788
diff changeset
82 g_free(xfer->filename);
51a6a98d276b [gaim-migrate @ 10657]
Mark Doliner <mark@kingant.net>
parents: 9788
diff changeset
83 g_free(xfer->remote_ip);
51a6a98d276b [gaim-migrate @ 10657]
Mark Doliner <mark@kingant.net>
parents: 9788
diff changeset
84 g_free(xfer->local_filename);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 g_free(xfer);
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
89 void
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
90 gaim_xfer_ref(GaimXfer *xfer)
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
91 {
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
92 g_return_if_fail(xfer != NULL);
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
93
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
94 xfer->ref++;
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
95 }
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
96
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
97 void
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
98 gaim_xfer_unref(GaimXfer *xfer)
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
99 {
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
100 g_return_if_fail(xfer != NULL);
12250
5e2a365af01b [gaim-migrate @ 14552]
Richard Laager <rlaager@wiktel.com>
parents: 12151
diff changeset
101 g_return_if_fail(xfer->ref > 0);
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
102
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
103 xfer->ref--;
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
104
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
105 if (xfer->ref == 0)
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
106 gaim_xfer_destroy(xfer);
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
107 }
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
108
9788
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
109 static void
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
110 gaim_xfer_set_status(GaimXfer *xfer, GaimXferStatusType status)
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
111 {
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
112 g_return_if_fail(xfer != NULL);
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
113
11281
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
114 if(xfer->type == GAIM_XFER_SEND) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
115 switch(status) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
116 case GAIM_XFER_STATUS_ACCEPTED:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
117 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-accept", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
118 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
119 case GAIM_XFER_STATUS_STARTED:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
120 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-start", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
121 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
122 case GAIM_XFER_STATUS_DONE:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
123 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-complete", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
124 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
125 case GAIM_XFER_STATUS_CANCEL_LOCAL:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
126 case GAIM_XFER_STATUS_CANCEL_REMOTE:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
127 gaim_signal_emit(gaim_xfers_get_handle(), "file-send-cancel", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
128 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
129 default:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
130 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
131 }
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
132 } else if(xfer->type == GAIM_XFER_RECEIVE) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
133 switch(status) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
134 case GAIM_XFER_STATUS_ACCEPTED:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
135 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-accept", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
136 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
137 case GAIM_XFER_STATUS_STARTED:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
138 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-start", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
139 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
140 case GAIM_XFER_STATUS_DONE:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
141 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-complete", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
142 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
143 case GAIM_XFER_STATUS_CANCEL_LOCAL:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
144 case GAIM_XFER_STATUS_CANCEL_REMOTE:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
145 gaim_signal_emit(gaim_xfers_get_handle(), "file-recv-cancel", xfer);
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
146 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
147 default:
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
148 break;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
149 }
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
150 }
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
151
9788
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
152 xfer->status = status;
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
153 }
1e9ecca6c97e [gaim-migrate @ 10656]
Luke Schierer <lschiere@pidgin.im>
parents: 9785
diff changeset
154
11084
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
155 void gaim_xfer_conversation_write(GaimXfer *xfer, char *message, gboolean is_error)
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
156 {
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
157 GaimConversation *conv = NULL;
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
158 GaimMessageFlags flags = GAIM_MESSAGE_SYSTEM;
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
159 char *escaped;
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
160
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
161 g_return_if_fail(xfer != NULL);
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
162 g_return_if_fail(message != NULL);
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
163
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11281
diff changeset
164 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, xfer->who,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10225
diff changeset
165 gaim_xfer_get_account(xfer));
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
166
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
167 if (conv == NULL)
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
168 return;
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
169
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
170 escaped = g_markup_escape_text(message, -1);
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
171
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
172 if (is_error)
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
173 flags = GAIM_MESSAGE_ERROR;
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
174
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
175 gaim_conversation_write(conv, NULL, escaped, flags, time(NULL));
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
176 g_free(escaped);
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
177 }
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
178
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
179 static void gaim_xfer_show_file_error(GaimXfer *xfer, const char *filename)
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
180 {
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
181 int err = errno;
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
182 gchar *msg = NULL, *utf8;
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
183 GaimXferType xfer_type = gaim_xfer_get_type(xfer);
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
184 GaimAccount *account = gaim_xfer_get_account(xfer);
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
185
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
186 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
187 switch(xfer_type) {
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
188 case GAIM_XFER_SEND:
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
189 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"),
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
190 utf8, strerror(err));
9795
719fc957e9ee [gaim-migrate @ 10663]
Luke Schierer <lschiere@pidgin.im>
parents: 9789
diff changeset
191 break;
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
192 case GAIM_XFER_RECEIVE:
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
193 msg = g_strdup_printf(_("Error writing %s: \n%s.\n"),
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
194 utf8, strerror(err));
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
195 break;
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
196 default:
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
197 msg = g_strdup_printf(_("Error accessing %s: \n%s.\n"),
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
198 utf8, strerror(err));
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
199 break;
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
200 }
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
201 g_free(utf8);
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
202
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
203 gaim_xfer_conversation_write(xfer, msg, TRUE);
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
204 gaim_xfer_error(xfer_type, account, xfer->who, msg);
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
205 g_free(msg);
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
206 }
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
207
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
208 static void
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
209 gaim_xfer_choose_file_ok_cb(void *user_data, const char *filename)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
210 {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
211 GaimXfer *xfer;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
212 struct stat st;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
213
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
214 xfer = (GaimXfer *)user_data;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
215
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10504
diff changeset
216 if (g_stat(filename, &st) != 0) {
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
217 /* File not found. */
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
218 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
219 gaim_xfer_request_accepted(xfer, filename);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
220 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
221 else {
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
222 gaim_xfer_show_file_error(xfer, filename);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
223 gaim_xfer_request_denied(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
224 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
225 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
226 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) &&
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
227 (st.st_size == 0)) {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
228
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
229 gaim_notify_error(NULL, NULL,
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
230 _("Cannot send a file of 0 bytes."), NULL);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
231
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
232 gaim_xfer_request_denied(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
233 }
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
234 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) &&
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
235 S_ISDIR(st.st_mode)) {
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
236 /*
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
237 * XXX - Sending a directory should be valid for some protocols.
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
238 */
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
239 gaim_notify_error(NULL, NULL,
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
240 _("Cannot send a directory."), NULL);
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
241
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
242 gaim_xfer_request_denied(xfer);
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
243 }
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
244 else if ((gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) &&
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
245 S_ISDIR(st.st_mode)) {
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
246 char *msg, *utf8;
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
247 utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
248 msg = g_strdup_printf(
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
249 _("%s is not a regular file. Cowardly refusing to overwrite it.\n"), utf8);
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
250 g_free(utf8);
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
251 gaim_notify_error(NULL, NULL, msg, NULL);
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
252 g_free(msg);
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
253 gaim_xfer_request_denied(xfer);
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
254 }
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
255 else {
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
256 gaim_xfer_request_accepted(xfer, filename);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
257 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
258
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
259 gaim_xfer_unref(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
260 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
261
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
262 static void
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
263 gaim_xfer_choose_file_cancel_cb(void *user_data, const char *filename)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
264 {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
265 GaimXfer *xfer = (GaimXfer *)user_data;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
266
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
267 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
268 gaim_xfer_request_denied(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
269 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
270
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
271 static int
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
272 gaim_xfer_choose_file(GaimXfer *xfer)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
273 {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
274 gaim_request_file(xfer, NULL, gaim_xfer_get_filename(xfer),
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
275 (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE),
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
276 G_CALLBACK(gaim_xfer_choose_file_ok_cb),
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
277 G_CALLBACK(gaim_xfer_choose_file_cancel_cb), xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
278
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
279 return 0;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
280 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
281
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
282 static int
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
283 cancel_recv_cb(GaimXfer *xfer)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
284 {
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
285 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
286 gaim_xfer_request_denied(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
287 gaim_xfer_unref(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
288
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
289 return 0;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
290 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
291
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
292 static void
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
293 gaim_xfer_ask_recv(GaimXfer *xfer)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
294 {
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
295 char *buf, *size_buf;
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
296 size_t size;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
297
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
298 /* If we have already accepted the request, ask the destination file
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
299 name directly */
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
300 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_ACCEPTED) {
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
301 GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
302
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
303 if (gaim_xfer_get_filename(xfer) != NULL)
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
304 {
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
305 size = gaim_xfer_get_size(xfer);
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
306 size_buf = gaim_str_size_to_units(size);
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
307 buf = g_strdup_printf(_("%s wants to send you %s (%s)"),
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
308 buddy ? gaim_buddy_get_alias(buddy) : xfer->who,
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
309 gaim_xfer_get_filename(xfer), size_buf);
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
310 g_free(size_buf);
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
311 }
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
312 else
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
313 {
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
314 buf = g_strdup_printf(_("%s wants to send you a file"),
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
315 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
316 }
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
317
9933
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
318 if (xfer->message != NULL)
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
319 serv_got_im(gaim_account_get_connection(xfer->account),
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
320 xfer->who, xfer->message, 0, time(NULL));
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
321
9976
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
322 gaim_request_accept_cancel(xfer, NULL, buf, NULL,
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
323 GAIM_DEFAULT_ACTION_NONE, xfer,
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
324 G_CALLBACK(gaim_xfer_choose_file),
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
325 G_CALLBACK(cancel_recv_cb));
9933
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
326
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
327 g_free(buf);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
328 } else
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
329 gaim_xfer_choose_file(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
330 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
331
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
332 static int
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
333 ask_accept_ok(GaimXfer *xfer)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
334 {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
335 gaim_xfer_request_accepted(xfer, NULL);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
336
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
337 return 0;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
338 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
339
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
340 static int
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
341 ask_accept_cancel(GaimXfer *xfer)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
342 {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
343 gaim_xfer_request_denied(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
344 gaim_xfer_unref(xfer);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
345
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
346 return 0;
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
347 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
348
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
349 static void
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
350 gaim_xfer_ask_accept(GaimXfer *xfer)
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
351 {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
352 char *buf, *buf2 = NULL;
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
353 GaimBuddy *buddy = gaim_find_buddy(xfer->account, xfer->who);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
354
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
355 buf = g_strdup_printf(_("Accept file transfer request from %s?"),
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
356 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
357 if (gaim_xfer_get_remote_ip(xfer) &&
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
358 gaim_xfer_get_remote_port(xfer))
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
359 buf2 = g_strdup_printf(_("A file is available for download from:\n"
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
360 "Remote host: %s\nRemote port: %d"),
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
361 gaim_xfer_get_remote_ip(xfer),
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
362 gaim_xfer_get_remote_port(xfer));
9976
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
363 gaim_request_accept_cancel(xfer, NULL, buf, buf2,
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
364 GAIM_DEFAULT_ACTION_NONE, xfer,
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
365 G_CALLBACK(ask_accept_ok),
f4ff7d2b9b2c [gaim-migrate @ 10887]
Mark Doliner <mark@kingant.net>
parents: 9941
diff changeset
366 G_CALLBACK(ask_accept_cancel));
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
367 g_free(buf);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
368 g_free(buf2);
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
369 }
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
370
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
371 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
372 gaim_xfer_request(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
373 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
374 g_return_if_fail(xfer != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
375 g_return_if_fail(xfer->ops.init != NULL);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
376
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
377 gaim_xfer_ref(xfer);
4247
3ea14f99c35c [gaim-migrate @ 4497]
Christian Hammond <chipx86@chipx86.com>
parents: 4245
diff changeset
378
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
379 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) {
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
380 if (gaim_xfer_get_filename(xfer) ||
11084
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
381 gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_ACCEPTED) {
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
382 gchar* message = NULL;
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
383 message = g_strdup_printf(_("%s is offering to send file %s"),
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
384 xfer->who, gaim_xfer_get_filename(xfer));
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
385 gaim_xfer_conversation_write(xfer, message, FALSE);
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
386 g_free(message);
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
387 gaim_xfer_ask_recv(xfer);
11084
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
388 } else {
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
389 gaim_xfer_ask_accept(xfer);
11084
2c21bffa8200 [gaim-migrate @ 13103]
Jonathan Clark <ardentlygnarly>
parents: 10919
diff changeset
390 }
9511
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
391 } else
3ed6001d5de8 [gaim-migrate @ 10338]
Mark Doliner <mark@kingant.net>
parents: 8585
diff changeset
392 gaim_xfer_choose_file(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
395 void
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
396 gaim_xfer_request_accepted(GaimXfer *xfer, const char *filename)
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
397 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
398 GaimXferType type;
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
399 struct stat st;
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
400 char *msg, *utf8;
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
401 GaimAccount *account;
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
402 GaimBuddy *buddy;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
403
8585
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
404 if (xfer == NULL)
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
405 return;
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
406
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
407 type = gaim_xfer_get_type(xfer);
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
408 account = gaim_xfer_get_account(xfer);
8585
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
409
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
410 if (!filename && type == GAIM_XFER_RECEIVE) {
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
411 xfer->status = GAIM_XFER_STATUS_ACCEPTED;
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
412 xfer->ops.init(xfer);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
413 return;
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
414 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
415
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
416 buddy = gaim_find_buddy(account, xfer->who);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
417
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
418 if (type == GAIM_XFER_SEND) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
419 /* Check the filename. */
11934
525cf7ecd919 [gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents: 11338
diff changeset
420 #ifdef _WIN32
525cf7ecd919 [gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents: 11338
diff changeset
421 if (g_strrstr(filename, "../") || g_strrstr(filename, "..\\")) {
525cf7ecd919 [gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents: 11338
diff changeset
422 #else
525cf7ecd919 [gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents: 11338
diff changeset
423 if (g_strrstr(filename, "../")) {
525cf7ecd919 [gaim-migrate @ 14225]
Richard Laager <rlaager@wiktel.com>
parents: 11338
diff changeset
424 #endif
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
425 char *utf8 = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
426
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
427 msg = g_strdup_printf(_("%s is not a valid filename.\n"), utf8);
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
428 gaim_xfer_error(type, account, xfer->who, msg);
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
429 g_free(utf8);
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
430 g_free(msg);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
431
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
432 gaim_xfer_unref(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
433 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
434 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
435
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10504
diff changeset
436 if (g_stat(filename, &st) == -1) {
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
437 gaim_xfer_show_file_error(xfer, filename);
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
438 gaim_xfer_unref(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
439 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
440 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
441
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
442 gaim_xfer_set_local_filename(xfer, filename);
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
443 gaim_xfer_set_size(xfer, st.st_size);
10134
0aca774bef87 [gaim-migrate @ 11198]
Mark Doliner <mark@kingant.net>
parents: 9976
diff changeset
444
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
445 utf8 = g_filename_to_utf8(g_basename(filename), -1, NULL, NULL, NULL);
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
446 gaim_xfer_set_filename(xfer, utf8);
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
447
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
448 msg = g_strdup_printf(_("Offering to send %s to %s"),
10919
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
449 utf8, buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
450 g_free(utf8);
9695281b1aa1 [gaim-migrate @ 12683]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10774
diff changeset
451
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
452 gaim_xfer_conversation_write(xfer, msg, FALSE);
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
453 g_free(msg);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
454 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
455 else {
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
456 xfer->status = GAIM_XFER_STATUS_ACCEPTED;
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
457 gaim_xfer_set_local_filename(xfer, filename);
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
458
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
459 msg = g_strdup_printf(_("Starting transfer of %s from %s"),
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
460 xfer->filename, buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
461 gaim_xfer_conversation_write(xfer, msg, FALSE);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
462 g_free(msg);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
463 }
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 3730
diff changeset
464
10259
1aa83016fbe0 [gaim-migrate @ 11402]
Tim Ringenbach <marv@pidgin.im>
parents: 10246
diff changeset
465 gaim_xfer_add(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
466 xfer->ops.init(xfer);
10259
1aa83016fbe0 [gaim-migrate @ 11402]
Tim Ringenbach <marv@pidgin.im>
parents: 10246
diff changeset
467
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
468 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
469
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
470 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
471 gaim_xfer_request_denied(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
472 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
473 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
474
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
475 if (xfer->ops.request_denied != NULL)
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
476 xfer->ops.request_denied(xfer);
5164
98d16e2d1bf9 [gaim-migrate @ 5528]
Mark Doliner <mark@kingant.net>
parents: 5146
diff changeset
477
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
478 gaim_xfer_unref(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
479 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
480
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
481 GaimXferType
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
482 gaim_xfer_get_type(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
483 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
484 g_return_val_if_fail(xfer != NULL, GAIM_XFER_UNKNOWN);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
485
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
486 return xfer->type;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
487 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
488
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5495
diff changeset
489 GaimAccount *
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
490 gaim_xfer_get_account(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
491 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
492 g_return_val_if_fail(xfer != NULL, NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
493
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
494 return xfer->account;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
495 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
496
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
497 GaimXferStatusType
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
498 gaim_xfer_get_status(const GaimXfer *xfer)
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
499 {
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
500 g_return_val_if_fail(xfer != NULL, GAIM_XFER_STATUS_UNKNOWN);
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
501
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
502 return xfer->status;
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
503 }
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
504
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
505 gboolean
7738
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
506 gaim_xfer_is_canceled(const GaimXfer *xfer)
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
507 {
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
508 g_return_val_if_fail(xfer != NULL, TRUE);
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
509
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
510 if ((gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) ||
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
511 (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_REMOTE))
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
512 return TRUE;
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
513 else
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
514 return FALSE;
7738
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
515 }
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
516
4539
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
517 gboolean
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
518 gaim_xfer_is_completed(const GaimXfer *xfer)
4539
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
519 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
520 g_return_val_if_fail(xfer != NULL, TRUE);
4539
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
521
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
522 return (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_DONE);
4539
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
523 }
05476ef20d58 [gaim-migrate @ 4818]
Christian Hammond <chipx86@chipx86.com>
parents: 4538
diff changeset
524
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
525 const char *
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
526 gaim_xfer_get_filename(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
527 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
528 g_return_val_if_fail(xfer != NULL, NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
529
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
530 return xfer->filename;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
531 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
532
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
533 const char *
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
534 gaim_xfer_get_local_filename(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
535 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
536 g_return_val_if_fail(xfer != NULL, NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
537
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
538 return xfer->local_filename;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
539 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
540
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
541 size_t
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
542 gaim_xfer_get_bytes_sent(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
543 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
544 g_return_val_if_fail(xfer != NULL, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
545
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
546 return xfer->bytes_sent;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
547 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
548
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
549 size_t
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
550 gaim_xfer_get_bytes_remaining(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
551 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
552 g_return_val_if_fail(xfer != NULL, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
553
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
554 return xfer->bytes_remaining;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
555 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
556
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
557 size_t
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
558 gaim_xfer_get_size(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
559 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
560 g_return_val_if_fail(xfer != NULL, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
561
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
562 return xfer->size;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
563 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
564
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
565 double
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
566 gaim_xfer_get_progress(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
567 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
568 g_return_val_if_fail(xfer != NULL, 0.0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
569
4517
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
570 if (gaim_xfer_get_size(xfer) == 0)
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
571 return 0.0;
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
572
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
573 return ((double)gaim_xfer_get_bytes_sent(xfer) /
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
574 (double)gaim_xfer_get_size(xfer));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
575 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
576
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
577 unsigned int
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
578 gaim_xfer_get_local_port(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
579 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
580 g_return_val_if_fail(xfer != NULL, -1);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
581
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
582 return xfer->local_port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
583 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
584
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
585 const char *
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
586 gaim_xfer_get_remote_ip(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
587 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
588 g_return_val_if_fail(xfer != NULL, NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
589
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
590 return xfer->remote_ip;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
591 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
592
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
593 unsigned int
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
594 gaim_xfer_get_remote_port(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
595 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
596 g_return_val_if_fail(xfer != NULL, -1);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
597
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
598 return xfer->remote_port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
599 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
600
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
601 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
602 gaim_xfer_set_completed(GaimXfer *xfer, gboolean completed)
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
603 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
604 GaimXferUiOps *ui_ops;
4656
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
605
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
606 g_return_if_fail(xfer != NULL);
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
607
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
608 if (completed == TRUE) {
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
609 char *msg = NULL;
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
610 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_DONE);
4656
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
611
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
612 if (gaim_xfer_get_filename(xfer) != NULL)
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
613 msg = g_strdup_printf(_("Transfer of file %s complete"),
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
614 gaim_xfer_get_filename(xfer));
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
615 else
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
616 msg = g_strdup_printf(_("File transfer complete"));
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
617 gaim_xfer_conversation_write(xfer, msg, FALSE);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
618 g_free(msg);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
619 }
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
620
4656
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
621 ui_ops = gaim_xfer_get_ui_ops(xfer);
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
622
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
623 if (ui_ops != NULL && ui_ops->update_progress != NULL)
e557a10a9541 [gaim-migrate @ 4967]
Mark Doliner <mark@kingant.net>
parents: 4634
diff changeset
624 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
625 }
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
626
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
627 void
9933
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
628 gaim_xfer_set_message(GaimXfer *xfer, const char *message)
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
629 {
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
630 g_return_if_fail(xfer != NULL);
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
631
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
632 g_free(xfer->message);
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
633
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
634 if (message != NULL)
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
635 xfer->message = g_strdup(message);
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
636 else
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
637 xfer->message = NULL;
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
638 }
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
639
cee849d17167 [gaim-migrate @ 10825]
Mark Doliner <mark@kingant.net>
parents: 9932
diff changeset
640 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
641 gaim_xfer_set_filename(GaimXfer *xfer, const char *filename)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
642 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
643 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
644
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
645 if (xfer->filename != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
646 g_free(xfer->filename);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
647
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
648 xfer->filename = (filename == NULL ? NULL : g_strdup(filename));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
649 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
650
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
651 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
652 gaim_xfer_set_local_filename(GaimXfer *xfer, const char *filename)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
653 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
654 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
655
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
656 if (xfer->local_filename != NULL)
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
657 g_free(xfer->local_filename);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
658
4605
4fe88c94c3b4 [gaim-migrate @ 4892]
Mark Doliner <mark@kingant.net>
parents: 4595
diff changeset
659 xfer->local_filename = (filename == NULL ? NULL : g_strdup(filename));
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
660 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
661
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
662 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
663 gaim_xfer_set_size(GaimXfer *xfer, size_t size)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
664 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
665 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
666
4540
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
667 if (xfer->size == 0)
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
668 xfer->bytes_remaining = size - xfer->bytes_sent;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
669
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
670 xfer->size = size;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
671 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
672
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
673 GaimXferUiOps *
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
674 gaim_xfer_get_ui_ops(const GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
675 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
676 g_return_val_if_fail(xfer != NULL, NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
677
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
678 return xfer->ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
679 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
680
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
681 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
682 gaim_xfer_set_init_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
683 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
684 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
685
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
686 xfer->ops.init = fnc;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
687 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
688
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
689 void gaim_xfer_set_request_denied_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *))
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
690 {
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
691 g_return_if_fail(xfer != NULL);
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
692
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
693 xfer->ops.request_denied = fnc;
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
694 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
695
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
696 void
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
697 gaim_xfer_set_read_fnc(GaimXfer *xfer, gssize (*fnc)(guchar **, GaimXfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
698 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
699 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
700
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
701 xfer->ops.read = fnc;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
702 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
703
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
704 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
705 gaim_xfer_set_write_fnc(GaimXfer *xfer,
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
706 gssize (*fnc)(const guchar *, size_t, GaimXfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
707 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
708 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
709
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
710 xfer->ops.write = fnc;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
711 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
712
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
713 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
714 gaim_xfer_set_ack_fnc(GaimXfer *xfer,
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
715 void (*fnc)(GaimXfer *, const guchar *, size_t))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
716 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
717 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
718
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
719 xfer->ops.ack = fnc;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
720 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
721
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
722 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
723 gaim_xfer_set_start_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
724 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
725 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
726
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
727 xfer->ops.start = fnc;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
728 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
729
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
730 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
731 gaim_xfer_set_end_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
732 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
733 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
734
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
735 xfer->ops.end = fnc;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
736 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
737
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
738 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
739 gaim_xfer_set_cancel_send_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *))
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
740 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
741 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
742
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
743 xfer->ops.cancel_send = fnc;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
744 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
745
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
746 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
747 gaim_xfer_set_cancel_recv_fnc(GaimXfer *xfer, void (*fnc)(GaimXfer *))
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
748 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
749 g_return_if_fail(xfer != NULL);
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
750
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
751 xfer->ops.cancel_recv = fnc;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
752 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
753
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
754 gssize
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
755 gaim_xfer_read(GaimXfer *xfer, guchar **buffer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
756 {
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
757 gssize s, r;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
758
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
759 g_return_val_if_fail(xfer != NULL, 0);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
760 g_return_val_if_fail(buffer != NULL, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
761
4517
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
762 if (gaim_xfer_get_size(xfer) == 0)
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
763 s = 4096;
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
764 else
a2b2cce63fb8 [gaim-migrate @ 4795]
Christian Hammond <chipx86@chipx86.com>
parents: 4514
diff changeset
765 s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
766
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
767 if (xfer->ops.read != NULL)
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
768 r = (xfer->ops.read)(buffer, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
769 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
770 *buffer = g_malloc0(s);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
771
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
772 r = read(xfer->fd, *buffer, s);
6482
16fcc379e484 [gaim-migrate @ 6996]
Christian Hammond <chipx86@chipx86.com>
parents: 6269
diff changeset
773 if ((gaim_xfer_get_size(xfer) > 0) &&
4617
858979ab3867 [gaim-migrate @ 4908]
Mark Doliner <mark@kingant.net>
parents: 4605
diff changeset
774 ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer)))
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4528
diff changeset
775 gaim_xfer_set_completed(xfer, TRUE);
8316
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
776 else if(r <= 0)
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
777 r = -1;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
778 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
779
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
780 return r;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
781 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
782
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
783 gssize
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
784 gaim_xfer_write(GaimXfer *xfer, const guchar *buffer, size_t size)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
785 {
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
786 gssize r, s;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
787
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
788 g_return_val_if_fail(xfer != NULL, 0);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
789 g_return_val_if_fail(buffer != NULL, 0);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
790 g_return_val_if_fail(size != 0, 0);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
791
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
792 s = MIN(gaim_xfer_get_bytes_remaining(xfer), size);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
793
8231
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
794 if (xfer->ops.write != NULL) {
5495
5b678994929b [gaim-migrate @ 5891]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5494
diff changeset
795 r = (xfer->ops.write)(buffer, s, xfer);
8231
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
796 } else {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
797 r = write(xfer->fd, buffer, s);
8231
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
798 if ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer))
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
799 gaim_xfer_set_completed(xfer, TRUE);
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
800 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
801
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
802 return r;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
803 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
804
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
805 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
806 transfer_cb(gpointer data, gint source, GaimInputCondition condition)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
807 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
808 GaimXferUiOps *ui_ops;
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
809 GaimXfer *xfer = (GaimXfer *)data;
11159
bd8ac1d4b2f2 [gaim-migrate @ 13246]
Mark Doliner <mark@kingant.net>
parents: 11084
diff changeset
810 guchar *buffer = NULL;
12151
de798f2f4bf1 [gaim-migrate @ 14452]
Richard Laager <rlaager@wiktel.com>
parents: 11934
diff changeset
811 gssize r = 0;
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
812
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
813 if (condition & GAIM_INPUT_READ) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
814 r = gaim_xfer_read(xfer, &buffer);
8316
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
815 if (r > 0) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
816 fwrite(buffer, 1, r, xfer->dest_fp);
8316
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
817 } else if(r < 0) {
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
818 gaim_xfer_cancel_remote(xfer);
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
819 return;
cf84056fed27 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
820 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
821 }
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9796
diff changeset
822
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9796
diff changeset
823 if (condition & GAIM_INPUT_WRITE) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
824 size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
825
8351
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
826 /* this is so the prpl can keep the connection open
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
827 if it needs to for some odd reason. */
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
828 if (s == 0) {
9798
255596f41014 [gaim-migrate @ 10666]
Tim Ringenbach <marv@pidgin.im>
parents: 9796
diff changeset
829 if (xfer->watcher) {
8351
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
830 gaim_input_remove(xfer->watcher);
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
831 xfer->watcher = 0;
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
832 }
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
833 return;
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
834 }
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
835
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
836 buffer = g_malloc0(s);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
837
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
838 fread(buffer, 1, s, xfer->dest_fp);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
839
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
840 /* Write as much as we're allowed to. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
841 r = gaim_xfer_write(xfer, buffer, s);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
842
8231
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
843 if (r == -1) {
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
844 gaim_xfer_cancel_remote(xfer);
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
845 g_free(buffer);
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
846 return;
f50c059b6384 [gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents: 8208
diff changeset
847 } else if (r < s) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
848 /* We have to seek back in the file now. */
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
849 fseek(xfer->dest_fp, r - s, SEEK_CUR);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
850 }
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
851 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
852
4540
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
853 if (gaim_xfer_get_size(xfer) > 0)
d83c5b925a05 [gaim-migrate @ 4819]
Christian Hammond <chipx86@chipx86.com>
parents: 4539
diff changeset
854 xfer->bytes_remaining -= r;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
855
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
856 xfer->bytes_sent += r;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
857
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
858 if (xfer->ops.ack != NULL)
4594
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4582
diff changeset
859 xfer->ops.ack(xfer, buffer, r);
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4582
diff changeset
860
a2c95c0d7333 [gaim-migrate @ 4879]
Mark Doliner <mark@kingant.net>
parents: 4582
diff changeset
861 g_free(buffer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
862
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
863 ui_ops = gaim_xfer_get_ui_ops(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
864
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
865 if (ui_ops != NULL && ui_ops->update_progress != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
866 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
867
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4540
diff changeset
868 if (gaim_xfer_is_completed(xfer))
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
869 gaim_xfer_end(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
870 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
871
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
872 static void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
873 begin_transfer(GaimXfer *xfer, GaimInputCondition cond)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
874 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
875 GaimXferType type = gaim_xfer_get_type(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
876
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10504
diff changeset
877 xfer->dest_fp = g_fopen(gaim_xfer_get_local_filename(xfer),
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
878 type == GAIM_XFER_RECEIVE ? "wb" : "rb");
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
879
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
880 if (xfer->dest_fp == NULL) {
9796
68574cef02e2 [gaim-migrate @ 10664]
Mark Doliner <mark@kingant.net>
parents: 9795
diff changeset
881 gaim_xfer_show_file_error(xfer, gaim_xfer_get_local_filename(xfer));
9785
2356d2153c94 [gaim-migrate @ 10653]
Tim Ringenbach <marv@pidgin.im>
parents: 9781
diff changeset
882 gaim_xfer_cancel_local(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
883 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
884 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
885
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
886 xfer->watcher = gaim_input_add(xfer->fd, cond, transfer_cb, xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
887
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
888 if (xfer->ops.start != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
889 xfer->ops.start(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
890 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
891
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
892 static void
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
893 connect_cb(gpointer data, gint source, GaimInputCondition condition)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
894 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
895 GaimXfer *xfer = (GaimXfer *)data;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
896
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
897 xfer->fd = source;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
898
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
899 begin_transfer(xfer, condition);
3609
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
900 }
4faf84dfdda2 [gaim-migrate @ 3722]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
901
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
902 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
903 gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip,
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
904 unsigned int port)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
905 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
906 GaimInputCondition cond;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
907 GaimXferType type;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
908
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
909 g_return_if_fail(xfer != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
910 g_return_if_fail(gaim_xfer_get_type(xfer) != GAIM_XFER_UNKNOWN);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
911
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
912 type = gaim_xfer_get_type(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
913
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
914 xfer->bytes_remaining = gaim_xfer_get_size(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
915 xfer->bytes_sent = 0;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
916
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
917 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_STARTED);
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
918
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
919 if (type == GAIM_XFER_RECEIVE) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
920 cond = GAIM_INPUT_READ;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
921
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
922 if (ip != NULL) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
923 xfer->remote_ip = g_strdup(ip);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
924 xfer->remote_port = port;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
925
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
926 /* Establish a file descriptor. */
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
927 gaim_proxy_connect(xfer->account, xfer->remote_ip,
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
928 xfer->remote_port, connect_cb, xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
929
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
930 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
931 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
932 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
933 xfer->fd = fd;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
934 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
935 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
936 else {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
937 cond = GAIM_INPUT_WRITE;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
938
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
939 xfer->fd = fd;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
940 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
941
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
942 begin_transfer(xfer, cond);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
943 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
944
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
945 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
946 gaim_xfer_end(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
947 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
948 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
949
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
950 /* See if we are actually trying to cancel this. */
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
951 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_DONE) {
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
952 gaim_xfer_cancel_local(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
953 return;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
954 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
955
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
956 if (xfer->ops.end != NULL)
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
957 xfer->ops.end(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
958
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
959 if (xfer->watcher != 0) {
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
960 gaim_input_remove(xfer->watcher);
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
961 xfer->watcher = 0;
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
962 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
963
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
964 if (xfer->fd != 0)
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
965 close(xfer->fd);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
966
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
967 if (xfer->dest_fp != NULL) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
968 fclose(xfer->dest_fp);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
969 xfer->dest_fp = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
970 }
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
971
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
972 gaim_xfer_unref(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
973 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
974
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
975 void
8585
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
976 gaim_xfer_add(GaimXfer *xfer)
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
977 {
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
978 GaimXferUiOps *ui_ops;
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
979
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
980 g_return_if_fail(xfer != NULL);
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
981
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
982 ui_ops = gaim_xfer_get_ui_ops(xfer);
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
983
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
984 if (ui_ops != NULL && ui_ops->add_xfer != NULL)
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
985 ui_ops->add_xfer(xfer);
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
986 }
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
987
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
988 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
989 gaim_xfer_cancel_local(GaimXfer *xfer)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
990 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
991 GaimXferUiOps *ui_ops;
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
992 char *msg = NULL;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
993
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
994 g_return_if_fail(xfer != NULL);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
995
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
996 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_LOCAL);
7738
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7272
diff changeset
997
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
998 if (gaim_xfer_get_filename(xfer) != NULL)
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
999 {
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1000 msg = g_strdup_printf(_("You canceled the transfer of %s"),
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
1001 gaim_xfer_get_filename(xfer));
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1002 }
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1003 else
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1004 {
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1005 msg = g_strdup_printf(_("File transfer cancelled"));
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1006 }
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
1007 gaim_xfer_conversation_write(xfer, msg, FALSE);
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
1008 g_free(msg);
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
1009
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1010 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1011 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1012 if (xfer->ops.cancel_send != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1013 xfer->ops.cancel_send(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1014 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1015 else
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1016 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1017 if (xfer->ops.cancel_recv != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1018 xfer->ops.cancel_recv(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1019 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1020
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1021 if (xfer->watcher != 0) {
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1022 gaim_input_remove(xfer->watcher);
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1023 xfer->watcher = 0;
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1024 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1025
4521
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1026 if (xfer->fd != 0)
dda0fbba1c46 [gaim-migrate @ 4799]
Christian Hammond <chipx86@chipx86.com>
parents: 4518
diff changeset
1027 close(xfer->fd);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1028
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1029 if (xfer->dest_fp != NULL) {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1030 fclose(xfer->dest_fp);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1031 xfer->dest_fp = NULL;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1032 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1033
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1034 ui_ops = gaim_xfer_get_ui_ops(xfer);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1035
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1036 if (ui_ops != NULL && ui_ops->cancel_local != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1037 ui_ops->cancel_local(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1038
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1039 xfer->bytes_remaining = 0;
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
1040
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
1041 gaim_xfer_unref(xfer);
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1042 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1043
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1044 void
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1045 gaim_xfer_cancel_remote(GaimXfer *xfer)
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1046 {
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1047 GaimXferUiOps *ui_ops;
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
1048 gchar *msg;
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1049 GaimAccount *account;
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1050 GaimBuddy *buddy;
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1051
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1052 g_return_if_fail(xfer != NULL);
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1053
9771
9812dde4323e [gaim-migrate @ 10639]
Mark Doliner <mark@kingant.net>
parents: 9523
diff changeset
1054 gaim_request_close_with_handle(xfer);
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
1055 gaim_xfer_set_status(xfer, GAIM_XFER_STATUS_CANCEL_REMOTE);
9771
9812dde4323e [gaim-migrate @ 10639]
Mark Doliner <mark@kingant.net>
parents: 9523
diff changeset
1056
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1057 account = gaim_xfer_get_account(xfer);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1058 buddy = gaim_find_buddy(account, xfer->who);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1059
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1060 if (gaim_xfer_get_filename(xfer) != NULL)
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1061 {
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1062 msg = g_strdup_printf(_("%s canceled the transfer of %s"),
10774
d83f745c997b [gaim-migrate @ 12383]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10654
diff changeset
1063 buddy ? gaim_buddy_get_alias(buddy) : xfer->who, gaim_xfer_get_filename(xfer));
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1064 }
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1065 else
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1066 {
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1067 msg = g_strdup_printf(_("%s canceled the file transfer"),
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1068 buddy ? gaim_buddy_get_alias(buddy) : xfer->who);
10470
eaa9552a5e0f [gaim-migrate @ 11752]
Mark Doliner <mark@kingant.net>
parents: 10259
diff changeset
1069 }
9932
3fa121db91d0 [gaim-migrate @ 10824]
Mark Doliner <mark@kingant.net>
parents: 9805
diff changeset
1070 gaim_xfer_conversation_write(xfer, msg, TRUE);
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1071 gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg);
9771
9812dde4323e [gaim-migrate @ 10639]
Mark Doliner <mark@kingant.net>
parents: 9523
diff changeset
1072 g_free(msg);
9812dde4323e [gaim-migrate @ 10639]
Mark Doliner <mark@kingant.net>
parents: 9523
diff changeset
1073
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1074 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1075 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1076 if (xfer->ops.cancel_send != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1077 xfer->ops.cancel_send(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1078 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1079 else
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1080 {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1081 if (xfer->ops.cancel_recv != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1082 xfer->ops.cancel_recv(xfer);
7272
02f697df677b [gaim-migrate @ 7849]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
1083 }
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1084
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1085 if (xfer->watcher != 0) {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1086 gaim_input_remove(xfer->watcher);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1087 xfer->watcher = 0;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1088 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1089
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1090 if (xfer->fd != 0)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1091 close(xfer->fd);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1092
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1093 if (xfer->dest_fp != NULL) {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1094 fclose(xfer->dest_fp);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1095 xfer->dest_fp = NULL;
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1096 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1097
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1098 ui_ops = gaim_xfer_get_ui_ops(xfer);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1099
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1100 if (ui_ops != NULL && ui_ops->cancel_remote != NULL)
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4656
diff changeset
1101 ui_ops->cancel_remote(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1102
4528
f8fec48f0fde [gaim-migrate @ 4806]
Christian Hammond <chipx86@chipx86.com>
parents: 4521
diff changeset
1103 xfer->bytes_remaining = 0;
7805
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
1104
5f0bb52c0609 [gaim-migrate @ 8452]
Mark Doliner <mark@kingant.net>
parents: 7738
diff changeset
1105 gaim_xfer_unref(xfer);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1106 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1107
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1108 void
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1109 gaim_xfer_error(GaimXferType type, GaimAccount *account, const char *who, const char *msg)
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1110 {
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1111 char *title;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1112
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1113 g_return_if_fail(msg != NULL);
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1114 g_return_if_fail(type != GAIM_XFER_UNKNOWN);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1115
10654
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1116 if (account) {
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1117 GaimBuddy *buddy;
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1118 buddy = gaim_find_buddy(account, who);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1119 if (buddy)
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1120 who = gaim_buddy_get_alias(buddy);
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1121 }
f2e86683cafc [gaim-migrate @ 12182]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
1122
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1123 if (type == GAIM_XFER_SEND)
11231
64e2c65ef650 [gaim-migrate @ 13371]
Richard Laager <rlaager@wiktel.com>
parents: 11159
diff changeset
1124 title = g_strdup_printf(_("File transfer to %s failed."), who);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1125 else
11231
64e2c65ef650 [gaim-migrate @ 13371]
Richard Laager <rlaager@wiktel.com>
parents: 11159
diff changeset
1126 title = g_strdup_printf(_("File transfer from %s failed."), who);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1127
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5169
diff changeset
1128 gaim_notify_error(NULL, NULL, title, msg);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1129
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1130 g_free(title);
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1131 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1132
8585
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1133 void
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1134 gaim_xfer_update_progress(GaimXfer *xfer)
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1135 {
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1136 GaimXferUiOps *ui_ops;
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1137
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1138 g_return_if_fail(xfer != NULL);
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1139
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1140 ui_ops = gaim_xfer_get_ui_ops(xfer);
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1141 if (ui_ops != NULL && ui_ops->update_progress != NULL)
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1142 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1143 }
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1144
e4087b5c0627 [gaim-migrate @ 9335]
Ethan Blanton <elb@pidgin.im>
parents: 8351
diff changeset
1145
6263
3565ee7a5dd3 [gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents: 6242
diff changeset
1146 /**************************************************************************
3565ee7a5dd3 [gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents: 6242
diff changeset
1147 * File Transfer Subsystem API
3565ee7a5dd3 [gaim-migrate @ 6760]
Christian Hammond <chipx86@chipx86.com>
parents: 6242
diff changeset
1148 **************************************************************************/
11281
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1149 void *
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1150 gaim_xfers_get_handle(void) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1151 static int handle = 0;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1152
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1153 return &handle;
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1154 }
6241
9ce44a7f9ae7 [gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
1155
9ce44a7f9ae7 [gaim-migrate @ 6735]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
1156 void
11281
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1157 gaim_xfers_init(void) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1158 void *handle = gaim_xfers_get_handle();
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1159
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1160 /* register signals */
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1161 gaim_signal_register(handle, "file-recv-accept",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1162 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1163 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1164 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1165 gaim_signal_register(handle, "file-send-accept",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1166 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1167 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1168 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1169 gaim_signal_register(handle, "file-recv-start",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1170 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1171 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1172 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1173 gaim_signal_register(handle, "file-send-start",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1174 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1175 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1176 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1177 gaim_signal_register(handle, "file-send-cancel",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1178 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1179 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1180 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1181 gaim_signal_register(handle, "file-recv-cancel",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1182 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1183 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1184 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1185 gaim_signal_register(handle, "file-send-complete",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1186 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1187 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1188 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1189 gaim_signal_register(handle, "file-recv-complete",
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1190 gaim_marshal_VOID__POINTER,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1191 NULL, 1,
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1192 gaim_value_new(GAIM_TYPE_POINTER));
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1193 }
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1194
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1195 void
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1196 gaim_xfers_uninit(void) {
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1197 gaim_signals_disconnect_by_handle(gaim_xfers_get_handle());
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1198 }
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1199
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1200 void
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1201 gaim_xfers_set_ui_ops(GaimXferUiOps *ops) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1202 xfer_ui_ops = ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1203 }
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1204
6240
ac191233b816 [gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1205 GaimXferUiOps *
11281
920a37a4c1be [gaim-migrate @ 13478]
Gary Kramlich <grim@reaperworld.com>
parents: 11231
diff changeset
1206 gaim_xfers_get_ui_ops(void) {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1207 return xfer_ui_ops;
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4249
diff changeset
1208 }