[polari/wip/fmuellner/disconnect-accounts: 2/6] lib: Add a small wrapper around TpAutomaticClientFactory
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/disconnect-accounts: 2/6] lib: Add a small wrapper around TpAutomaticClientFactory
- Date: Fri, 2 Feb 2018 21:23:30 +0000 (UTC)
commit bcba856a47ac0b9f4bd4097c9d83d610bd8df90b
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Nov 9 03:10:27 2017 +0100
lib: Add a small wrapper around TpAutomaticClientFactory
Introspection depends on a corresponding invoker function of virtual
methods for transfer annotations, so all create_* vfuncs in
TpSimpleClientFactory are non-introspectable.
Work around this with a small wrapper class that exposes the vfunc
we are interested in to gobject-introspection.
https://bugzilla.gnome.org/show_bug.cgi?id=771889
src/lib/polari-client-factory.c | 73 +++++++++++++++++++++++++++++++++++++++++
src/lib/polari-client-factory.h | 43 ++++++++++++++++++++++++
src/lib/polari-tp-autocleanup.h | 1 +
src/meson.build | 2 ++
4 files changed, 119 insertions(+)
---
diff --git a/src/lib/polari-client-factory.c b/src/lib/polari-client-factory.c
new file mode 100644
index 0000000..18ebb08
--- /dev/null
+++ b/src/lib/polari-client-factory.c
@@ -0,0 +1,73 @@
+/* polari-client-factory.c
+ *
+ * Copyright © 2017 Florian Müllner <fmuellner gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "polari-client-factory.h"
+
+G_DEFINE_TYPE (PolariClientFactory, polari_client_factory, TP_TYPE_AUTOMATIC_CLIENT_FACTORY)
+
+PolariClientFactory *
+polari_client_factory_new (void)
+{
+ return g_object_new (POLARI_TYPE_CLIENT_FACTORY, NULL);
+}
+
+/**
+ * polari_client_factory_create_account:
+ * Returns: (transfer full):
+ */
+TpAccount *
+polari_client_factory_create_account (PolariClientFactory *self,
+ const char *object_path,
+ GError **error)
+{
+ PolariClientFactoryClass *klass = POLARI_CLIENT_FACTORY_GET_CLASS (self);
+ TpSimpleClientFactoryClass *simple_class =
+ TP_SIMPLE_CLIENT_FACTORY_CLASS (polari_client_factory_parent_class);
+
+ if (klass->create_account)
+ return klass->create_account (self, object_path, error);
+
+ return simple_class->create_account (TP_SIMPLE_CLIENT_FACTORY (self),
+ object_path,
+ NULL,
+ error);
+}
+
+static TpAccount *
+polari_client_factory_create_account_impl (TpSimpleClientFactory *self,
+ const char *object_path,
+ const GHashTable *immutable_props,
+ GError **error)
+{
+ return polari_client_factory_create_account (POLARI_CLIENT_FACTORY (self),
+ object_path,
+ error);
+}
+
+static void
+polari_client_factory_class_init (PolariClientFactoryClass *klass)
+{
+ TpSimpleClientFactoryClass *simple_class = TP_SIMPLE_CLIENT_FACTORY_CLASS (klass);
+
+ simple_class->create_account = polari_client_factory_create_account_impl;
+}
+
+static void
+polari_client_factory_init (PolariClientFactory *self)
+{
+}
diff --git a/src/lib/polari-client-factory.h b/src/lib/polari-client-factory.h
new file mode 100644
index 0000000..dbf771d
--- /dev/null
+++ b/src/lib/polari-client-factory.h
@@ -0,0 +1,43 @@
+/* polari-client-factory.h
+ *
+ * Copyright © 2017 Florian Müllner <fmuellner gnome org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <telepathy-glib/telepathy-glib.h>
+#include "polari-tp-autocleanup.h"
+
+G_BEGIN_DECLS
+
+#define POLARI_TYPE_CLIENT_FACTORY (polari_client_factory_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (PolariClientFactory, polari_client_factory, POLARI, CLIENT_FACTORY,
TpAutomaticClientFactory)
+
+struct _PolariClientFactoryClass
+{
+ TpAutomaticClientFactoryClass parent;
+
+ TpAccount * (*create_account) (PolariClientFactory *self,
+ const char *object_path,
+ GError **error);
+};
+
+PolariClientFactory *polari_client_factory_new (void);
+TpAccount *polari_client_factory_create_account (PolariClientFactory *self,
+ const char *object_path,
+ GError **error);
+
+G_END_DECLS
diff --git a/src/lib/polari-tp-autocleanup.h b/src/lib/polari-tp-autocleanup.h
index 274d5bd..d3716c4 100644
--- a/src/lib/polari-tp-autocleanup.h
+++ b/src/lib/polari-tp-autocleanup.h
@@ -22,6 +22,7 @@
G_BEGIN_DECLS
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (TpAutomaticClientFactory, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TpMessage, g_object_unref)
G_END_DECLS
diff --git a/src/meson.build b/src/meson.build
index 9a1b188..d815d6b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -83,6 +83,8 @@ polari = executable('polari', ['polari.c', src_resources, data_resources],
)
libsources = [
+ 'lib/polari-client-factory.c',
+ 'lib/polari-client-factory.h',
'lib/polari-drag-helper.c',
'lib/polari-drag-helper.h',
'lib/polari-room.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]