[rygel-grilo] Move introspection to header file
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Move introspection to header file
- Date: Tue, 4 May 2010 10:28:44 +0000 (UTC)
commit 07b47e09a3caf4045d7fcf5a98712668f13daaf4
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Wed Apr 28 13:55:18 2010 +0200
Move introspection to header file
XML file is not needed right now, because we are not using bindings-generator.
Also, we need to deal with two introspection types: one for containers, and one
for items.
data/Makefile.am | 6 --
data/media-server2.xml | 65 ---------------------
lib/Makefile.am | 1 +
lib/media-server2-introspection.h | 112 +++++++++++++++++++++++++++++++++++++
lib/media-server2-server.c | 31 ++--------
5 files changed, 119 insertions(+), 96 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index a2b8780..a2b3cde 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -5,15 +5,9 @@
#
# Copyright (C) 2010 Igalia S.L. All rights reserved.
-configdir = $(datadir)/rygel-grilo
-
-config_DATA = \
- media-server2.xml
-
sysconf_DATA = \
rygel-grilo.conf
EXTRA_DIST = \
- $(config_DATA) \
$(sysconf_DATA)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 632bfae..fb31ccd 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -16,6 +16,7 @@ libmediaserver2_la_LIBADD = \
$(DEPS_LIBS)
libmediaserver2_la_SOURCES = \
+ media-server2-introspection.h \
media-server2-common.h \
media-server2-server.h \
media-server2-server-table.c \
diff --git a/lib/media-server2-introspection.h b/lib/media-server2-introspection.h
new file mode 100644
index 0000000..1c2657a
--- /dev/null
+++ b/lib/media-server2-introspection.h
@@ -0,0 +1,112 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _MEDIA_SERVER2_INTROSPECTION_H_
+#define _MEDIA_SERVER2_INTROSPECTION_H_
+
+#define INTROSPECTION_OPEN \
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \
+ "<node>" \
+ " <!-- http://live.gnome.org/Rygel/MediaServer2Spec -->"
+
+#define INTROSPECTION_CLOSE \
+ "</node>"
+
+#define MEDIAOBJECT2_IFACE \
+ " <interface name=\"org.gnome.UPnP.MediaObject2\">" \
+ " <property name=\"DisplayName\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"IsContainer\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"IsItem\" type=\"b\" access=\"read\"/>" \
+ " <property name=\"Parent\" type=\"o\" access=\"read\"/>" \
+ " <property name=\"Path\" type=\"o\" access=\"read\"/>" \
+ " </interface>"
+
+#define MEDIAITEM2_IFACE \
+ " <interface name=\"org.gnome.UPnP.MediaItem2\">" \
+ " <property name=\"Album\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"Artist\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"Bitrate\" type=\"i\" access=\"read\"/>" \
+ " <property name=\"Duration\" type=\"i\" access=\"read\"/>" \
+ " <property name=\"Genre\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"Height\" type=\"i\" access=\"read\"/>" \
+ " <property name=\"MIMEType\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"Type\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"URLs\" type=\"as\" access=\"read\"/>" \
+ " <property name=\"Width\" type=\"i\" access=\"read\"/>" \
+ " </interface>"
+
+#define MEDIACONTAINER2_IFACE \
+ " <interface name=\"org.gnome.UPnP.MediaContainer2\">" \
+ " <property name=\"CanSearch\" type=\"b\" access=\"read\"/>" \
+ " <method name=\"ListObjects\">" \
+ " <arg name=\"offset\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"max\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"filter\" direction=\"in\" type=\"as\"/>" \
+ " <arg name=\"objects\" direction=\"out\" type=\"a(a{sv})\"/>" \
+ " </method>" \
+ " <method name=\"SearchObjects\">" \
+ " <arg name=\"query\" direction=\"in\" type=\"s\"/>" \
+ " <arg name=\"offset\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"max\" direction=\"in\" type=\"u\"/>" \
+ " <arg name=\"filter\" direction=\"in\" type=\"as\"/>" \
+ " <arg name=\"objects\" direction=\"out\" type=\"a(a{sv})\"/>" \
+ " </method>" \
+ " </interface>"
+
+#define INTROSPECTABLE_IFACE \
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">" \
+ " <method name=\"Introspect\">" \
+ " <arg name=\"xml_data\" direction=\"out\" type=\"s\"/>" \
+ " </method>" \
+ " </interface>"
+
+#define PROPERTIES_IFACE \
+ " <interface name=\"org.freedesktop.DBus.Properties\">" \
+ " <method name=\"Get\">" \
+ " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
+ " <arg name=\"property\" direction=\"in\" type=\"s\"/>" \
+ " <arg name=\"value\" direction=\"out\" type=\"v\"/>" \
+ " </method>" \
+ " <method name=\"GetAll\">" \
+ " <arg name=\"interface\" direction=\"in\" type=\"s\"/>" \
+ " <arg name=\"propeties\" direction=\"out\" type=\"a{sv}\"/>" \
+ " </method>" \
+ " </interface>"
+
+#define CONTAINER_INTROSPECTION \
+ INTROSPECTION_OPEN \
+ MEDIAOBJECT2_IFACE \
+ MEDIACONTAINER2_IFACE \
+ INTROSPECTABLE_IFACE \
+ PROPERTIES_IFACE \
+ INTROSPECTION_CLOSE
+
+#define ITEM_INTROSPECTION \
+ INTROSPECTION_OPEN \
+ MEDIAOBJECT2_IFACE \
+ MEDIAITEM2_IFACE \
+ INTROSPECTABLE_IFACE \
+ PROPERTIES_IFACE \
+ INTROSPECTION_CLOSE
+
+#endif /* _MEDIA_SERVER2_INTROSPECTION_H_ */
+
diff --git a/lib/media-server2-server.c b/lib/media-server2-server.c
index a607182..509b4be 100644
--- a/lib/media-server2-server.c
+++ b/lib/media-server2-server.c
@@ -29,6 +29,7 @@
#include "media-server2-private.h"
#include "media-server2-server.h"
+#include "media-server2-introspection.h"
#define INTROSPECTION_FILE \
"/home/jasuarez/Projects/grilo/rygel-grilo/data/media-server2.xml"
@@ -249,25 +250,6 @@ check_properties (const gchar **filter)
return NULL;
}
-static const gchar *
-get_introspection ()
-{
- GError *error = NULL;
- GFile *uri;
- static gchar *introspection = NULL;
-
- if (!introspection) {
- uri = g_vfs_get_file_for_path (g_vfs_get_default (), INTROSPECTION_FILE);
- if (!g_file_load_contents (uri, NULL, &introspection, NULL, NULL, &error)) {
- g_printerr ("Unable to load introspection data, %s\n", error->message);
- g_error_free (error);
- }
- g_object_unref (uri);
- }
-
- return introspection;
-}
-
static gboolean
is_property_valid (const gchar *interface,
const gchar *property)
@@ -430,16 +412,15 @@ append_variant_arg (DBusMessage *m, const GValue *v)
}
static DBusHandlerResult
-handle_introspect_message (DBusConnection *c,
- DBusMessage *m,
- void *userdata)
+handle_introspect_container_message (DBusConnection *c,
+ DBusMessage *m,
+ void *userdata)
{
- const gchar *xml;
+ static const gchar *xml = CONTAINER_INTROSPECTION;
DBusMessage *r;
/* Check signature */
if (dbus_message_has_signature (m, introspect_sgn)) {
- xml = get_introspection ();
r = dbus_message_new_method_return (m);
dbus_message_append_args (r, DBUS_TYPE_STRING, &xml, DBUS_TYPE_INVALID);
dbus_connection_send (c, r, NULL);
@@ -500,7 +481,7 @@ root_handler (DBusConnection *c,
if (dbus_message_is_method_call (m,
"org.freedesktop.DBus.Introspectable",
"Introspect")) {
- return handle_introspect_message (c, m, userdata);
+ return handle_introspect_container_message (c, m, userdata);
} else if (dbus_message_is_method_call (m,
"org.freedesktop.DBus.Properties",
"Get")) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]