[next] telepathy-glib: inline tp_protocol_new()
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Mon Mar 17 07:25:41 PDT 2014
Module: telepathy-glib
Branch: next
Commit: ecb3bfc2ecbc111dc25dae143a0d721e841bba3b
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=ecb3bfc2ecbc111dc25dae143a0d721e841bba3b
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Mon Mar 3 16:15:44 2014 +0100
inline tp_protocol_new()
---
telepathy-glib/protocol.c | 87 +++++++++++++++------------------------------
1 file changed, 28 insertions(+), 59 deletions(-)
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index e0e4456..dfc8aa1 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -912,33 +912,47 @@ tp_protocol_init (TpProtocol *self)
TpProtocolPrivate);
}
-/*
- * tp_protocol_new:
+/**
+ * tp_protocol_new_vardict:
* @dbus: proxy for the D-Bus daemon; may not be %NULL
* @cm_name: the connection manager name (such as "gabble")
* @protocol_name: the protocol name (such as "jabber")
- * @immutable_properties: the immutable D-Bus properties for this protocol
+ * @immutable_properties: (allow-none): the immutable D-Bus properties for this
+ * protocol, or %NULL
* @error: used to indicate the error if %NULL is returned
*
- * <!-- -->
+ * Create a new protocol proxy.
+ *
+ * If @immutable_properties is a floating reference, this function will
+ * take ownership of it, much like g_variant_ref_sink(). See documentation of
+ * that function for details.
*
* Returns: a new protocol proxy, or %NULL on invalid arguments
*
- * Since: 0.11.11
+ * Since: 0.UNRELEASED
*/
-static TpProtocol *
-tp_protocol_new (TpDBusDaemon *dbus,
+TpProtocol *
+tp_protocol_new_vardict (TpDBusDaemon *dbus,
const gchar *cm_name,
const gchar *protocol_name,
- const GHashTable *immutable_properties,
+ GVariant *immutable_properties,
GError **error)
{
TpProtocol *ret = NULL;
gchar *bus_name = NULL;
gchar *object_path = NULL;
+ GHashTable *hash = NULL;
+ g_return_val_if_fail (immutable_properties == NULL ||
+ g_variant_is_of_type (immutable_properties, G_VARIANT_TYPE_VARDICT),
+ NULL);
g_return_val_if_fail (TP_IS_DBUS_DAEMON (dbus), NULL);
+ if (immutable_properties == NULL)
+ immutable_properties = g_variant_new ("a{sv}", NULL);
+
+ g_variant_ref_sink (immutable_properties);
+
if (!tp_connection_manager_check_valid_protocol_name (protocol_name, error))
goto finally;
@@ -951,72 +965,27 @@ tp_protocol_new (TpDBusDaemon *dbus,
/* e.g. local-xmpp -> local_xmpp */
g_strdelimit (object_path, "-", '_');
+ hash = tp_asv_from_vardict (immutable_properties);
+
ret = TP_PROTOCOL (g_object_new (TP_TYPE_PROTOCOL,
"dbus-daemon", dbus,
"bus-name", bus_name,
"object-path", object_path,
"protocol-name", protocol_name,
- "protocol-properties", immutable_properties,
+ "protocol-properties", hash,
"cm-name", cm_name,
NULL));
+ g_hash_table_unref (hash);
+
finally:
+ g_variant_unref (immutable_properties);
g_free (bus_name);
g_free (object_path);
return ret;
}
/**
- * tp_protocol_new_vardict:
- * @dbus: proxy for the D-Bus daemon; may not be %NULL
- * @cm_name: the connection manager name (such as "gabble")
- * @protocol_name: the protocol name (such as "jabber")
- * @immutable_properties: (allow-none): the immutable D-Bus properties for this
- * protocol, or %NULL
- * @error: used to indicate the error if %NULL is returned
- *
- * Create a new protocol proxy.
- *
- * If @immutable_properties is a floating reference, this function will
- * take ownership of it, much like g_variant_ref_sink(). See documentation of
- * that function for details.
- *
- * Returns: a new protocol proxy, or %NULL on invalid arguments
- *
- * Since: 0.UNRELEASED
- */
-TpProtocol *
-tp_protocol_new_vardict (TpDBusDaemon *dbus,
- const gchar *cm_name,
- const gchar *protocol_name,
- GVariant *immutable_properties,
- GError **error)
-{
- TpProtocol *ret;
-
- g_return_val_if_fail (immutable_properties == NULL ||
- g_variant_is_of_type (immutable_properties, G_VARIANT_TYPE_VARDICT),
- NULL);
-
- if (immutable_properties != NULL)
- {
- GHashTable *hash;
-
- g_variant_ref_sink (immutable_properties);
- hash = tp_asv_from_vardict (immutable_properties);
- ret = tp_protocol_new (dbus, cm_name, protocol_name, hash, error);
- g_hash_table_unref (hash);
- g_variant_unref (immutable_properties);
- }
- else
- {
- ret = tp_protocol_new (dbus, cm_name, protocol_name, NULL, error);
- }
-
- return ret;
-}
-
-/**
* tp_protocol_init_known_interfaces:
*
* Ensure that the known interfaces for TpProtocol have been set up.
More information about the telepathy-commits
mailing list