Retabbed
authorEnrico Zini <enrico@enricozini.org>
Wed, 16 Dec 2009 14:44:31 +0000 (14:44 +0000)
committerEnrico Zini <enrico@enricozini.org>
Wed, 16 Dec 2009 14:44:31 +0000 (14:44 +0000)
src/registry.vala

index d6b545dc7f5d6cf56b7e55613773b73442a73ab3..a95e16045a60647b9c2f9398be90affdd7f5bcd1 100644 (file)
@@ -25,27 +25,27 @@ namespace zavai {
 
 public class Registry : Object, Resource
 {
-       HashMap<string, Resource> memb_resources;
-       HashMap<string, Service> memb_services;
-       HashMap<string, Applet> memb_applets;
-       HashMap<string, Menu> memb_menus;
-       protected ArrayList<Resource> registration_order;
-       public DBus.Connection sbus;
+    HashMap<string, Resource> memb_resources;
+    HashMap<string, Service> memb_services;
+    HashMap<string, Applet> memb_applets;
+    HashMap<string, Menu> memb_menus;
+    protected ArrayList<Resource> registration_order;
+    public DBus.Connection sbus;
     public string bus_name;
 
-       public Registry()
-       {
-               memb_resources = new HashMap<string, Resource>(str_hash, str_equal);
-               memb_services = new HashMap<string, Service>(str_hash, str_equal);
-               memb_applets = new HashMap<string, Applet>(str_hash, str_equal);
-               memb_menus = new HashMap<string, Menu>(str_hash, str_equal);
-               registration_order = new ArrayList<Resource>();
-               try {
-                       sbus = DBus.Bus.get(DBus.BusType.SYSTEM);
-               } catch (DBus.Error e) {
-                       stderr.printf("Cannot access system DBus bus: %s\n", e.message);
-                       sbus = null;
-               }
+    public Registry()
+    {
+        memb_resources = new HashMap<string, Resource>(str_hash, str_equal);
+        memb_services = new HashMap<string, Service>(str_hash, str_equal);
+        memb_applets = new HashMap<string, Applet>(str_hash, str_equal);
+        memb_menus = new HashMap<string, Menu>(str_hash, str_equal);
+        registration_order = new ArrayList<Resource>();
+        try {
+            sbus = DBus.Bus.get(DBus.BusType.SYSTEM);
+        } catch (DBus.Error e) {
+            stderr.printf("Cannot access system DBus bus: %s\n", e.message);
+            sbus = null;
+        }
 
         bus_name = DBus.bus_get_unique_name(sbus.get_connection());
         zavai.log.info("My bus name: " + bus_name);
@@ -71,83 +71,83 @@ public class Registry : Object, Resource
                 zavai.log.info("I already own the name " + bus_name + " but I do not remember asking for it");
                 break;
         }
-       }
-
-       public void shutdown()
-       {
-               // Shutdown in reverse registration order
-               for (int i = registration_order.size - 1; i >= 0; --i) 
-                       registration_order[i].shutdown();
-       }
-
-       public void register_resource(string name, Resource obj)
-       {
-               memb_resources[name] = obj;
-               registration_order.add(obj);
-       }
-
-       public void register_service(Service obj)
-       {
-               memb_services[obj.name] = obj;
-               registration_order.add(obj);
-       }
-
-       public void register_applet(string name, Applet obj)
-       {
-               memb_applets[name] = obj;
-               registration_order.add(obj);
-       }
-
-       public void register_menu(string name, Menu obj)
-       {
-               memb_applets[name] = obj;
-               memb_menus[name] = obj;
-               registration_order.add(obj);
-       }
-
-       public Resource? getr(string name)
-       {
-               if (name in memb_resources)
-                       return memb_resources[name];
-               else
-               {
-                       log.error("getr: no resource found: " + name);
-                       return null;
-               }
-       }
-
-       public Service? gets(string name)
-       {
-               if (name in memb_services)
-                       return memb_services[name];
-               else
-               {
-                       log.error("gets: no service found: " + name);
-                       return null;
-               }
-       }
-
-       public Applet? geta(string name)
-       {
-               if (name in memb_applets)
-                       return memb_applets[name];
-               else
-               {
-                       log.error("geta: no applet found: " + name);
-                       return null;
-               }
-       }
-
-       public Menu? getmenu(string name)
-       {
-               if (name in memb_menus)
-                       return memb_menus[name];
-               else
-               {
-                       log.error("getmenu: no menu found: " + name);
-                       return null;
-               }
-       }
+    }
+
+    public void shutdown()
+    {
+        // Shutdown in reverse registration order
+        for (int i = registration_order.size - 1; i >= 0; --i) 
+            registration_order[i].shutdown();
+    }
+
+    public void register_resource(string name, Resource obj)
+    {
+        memb_resources[name] = obj;
+        registration_order.add(obj);
+    }
+
+    public void register_service(Service obj)
+    {
+        memb_services[obj.name] = obj;
+        registration_order.add(obj);
+    }
+
+    public void register_applet(string name, Applet obj)
+    {
+        memb_applets[name] = obj;
+        registration_order.add(obj);
+    }
+
+    public void register_menu(string name, Menu obj)
+    {
+        memb_applets[name] = obj;
+        memb_menus[name] = obj;
+        registration_order.add(obj);
+    }
+
+    public Resource? getr(string name)
+    {
+        if (name in memb_resources)
+            return memb_resources[name];
+        else
+        {
+            log.error("getr: no resource found: " + name);
+            return null;
+        }
+    }
+
+    public Service? gets(string name)
+    {
+        if (name in memb_services)
+            return memb_services[name];
+        else
+        {
+            log.error("gets: no service found: " + name);
+            return null;
+        }
+    }
+
+    public Applet? geta(string name)
+    {
+        if (name in memb_applets)
+            return memb_applets[name];
+        else
+        {
+            log.error("geta: no applet found: " + name);
+            return null;
+        }
+    }
+
+    public Menu? getmenu(string name)
+    {
+        if (name in memb_menus)
+            return memb_menus[name];
+        else
+        {
+            log.error("getmenu: no menu found: " + name);
+            return null;
+        }
+    }
 }
 
 public zavai.Registry registry;