Commit bcba856a by Florian Müllner Committed by Bastian Ilsø Hougaard

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
parent 30067e51
/* 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)
{
}
/* 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
......@@ -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
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment