summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-05-26 16:06:45 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-05-26 16:06:45 +0100
commite183be2acb77ebd9117723ff3eb8da874aa8ab16 (patch)
tree440b73143c0974af64ab5c399294b340d8d98c78
parent6cf8ed2299d4e473550c1f828ac9af596c607721 (diff)
downloadtelepathy-mission-control-e183be2acb77ebd9117723ff3eb8da874aa8ab16.tar.gz
_mcd_manager_dup_protocol, _mcd_manager_protocol_free: add
Copied from telepathy-glib 0.11.6 to avoid a dependency on that version in this stable branch; in git master, they should be replaced by calls to the newer telepathy-glib API.
-rw-r--r--src/Makefile.am1
-rw-r--r--src/mcd-manager-priv.h39
-rw-r--r--src/mcd-manager.c89
3 files changed, 129 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index df5b8bf4..56434a5f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -151,6 +151,7 @@ libmcd_convenience_la_SOURCES = \
mcd-master.c \
mcd-master-priv.h \
mcd-manager.c \
+ mcd-manager-priv.h \
mcd-connection.c \
mcd-connection-priv.h \
mcd-dispatcher.c \
diff --git a/src/mcd-manager-priv.h b/src/mcd-manager-priv.h
new file mode 100644
index 00000000..33d47875
--- /dev/null
+++ b/src/mcd-manager-priv.h
@@ -0,0 +1,39 @@
+/* vi: set et sw=4 ts=8 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2007-2009 Nokia Corporation.
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * Contact: Naba Kumar <naba.kumar@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * 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 MCD_MANAGER_PRIV_H
+#define MCD_MANAGER_PRIV_H
+
+#include "mcd-manager.h"
+
+G_BEGIN_DECLS
+
+void _mcd_manager_protocol_free (TpConnectionManagerProtocol *proto);
+TpConnectionManagerProtocol *_mcd_manager_dup_protocol (McdManager *manager,
+ const gchar *protocol);
+
+G_END_DECLS
+#endif /* MCD_MANAGER_H */
diff --git a/src/mcd-manager.c b/src/mcd-manager.c
index 7df8ccf9..69cc284f 100644
--- a/src/mcd-manager.c
+++ b/src/mcd-manager.c
@@ -38,6 +38,7 @@
#define _POSIX_C_SOURCE 200112L /* for strtok_r() */
#include "config.h"
#include "mcd-manager.h"
+#include "mcd-manager-priv.h"
#include "mcd-misc.h"
#include <stdio.h>
@@ -473,6 +474,94 @@ mcd_manager_get_parameters (McdManager *manager, const gchar *protocol)
return NULL;
}
+/* Copied from telepathy-glib 0.11.6 for _mcd_manager_copy_protocol() */
+static void
+_tp_connection_manager_param_free_contents (TpConnectionManagerParam *param)
+{
+ g_free (param->name);
+ g_free (param->dbus_signature);
+
+ if (G_IS_VALUE (&param->default_value))
+ g_value_unset (&param->default_value);
+}
+
+/* Copied from telepathy-glib 0.11.6 for _mcd_manager_copy_protocol() */
+void
+_mcd_manager_protocol_free (TpConnectionManagerProtocol *proto)
+{
+ TpConnectionManagerParam *param;
+
+ g_free (proto->name);
+
+ for (param = proto->params; param->name != NULL; param++)
+ {
+ _tp_connection_manager_param_free_contents (param);
+ }
+
+ g_free (proto->params);
+
+ g_slice_free (TpConnectionManagerProtocol, proto);
+}
+
+/* Copied from telepathy-glib 0.11.6 for _mcd_manager_copy_protocol() */
+static void
+_tp_connection_manager_param_copy_contents (
+ const TpConnectionManagerParam *in,
+ TpConnectionManagerParam *out)
+{
+ out->name = g_strdup (in->name);
+ out->dbus_signature = g_strdup (in->dbus_signature);
+ out->flags = in->flags;
+
+ if (G_IS_VALUE (&in->default_value))
+ {
+ g_value_init (&out->default_value, G_VALUE_TYPE (&in->default_value));
+ g_value_copy (&in->default_value, &out->default_value);
+ }
+}
+
+/* Copied from telepathy-glib 0.11.6's tp_connection_manager_protocol_copy();
+ * duplicated here to avoid a newer dependency in the stable branch. */
+static TpConnectionManagerProtocol *
+_mcd_manager_copy_protocol (const TpConnectionManagerProtocol *in)
+{
+ TpConnectionManagerProtocol *out = g_slice_new0 (TpConnectionManagerProtocol);
+ TpConnectionManagerParam *param;
+ GArray *params = g_array_new (TRUE, TRUE,
+ sizeof (TpConnectionManagerParam));
+
+ out->name = g_strdup (in->name);
+
+ for (param = in->params; param->name != NULL; param++)
+ {
+ TpConnectionManagerParam copy = { 0, };
+
+ _tp_connection_manager_param_copy_contents (param, &copy);
+ g_array_append_val (params, copy);
+ }
+
+ out->params = (TpConnectionManagerParam *) g_array_free (params, FALSE);
+
+ return out;
+}
+
+TpConnectionManagerProtocol *
+_mcd_manager_dup_protocol (McdManager *manager,
+ const gchar *protocol)
+{
+ const TpConnectionManagerProtocol *p;
+ g_return_val_if_fail (MCD_IS_MANAGER (manager), NULL);
+ g_return_val_if_fail (protocol != NULL, NULL);
+
+ p = tp_connection_manager_get_protocol (manager->priv->tp_conn_mgr,
+ protocol);
+
+ if (p == NULL)
+ return NULL;
+ else
+ return _mcd_manager_copy_protocol (p);
+}
+
const TpConnectionManagerParam *
mcd_manager_get_protocol_param (McdManager *manager, const gchar *protocol,
const gchar *param)