summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collaora.co.uk>2011-03-29 10:08:58 +0200
committerStef Walter <stefw@collaora.co.uk>2011-03-29 12:21:00 +0200
commitfcc89db5e4b59b41fad72d161c29fd7d09c691bf (patch)
tree5d5669e760a9402390e879da4ed9a02db50ed9c3
parent7bce4e654ce59de52640bff587ab64f3d48e927e (diff)
Use TpProxy to make EnsureSidecar call.
-rw-r--r--configure.ac1
-rw-r--r--telepathy-ytstenut-glib/Makefile.am21
-rw-r--r--telepathy-ytstenut-glib/extensions/Connection_Future.xml110
-rw-r--r--telepathy-ytstenut-glib/extensions/Makefile.am70
-rw-r--r--telepathy-ytstenut-glib/extensions/all.xml9
-rw-r--r--telepathy-ytstenut-glib/extensions/connection-future.c131
-rw-r--r--telepathy-ytstenut-glib/extensions/connection-future.h43
-rw-r--r--telepathy-ytstenut-glib/extensions/extensions.c4
-rw-r--r--telepathy-ytstenut-glib/extensions/extensions.h14
-rw-r--r--telepathy-ytstenut-glib/status.c102
10 files changed, 419 insertions, 86 deletions
diff --git a/configure.ac b/configure.ac
index 3ada5c9..ce2c01a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -211,5 +211,6 @@ AC_OUTPUT([
telepathy-ytstenut-glib/Makefile
telepathy-ytstenut-glib/telepathy-ytstenut-glib.pc
telepathy-ytstenut-glib/telepathy-ytstenut-glib-uninstalled.pc
+ telepathy-ytstenut-glib/extensions/Makefile
telepathy-ytstenut-glib/tests/Makefile
])
diff --git a/telepathy-ytstenut-glib/Makefile.am b/telepathy-ytstenut-glib/Makefile.am
index 0169d1c..4c871db 100644
--- a/telepathy-ytstenut-glib/Makefile.am
+++ b/telepathy-ytstenut-glib/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = . tests
+SUBDIRS = extensions . tests
pkgconfigdir = ${libdir}/pkgconfig
pkgconfig_DATA = telepathy-ytstenut-glib.pc
@@ -38,6 +38,9 @@ nodist_libtelepathy_ytstenut_glib_la_SOURCES = \
libtelepathy_ytstenut_glib_la_LDFLAGS = \
-version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)"
+libtelepathy_ytstenut_glib_la_LIBADD = \
+ $(builddir)/extensions/libfuture-extensions.la
+
BUILT_SOURCES = \
_gen/all.xml \
$(nodist_libtelepathy_ytstenut_glib_la_SOURCES)
@@ -62,9 +65,18 @@ EXTRA_DIST = \
CLEANFILES = \
$(BUILT_SOURCES)
-AM_CFLAGS = $(ERROR_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@ @TP_GLIB_CFLAGS@ \
+AM_CFLAGS = \
+ $(ERROR_CFLAGS) \
+ @DBUS_CFLAGS@ \
+ @GLIB_CFLAGS@ \
+ @TP_GLIB_CFLAGS@ \
-I$(top_srcdir)
-AM_LDFLAGS = @DBUS_LIBS@ @GLIB_LIBS@ @TP_GLIB_LIBS@
+
+AM_LDFLAGS = \
+ @DBUS_LIBS@ \
+ @GLIB_LIBS@ \
+ @TP_GLIB_LIBS@
+
# Generated stuff
@@ -115,8 +127,7 @@ _gen/signals-marshal.c: _gen/signals-marshal.list Makefile.am
$(AM_V_GEN){ echo '#include "_gen/signals-marshal.h"' && \
$(GLIB_GENMARSHAL) --body --prefix=_tp_yts_marshal $< ; } > $@
-_gen/enums.h: _gen/all.xml $(tools_dir)/c-constants-gen.py \
- Makefile.am
+_gen/enums.h: _gen/all.xml $(tools_dir)/c-constants-gen.py Makefile.am
$(AM_V_GEN)$(PYTHON) $(tools_dir)/c-constants-gen.py Tp_Yts $< > $@
_gen/interfaces.h _gen/interfaces-body.h: _gen/all.xml \
diff --git a/telepathy-ytstenut-glib/extensions/Connection_Future.xml b/telepathy-ytstenut-glib/extensions/Connection_Future.xml
new file mode 100644
index 0000000..6b5291e
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/Connection_Future.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" ?>
+<node name="/Connection_FUTURE"
+ xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
+ >
+ <tp:copyright>Copyright © 2009 Collabora Limited</tp:copyright>
+ <tp:copyright>Copyright © 2009 Nokia Corporation</tp:copyright>
+ <tp:license xmlns="http://www.w3.org/1999/xhtml">
+<p>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.</p>
+
+<p>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.</p>
+
+<p>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 Street, Fifth Floor, Boston, MA 02110-1301,
+USA.</p>
+ </tp:license>
+ <interface name="org.freedesktop.Telepathy.Connection.FUTURE"
+ tp:causes-havoc='experimental'>
+ <tp:requires interface="org.freedesktop.Telepathy.Connection"/>
+
+ <method name="EnsureSidecar" tp:name-for-bindings="Ensure_Sidecar">
+ <tp:added version="0.19.0">(as a draft)</tp:added>
+
+ <arg direction="in" name="Main_Interface" type="s"
+ tp:type="DBus_Interface">
+ <tp:docstring>
+ The "primary" interface implemented by an object attached
+ to a connection. For example, a Gabble plugin implementing
+ fine-grained control of XEP-0016 privacy lists might expose an object
+ implementing <tt>com.example.PrivacyLists</tt>.
+ </tp:docstring>
+ </arg>
+
+ <arg direction="out" name="Path" type="o">
+ <tp:docstring>The object path of the sidecar, exported by the same bus
+ name as the Connection to which it is attached.</tp:docstring>
+ </arg>
+ <arg direction="out" name="Properties" type="a{sv}"
+ tp:type="Qualified_Property_Value_Map">
+ <tp:docstring>Immutable properties of the sidecar.</tp:docstring>
+ </arg>
+
+ <tp:docstring xmlns="http://www.w3.org/1999/xhtml">
+ <p>Request an object with a particular interface providing additional
+ connection-specific functionality, together with its immutable
+ properties. These will often be implemented by plug-ins to the
+ connection managers; for example, support for an XMPP XEP for which
+ no generic Telepathy interface exists might be implemented by a
+ Gabble plugin exposing a sidecar with a particular interface.</p>
+
+ <p>This method may be called at any point during the lifetime of a
+ connection, even before its <tp:type>Connection_Status</tp:type>
+ changes to Connected. It MAY take a long time to
+ return—perhaps it needs to wait for a connection to be established
+ and for all the services supported by the server to be discovered
+ before determining whether necessary server-side support is
+ available—so callers SHOULD override the default method timeout (25
+ seconds) with a much higher value (perhaps even MAX_INT32, meaning
+ “no timeout” in recent versions of libdbus).</p>
+
+ <tp:rationale>
+ <p>There is an implicit assumption that any connection
+ manager plugin will only want to export one “primary” object per
+ feature it implements, since there is a one-to-one mapping between
+ interface and object. This is reasonable since Sidecars are
+ (intended to be) analogous to extra interfaces on the connection,
+ providing once-per-connection shared functionality; it also makes
+ client code straightforward (look up the interface you care about
+ in a dictionary, build a proxy object from the value). More
+ “plural” plugins are likely to want to implement new types of
+ <tp:dbus-ref
+ namespace="org.freedesktop.Telepathy">Channel</tp:dbus-ref>
+ instead.</p>
+ </tp:rationale>
+ </tp:docstring>
+
+ <tp:error name="org.freedesktop.Telepathy.Error.NotImplemented">
+ <tp:docstring>
+ The requested sidecar is not implemented by this connection manager,
+ or a necessary server-side component does not exist. (FIXME: split
+ these two errors out? Then again, once we list the guaranteed and
+ possible sidecars on a Protocol object, clients can tell the
+ difference themselves, because they shouldn't be calling this in the
+ first case.)
+ </tp:docstring>
+ </tp:error>
+
+ <tp:error name="org.freedesktop.Telepathy.Error.ServiceBusy">
+ <tp:docstring>
+ A server-side component needed by the requested sidecar reported it
+ is currently too busy, or did not respond for some
+ implementation-defined time. The caller may wish to try again later.
+ </tp:docstring>
+ </tp:error>
+
+ <tp:error name="org.freedesktop.Telepathy.Error.Cancelled">
+ <tp:docstring>
+ The connection was disconnected while the sidecar was being set up.
+ </tp:docstring>
+ </tp:error>
+ </method>
+
+ </interface>
+</node>
diff --git a/telepathy-ytstenut-glib/extensions/Makefile.am b/telepathy-ytstenut-glib/extensions/Makefile.am
new file mode 100644
index 0000000..9dce483
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/Makefile.am
@@ -0,0 +1,70 @@
+# This directory re-uses telepathy-glib's code generation mechanisms to
+# generate code for interfaces that aren't stable enough for telepathy-glib
+
+tools_dir = $(top_srcdir)/tp-glib-tools
+
+AM_CFLAGS = \
+ $(ERROR_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(TP_GLIB_CFLAGS)
+AM_LDFLAGS = \
+ $(ERROR_LDFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ all.xml \
+ Connection_Future.xml
+
+noinst_LTLIBRARIES = libfuture-extensions.la
+
+# In an external project you'd use $(TP_GLIB_LIBS) (obtained from
+# pkg-config via autoconf) instead of the .la path
+libfuture_extensions_la_LIBADD = \
+ $(GLIB_LIBS) \
+ $(DBUS_LIBS) \
+ $(TP_GLIB_LIBS)
+
+libfuture_extensions_la_SOURCES = \
+ connection-future.c \
+ connection-future.h \
+ extensions.c \
+ extensions.h
+
+nodist_libfuture_extensions_la_SOURCES = \
+ _gen/interfaces.h \
+ _gen/interfaces-body.h \
+ _gen/cli-connection-future.h \
+ _gen/cli-connection-future-body.h
+
+BUILT_SOURCES = \
+ _gen/all.xml \
+ $(nodist_libfuture_extensions_la_SOURCES)
+
+CLEANFILES = $(BUILT_SOURCES)
+
+clean-local:
+ rm -rf _gen
+
+XSLTPROCFLAGS = --nonet --novalid
+
+# Generated files which can be generated for all categories simultaneously
+
+_gen/all.xml: all.xml $(wildcard $(srcdir)/*.xml) $(wildcard $(top_srcdir)/spec/*.xml) $(tools_dir)/xincludator.py
+ $(mkdir_p) _gen
+ $(AM_V_GEN)$(PYTHON) $(tools_dir)/xincludator.py $< > $@
+
+_gen/interfaces-body.h _gen/interfaces.h: _gen/all.xml \
+ $(tools_dir)/glib-interfaces-gen.py
+ $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-interfaces-gen.py \
+ Extensions _gen/interfaces-body.h _gen/interfaces.h $<
+
+_gen/cli-connection-future-body.h _gen/cli-connection-future.h: _gen/all.xml \
+ $(tools_dir)/glib-client-gen.py Makefile.am
+ $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-client-gen.py \
+ --group=connection_future \
+ --subclass=TpConnection \
+ --subclass-assert=TP_IS_CONNECTION \
+ --iface-quark-prefix=EXTENSIONS_IFACE_QUARK \
+ --tp-proxy-api=0.7.6 \
+ $< Extensions_Cli _gen/cli-connection-future \ No newline at end of file
diff --git a/telepathy-ytstenut-glib/extensions/all.xml b/telepathy-ytstenut-glib/extensions/all.xml
new file mode 100644
index 0000000..3a42d9b
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/all.xml
@@ -0,0 +1,9 @@
+<tp:spec
+ xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+
+<tp:title>Extensions from the future</tp:title>
+
+<xi:include href="Connection_Future.xml"/>
+
+</tp:spec>
diff --git a/telepathy-ytstenut-glib/extensions/connection-future.c b/telepathy-ytstenut-glib/extensions/connection-future.c
new file mode 100644
index 0000000..7c13e0a
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/connection-future.c
@@ -0,0 +1,131 @@
+/*
+ * connection-future.c - proxy for Connection.FUTURE
+ *
+ * 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 "connection-future.h"
+
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/gtypes.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/proxy-subclass.h>
+#include <telepathy-glib/util.h>
+
+#include "_gen/interfaces.h"
+#include "_gen/cli-connection-future-body.h"
+
+#define DEBUG(msg, ...) \
+ g_debug ("%s: " msg, G_STRFUNC, ##__VA_ARGS__)
+
+typedef struct {
+ gchar *object_path;
+ GHashTable *immutable_properties;
+} connection_future_ensure_sidecar_values;
+
+static void
+free_connection_future_ensure_sidecar_values (gpointer data)
+{
+ connection_future_ensure_sidecar_values *values = data;
+ g_free (values->object_path);
+ g_hash_table_unref (values->immutable_properties);
+ g_slice_free (connection_future_ensure_sidecar_values, values);
+}
+
+static void
+on_connection_future_ensure_sidecar_returned (TpConnection *connection,
+ const gchar *object_path,
+ GHashTable *immutable_properties,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
+ connection_future_ensure_sidecar_values *values;
+
+ if (error == NULL)
+ {
+ values = g_slice_new (connection_future_ensure_sidecar_values);
+ values->object_path = g_strdup (object_path);
+ values->immutable_properties = g_hash_table_ref (immutable_properties);
+ g_simple_async_result_set_op_res_gpointer (res, values,
+ free_connection_future_ensure_sidecar_values);
+ }
+ else
+ {
+ DEBUG ("Connection.FUTURE.EnsureSidecar failed: %s", error->message);
+ g_simple_async_result_set_from_error (res, error);
+ }
+
+ g_simple_async_result_complete (res);
+}
+
+void
+extensions_tp_connection_future_ensure_sidecar_async (TpConnection *connection,
+ const gchar *interface,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *res;
+
+ g_return_if_fail (TP_IS_CONNECTION (connection));
+
+ if (!tp_proxy_borrow_interface_by_id (TP_PROXY (connection),
+ EXTENSIONS_IFACE_QUARK_CONNECTION_FUTURE, NULL))
+ {
+ tp_proxy_add_interface_by_id (TP_PROXY (connection),
+ EXTENSIONS_IFACE_QUARK_CONNECTION_FUTURE);
+ g_signal_connect (connection, "interface-added",
+ G_CALLBACK (extensions_cli_connection_future_add_signals), NULL);
+ }
+
+ res = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
+ extensions_tp_connection_future_ensure_sidecar_async);
+
+ extensions_cli_connection_future_call_ensure_sidecar (connection, -1,
+ interface, on_connection_future_ensure_sidecar_returned,
+ res, g_object_unref, G_OBJECT (connection));
+}
+
+gchar *
+extensions_tp_connection_future_ensure_sidecar_finish (TpConnection *connection,
+ GAsyncResult *result,
+ GHashTable **immutable_properties,
+ GError **error)
+{
+ connection_future_ensure_sidecar_values *values;
+ GSimpleAsyncResult *res;
+
+ g_return_val_if_fail (TP_IS_CONNECTION (connection), NULL);
+ g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
+
+ res = G_SIMPLE_ASYNC_RESULT (result);
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (connection),
+ extensions_tp_connection_future_ensure_sidecar_async), NULL);
+
+ if (g_simple_async_result_propagate_error (res, error))
+ return NULL;
+
+ values = g_simple_async_result_get_op_res_gpointer (res);
+ if (immutable_properties)
+ *immutable_properties = g_hash_table_ref (values->immutable_properties);
+ return g_strdup (values->object_path);
+}
diff --git a/telepathy-ytstenut-glib/extensions/connection-future.h b/telepathy-ytstenut-glib/extensions/connection-future.h
new file mode 100644
index 0000000..9de00ec
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/connection-future.h
@@ -0,0 +1,43 @@
+/*
+ * connection-future.h - proxy for Connection.FUTURE
+ *
+ * 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 EXTENSIONS_CONNECTION_FUTURE_H
+#define EXTENSIONS_CONNECTION_FUTURE_H
+
+#include <telepathy-glib/connection.h>
+#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/defs.h>
+#include <telepathy-glib/proxy.h>
+
+G_BEGIN_DECLS
+
+void extensions_tp_connection_future_ensure_sidecar_async (
+ TpConnection *connection, const gchar *interface, GCancellable *cancellable,
+ GAsyncReadyCallback callback, gpointer user_data);
+
+gchar *extensions_tp_connection_future_ensure_sidecar_finish (
+ TpConnection *connection, GAsyncResult *result,
+ GHashTable **immutable_properties, GError **error);
+
+G_END_DECLS
+
+#include "_gen/cli-connection-future.h"
+
+#endif
diff --git a/telepathy-ytstenut-glib/extensions/extensions.c b/telepathy-ytstenut-glib/extensions/extensions.c
new file mode 100644
index 0000000..605032b
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/extensions.c
@@ -0,0 +1,4 @@
+#include "extensions.h"
+
+/* include auto-generated stubs for things common to service and client */
+#include "_gen/interfaces-body.h"
diff --git a/telepathy-ytstenut-glib/extensions/extensions.h b/telepathy-ytstenut-glib/extensions/extensions.h
new file mode 100644
index 0000000..bc8a622
--- /dev/null
+++ b/telepathy-ytstenut-glib/extensions/extensions.h
@@ -0,0 +1,14 @@
+#ifndef FUTURE_EXTENSIONS_H
+#define FUTURE_EXTENSIONS_H
+
+#include <glib-object.h>
+#include <telepathy-glib/telepathy-glib.h>
+
+G_BEGIN_DECLS
+
+#include "_gen/cli-connection-future.h"
+#include "_gen/interfaces.h"
+
+G_END_DECLS
+
+#endif
diff --git a/telepathy-ytstenut-glib/status.c b/telepathy-ytstenut-glib/status.c
index 99f97c3..b3385e7 100644
--- a/telepathy-ytstenut-glib/status.c
+++ b/telepathy-ytstenut-glib/status.c
@@ -30,6 +30,7 @@
#include <telepathy-glib/proxy-subclass.h>
#include <telepathy-glib/util.h>
+#include "extensions/connection-future.h"
#include "_gen/interfaces.h"
#include "_gen/cli-status-body.h"
@@ -85,87 +86,16 @@ tp_yts_status_class_init (TpYtsStatusClass *klass)
TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
}
-typedef void (*callback_for_connection_ensure_sidecar) (
- TpConnection *connection, const GError *error, const gchar *sidecar_path,
- GHashTable *sidecar_properties, gpointer user_data, GObject *weak_object);
-
-static void
-on_connection_ensure_sidecar_returned (DBusGProxy *proxy,
- DBusGProxyCall *call_id,
- gpointer user_data)
-{
- GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
- GError *error = NULL;
- gchar *sidecar_path;
- GHashTable *sidecar_properties;
- TpYtsStatus *status;
- TpProxy *connection;
-
- connection = TP_PROXY (g_async_result_get_source_object (
- G_ASYNC_RESULT (res)));
-
- if (dbus_g_proxy_end_call (proxy, call_id, &error,
- DBUS_TYPE_G_OBJECT_PATH,
- &sidecar_path,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
- &sidecar_properties,
- G_TYPE_INVALID))
- {
- status = TP_YTS_STATUS (g_object_new (TP_TYPE_YTS_STATUS,
- "dbus-daemon", tp_proxy_get_dbus_daemon (connection),
- "dbus-connection", tp_proxy_get_dbus_connection (connection),
- "bus-name", tp_proxy_get_bus_name (connection),
- "object-path", sidecar_path,
- NULL));
- g_simple_async_result_set_op_res_gpointer (res, status, g_object_unref);
- g_free (sidecar_path);
- g_hash_table_unref (sidecar_properties);
- }
- else
- {
- g_simple_async_result_set_from_error (res, error);
- g_clear_error (&error);
- }
-
- g_simple_async_result_complete (res);
-}
-
void
tp_yts_status_ensure_for_connection_async (TpConnection *connection,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- DBusGProxy *future_iface;
- GSimpleAsyncResult *res;
- GError *error = NULL;
- GQuark iface_id;
-
g_return_if_fail (TP_IS_CONNECTION (connection));
- res = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
- tp_yts_status_ensure_for_connection_async);
-
- /* Declare that this connection supports EnsureSidecars */
- iface_id = g_quark_from_static_string (IFACE_CONNECTION_FUTURE);
- tp_proxy_add_interface_by_id (TP_PROXY (connection), iface_id);
-
- future_iface = tp_proxy_borrow_interface_by_id (TP_PROXY (connection),
- iface_id, &error);
- if (!future_iface)
- {
- g_simple_async_result_set_from_error (res, error);
- g_simple_async_result_complete_in_idle (res);
- g_clear_error (&error);
- g_object_unref (res);
- return;
- }
-
- dbus_g_proxy_begin_call_with_timeout (future_iface,
- "EnsureSidecar", on_connection_ensure_sidecar_returned,
- res, g_object_unref, -1,
- G_TYPE_STRING, TP_YTS_IFACE_STATUS,
- G_TYPE_INVALID);
+ extensions_tp_connection_future_ensure_sidecar_async (connection,
+ TP_YTS_IFACE_STATUS, cancellable, callback, user_data);
}
TpYtsStatus *
@@ -173,19 +103,29 @@ tp_yts_status_ensure_for_connection_finish (TpConnection *connection,
GAsyncResult *result,
GError **error)
{
- GSimpleAsyncResult *res;
+ TpYtsStatus *status = NULL;
+ gchar *object_path;
+ GHashTable *immutable_properties;
g_return_val_if_fail (TP_IS_CONNECTION (connection), NULL);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL);
- g_return_val_if_fail (g_simple_async_result_is_valid (result,
- G_OBJECT (connection), tp_yts_status_advertise_status_async), NULL);
- res = G_SIMPLE_ASYNC_RESULT (result);
+ object_path = extensions_tp_connection_future_ensure_sidecar_finish (
+ connection, result, &immutable_properties, error);
- if (g_simple_async_result_propagate_error (res, error))
- return NULL;
+ if (error == NULL)
+ {
+ status = g_object_new (TP_TYPE_YTS_STATUS,
+ "dbus-daemon", tp_proxy_get_dbus_daemon (connection),
+ "dbus-connection", tp_proxy_get_dbus_connection (connection),
+ "bus-name", tp_proxy_get_bus_name (connection),
+ "object-path", object_path,
+ "immutable-properties", immutable_properties,
+ NULL);
+ g_hash_table_unref (immutable_properties);
+ g_free (object_path);
+ }
- return g_object_ref (g_simple_async_result_get_op_res_gpointer (res));
+ return status;
}
static void