summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-08 13:41:56 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-09-08 13:55:37 +0100
commit3177f72e2c248643bf69ec5fda488d8361d5c1e1 (patch)
tree7001bfc551d8697ab3c604c497104ceac763b07c
parentc0ad2048de760b16649649de88bbe4e49caed971 (diff)
client-factory: implement simple TpAutomaticClientFactory subclass
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--docs/reference/telepathy-ytstenut-glib-docs.sgml1
-rw-r--r--docs/reference/telepathy-ytstenut-glib-sections.txt16
-rw-r--r--telepathy-ytstenut-glib/Makefile.am2
-rw-r--r--telepathy-ytstenut-glib/client-factory.c113
-rw-r--r--telepathy-ytstenut-glib/client-factory.h63
5 files changed, 195 insertions, 0 deletions
diff --git a/docs/reference/telepathy-ytstenut-glib-docs.sgml b/docs/reference/telepathy-ytstenut-glib-docs.sgml
index 8cd1ce4..c6d0c3d 100644
--- a/docs/reference/telepathy-ytstenut-glib-docs.sgml
+++ b/docs/reference/telepathy-ytstenut-glib-docs.sgml
@@ -17,6 +17,7 @@
<title>Using Ytstenut Objects</title>
<xi:include href="xml/account-manager.xml"/>
<xi:include href="xml/channel.xml"/>
+ <xi:include href="xml/client-factory.xml"/>
<xi:include href="xml/channel-factory.xml"/>
<xi:include href="xml/client.xml"/>
<xi:include href="xml/status.xml"/>
diff --git a/docs/reference/telepathy-ytstenut-glib-sections.txt b/docs/reference/telepathy-ytstenut-glib-sections.txt
index 6fbca6d..854503f 100644
--- a/docs/reference/telepathy-ytstenut-glib-sections.txt
+++ b/docs/reference/telepathy-ytstenut-glib-sections.txt
@@ -169,6 +169,22 @@ TP_IS_YTS_CHANNEL_FACTORY_CLASS
</SECTION>
<SECTION>
+<FILE>client-factory</FILE>
+tp_yts_client_factory_new
+TpYtsClientFactory
+TpYtsClientFactoryClass
+<SUBSECTION Standard>
+tp_yts_client_factory_get_type
+TpYtsClientFactoryPrivate
+TP_YTS_CLIENT_FACTORY
+TP_YTS_CLIENT_FACTORY_CLASS
+TP_YTS_CLIENT_FACTORY_GET_CLASS
+TP_TYPE_YTS_CLIENT_FACTORY
+TP_IS_YTS_CLIENT_FACTORY
+TP_IS_YTS_CLIENT_FACTORY_CLASS
+</SECTION>
+
+<SECTION>
<FILE>svc-channel</FILE>
TpYtsSvcChannel
TpYtsSvcChannelClass
diff --git a/telepathy-ytstenut-glib/Makefile.am b/telepathy-ytstenut-glib/Makefile.am
index bdb8e71..28a7243 100644
--- a/telepathy-ytstenut-glib/Makefile.am
+++ b/telepathy-ytstenut-glib/Makefile.am
@@ -16,6 +16,8 @@ libtelepathy_ytstenut_glib_la_SOURCES = \
channel.h \
channel-factory.c \
channel-factory.h \
+ client-factory.c \
+ client-factory.h \
client.c \
client.h \
generated.h \
diff --git a/telepathy-ytstenut-glib/client-factory.c b/telepathy-ytstenut-glib/client-factory.c
new file mode 100644
index 0000000..efed607
--- /dev/null
+++ b/telepathy-ytstenut-glib/client-factory.c
@@ -0,0 +1,113 @@
+/*
+ * client-factory.c - client factory for TpYtsChannel
+ *
+ * Copyright (C) 2011 Intel Corp.
+ *
+ * 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 "client-factory.h"
+#include "channel.h"
+
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/util.h>
+
+#define DEBUG(msg, ...) \
+ g_debug ("%s: " msg, G_STRFUNC, ##__VA_ARGS__)
+
+/**
+ * SECTION:client-factory
+ * @title: TpYtsClientFactory
+ * @short_description: client factory for #TpYtsChannel
+ *
+ * A #TpSimpleClientFactory for creating #TpYtsChannel objects. In general
+ * you won't need to use this object directly because #TpYtsAccountManager creates
+ * and uses it as necessary.
+ */
+
+/**
+ * TpYtsClientFactory:
+ *
+ * A factory for creating #TpYtsChannel objects.
+ */
+
+/**
+ * TpYtsClientFactoryClass:
+ *
+ * The class of a #TpYtsClientFactory.
+ */
+
+G_DEFINE_TYPE (TpYtsClientFactory, tp_yts_client_factory,
+ TP_TYPE_AUTOMATIC_CLIENT_FACTORY)
+
+#define chainup ((TpSimpleClientFactoryClass *) \
+ tp_yts_client_factory_parent_class)
+
+static void
+tp_yts_client_factory_init (TpYtsClientFactory *self)
+{
+
+}
+
+static TpChannel *
+tp_yts_client_factory_obj_create_channel (TpSimpleClientFactory *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_YTS_IFACE_CHANNEL))
+ {
+ return tp_yts_channel_new_with_factory (self, conn, object_path,
+ (GHashTable *) properties, error);
+ }
+
+ /* Chainup on parent implementation as fallback */
+ return chainup->create_channel (self, conn, object_path, properties, error);
+}
+
+static void
+tp_yts_client_factory_class_init (TpYtsClientFactoryClass *klass)
+{
+ TpSimpleClientFactoryClass *simple_class = (TpSimpleClientFactoryClass *) klass;
+
+ simple_class->create_channel = tp_yts_client_factory_obj_create_channel;
+}
+
+/**
+ * tp_yts_client_factory_new:
+ *
+ * Create a new #TpYtsClientFactory object. In general you won't need to
+ * call this function because #TpYtsClient creates #TpYtsClientFactory
+ * objects as necessary.
+ *
+ * Returns: A newly allocated factory object.
+ */
+TpSimpleClientFactory *
+tp_yts_client_factory_new (TpDBusDaemon *dbus)
+{
+ g_return_val_if_fail (TP_IS_DBUS_DAEMON (dbus), NULL);
+
+ return g_object_new (TP_TYPE_YTS_CLIENT_FACTORY,
+ "dbus-daemon", dbus,
+ NULL);
+}
diff --git a/telepathy-ytstenut-glib/client-factory.h b/telepathy-ytstenut-glib/client-factory.h
new file mode 100644
index 0000000..a5e543f
--- /dev/null
+++ b/telepathy-ytstenut-glib/client-factory.h
@@ -0,0 +1,63 @@
+/*
+ * client-factory.h - client factory for TpYtsClient
+ *
+ * Copyright (C) 2011 Intel Corp.
+ *
+ * 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
+ */
+
+#ifndef TP_YTS_CLIENT_FACTORY_H
+#define TP_YTS_CLIENT_FACTORY_H
+
+#include <telepathy-glib/automatic-client-factory.h>
+
+G_BEGIN_DECLS
+
+typedef struct _TpYtsClientFactory TpYtsClientFactory;
+typedef struct _TpYtsClientFactoryClass TpYtsClientFactoryClass;
+typedef struct _TpYtsClientFactoryPrivate TpYtsClientFactoryPrivate;
+
+struct _TpYtsClientFactory {
+ /*<private>*/
+ TpAutomaticClientFactory parent;
+ TpYtsClientFactoryPrivate *priv;
+};
+
+struct _TpYtsClientFactoryClass {
+ /*<private>*/
+ TpAutomaticClientFactoryClass parent_class;
+ GCallback _padding[7];
+};
+
+GType tp_yts_client_factory_get_type (void);
+
+#define TP_TYPE_YTS_CLIENT_FACTORY (tp_yts_client_factory_get_type ())
+#define TP_YTS_CLIENT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ TP_TYPE_YTS_CLIENT_FACTORY, TpYtsClientFactory))
+#define TP_YTS_CLIENT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ TP_TYPE_YTS_CLIENT_FACTORY, TpYtsClientFactoryClass))
+#define TP_IS_YTS_CLIENT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ TP_TYPE_YTS_CLIENT_FACTORY))
+#define TP_IS_YTS_CLIENT_FACTORY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TYPE_YTS_CLIENT_FACTORY))
+#define TP_YTS_CLIENT_FACTORY_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_YTS_CLIENT_FACTORY, \
+ TpYtsClientFactoryClass))
+
+TpSimpleClientFactory *tp_yts_client_factory_new (TpDBusDaemon *dbus);
+
+G_END_DECLS
+
+#endif