[gnome-control-center] sharing: start or stop Rygel when Media Sharing is enabled or disabled
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] sharing: start or stop Rygel when Media Sharing is enabled or disabled
- Date: Thu, 14 Feb 2013 15:12:32 +0000 (UTC)
commit 4d6d7253ed92d816261dbd319c13e8e020c09a0f
Author: Thomas Wood <thomas wood intel com>
Date: Thu Feb 14 11:05:26 2013 +0000
sharing: start or stop Rygel when Media Sharing is enabled or disabled
Ensure Rygel is started when the Media Sharing option is enabled and
stopped when it is disabled. This also adds and removes Rygel from the
autostart directory as appropriate.
https://bugzilla.gnome.org/show_bug.cgi?id=692702
panels/sharing/cc-media-sharing.c | 77 +++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/panels/sharing/cc-media-sharing.c b/panels/sharing/cc-media-sharing.c
index 03dcc9e..50079e2 100644
--- a/panels/sharing/cc-media-sharing.c
+++ b/panels/sharing/cc-media-sharing.c
@@ -21,6 +21,15 @@
#include "cc-media-sharing.h"
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
+#include <glib/gstdio.h>
+
+#define BUS_NAME "org.gnome.Rygel1"
+#define OBJECT_PATH "/org/gnome/Rygel1"
+#define INTERFACE_NAME "org.gnome.Rygel1"
+#define RYGEL_DESKTOP_ID "rygel.desktop"
+
static GKeyFile*
cc_media_sharing_open_key_file (void)
{
@@ -40,6 +49,69 @@ cc_media_sharing_open_key_file (void)
return file;
}
+static void
+cc_media_sharing_enable_autostart (void)
+{
+ const gchar *source;
+ gchar *destination;
+ GDesktopAppInfo *info;
+ GFile *file;
+
+ info = g_desktop_app_info_new (RYGEL_DESKTOP_ID);
+ if (!info)
+ return;
+
+ /* start rygel */
+ g_app_info_launch (info, NULL, NULL, NULL);
+
+ /* create a symbolic link to the rygel desktop file in the autostart
+ * directory */
+ source = g_desktop_app_info_get_filename (info);
+
+ destination = g_build_filename (g_get_user_config_dir (), "autostart",
+ RYGEL_DESKTOP_ID, NULL);
+ file = g_file_new_for_path (destination);
+ g_free (destination);
+
+ g_file_make_symbolic_link (file, source, NULL, NULL);
+
+ g_object_unref (info);
+ g_object_unref (file);
+}
+
+static void
+cc_media_sharing_bus_ready_callback (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GDBusConnection *connection;
+
+ connection = g_bus_get_finish (result, NULL);
+
+ if (!connection)
+ return;
+
+ g_dbus_connection_call (connection, BUS_NAME, OBJECT_PATH, INTERFACE_NAME,
+ "Shutdown", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL, NULL, NULL);
+}
+
+static void
+cc_media_sharing_disable_autostart (void)
+{
+ gchar *path;
+
+ path = g_build_filename (g_get_user_config_dir (), "autostart",
+ RYGEL_DESKTOP_ID, NULL);
+
+ g_unlink (path);
+ g_free (path);
+
+ /* stop rygel */
+ g_bus_get (G_BUS_TYPE_SESSION, NULL, cc_media_sharing_bus_ready_callback,
+ NULL);
+}
+
void
cc_media_sharing_get_preferences (gboolean *enabled,
gchar ***folders)
@@ -99,6 +171,11 @@ cc_media_sharing_set_preferences (gboolean enabled,
file = cc_media_sharing_open_key_file ();
+ if (enabled)
+ cc_media_sharing_enable_autostart ();
+ else
+ cc_media_sharing_disable_autostart ();
+
g_key_file_set_boolean (file, "general", "upnp-enabled", enabled);
str_list = folders;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]