diff options
author | Michal Hruby <michal.mhr@gmail.com> | 2011-10-13 17:59:53 +0200 |
---|---|---|
committer | Michal Hruby <michal.mhr@gmail.com> | 2011-10-13 17:59:53 +0200 |
commit | 4d660567d642ba318d29ff39203a73654c86a101 (patch) | |
tree | 585419a1fc125289a7c1afd3aa45c9538d55df3f | |
parent | 9f9eb97053983aa173b852dc5fd282e79b721693 (diff) | |
parent | 52e0b89f25330af65c83a3b61aa7087a02403e83 (diff) |
Merge from my branch
-rw-r--r-- | src/zeitgeist-daemon.vala | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/src/zeitgeist-daemon.vala b/src/zeitgeist-daemon.vala index 54ec7f31..5bd6700d 100644 --- a/src/zeitgeist-daemon.vala +++ b/src/zeitgeist-daemon.vala | |||
@@ -251,24 +251,6 @@ namespace Zeitgeist | |||
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | static void on_bus_acquired (DBusConnection conn) | ||
255 | { | ||
256 | try | ||
257 | { | ||
258 | instance = new Daemon (); | ||
259 | instance.register_dbus_object (conn); | ||
260 | } | ||
261 | catch (EngineError err) | ||
262 | { | ||
263 | critical ("%s", err.message); | ||
264 | mainloop.quit (); | ||
265 | } | ||
266 | catch (IOError e) | ||
267 | { | ||
268 | critical ("Could not register service"); | ||
269 | } | ||
270 | } | ||
271 | |||
272 | private static bool quit_running_instance (DBusConnection conn) | 254 | private static bool quit_running_instance (DBusConnection conn) |
273 | { | 255 | { |
274 | try | 256 | try |
@@ -306,7 +288,12 @@ namespace Zeitgeist | |||
306 | 288 | ||
307 | private static void name_lost_callback (DBusConnection? conn) | 289 | private static void name_lost_callback (DBusConnection? conn) |
308 | { | 290 | { |
309 | if (instance != null && !name_acquired) | 291 | if (conn == null) |
292 | { | ||
293 | // something happened to our bus connection | ||
294 | mainloop.quit (); | ||
295 | } | ||
296 | else if (instance != null && !name_acquired) | ||
310 | { | 297 | { |
311 | // we acquired bus connection, but couldn't own the name | 298 | // we acquired bus connection, but couldn't own the name |
312 | if (!replace_mode) | 299 | if (!replace_mode) |
@@ -332,11 +319,6 @@ namespace Zeitgeist | |||
332 | // we owned the name and we lost it... what to do? | 319 | // we owned the name and we lost it... what to do? |
333 | mainloop.quit (); | 320 | mainloop.quit (); |
334 | } | 321 | } |
335 | else if (conn == null) | ||
336 | { | ||
337 | // we couldn't even acquire the bus connection | ||
338 | mainloop.quit (); | ||
339 | } | ||
340 | } | 322 | } |
341 | 323 | ||
342 | static void run () | 324 | static void run () |
@@ -358,7 +340,7 @@ namespace Zeitgeist | |||
358 | } | 340 | } |
359 | if (name_owned) | 341 | if (name_owned) |
360 | { | 342 | { |
361 | if (replace_mode) | 343 | if (replace_mode || quit_daemon) |
362 | { | 344 | { |
363 | quit_running_instance (connection); | 345 | quit_running_instance (connection); |
364 | } | 346 | } |
@@ -369,8 +351,22 @@ namespace Zeitgeist | |||
369 | Posix.exit (10); | 351 | Posix.exit (10); |
370 | } | 352 | } |
371 | } | 353 | } |
372 | on_bus_acquired (connection); | 354 | |
373 | if (instance == null) return; | 355 | /* don't do anything else if we were called with --quit param */ |
356 | if (quit_daemon) return; | ||
357 | |||
358 | /* setup Engine instance and register objects on dbus */ | ||
359 | try | ||
360 | { | ||
361 | instance = new Daemon (); | ||
362 | instance.register_dbus_object (connection); | ||
363 | } | ||
364 | catch (Error err) | ||
365 | { | ||
366 | critical ("%s", err.message); | ||
367 | return; | ||
368 | } | ||
369 | |||
374 | uint owner_id = Bus.own_name_on_connection (connection, | 370 | uint owner_id = Bus.own_name_on_connection (connection, |
375 | DBUS_NAME, | 371 | DBUS_NAME, |
376 | BusNameOwnerFlags.NONE, | 372 | BusNameOwnerFlags.NONE, |
@@ -434,12 +430,6 @@ namespace Zeitgeist | |||
434 | 430 | ||
435 | return 0; | 431 | return 0; |
436 | } | 432 | } |
437 | if (quit_daemon) | ||
438 | { | ||
439 | var conn = Bus.get_sync (BusType.SESSION); | ||
440 | quit_running_instance (conn); | ||
441 | return 0; | ||
442 | } | ||
443 | run (); | 433 | run (); |
444 | } | 434 | } |
445 | catch (Error err) | 435 | catch (Error err) |