From 1ab727d453417a6a81ca27bf3fb80ce6f7c44ac4 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Mon, 24 Mar 2014 17:49:19 +0200 Subject: [PATCH] lms: get db path over dbus from LMS --- src/plugins/lms/Makefile.am | 3 ++- src/plugins/lms/rygel-lms-dbus-interfaces.vala | 28 ++++++++++++++++++++++++++ src/plugins/lms/rygel-lms-root-container.vala | 14 +++++++++---- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/plugins/lms/rygel-lms-dbus-interfaces.vala diff --git a/src/plugins/lms/Makefile.am b/src/plugins/lms/Makefile.am index 1e777dd..f96a2ab 100644 --- a/src/plugins/lms/Makefile.am +++ b/src/plugins/lms/Makefile.am @@ -22,7 +22,8 @@ librygel_lms_la_SOURCES = \ rygel-lms-image-year.vala \ rygel-lms-sql-function.vala \ rygel-lms-sql-operator.vala \ - rygel-lms-collate.c + rygel-lms-collate.c \ + rygel-lms-dbus-interfaces.vala librygel_lms_la_VALAFLAGS = \ --enable-experimental \ diff --git a/src/plugins/lms/rygel-lms-dbus-interfaces.vala b/src/plugins/lms/rygel-lms-dbus-interfaces.vala new file mode 100644 index 0000000..6c14f5b --- /dev/null +++ b/src/plugins/lms/rygel-lms-dbus-interfaces.vala @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2014 Intel Corporation. + * + * Author: Alexander Kanavin + * + * 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. + */ + +[DBus (name = "org.lightmediascanner.Scanner1")] +interface Rygel.LMS.DBus : Object { + public abstract string data_base_path { owned get; } + + //TODO: add all the other API items which are currently unused +} \ No newline at end of file diff --git a/src/plugins/lms/rygel-lms-root-container.vala b/src/plugins/lms/rygel-lms-root-container.vala index d7307be..a7a7f98 100644 --- a/src/plugins/lms/rygel-lms-root-container.vala +++ b/src/plugins/lms/rygel-lms-root-container.vala @@ -38,11 +38,17 @@ public class Rygel.LMS.RootContainer : Rygel.SimpleContainer { base.root(title); - string db_path; + string db_path = null; try { - db_path = config.get_string ("LightMediaScanner", "db-path"); - debug ("Using sqlite database location '%s'", db_path); - } catch (GLib.Error error) { + LMS.DBus lms_proxy = Bus.get_proxy_sync (BusType.SESSION, + "org.lightmediascanner", + "/org/lightmediascanner/Scanner1"); + db_path = lms_proxy.data_base_path; + debug ("Got db path %s from LMS over dbus", db_path); + } catch (Error e) { + warning("Using dbus to get db location failed: %s", e.message); + } + if (db_path == null) { db_path = Environment.get_user_config_dir() + "/lightmediascannerd/db.sqlite3"; debug ("Using default sqlite database location %s", db_path); -- 2.7.4