|
Packit |
3ff832 |
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
|
Packit |
3ff832 |
/* vim:set et sts=4: */
|
|
Packit |
3ff832 |
/* ibus - The Input Bus
|
|
Packit |
3ff832 |
* Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
|
|
Packit |
3ff832 |
* Copyright (C) 2008-2010 Red Hat, Inc.
|
|
Packit |
3ff832 |
*
|
|
Packit |
3ff832 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
3ff832 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
3ff832 |
* License as published by the Free Software Foundation; either
|
|
Packit |
3ff832 |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
3ff832 |
*
|
|
Packit |
3ff832 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
3ff832 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
3ff832 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
3ff832 |
* Lesser General Public License for more details.
|
|
Packit |
3ff832 |
*
|
|
Packit |
3ff832 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
3ff832 |
* License along with this library; if not, write to the Free Software
|
|
Packit |
3ff832 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
|
Packit |
3ff832 |
* USA
|
|
Packit |
3ff832 |
*/
|
|
Packit |
3ff832 |
#include "factoryproxy.h"
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
#include "dbusimpl.h"
|
|
Packit |
3ff832 |
#include "global.h"
|
|
Packit |
3ff832 |
#include "marshalers.h"
|
|
Packit |
3ff832 |
#include "types.h"
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
struct _BusFactoryProxy {
|
|
Packit |
3ff832 |
IBusProxy parent;
|
|
Packit |
3ff832 |
/* instance members */
|
|
Packit |
3ff832 |
};
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
struct _BusFactoryProxyClass {
|
|
Packit |
3ff832 |
IBusProxyClass parent;
|
|
Packit |
3ff832 |
/* class members */
|
|
Packit |
3ff832 |
};
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
/* functions prototype */
|
|
Packit |
3ff832 |
static void bus_factory_proxy_destroy (IBusProxy *proxy);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
G_DEFINE_TYPE (BusFactoryProxy, bus_factory_proxy, IBUS_TYPE_PROXY)
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
static void
|
|
Packit |
3ff832 |
bus_factory_proxy_class_init (BusFactoryProxyClass *class)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
IBUS_PROXY_CLASS (class)->destroy = bus_factory_proxy_destroy;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
static void
|
|
Packit |
3ff832 |
bus_factory_proxy_init (BusFactoryProxy *factory)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
static void
|
|
Packit |
3ff832 |
bus_factory_proxy_destroy (IBusProxy *proxy)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
IBUS_PROXY_CLASS (bus_factory_proxy_parent_class)->destroy (IBUS_PROXY (proxy));
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
BusFactoryProxy *
|
|
Packit |
3ff832 |
bus_factory_proxy_new (BusConnection *connection)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
g_assert (BUS_IS_CONNECTION (connection));
|
|
Packit |
3ff832 |
BusFactoryProxy *factory;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START |
|
|
Packit |
3ff832 |
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES;
|
|
Packit |
3ff832 |
factory = (BusFactoryProxy *) g_initable_new (
|
|
Packit |
3ff832 |
BUS_TYPE_FACTORY_PROXY,
|
|
Packit |
3ff832 |
NULL, NULL,
|
|
Packit |
3ff832 |
"g-object-path", IBUS_PATH_FACTORY,
|
|
Packit |
3ff832 |
"g-interface-name", IBUS_INTERFACE_FACTORY,
|
|
Packit |
3ff832 |
"g-connection", bus_connection_get_dbus_connection (connection),
|
|
Packit |
3ff832 |
"g-default-timeout", g_gdbus_timeout,
|
|
Packit |
3ff832 |
"g-flags", flags,
|
|
Packit |
3ff832 |
NULL);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
return factory;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
void
|
|
Packit |
3ff832 |
bus_factory_proxy_create_engine (BusFactoryProxy *factory,
|
|
Packit |
3ff832 |
IBusEngineDesc *desc,
|
|
Packit |
3ff832 |
gint timeout,
|
|
Packit |
3ff832 |
GCancellable *cancellable,
|
|
Packit |
3ff832 |
GAsyncReadyCallback callback,
|
|
Packit |
3ff832 |
gpointer user_data)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
g_assert (BUS_IS_FACTORY_PROXY (factory));
|
|
Packit |
3ff832 |
g_assert (IBUS_IS_ENGINE_DESC (desc));
|
|
Packit |
3ff832 |
g_assert (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
g_dbus_proxy_call ((GDBusProxy *) factory,
|
|
Packit |
3ff832 |
"CreateEngine",
|
|
Packit |
3ff832 |
g_variant_new ("(s)", ibus_engine_desc_get_name (desc)),
|
|
Packit |
3ff832 |
G_DBUS_CALL_FLAGS_NONE,
|
|
Packit |
3ff832 |
timeout,
|
|
Packit |
3ff832 |
cancellable,
|
|
Packit |
3ff832 |
callback,
|
|
Packit |
3ff832 |
user_data);
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
gchar *
|
|
Packit |
3ff832 |
bus_factory_proxy_create_engine_finish (BusFactoryProxy *factory,
|
|
Packit |
3ff832 |
GAsyncResult *res,
|
|
Packit |
3ff832 |
GError **error)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
GVariant *retval = g_dbus_proxy_call_finish ((GDBusProxy *) factory,
|
|
Packit |
3ff832 |
res,
|
|
Packit |
3ff832 |
error);
|
|
Packit |
3ff832 |
if (retval == NULL)
|
|
Packit |
3ff832 |
return NULL;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
gchar *object_path = NULL;
|
|
Packit |
3ff832 |
g_variant_get (retval, "(o)", &object_path);
|
|
Packit |
3ff832 |
g_variant_unref (retval);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
return object_path;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
|