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
94
95
96
97
98
99
100
101
102
103
104
|
/*
* Copyright (C) 2012 Collabora Ltd.
*
* 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
*
* Authors: Xavier Claessens <xavier.claessens@collabora.co.uk>
*/
#include "config.h"
#include "client-factory-internal.h"
#include <telepathy-glib/telepathy-glib.h>
#include <telepathy-glib/telepathy-glib-dbus.h>
#include <telepathy-logger/text-channel-internal.h>
#include <telepathy-logger/call-channel-internal.h>
G_DEFINE_TYPE (TplClientFactory, _tpl_client_factory,
TP_TYPE_AUTOMATIC_CLIENT_FACTORY)
#define chainup ((TpClientFactoryClass *) \
_tpl_client_factory_parent_class)
static TpChannel *
create_channel_impl (TpClientFactory *self,
TpConnection *conn,
const gchar *object_path,
const GHashTable *properties,
GError **error)
{
const gchar *chan_type;
chan_type = tp_asv_get_string (properties, TP_PROP_CHANNEL_CHANNEL_TYPE);
if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
{
return (TpChannel *) _tpl_text_channel_new_with_factory (self, conn,
object_path, properties, error);
}
else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_CALL))
{
return (TpChannel *) _tpl_call_channel_new_with_factory (self, conn,
object_path, properties, error);
}
return chainup->create_channel (self, conn, object_path, properties, error);
}
static GArray *
dup_channel_features_impl (TpClientFactory *self,
TpChannel *channel)
{
GArray *features;
GQuark f;
features = chainup->dup_channel_features (self, channel);
if (TPL_IS_CALL_CHANNEL (channel))
{
f = TPL_CALL_CHANNEL_FEATURE_CORE;
g_array_append_val (features, f);
}
else if (TPL_IS_TEXT_CHANNEL (channel))
{
f = TPL_TEXT_CHANNEL_FEATURE_CORE;
g_array_append_val (features, f);
}
return features;
}
static void
_tpl_client_factory_init (TplClientFactory *self)
{
}
static void
_tpl_client_factory_class_init (TplClientFactoryClass *cls)
{
TpClientFactoryClass *factory_class = (TpClientFactoryClass *) cls;
factory_class->create_channel = create_channel_impl;
factory_class->dup_channel_features = dup_channel_features_impl;
}
TpClientFactory *
_tpl_client_factory_new (TpDBusDaemon *dbus)
{
return g_object_new (TPL_TYPE_CLIENT_FACTORY,
"dbus-daemon", dbus,
NULL);
}
|