[telepathy-gabble/master] Initial dummy version of CallContent objects
Sjoerd Simons
sjoerd.simons at collabora.co.uk
Tue Dec 29 05:34:38 PST 2009
---
src/Makefile.am | 2 +
src/call-channel.c | 54 +++++++++++-
src/call-content.c | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/call-content.h | 67 ++++++++++++++
4 files changed, 364 insertions(+), 2 deletions(-)
create mode 100644 src/call-content.c
create mode 100644 src/call-content.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 9dcd82c..d37dd88 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,8 @@ libgabble_convenience_la_SOURCES = \
bytestream-multiple.c \
bytestream-socks5.h \
bytestream-socks5.c \
+ call-content.h \
+ call-content.c \
call-channel.h \
call-channel.c \
capabilities.h \
diff --git a/src/call-channel.c b/src/call-channel.c
index 505d213..f94078a 100644
--- a/src/call-channel.c
+++ b/src/call-channel.c
@@ -32,11 +32,13 @@
#include <telepathy-glib/svc-channel.h>
#include <telepathy-glib/svc-properties-interface.h>
#include <telepathy-glib/base-connection.h>
+#include <telepathy-glib/gtypes.h>
#include <extensions/extensions.h>
#include "util.h"
#include "call-channel.h"
+#include "call-content.h"
#include "connection.h"
#include "jingle-session.h"
@@ -87,6 +89,7 @@ enum
PROP_INITIAL_AUDIO,
PROP_INITIAL_VIDEO,
PROP_MUTABLE_CONTENTS,
+ PROP_CONTENTS,
PROP_SESSION,
LAST_PROPERTY
@@ -247,6 +250,22 @@ gabble_call_channel_get_property (GObject *object,
case PROP_MUTABLE_CONTENTS:
g_value_set_boolean (value, priv->mutable_contents);
break;
+ case PROP_CONTENTS:
+ {
+ GPtrArray *arr = g_ptr_array_sized_new (2);
+ GList *l;
+
+ for (l = priv->contents; l != NULL; l = g_list_next (l))
+ {
+ GabbleCallContent *c = GABBLE_CALL_CONTENT (l->data);
+ g_ptr_array_add (arr,
+ (gpointer) gabble_call_content_get_object_path (c));
+ }
+
+ g_value_set_boxed (value, arr);
+ g_ptr_array_free (arr, TRUE);
+ break;
+ }
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -320,6 +339,7 @@ gabble_call_channel_class_init (
{ "MutableContents", "mutable-contents", NULL },
{ "InitialAudio", "initial-audio", NULL },
{ "InitialVideo", "initial-video", NULL },
+ { "Contents", "contents", NULL },
{ NULL }
};
@@ -426,6 +446,13 @@ gabble_call_channel_class_init (
g_object_class_install_property (object_class, PROP_MUTABLE_CONTENTS,
param_spec);
+ param_spec = g_param_spec_boxed ("contents", "Contents",
+ "The contents of the channel",
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_CONTENTS,
+ param_spec);
+
gabble_call_channel_class->dbus_props_class.interfaces = prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (GabbleCallChannelClass, dbus_props_class));
@@ -435,12 +462,23 @@ void
gabble_call_channel_dispose (GObject *object)
{
GabbleCallChannel *self = GABBLE_CALL_CHANNEL (object);
+ GabbleCallChannelPrivate *priv = self->priv;
+ GList *l;
- if (self->priv->dispose_has_run)
+ if (priv->dispose_has_run)
return;
self->priv->dispose_has_run = TRUE;
+ for (l = priv->contents; l != NULL; l = g_list_next (l))
+ {
+ g_object_unref (l->data);
+ }
+
+ g_list_free (priv->contents);
+ priv->contents = NULL;
+
+
/* release any references held by the object here */
if (G_OBJECT_CLASS (gabble_call_channel_parent_class)->dispose)
G_OBJECT_CLASS (gabble_call_channel_parent_class)->dispose (object);
@@ -467,6 +505,8 @@ call_channel_add_content (GabbleCallChannel *self,
GabbleCallChannelPrivate *priv = self->priv;
const gchar *content_ns;
GabbleJingleContent *c;
+ GabbleCallContent *content;
+ gchar *object_path;
content_ns = jingle_pick_best_content_type (priv->conn, priv->target,
gabble_jingle_session_get_peer_resource (priv->session),
@@ -478,9 +518,19 @@ call_channel_add_content (GabbleCallChannel *self,
c = gabble_jingle_session_add_content (priv->session,
type, content_ns, priv->transport_ns);
- /* FIXME add this to a CallContent */
+ object_path = g_strdup_printf ("%s/Content%p", priv->object_path, c);
+
+ content = g_object_new (GABBLE_TYPE_CALL_CONTENT,
+ "object-path", object_path,
+ "jingle-content", c,
+ NULL);
+
+ g_free (object_path);
+
+ priv->contents = g_list_prepend (priv->contents, content);
}
+
static void
call_channel_setup (GabbleCallChannel *self)
{
diff --git a/src/call-content.c b/src/call-content.c
new file mode 100644
index 0000000..4c90e05
--- /dev/null
+++ b/src/call-content.c
@@ -0,0 +1,243 @@
+/*
+ * gabble-call-content.c - Source for GabbleCallContent
+ * Copyright (C) 2009 Collabora Ltd.
+ * @author Sjoerd Simons <sjoerd.simons at collabora.co.uk>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/svc-properties-interface.h>
+#include <telepathy-glib/base-connection.h>
+#include <extensions/extensions.h>
+
+#include "call-content.h"
+#include "jingle-content.h"
+
+#define DEBUG_FLAG GABBLE_DEBUG_MEDIA
+
+#include "debug.h"
+
+static void call_content_iface_init (gpointer, gpointer);
+static void call_content_media_iface_init (gpointer, gpointer);
+
+G_DEFINE_TYPE_WITH_CODE(GabbleCallContent, gabble_call_content,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
+ tp_dbus_properties_mixin_iface_init);
+ G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_CALL_CONTENT,
+ call_content_iface_init);
+ G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_CALL_CONTENT_INTERFACE_MEDIA,
+ call_content_media_iface_init);
+ );
+
+/* properties */
+enum
+{
+ PROP_OBJECT_PATH = 1,
+ PROP_JINGLE_CONTENT,
+};
+
+#if 0
+/* signal enum */
+enum
+{
+ STREAM_ADDED,
+ STREAM_REMOVED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+#endif
+
+/* private structure */
+struct _GabbleCallContentPrivate
+{
+ gchar *object_path;
+ GabbleJingleContent *content;
+
+ gboolean dispose_has_run;
+};
+
+static void
+gabble_call_content_init (GabbleCallContent *self)
+{
+ GabbleCallContentPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ GABBLE_TYPE_CALL_CONTENT, GabbleCallContentPrivate);
+
+ self->priv = priv;
+}
+
+static void gabble_call_content_dispose (GObject *object);
+static void gabble_call_content_finalize (GObject *object);
+
+static void
+gabble_call_content_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleCallContent *content = GABBLE_CALL_CONTENT (object);
+ GabbleCallContentPrivate *priv = content->priv;
+
+ switch (property_id)
+ {
+ case PROP_OBJECT_PATH:
+ g_value_set_string (value, priv->object_path);
+ break;
+ case PROP_JINGLE_CONTENT:
+ g_value_set_object (value, priv->content);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gabble_call_content_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GabbleCallContent *content = GABBLE_CALL_CONTENT (object);
+ GabbleCallContentPrivate *priv = content->priv;
+
+ switch (property_id)
+ {
+ case PROP_OBJECT_PATH:
+ g_free (priv->object_path);
+ priv->object_path = g_value_dup_string (value);
+ break;
+ case PROP_JINGLE_CONTENT:
+ priv->content = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static GObject *
+gabble_call_content_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *obj;
+ GabbleCallContentPrivate *priv;
+ DBusGConnection *bus;
+
+ obj = G_OBJECT_CLASS (gabble_call_content_parent_class)->
+ constructor (type, n_props, props);
+
+ priv = GABBLE_CALL_CONTENT (obj)->priv;
+
+ /* register object on the bus */
+ bus = tp_get_bus ();
+ DEBUG ("Registering %s", priv->object_path);
+ dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+
+ return obj;
+}
+
+static void
+gabble_call_content_class_init (
+ GabbleCallContentClass *gabble_call_content_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (gabble_call_content_class);
+ GParamSpec *param_spec;
+
+ g_type_class_add_private (gabble_call_content_class,
+ sizeof (GabbleCallContentPrivate));
+
+ object_class->constructor = gabble_call_content_constructor;
+
+ object_class->get_property = gabble_call_content_get_property;
+ object_class->set_property = gabble_call_content_set_property;
+
+ object_class->dispose = gabble_call_content_dispose;
+ object_class->finalize = gabble_call_content_finalize;
+
+ param_spec = g_param_spec_string ("object-path", "D-Bus object path",
+ "The D-Bus object path used for this "
+ "object on the bus.",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_OBJECT_PATH, param_spec);
+
+ param_spec = g_param_spec_object ("jingle-content", "Jingle Content",
+ "The Jingle Content related to this content object",
+ GABBLE_TYPE_JINGLE_CONTENT,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB);
+ g_object_class_install_property (object_class, PROP_JINGLE_CONTENT,
+ param_spec);
+}
+
+void
+gabble_call_content_dispose (GObject *object)
+{
+ GabbleCallContent *self = GABBLE_CALL_CONTENT (object);
+ GabbleCallContentPrivate *priv = self->priv;
+
+ if (priv->dispose_has_run)
+ return;
+
+ priv->dispose_has_run = TRUE;
+
+ /* release any references held by the object here */
+ g_object_unref (priv->content);
+ priv->content = NULL;
+
+ if (G_OBJECT_CLASS (gabble_call_content_parent_class)->dispose)
+ G_OBJECT_CLASS (gabble_call_content_parent_class)->dispose (object);
+}
+
+void
+gabble_call_content_finalize (GObject *object)
+{
+ GabbleCallContent *self = GABBLE_CALL_CONTENT (object);
+ GabbleCallContentPrivate *priv = self->priv;
+
+ /* free any data held directly by the object here */
+ g_free (priv->object_path);
+
+ G_OBJECT_CLASS (gabble_call_content_parent_class)->finalize (object);
+}
+
+static void
+call_content_iface_init (gpointer g_iface, gpointer iface_data)
+{
+}
+
+static void
+call_content_media_iface_init (gpointer g_iface, gpointer iface_data)
+{
+}
+
+const gchar *
+gabble_call_content_get_object_path (GabbleCallContent *content)
+{
+ return content->priv->object_path;
+}
diff --git a/src/call-content.h b/src/call-content.h
new file mode 100644
index 0000000..d04f071
--- /dev/null
+++ b/src/call-content.h
@@ -0,0 +1,67 @@
+/*
+ * gabble-call-content.h - Header for GabbleCallContent
+ * Copyright (C) 2009 Collabora Ltd.
+ * @author Sjoerd Simons <sjoerd.simons at collabora.co.uk>
+ *
+ * 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 __GABBLE_CALL_CONTENT_H__
+#define __GABBLE_CALL_CONTENT_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GabbleCallContent GabbleCallContent;
+typedef struct _GabbleCallContentPrivate GabbleCallContentPrivate;
+typedef struct _GabbleCallContentClass GabbleCallContentClass;
+
+struct _GabbleCallContentClass {
+ GObjectClass parent_class;
+
+ TpDBusPropertiesMixinClass dbus_props_class;
+};
+
+struct _GabbleCallContent {
+ GObject parent;
+
+ GabbleCallContentPrivate *priv;
+};
+
+GType gabble_call_content_get_type (void);
+
+/* TYPE MACROS */
+#define GABBLE_TYPE_CALL_CONTENT \
+ (gabble_call_content_get_type ())
+#define GABBLE_CALL_CONTENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), \
+ GABBLE_TYPE_CALL_CONTENT, GabbleCallContent))
+#define GABBLE_CALL_CONTENT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), \
+ GABBLE_TYPE_CALL_CONTENT, GabbleCallContentClass))
+#define GABBLE_IS_CALL_CONTENT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_CALL_CONTENT))
+#define GABBLE_IS_CALL_CONTENT_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_CALL_CONTENT))
+#define GABBLE_CALL_CONTENT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ GABBLE_TYPE_CALL_CONTENT, GabbleCallContentClass))
+
+const gchar *gabble_call_content_get_object_path (GabbleCallContent *content);
+
+G_END_DECLS
+
+#endif /* #ifndef __GABBLE_CALL_CONTENT_H__*/
--
1.5.6.5
More information about the telepathy-commits
mailing list