libpurple/purpleprotocolfactory.c

Thu, 03 Sep 2020 20:16:32 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 03 Sep 2020 20:16:32 -0500
changeset 40526
c8cc1a4c4a02
parent 40339
54813fd13c13
child 41024
a2ad2d034162
permissions
-rw-r--r--

Add support for message attachments

Add a PurpleAttachment for storing message attachments

A start to implementing the attachment api in PidginMessage

Add PidginAttachment that wraps PurpleAttachment.

Finish implementing the attachment management api in PidginMessage

Add PidginAttachment to the docs

Testing Done:
Compiled and ran. Messaged with bonjour.

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

40339
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleprotocolfactory.h"
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 G_DEFINE_INTERFACE(PurpleProtocolFactory, purple_protocol_factory, G_TYPE_INVALID);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 /******************************************************************************
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 * GInterface Implementation
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 *****************************************************************************/
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 static void
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 purple_protocol_factory_default_init(PurpleProtocolFactoryInterface *iface) {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 }
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 /******************************************************************************
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 * Public API
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 *****************************************************************************/
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PurpleConnection *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 purple_protocol_factory_connection_new(PurpleProtocolFactory *factory,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PurpleAccount *account,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 const gchar *password)
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PurpleProtocolFactoryInterface *iface = NULL;
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 g_return_val_if_fail(PURPLE_IS_PROTOCOL_FACTORY(factory), NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 iface = PURPLE_PROTOCOL_FACTORY_GET_IFACE(factory);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 if(iface && iface->connection_new) {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 return iface->connection_new(factory, account, password);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 }
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 return NULL;
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 }
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 PurpleRoomlist *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 purple_protocol_factory_roomlist_new(PurpleProtocolFactory *factory,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 PurpleAccount *account)
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PurpleProtocolFactoryInterface *iface = NULL;
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 g_return_val_if_fail(PURPLE_IS_PROTOCOL_FACTORY(factory), NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 iface = PURPLE_PROTOCOL_FACTORY_GET_IFACE(factory);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 if(iface && iface->roomlist_new) {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 return iface->roomlist_new(factory, account);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 }
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 return NULL;
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 }
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 PurpleWhiteboard *
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 purple_protocol_factory_whiteboard_new(PurpleProtocolFactory *factory,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 PurpleAccount *account,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 const gchar *who,
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 gint state)
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 PurpleProtocolFactoryInterface *iface = NULL;
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 g_return_val_if_fail(PURPLE_IS_PROTOCOL_FACTORY(factory), NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_return_val_if_fail(who, NULL);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 iface = PURPLE_PROTOCOL_FACTORY_GET_IFACE(factory);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 if(iface && iface->whiteboard_new) {
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 return iface->whiteboard_new(factory, account, who, state);
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 }
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 return NULL;
54813fd13c13 Pull PurpleProtocolFactory out to it's own file.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 }

mercurial