>From 5a23f61335e05b06487f66d7bcf3986fb9d21012 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 10 Feb 2011 15:02:04 +0000 Subject: [PATCH 1/2] fix miner initialization Signed-off-by: Lionel Landwerlin --- src/tracker-miner-upnp.vala | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/tracker-miner-upnp.vala b/src/tracker-miner-upnp.vala index 36fdeea..072d85a 100644 --- a/src/tracker-miner-upnp.vala +++ b/src/tracker-miner-upnp.vala @@ -5,12 +5,12 @@ * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * 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 Street, Fifth Floor, Boston, MA @@ -26,8 +26,8 @@ using GUPnP; namespace Tracker.UPnP { -public class Miner : Tracker.Miner -{ +public class Miner : Tracker.Miner, GLib.Initable { + private static const string MINER_NAME = "UPnP"; private static const string MINER_DESCRIPTION = "Tracker miner for UPnP ContentDirectories"; private static const string MEDIASERVER_DEVICE = "urn:schemas-upnp-org:device:MediaServer:1"; @@ -53,8 +53,10 @@ public class Miner : Tracker.Miner name = MINER_NAME; } - private Miner () + public bool init (GLib.Cancellable? cancellable) throws GLib.Error { + base.init (cancellable); + main_loop = new MainLoop (null, false); manager = new ContextManager (null, 0); mediaservers = new HashTable (str_hash, str_equal); @@ -64,11 +66,8 @@ public class Miner : Tracker.Miner update_status (); update_progress (); - try { - UPnPSparql.set_all_content_directories_unavailable (get_connection()); - } catch (Error error) { - warning ("Failed to set content directories unavailable on startup: %s".printf (error.message)); - } + UPnPSparql.set_all_content_directories_unavailable (get_connection()); + return true; } public override void started () @@ -96,7 +95,7 @@ public class Miner : Tracker.Miner HashTableIter iter = HashTableIter (mediaservers); ContentDirectory? dir; - while (iter.next (null, out dir)) { + while (iter.next (null, out dir)) { if (dir != null) dir.paused = !running; } @@ -110,7 +109,7 @@ public class Miner : Tracker.Miner string server_string = ""; uint count; - while (iter.next (null, out dir)) { + while (iter.next (null, out dir)) { if (dir == null) return; @@ -152,7 +151,7 @@ public class Miner : Tracker.Miner double total_progress = 0.0; int count = 0; - while (iter.next (null, out dir)) { + while (iter.next (null, out dir)) { if (dir != null){ total_progress += dir.progress; } @@ -229,7 +228,7 @@ public class Miner : Tracker.Miner { Environment.set_application_name ("UPnP tracker miner"); - UPnP.Miner miner = new UPnP.Miner (); + UPnP.Miner miner = Initable.new (typeof (UPnP.Miner), null) as UPnP.Miner; int exit_code = miner.run (); return exit_code; } -- 1.7.2.3