libpurple/purpleprotocolfiletransfer.c

Sun, 14 Apr 2024 01:14:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sun, 14 Apr 2024 01:14:59 -0500
changeset 42725
ceb13f1de2d2
parent 42594
eddde70cedd8
child 42821
4032fe617b2a
permissions
-rw-r--r--

Remove PurpleBuddy

PurpleContactInfo was created long ago to replace this, it is now its time!

Testing Done:
Ran the turtles.

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

42375
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
42375
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
12 * any later version.
42375
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
17 * more details.
42375
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42375
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
42375
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleprotocolfiletransfer.h"
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 * GInterface Implementation
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 *****************************************************************************/
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 G_DEFINE_INTERFACE(PurpleProtocolFileTransfer, purple_protocol_file_transfer,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 PURPLE_TYPE_PROTOCOL)
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 static void
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 purple_protocol_file_transfer_default_init(G_GNUC_UNUSED PurpleProtocolFileTransferInterface *iface)
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 /******************************************************************************
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 * Public API
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 *****************************************************************************/
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 void
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 purple_protocol_file_transfer_send_async(PurpleProtocolFileTransfer *protocol,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PurpleFileTransfer *transfer,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GAsyncReadyCallback callback,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 gpointer data)
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PurpleProtocolFileTransferInterface *iface = NULL;
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 g_return_if_fail(PURPLE_IS_PROTOCOL_FILE_TRANSFER(protocol));
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 iface = PURPLE_PROTOCOL_FILE_TRANSFER_GET_IFACE(protocol);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 if(iface != NULL && iface->send_async != NULL) {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 iface->send_async(protocol, transfer, callback, data);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 } else {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 g_warning("%s does not implement send_async",
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 G_OBJECT_TYPE_NAME(protocol));
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 gboolean
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 purple_protocol_file_transfer_send_finish(PurpleProtocolFileTransfer *protocol,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 GAsyncResult *result,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 GError **error)
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 PurpleProtocolFileTransferInterface *iface = NULL;
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 g_return_val_if_fail(PURPLE_IS_PROTOCOL_FILE_TRANSFER(protocol), FALSE);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 iface = PURPLE_PROTOCOL_FILE_TRANSFER_GET_IFACE(protocol);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 if(iface != NULL && iface->send_finish != NULL) {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 return iface->send_finish(protocol, result, error);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 } else {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 g_warning("%s does not implement send_finish",
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 G_OBJECT_TYPE_NAME(protocol));
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 return FALSE;
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 void
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 purple_protocol_file_transfer_receive_async(PurpleProtocolFileTransfer *protocol,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 PurpleFileTransfer *transfer,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 GAsyncReadyCallback callback,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 gpointer data)
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 PurpleProtocolFileTransferInterface *iface = NULL;
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 g_return_if_fail(PURPLE_IS_PROTOCOL_FILE_TRANSFER(protocol));
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 iface = PURPLE_PROTOCOL_FILE_TRANSFER_GET_IFACE(protocol);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 if(iface != NULL && iface->receive_async != NULL) {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 iface->receive_async(protocol, transfer, callback, data);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 } else {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 g_warning("%s does not implement receive_async",
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 G_OBJECT_TYPE_NAME(protocol));
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 gboolean
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 purple_protocol_file_transfer_receive_finish(PurpleProtocolFileTransfer *protocol,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 GAsyncResult *result,
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 GError **error)
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 PurpleProtocolFileTransferInterface *iface = NULL;
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 g_return_val_if_fail(PURPLE_IS_PROTOCOL_FILE_TRANSFER(protocol), FALSE);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 iface = PURPLE_PROTOCOL_FILE_TRANSFER_GET_IFACE(protocol);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 if(iface != NULL && iface->receive_finish != NULL) {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 return iface->receive_finish(protocol, result, error);
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 } else {
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 g_warning("%s does not implement receive_finish",
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 G_OBJECT_TYPE_NAME(protocol));
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 }
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 return FALSE;
8e61249e9b10 Implement ProtocolFileTransfer
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 }

mercurial