[rygel] Only load DVB plugin if service is available
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] Only load DVB plugin if service is available
- Date: Mon, 25 May 2009 17:21:44 -0400 (EDT)
commit 1abd7f2307a6ef6123346d7ee76bb52b0094bae5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon May 25 23:28:48 2009 +0300
Only load DVB plugin if service is available
Try to launch the DVB Daemon service by name and if we fail, don't load
the DVB plugin.
---
src/plugins/dvb/Makefile.am | 7 ++-
src/plugins/dvb/rygel-dvb-plugin-factory.vala | 76 +++++++++++++++++++++++++
src/plugins/dvb/rygel-dvb-plugin.vala | 21 +++----
3 files changed, 91 insertions(+), 13 deletions(-)
diff --git a/src/plugins/dvb/Makefile.am b/src/plugins/dvb/Makefile.am
index 87ec098..4d06510 100644
--- a/src/plugins/dvb/Makefile.am
+++ b/src/plugins/dvb/Makefile.am
@@ -15,7 +15,8 @@ BUILT_SOURCES = rygel-dvb.stamp \
rygel-dvb-root-container.c \
rygel-dvb-channel-group.c \
rygel-dvb-channel.c \
- rygel-dvb-plugin.c
+ rygel-dvb-plugin.c \
+ rygel-dvb-plugin-factory.c
librygel_dvb_la_SOURCES = rygel-dvb-content-dir.c \
rygel-dvb-content-dir.vala \
@@ -26,7 +27,9 @@ librygel_dvb_la_SOURCES = rygel-dvb-content-dir.c \
rygel-dvb-channel.c \
rygel-dvb-channel.vala \
rygel-dvb-plugin.c \
- rygel-dvb-plugin.vala
+ rygel-dvb-plugin.vala \
+ rygel-dvb-plugin-factory.c \
+ rygel-dvb-plugin-factory.vala
rygel-dvb.stamp: $(filter %.vala,$(librygel_dvb_la_SOURCES))
$(VALAC) -C --vapidir=$(top_srcdir)/src/rygel \
diff --git a/src/plugins/dvb/rygel-dvb-plugin-factory.vala b/src/plugins/dvb/rygel-dvb-plugin-factory.vala
new file mode 100644
index 0000000..18e981e
--- /dev/null
+++ b/src/plugins/dvb/rygel-dvb-plugin-factory.vala
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2009 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * <zeeshan ali nokia com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using Rygel;
+using Gee;
+using CStuff;
+
+private DVBPluginFactory plugin_factory;
+
+[ModuleInit]
+public void module_init (PluginLoader loader) {
+ try {
+ plugin_factory = new DVBPluginFactory (loader);
+ } catch (DBus.Error error) {
+ critical ("Failed to fetch list of external services: %s\n",
+ error.message);
+ }
+}
+
+public class DVBPluginFactory {
+ private const string DBUS_SERVICE = "org.freedesktop.DBus";
+ private const string DBUS_OBJECT = "/org/freedesktop/DBus";
+ private const string DBUS_IFACE = "org.freedesktop.DBus";
+
+ private const string TRACKER_SERVICE = "org.gnome.DVB";
+
+ dynamic DBus.Object dbus_obj;
+ PluginLoader loader;
+
+ public DVBPluginFactory (PluginLoader loader) throws DBus.Error {
+ var connection = DBus.Bus.get (DBus.BusType.SESSION);
+
+ this.dbus_obj = connection.get_object (DBUS_SERVICE,
+ DBUS_OBJECT,
+ DBUS_IFACE);
+ this.loader = loader;
+
+ dbus_obj.StartServiceByName (TRACKER_SERVICE,
+ (uint32) 0,
+ this.start_service_cb);
+ }
+
+ private void start_service_cb (uint32 status, GLib.Error err) {
+ if (err != null) {
+ warning ("Failed to start DVB service: %s\n",
+ err.message);
+ warning ("DVB plugin disabled.\n");
+
+ return;
+ }
+
+ this.loader.add_plugin (new DVBPlugin ());
+ }
+}
+
diff --git a/src/plugins/dvb/rygel-dvb-plugin.vala b/src/plugins/dvb/rygel-dvb-plugin.vala
index bc24c8d..86dc696 100644
--- a/src/plugins/dvb/rygel-dvb-plugin.vala
+++ b/src/plugins/dvb/rygel-dvb-plugin.vala
@@ -28,18 +28,17 @@ using Rygel;
using Gee;
using CStuff;
-[ModuleInit]
-public void module_init (PluginLoader loader) {
- Plugin plugin = new Plugin ("DVB", "Digital TV");
+public class DVBPlugin : Plugin {
+ public DVBPlugin () {
+ base ("DVB", "Digital TV");
- // We only implement a ContentDirectory service
- var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
- ContentDirectory.UPNP_TYPE,
- ContentDirectory.DESCRIPTION_PATH,
- typeof (DVBContentDir));
+ // We only implement a ContentDirectory service
+ var resource_info = new ResourceInfo (ContentDirectory.UPNP_ID,
+ ContentDirectory.UPNP_TYPE,
+ ContentDirectory.DESCRIPTION_PATH,
+ typeof (DVBContentDir));
- plugin.add_resource (resource_info);
-
- loader.add_plugin (plugin);
+ this.add_resource (resource_info);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]