Merge authors:
  Michal Hruby (mhr3)
------------------------------------------------------------
revno: 311 [merge]
committer: Michal Hruby <michal....@gmail.com>
branch nick: bluebird
timestamp: Thu 2011-10-13 17:59:53 +0200
message:
  Merge from my branch
modified:
  src/zeitgeist-daemon.vala


--
lp:~zeitgeist/zeitgeist/bluebird
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch 
lp:~zeitgeist/zeitgeist/bluebird.
To unsubscribe from this branch go to 
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'src/zeitgeist-daemon.vala'
--- src/zeitgeist-daemon.vala	2011-10-13 13:14:29 +0000
+++ src/zeitgeist-daemon.vala	2011-10-13 15:59:53 +0000
@@ -251,24 +251,6 @@
             }
         }
 
-        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 @@
 
         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 @@
                 // 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 @@
             }
             if (name_owned)
             {
-                if (replace_mode)
+                if (replace_mode || quit_daemon)
                 {
                     quit_running_instance (connection);
                 }
@@ -369,8 +351,22 @@
                     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 @@
 
                     return 0;
                 }
-                if (quit_daemon)
-                {
-                    var conn = Bus.get_sync (BusType.SESSION);
-                    quit_running_instance (conn);
-                    return 0;
-                }
                 run ();
             }
             catch (Error err)

_______________________________________________
Mailing list: https://launchpad.net/~zeitgeist
Post to     : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp

Reply via email to