diff options
author | Michal Hruby <michal.mhr@gmail.com> | 2012-03-26 15:52:20 +0200 |
---|---|---|
committer | Michal Hruby <michal.mhr@gmail.com> | 2012-03-26 15:52:20 +0200 |
commit | d79366bde94b5b8e00b7ad2e8e5763c5305a6aaf (patch) | |
tree | 24ad2fd84a349c644d05ee34b112a8a86ab4a29c /extensions/fts++ | |
parent | c1a9d8713be617084edb3ae5e3c81974c1bf807f (diff) | |
download | zeitgeist-d79366bde94b5b8e00b7ad2e8e5763c5305a6aaf.tar.gz |
Quit FTS when zeitgeist exists
Diffstat (limited to 'extensions/fts++')
-rw-r--r-- | extensions/fts++/zeitgeist-fts.vala | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/extensions/fts++/zeitgeist-fts.vala b/extensions/fts++/zeitgeist-fts.vala index 79bc1905..a4c25be1 100644 --- a/extensions/fts++/zeitgeist-fts.vala +++ b/extensions/fts++/zeitgeist-fts.vala @@ -54,6 +54,7 @@ namespace Zeitgeist private static FtsDaemon? instance; private static MainLoop mainloop; private static bool name_acquired = false; + private static bool zeitgeist_up = false; private DbReader engine; private Indexer indexer; @@ -170,6 +171,16 @@ namespace Zeitgeist } } + private static void zeitgeist_vanished () + { + if (zeitgeist_up) + { + // client apis query us via zeitgeist, so quit if zg goes away + mainloop.quit (); + } + zeitgeist_up = false; + } + static void run () throws Error { @@ -177,10 +188,7 @@ namespace Zeitgeist var proxy = connection.get_proxy_sync<RemoteDBus> ( "org.freedesktop.DBus", "/org/freedesktop/DBus", DBusProxyFlags.DO_NOT_LOAD_PROPERTIES); - bool zeitgeist_up = proxy.name_has_owner (ZEITGEIST_DBUS_NAME); - // FIXME: throw an error that zeitgeist isn't up? or just start it? - bool name_owned = proxy.name_has_owner (DBUS_NAME); - if (name_owned) + if (proxy.name_has_owner (DBUS_NAME)) { throw new EngineError.EXISTING_INSTANCE ( "The FTS daemon is running already."); @@ -214,6 +222,10 @@ namespace Zeitgeist name_acquired_callback, name_lost_callback); + Bus.watch_name (BusType.SESSION, ZEITGEIST_DBUS_NAME, 0, + () => { zeitgeist_up = true; }, + zeitgeist_vanished); + mainloop = new MainLoop (); mainloop.run (); |