1 /*
2 * caps-channel-manager.c - interface holding capabilities functions for
3 * channel managers
4 *
5 * Copyright (C) 2008 Collabora Ltd.
6 * Copyright (C) 2008 Nokia Corporation
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config.h"
24
25 #include <salut/caps-channel-manager.h>
26
27 #include <telepathy-glib/dbus.h>
28 #include <telepathy-glib/channel-manager.h>
29
30
31 #define DEBUG_FLAG DEBUG_PRESENCE
32 #include "debug.h"
33
34 GType
gabble_caps_channel_manager_get_type(void)35 gabble_caps_channel_manager_get_type (void)
36 {
37 static GType type = 0;
38
39 if (G_UNLIKELY (type == 0))
40 {
41 static const GTypeInfo info = {
42 sizeof (GabbleCapsChannelManagerIface),
43 NULL, /* base_init */
44 NULL, /* base_finalize */
45 NULL, /* class_init */
46 NULL, /* class_finalize */
47 NULL, /* class_data */
48 0,
49 0, /* n_preallocs */
50 NULL /* instance_init */
51 };
52
53 type = g_type_register_static (G_TYPE_INTERFACE,
54 "GabbleCapsChannelManager", &info, 0);
55
56 g_type_interface_add_prerequisite (type, TP_TYPE_CHANNEL_MANAGER);
57 }
58
59 return type;
60 }
61
62 /* Virtual-method wrappers */
63 void
gabble_caps_channel_manager_reset_capabilities(GabbleCapsChannelManager * caps_manager)64 gabble_caps_channel_manager_reset_capabilities (
65 GabbleCapsChannelManager *caps_manager)
66 {
67 GabbleCapsChannelManagerIface *iface =
68 GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
69 GabbleCapsChannelManagerResetCapsFunc method = iface->reset_caps;
70
71 if (method != NULL)
72 {
73 method (caps_manager);
74 }
75 /* ... else assume there is no need to reset the caps */
76 }
77
78 void
gabble_caps_channel_manager_get_contact_capabilities(GabbleCapsChannelManager * caps_manager,TpHandle handle,const GabbleCapabilitySet * caps,GPtrArray * arr)79 gabble_caps_channel_manager_get_contact_capabilities (
80 GabbleCapsChannelManager *caps_manager,
81 TpHandle handle,
82 const GabbleCapabilitySet *caps,
83 GPtrArray *arr)
84 {
85 GabbleCapsChannelManagerIface *iface =
86 GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
87 GabbleCapsChannelManagerGetContactCapsFunc method = iface->get_contact_caps;
88
89 if (method != NULL)
90 {
91 method (caps_manager, handle, caps, arr);
92 }
93 /* ... else assume there is not caps for this kind of channels */
94 }
95
96 /**
97 * gabble_caps_channel_manager_represent_client:
98 * @self: a channel manager
99 * @client_name: the name of the client, for any debug messages
100 * @filters: the channel classes accepted by the client, as an array of
101 * GHashTable with string keys and GValue values
102 * @cap_tokens: the handler capability tokens supported by the client
103 * @cap_set: a set into which to merge additional XMPP capabilities
104 *
105 * Convert the capabilities of a Telepathy client into XMPP capabilities to be
106 * advertised.
107 *
108 * (The actual XMPP capabilities advertised will be the union of the XMPP
109 * capabilities of every installed client.)
110 */
111 void
gabble_caps_channel_manager_represent_client(GabbleCapsChannelManager * caps_manager,const gchar * client_name,const GPtrArray * filters,const gchar * const * cap_tokens,GabbleCapabilitySet * cap_set,GPtrArray * data_forms)112 gabble_caps_channel_manager_represent_client (
113 GabbleCapsChannelManager *caps_manager,
114 const gchar *client_name,
115 const GPtrArray *filters,
116 const gchar * const *cap_tokens,
117 GabbleCapabilitySet *cap_set,
118 GPtrArray *data_forms)
119 {
120 GabbleCapsChannelManagerIface *iface =
121 GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
122 GabbleCapsChannelManagerRepresentClientFunc method = iface->represent_client;
123
124 if (method != NULL)
125 {
126 method (caps_manager, client_name, filters, cap_tokens, cap_set, data_forms);
127 }
128 }
129