summaryrefslogtreecommitdiff
path: root/src/caps-channel-manager.c
blob: ec18975e43b6108fe8bf2c95f87582b71913cd8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * caps-channel-manager.c - interface holding capabilities functions for
 * channel managers
 *
 * Copyright (C) 2008 Collabora Ltd.
 * Copyright (C) 2008 Nokia Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "config.h"
#include "gabble/caps-channel-manager.h"

#include <telepathy-glib/telepathy-glib.h>

#define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
#include "debug.h"

G_DEFINE_INTERFACE (GabbleCapsChannelManager, gabble_caps_channel_manager,
    TP_TYPE_CHANNEL_MANAGER);

/* stub function needed for the G_DEFINE_INTERFACE macro above */
static void
gabble_caps_channel_manager_default_init (
    GabbleCapsChannelManagerInterface *interface)
{
}

/* Virtual-method wrappers */
void
gabble_caps_channel_manager_get_contact_capabilities (
    GabbleCapsChannelManager *caps_manager,
    TpHandle handle,
    const GabbleCapabilitySet *caps,
    GPtrArray *arr)
{
  GabbleCapsChannelManagerInterface *iface =
    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
  GabbleCapsChannelManagerGetContactCapsFunc method = iface->get_contact_caps;

  if (method != NULL)
    {
      method (caps_manager, handle, caps, arr);
    }
  /* ... else assume there are no caps for this kind of channel */
}

/**
 * gabble_caps_channel_manager_represent_client:
 * @self: a channel manager
 * @client_name: the name of the client, for any debug messages
 * @filters: the channel classes accepted by the client, as an array of
 *  GHashTable with string keys and GValue values
 * @cap_tokens: the handler capability tokens supported by the client
 * @cap_set: a set into which to merge additional XMPP capabilities
 * @data_forms: a #GPtrArray of #WockyDataForm objects
 *
 * Convert the capabilities of a Telepathy client into XMPP capabilities to be
 * advertised.
 *
 * (The actual XMPP capabilities advertised will be the union of the XMPP
 * capabilities of every installed client.)
 */
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)
{
  GabbleCapsChannelManagerInterface *iface =
    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
  GabbleCapsChannelManagerRepresentClientFunc method = iface->represent_client;

  if (method != NULL)
    {
      method (caps_manager, client_name, filters, cap_tokens, cap_set, data_forms);
    }
}