[rygel-grilo] Split media-server2 code
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Split media-server2 code
- Date: Tue, 13 Apr 2010 09:33:42 +0000 (UTC)
commit 117e1e7cd026034aa3bf685675bcff3a00f8cdce
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Mon Apr 12 13:52:08 2010 +0200
Split media-server2 code
Split code between client and server, in respectively files.
lib/Makefile.am | 3 +-
lib/media-server2-client.c | 124 +++++++++++++++++++++++
lib/{media-server2.c => media-server2-server.c} | 92 -----------------
3 files changed, 126 insertions(+), 93 deletions(-)
---
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 6a3d6b5..e5df246 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -34,9 +34,10 @@ libmediaserver2_la_SOURCES = \
media-server2-server-glue.h \
media-server2-server-private.h \
media-server2-server.h \
+ media-server2-server.c \
media-server2-client-glue.h \
media-server2-client.h \
- media-server2.c
+ media-server2-client.c
MAINTAINERCLEANFILES = \
*.in
diff --git a/lib/media-server2-client.c b/lib/media-server2-client.c
new file mode 100644
index 0000000..f0ed037
--- /dev/null
+++ b/lib/media-server2-client.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * Authors: Juan A. Suarez Romero <jasuarez igalia com>
+ *
+ * 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; 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 <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib.h>
+#include <string.h>
+
+#include "media-server2-client-glue.h"
+#include "media-server2-client.h"
+
+#define ENTRY_POINT_IFACE "/org/gnome/UPnP/MediaServer2/"
+#define ENTRY_POINT_NAME "org.gnome.UPnP.MediaServer2."
+
+#define DBUS_TYPE_G_ARRAY_OF_STRING \
+ (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
+
+#define MS2_CLIENT_GET_PRIVATE(o) \
+ G_TYPE_INSTANCE_GET_PRIVATE((o), MS2_TYPE_CLIENT, MS2ClientPrivate)
+
+struct _MS2ClientPrivate {
+ gpointer *reserved;
+};
+
+G_DEFINE_TYPE (MS2Client, ms2_client, G_TYPE_OBJECT);
+
+/* Class init function */
+static void
+ms2_client_class_init (MS2ClientClass *klass)
+{
+ g_type_class_add_private (klass, sizeof (MS2ClientPrivate));
+}
+
+static void
+ms2_client_init (MS2Client *client)
+{
+ client->priv = MS2_CLIENT_GET_PRIVATE (client);
+}
+
+gchar **
+ms2_client_get_providers ()
+{
+ DBusGConnection *connection;
+ DBusGProxy *gproxy;
+ GError *error = NULL;
+ GPtrArray *providers;
+ gchar **dbus_names;
+ gchar **list_providers;
+ gchar **p;
+ gint i;
+ gint prefix_size = strlen (ENTRY_POINT_NAME);
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (!connection) {
+ g_printerr ("Could not connect to session bus, %s\n", error->message);
+ g_clear_error (&error);
+ return FALSE;
+ }
+
+ gproxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ org_freedesktop_DBus_list_names (gproxy, &dbus_names, &error);
+ g_object_unref (gproxy);
+
+ if (error) {
+ g_printerr ("Could not get list of dbus names, %s\n", error->message);
+ g_clear_error (&error);
+ return FALSE;
+ }
+
+ if (!dbus_names) {
+ return FALSE;
+ }
+
+ providers = g_ptr_array_new ();
+ for (p = dbus_names; *p; p++) {
+ if (g_str_has_prefix (*p, ENTRY_POINT_NAME)) {
+ g_ptr_array_add (providers, *p);
+ }
+ }
+
+
+ list_providers = g_new (gchar *, providers->len + 1);
+ for (i = 0; i < providers->len; i++) {
+ list_providers[i] = g_strdup (g_ptr_array_index (providers, i) + prefix_size);
+ }
+
+ list_providers[i] = NULL;
+
+ g_strfreev (dbus_names);
+ g_ptr_array_free (providers, TRUE);
+
+ return list_providers;
+}
+
+MS2Client *ms2_client_new (const gchar *provider)
+{
+ MS2Client *client;
+
+ client = g_object_new (MS2_TYPE_CLIENT, NULL);
+
+ return client;
+}
diff --git a/lib/media-server2.c b/lib/media-server2-server.c
similarity index 90%
rename from lib/media-server2.c
rename to lib/media-server2-server.c
index a1481a3..0d21006 100644
--- a/lib/media-server2.c
+++ b/lib/media-server2-server.c
@@ -28,9 +28,6 @@
#include "media-server2-server-glue.h"
#include "media-server2-server.h"
-#include "media-server2-client-glue.h"
-#include "media-server2-client.h"
-
#define ENTRY_POINT_IFACE "/org/gnome/UPnP/MediaServer2/"
#define ENTRY_POINT_NAME "org.gnome.UPnP.MediaServer2."
@@ -40,9 +37,6 @@
#define MS2_SERVER_GET_PRIVATE(o) \
G_TYPE_INSTANCE_GET_PRIVATE((o), MS2_TYPE_SERVER, MS2ServerPrivate)
-#define MS2_CLIENT_GET_PRIVATE(o) \
- G_TYPE_INSTANCE_GET_PRIVATE((o), MS2_TYPE_CLIENT, MS2ClientPrivate)
-
/*
* Private MS2Server structure
* data: holds stuff for owner
@@ -55,12 +49,7 @@ struct _MS2ServerPrivate {
GetPropertiesFunc get_properties;
};
-struct _MS2ClientPrivate {
- gpointer *reserved;
-};
-
G_DEFINE_TYPE (MS2Server, ms2_server, G_TYPE_OBJECT);
-G_DEFINE_TYPE (MS2Client, ms2_client, G_TYPE_OBJECT);
/* Registers the MS2Server object in dbus */
static gboolean
@@ -119,13 +108,6 @@ ms2_server_class_init (MS2ServerClass *klass)
&dbus_glib_ms2_server_object_info);
}
-/* Class init function */
-static void
-ms2_client_class_init (MS2ClientClass *klass)
-{
- g_type_class_add_private (klass, sizeof (MS2ClientPrivate));
-}
-
/* Object init function */
static void
ms2_server_init (MS2Server *server)
@@ -133,13 +115,6 @@ ms2_server_init (MS2Server *server)
server->priv = MS2_SERVER_GET_PRIVATE (server);
}
-/* Object init function */
-static void
-ms2_client_init (MS2Client *client)
-{
- client->priv = MS2_CLIENT_GET_PRIVATE (client);
-}
-
/* Free gvalue */
static void
free_value (GValue *value)
@@ -1010,70 +985,3 @@ ms2_server_set_urls (GHashTable *properties,
}
}
-gchar **
-ms2_client_get_providers ()
-{
- DBusGConnection *connection;
- DBusGProxy *gproxy;
- GError *error = NULL;
- GPtrArray *providers;
- gchar **dbus_names;
- gchar **list_providers;
- gchar **p;
- gint i;
- gint prefix_size = strlen (ENTRY_POINT_NAME);
-
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!connection) {
- g_printerr ("Could not connect to session bus, %s\n", error->message);
- g_clear_error (&error);
- return FALSE;
- }
-
- gproxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
-
- org_freedesktop_DBus_list_names (gproxy, &dbus_names, &error);
- g_object_unref (gproxy);
-
- if (error) {
- g_printerr ("Could not get list of dbus names, %s\n", error->message);
- g_clear_error (&error);
- return FALSE;
- }
-
- if (!dbus_names) {
- return FALSE;
- }
-
- providers = g_ptr_array_new ();
- for (p = dbus_names; *p; p++) {
- if (g_str_has_prefix (*p, ENTRY_POINT_NAME)) {
- g_ptr_array_add (providers, *p);
- }
- }
-
-
- list_providers = g_new (gchar *, providers->len + 1);
- for (i = 0; i < providers->len; i++) {
- list_providers[i] = g_strdup (g_ptr_array_index (providers, i) + prefix_size);
- }
-
- list_providers[i] = NULL;
-
- g_strfreev (dbus_names);
- g_ptr_array_free (providers, TRUE);
-
- return list_providers;
-}
-
-MS2Client *ms2_client_new (const gchar *provider)
-{
- MS2Client *client;
-
- client = g_object_new (MS2_TYPE_CLIENT, NULL);
-
- return client;
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]