summaryrefslogtreecommitdiff
authorMichal Hruby <michal.mhr@gmail.com>2011-10-13 15:59:53 (GMT)
committer Michal Hruby <michal.mhr@gmail.com>2011-10-13 15:59:53 (GMT)
commit4d660567d642ba318d29ff39203a73654c86a101 (patch) (side-by-side diff)
tree585419a1fc125289a7c1afd3aa45c9538d55df3f
parent9f9eb97053983aa173b852dc5fd282e79b721693 (diff)
parent52e0b89f25330af65c83a3b61aa7087a02403e83 (diff)
downloadzeitgeist-4d660567d642ba318d29ff39203a73654c86a101.zip
zeitgeist-4d660567d642ba318d29ff39203a73654c86a101.tar.gz
Merge from my branch
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/zeitgeist-daemon.vala56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/zeitgeist-daemon.vala b/src/zeitgeist-daemon.vala
index 54ec7f3..5bd6700 100644
--- a/src/zeitgeist-daemon.vala
+++ b/src/zeitgeist-daemon.vala
@@ -251,24 +251,6 @@ namespace Zeitgeist
}
}
- static void on_bus_acquired (DBusConnection conn)
- {
- try
- {
- instance = new Daemon ();
- instance.register_dbus_object (conn);
- }
- catch (EngineError err)
- {
- critical ("%s", err.message);
- mainloop.quit ();
- }
- catch (IOError e)
- {
- critical ("Could not register service");
- }
- }
-
private static bool quit_running_instance (DBusConnection conn)
{
try
@@ -306,7 +288,12 @@ namespace Zeitgeist
private static void name_lost_callback (DBusConnection? conn)
{
- if (instance != null && !name_acquired)
+ if (conn == null)
+ {
+ // something happened to our bus connection
+ mainloop.quit ();
+ }
+ else if (instance != null && !name_acquired)
{
// we acquired bus connection, but couldn't own the name
if (!replace_mode)
@@ -332,11 +319,6 @@ namespace Zeitgeist
// we owned the name and we lost it... what to do?
mainloop.quit ();
}
- else if (conn == null)
- {
- // we couldn't even acquire the bus connection
- mainloop.quit ();
- }
}
static void run ()
@@ -358,7 +340,7 @@ namespace Zeitgeist
}
if (name_owned)
{
- if (replace_mode)
+ if (replace_mode || quit_daemon)
{
quit_running_instance (connection);
}
@@ -369,8 +351,22 @@ namespace Zeitgeist
Posix.exit (10);
}
}
- on_bus_acquired (connection);
- if (instance == null) return;
+
+ /* don't do anything else if we were called with --quit param */
+ if (quit_daemon) return;
+
+ /* setup Engine instance and register objects on dbus */
+ try
+ {
+ instance = new Daemon ();
+ instance.register_dbus_object (connection);
+ }
+ catch (Error err)
+ {
+ critical ("%s", err.message);
+ return;
+ }
+
uint owner_id = Bus.own_name_on_connection (connection,
DBUS_NAME,
BusNameOwnerFlags.NONE,
@@ -434,12 +430,6 @@ namespace Zeitgeist
return 0;
}
- if (quit_daemon)
- {
- var conn = Bus.get_sync (BusType.SESSION);
- quit_running_instance (conn);
- return 0;
- }
run ();
}
catch (Error err)