[folks] Maximize use of the 'var' keyword.



commit b93b4445e87bc645c1b6c1425deb17a99c27304c
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Mon Dec 27 17:22:21 2010 -0800

    Maximize use of the 'var' keyword.
    
    This is used whenever a variable:
    1. is declared and initialized in the same line
    AND
    2. would not avoid a copy by using the 'unowned'. In the future, we may be able
    to declare variables 'unowned var', in which case this point won't matter. See
    bgo#638199.
    
    The net benefit is less noise on variable declaration lines.
    
    Helps bgo#629083

 HACKING                                       |    6 ++
 backends/key-file/kf-backend.vala             |    2 +-
 backends/key-file/kf-persona-store.vala       |   12 ++--
 backends/key-file/kf-persona.vala             |   25 ++++----
 backends/telepathy/lib/tpf-persona-store.vala |   35 ++++++-----
 backends/telepathy/lib/tpf-persona.vala       |    6 +-
 backends/telepathy/tp-backend.vala            |    3 +-
 folks/backend-store.vala                      |   33 +++++-----
 folks/debug.vala                              |    2 +-
 folks/individual-aggregator.vala              |   80 ++++++++++++-------------
 folks/individual.vala                         |   44 +++++++-------
 folks/persona.vala                            |    2 +-
 12 files changed, 127 insertions(+), 123 deletions(-)
---
diff --git a/HACKING b/HACKING
index 7e9e433..b373c84 100644
--- a/HACKING
+++ b/HACKING
@@ -82,3 +82,9 @@ Vala-specific rules
 6. Private and internal class functions should begin with a _ (public functions
    should not begin with a _). This is to make non-public functions instantly
    recognizable as such (which helps readability).
+
+7. Maximize use of the 'var' variable type. This shortens the declarations where
+   it's valid, reducing noise.
+
+   Rarely, the use of 'var' can obscure the effective type of the variable. In
+   this case, it's acceptable to provide an explicit type.
diff --git a/backends/key-file/kf-backend.vala b/backends/key-file/kf-backend.vala
index 4f1f4c9..d5edb92 100644
--- a/backends/key-file/kf-backend.vala
+++ b/backends/key-file/kf-backend.vala
@@ -78,7 +78,7 @@ public class Folks.Backends.Kf.Backend : Folks.Backend
           if (!this._is_prepared)
             {
               File file;
-              string path = Environment.get_variable (
+              var path = Environment.get_variable (
                   "FOLKS_BACKEND_KEY_FILE_PATH");
               if (path == null)
                 {
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index 3f5ab65..16b3c79 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -119,7 +119,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
    */
   public PersonaStore (File key_file)
     {
-      string id = key_file.get_basename ();
+      var id = key_file.get_basename ();
 
       Object (id: id,
               display_name: id);
@@ -138,7 +138,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
         {
           if (!this._is_prepared)
             {
-              string filename = this._file.get_path ();
+              var filename = this._file.get_path ();
               this._key_file = new GLib.KeyFile ();
 
               /* Load or create the file */
@@ -225,8 +225,8 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
               /* We've loaded or created a key file by now, so cycle through the
                * groups: each group is a persona which we have to create and
                * emit */
-              string[] groups = this._key_file.get_groups ();
-              foreach (string persona_id in groups)
+              var groups = this._key_file.get_groups ();
+              foreach (var persona_id in groups)
                 {
                   if (persona_id.to_int () == this._first_unused_id)
                     this._first_unused_id++;
@@ -338,8 +338,8 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
 
   internal async void save_key_file ()
     {
-      string key_file_data = this._key_file.to_data ();
-      Cancellable cancellable = new Cancellable ();
+      var key_file_data = this._key_file.to_data ();
+      var cancellable = new Cancellable ();
 
       debug ("Saving key file '%s'.", this._file.get_path ());
 
diff --git a/backends/key-file/kf-persona.vala b/backends/key-file/kf-persona.vala
index c6d7c01..b69a5ab 100644
--- a/backends/key-file/kf-persona.vala
+++ b/backends/key-file/kf-persona.vala
@@ -106,9 +106,9 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
               unowned string protocol = (string) k;
               unowned GenericArray<string?> addresses =
                   (GenericArray<string?>) v;
-              uint offset = 0;
+              var offset = 0;
 
-              for (int i = 0; i < addresses.length; i++)
+              for (var i = 0; i < addresses.length; i++)
                 {
                   try
                     {
@@ -157,8 +157,8 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
    */
   public Persona (KeyFile key_file, string id, Folks.PersonaStore store)
     {
-      string iid = store.id + ":" + id;
-      string uid = this.build_uid ("key-file", store.id, id);
+      var iid = store.id + ":" + id;
+      var uid = this.build_uid ("key-file", store.id, id);
 
       Object (display_id: id,
               iid: iid,
@@ -176,8 +176,8 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
       /* Load the IM addresses from the key file */
       try
         {
-          string[] keys = this._key_file.get_keys (this.display_id);
-          foreach (string key in keys)
+          var keys = this._key_file.get_keys (this.display_id);
+          foreach (var key in keys)
             {
               /* Alias */
               if (key == "__alias")
@@ -189,23 +189,22 @@ public class Folks.Backends.Kf.Persona : Folks.Persona,
                 }
 
               /* IM addresses */
-              string protocol = key;
-              string[] im_addresses = this._key_file.get_string_list (
+              var protocol = key;
+              var im_addresses = this._key_file.get_string_list (
                   this.display_id, protocol);
 
               /* FIXME: We have to convert our nice efficient string[] to a
                * GenericArray<string> because Vala doesn't like null-terminated
                * arrays as generic types.
                * We can take this opportunity to remove duplicates. */
-              HashSet<string> address_set = new HashSet<string> ();
-              GenericArray<string> im_address_array =
-                  new GenericArray<string> ();
+              var address_set = new HashSet<string> ();
+              var im_address_array = new GenericArray<string> ();
 
-              foreach (string im_address in im_addresses)
+              foreach (var im_address in im_addresses)
                 {
                   try
                     {
-                      string address = IMable.normalise_im_address (im_address,
+                      var address = IMable.normalise_im_address (im_address,
                           protocol);
 
                       if (!address_set.contains (address))
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index fd92d14..4a28ea8 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -42,7 +42,12 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       ".ChannelType";
   private static string _tp_channel_handle_type = _tp_channel_iface +
       ".TargetHandleType";
-  private string[] _undisplayed_groups = { "publish", "stored", "subscribe" };
+  private static string[] _undisplayed_groups =
+      {
+        "publish",
+        "stored",
+        "subscribe"
+      };
   private static ContactFeature[] _contact_features =
       {
         ContactFeature.ALIAS,
@@ -305,7 +310,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       /* Get an initial set of favourite contacts */
       try
         {
-          string[] contacts = yield this._logger.get_favourite_contacts ();
+          var contacts = yield this._logger.get_favourite_contacts ();
 
           if (contacts.length == 0)
             return;
@@ -349,8 +354,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
       for (var i = 0; i < handles.length; i++)
         {
-          Handle h = handles[i];
-          Persona p = this._handle_persona_map[h];
+          var h = handles[i];
+          var p = this._handle_persona_map[h];
 
           /* Add/Remove the handle to the set of favourite handles, since we
            * might not have the corresponding contact yet */
@@ -461,7 +466,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       /* Deal with the case where the connection is already ready
        * FIXME: We have to access the property manually until bgo#571348 is
        * fixed. */
-      bool connection_ready = false;
+      var connection_ready = false;
       conn.get ("connection-ready", out connection_ready);
 
       if (connection_ready == true)
@@ -472,7 +477,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
   private void _connection_ready_cb (Object s, ParamSpec? p)
     {
-      Connection c = (Connection) s;
+      var c = (Connection) s;
       this._ll.connection_connect_to_new_group_channels (c,
           this._new_group_channels_cb);
 
@@ -570,7 +575,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
 
   private void _self_handle_changed_cb (Object s, ParamSpec? p)
     {
-      Connection c = (Connection) s;
+      var c = (Connection) s;
 
       /* Remove the old self persona */
       if (this._self_contact != null)
@@ -885,16 +890,16 @@ public class Tpf.PersonaStore : Folks.PersonaStore
             return;
         }
 
-      string? message = TelepathyGLib.asv_get_string (details, "message");
+      var message = TelepathyGLib.asv_get_string (details, "message");
       bool valid;
       Persona? actor = null;
-      uint32 actor_handle = TelepathyGLib.asv_get_uint32 (details, "actor",
+      var actor_handle = TelepathyGLib.asv_get_uint32 (details, "actor",
           out valid);
       if (actor_handle > 0 && valid)
         actor = this._handle_persona_map[actor_handle];
 
       Groupable.ChangeReason reason = Groupable.ChangeReason.NONE;
-      uint32 tp_reason = TelepathyGLib.asv_get_uint32 (details, "change-reason",
+      var tp_reason = TelepathyGLib.asv_get_uint32 (details, "change-reason",
           out valid);
       if (valid)
         reason = _change_reason_from_tp_reason (tp_reason);
@@ -1246,8 +1251,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
                   this._conn, contact_ids, (uint[]) _contact_features);
 
           GLib.List<Persona> personas = new GLib.List<Persona> ();
-          uint err_count = 0;
-          string err_string = "";
+          var err_count = 0;
+          var err_string = "";
           unowned GLib.List<TelepathyGLib.Contact> l;
           for (l = contacts; l != null; l = l.next)
             {
@@ -1406,7 +1411,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
               _("Cannot create a new persona while offline."));
         }
 
-      string[] contact_ids = new string[1];
+      var contact_ids = new string[1];
       contact_ids[0] = contact_id;
 
       try
@@ -1444,8 +1449,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
             {
               /* We ignore the case of an empty list, as it just means the
                * contact was already in our roster */
-              uint num_personas = personas.length ();
-              string message =
+              var num_personas = personas.length ();
+              var message =
                   ngettext (
                       /* Translators: the parameter is the number of personas
                        * which were returned. */
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index 26e1944..6e530cd 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -177,7 +177,7 @@ public class Tpf.Persona : Folks.Persona,
 
   private bool _change_group (string group, bool is_member)
     {
-      bool changed = false;
+      var changed = false;
 
       if (is_member)
         {
@@ -215,7 +215,7 @@ public class Tpf.Persona : Folks.Persona,
       unowned string id = contact.get_identifier ();
       unowned Connection connection = contact.connection;
       var account = _account_for_connection (connection);
-      string uid = this.build_uid ("telepathy", account.get_protocol (), id);
+      var uid = this.build_uid ("telepathy", account.get_protocol (), id);
 
       Object (alias: contact.get_alias (),
               contact: contact,
@@ -314,7 +314,7 @@ public class Tpf.Persona : Folks.Persona,
   private static Account? _account_for_connection (Connection conn)
     {
       var manager = AccountManager.dup ();
-      GLib.List<unowned Account> accounts = manager.get_valid_accounts ();
+      var accounts = manager.get_valid_accounts ();
 
       Account account_found = null;
       accounts.foreach ((l) =>
diff --git a/backends/telepathy/tp-backend.vala b/backends/telepathy/tp-backend.vala
index 3d32e87..3595b23 100644
--- a/backends/telepathy/tp-backend.vala
+++ b/backends/telepathy/tp-backend.vala
@@ -131,8 +131,7 @@ public class Folks.Backends.Tp.Backend : Folks.Backend
 
   private void _account_enabled_cb (Account account)
     {
-      PersonaStore store = this._persona_stores.lookup (
-          account.get_object_path ());
+      var store = this._persona_stores.lookup (account.get_object_path ());
 
       if (store != null)
         return;
diff --git a/folks/backend-store.vala b/folks/backend-store.vala
index 8406023..10dc0d6 100644
--- a/folks/backend-store.vala
+++ b/folks/backend-store.vala
@@ -202,7 +202,7 @@ public class Folks.BackendStore : Object {
       var path_split = path.split (":");
       foreach (var subpath in path_split)
         {
-          File file = File.new_for_path (subpath);
+          var file = File.new_for_path (subpath);
           assert (file != null);
 
           bool is_file;
@@ -265,7 +265,7 @@ public class Folks.BackendStore : Object {
 
   private async bool _backend_unload_if_needed (Backend backend)
     {
-      bool unloaded = false;
+      var unloaded = false;
 
       if (!this._backend_is_enabled (backend.name))
         {
@@ -311,7 +311,7 @@ public class Folks.BackendStore : Object {
 
   private bool _backend_is_enabled (string name)
     {
-      bool enabled = true;
+      var enabled = true;
       try
         {
           enabled = this.backends_key_file.get_boolean (name, "enabled");
@@ -388,18 +388,18 @@ public class Folks.BackendStore : Object {
     {
       debug ("Searching for modules in folder '%s' ..", dir.get_path ());
 
-      string attributes = FILE_ATTRIBUTE_STANDARD_NAME + "," +
-                          FILE_ATTRIBUTE_STANDARD_TYPE + "," +
-                          FILE_ATTRIBUTE_STANDARD_IS_SYMLINK + "," +
-                          FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE;
+      var attributes =
+          FILE_ATTRIBUTE_STANDARD_NAME + "," +
+          FILE_ATTRIBUTE_STANDARD_TYPE + "," +
+          FILE_ATTRIBUTE_STANDARD_IS_SYMLINK + "," +
+          FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE;
 
       GLib.List<FileInfo> infos;
-      FileEnumerator enumerator;
-
       try
         {
-          enumerator = yield dir.enumerate_children_async (attributes,
-              FileQueryInfoFlags.NONE, Priority.DEFAULT, null);
+          FileEnumerator enumerator =
+            yield dir.enumerate_children_async (attributes,
+                FileQueryInfoFlags.NONE, Priority.DEFAULT, null);
 
           infos = yield enumerator.next_files_async (int.MAX,
               Priority.DEFAULT, null);
@@ -418,8 +418,8 @@ public class Folks.BackendStore : Object {
 
       foreach (var info in infos)
         {
-          File file = dir.get_child (info.get_name ());
-          FileType file_type = info.get_file_type ();
+          var file = dir.get_child (info.get_name ());
+          var file_type = info.get_file_type ();
           unowned string content_type = info.get_content_type ();
           /* don't load the library multiple times for its various symlink
            * aliases */
@@ -458,7 +458,7 @@ public class Folks.BackendStore : Object {
 
   private void _load_module_from_file (File file)
     {
-      string file_path = file.get_path ();
+      var file_path = file.get_path ();
 
       if (this.modules.has_key (file_path))
         return;
@@ -544,8 +544,7 @@ public class Folks.BackendStore : Object {
   private async void _load_disabled_backend_names ()
     {
       File file;
-      string path =
-          Environment.get_variable ("FOLKS_BACKEND_STORE_KEY_FILE_PATH");
+      var path = Environment.get_variable ("FOLKS_BACKEND_STORE_KEY_FILE_PATH");
       if (path == null)
         {
           file = File.new_for_path (Environment.get_user_data_dir ());
@@ -593,7 +592,7 @@ public class Folks.BackendStore : Object {
 
   private async void _save_key_file ()
     {
-      string key_file_data = this.backends_key_file.to_data ();
+      var key_file_data = this.backends_key_file.to_data ();
 
       debug ("Saving backend key file '%s'.", this.config_file.get_path ());
 
diff --git a/folks/debug.vala b/folks/debug.vala
index f9c6cd3..1e03e16 100644
--- a/folks/debug.vala
+++ b/folks/debug.vala
@@ -40,7 +40,7 @@ namespace Folks.Debug
               value = Domains.KEY_FILE_BACKEND }
         };
 
-      uint flags = GLib.parse_debug_string (debug_flags, keys);
+      var flags = GLib.parse_debug_string (debug_flags, keys);
 
       foreach (unowned DebugKey key in keys)
         {
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 4336f89..aab8eec 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -147,8 +147,7 @@ public class Folks.IndividualAggregator : Object
 
       this._backends = new HashSet<Backend> ();
 
-      string disable_linking =
-          Environment.get_variable ("FOLKS_DISABLE_LINKING");
+      var disable_linking = Environment.get_variable ("FOLKS_DISABLE_LINKING");
       if (disable_linking != null)
         disable_linking = disable_linking.strip ().down ();
       this._linking_enabled = (disable_linking == null ||
@@ -218,7 +217,7 @@ public class Folks.IndividualAggregator : Object
   private void _backend_persona_store_added_cb (Backend backend,
       PersonaStore store)
     {
-      string store_id = this._get_store_full_id (store.type_id, store.id);
+      var store_id = this._get_store_full_id (store.type_id, store.id);
 
       /* FIXME: We hardcode the key-file backend's singleton PersonaStore as the
        * only trusted and writeable PersonaStore for now. */
@@ -289,7 +288,7 @@ public class Folks.IndividualAggregator : Object
        * confines of this function call. */
       HashSet<Individual> almost_added_individuals = new HashSet<Individual> ();
 
-      foreach (unowned Persona persona in added)
+      foreach (var persona in added)
         {
           PersonaStoreTrust trust_level = persona.store.trust_level;
 
@@ -323,7 +322,7 @@ public class Folks.IndividualAggregator : Object
            * Persona to any existing Individual */
           if (trust_level != PersonaStoreTrust.NONE)
             {
-              Individual candidate_ind = this._link_map.lookup (persona.iid);
+              var candidate_ind = this._link_map.lookup (persona.iid);
               if (candidate_ind != null &&
                   candidate_ind.trust_level != TrustLevel.NONE)
                 {
@@ -345,6 +344,7 @@ public class Folks.IndividualAggregator : Object
                    * prop_name ends up as NULL. bgo#628336 */
                   unowned string prop_name = foo;
 
+                  /* FIXME: can't be var because of bgo#638208 */
                   unowned ObjectClass pclass = persona.get_class ();
                   if (pclass.find_property (prop_name) == null)
                     {
@@ -357,8 +357,8 @@ public class Folks.IndividualAggregator : Object
 
                   persona.linkable_property_to_links (prop_name, (l) =>
                     {
-                      string prop_linking_value = (string) l;
-                      Individual candidate_ind =
+                      var prop_linking_value = (string) l;
+                      var candidate_ind =
                           this._link_map.lookup (prop_linking_value);
 
                       if (candidate_ind != null &&
@@ -387,7 +387,7 @@ public class Folks.IndividualAggregator : Object
                * Individuals so that the Individuals themselves are removed. */
               candidate_inds.foreach ((i) =>
                 {
-                  unowned Individual individual = (Individual) i;
+                  var individual = (Individual) i;
 
                   /* FIXME: It would be faster to prepend a reversed copy of
                    * `individual.personas`, then reverse the entire
@@ -417,7 +417,7 @@ public class Folks.IndividualAggregator : Object
               final_individual.id);
           final_personas.foreach ((i) =>
             {
-              unowned Persona final_persona = (Persona) i;
+              var final_persona = (Persona) i;
 
               debug ("        %s (is user: %s, IID: %s)", final_persona.uid,
                   final_persona.is_user ? "yes" : "no", final_persona.iid);
@@ -439,6 +439,7 @@ public class Folks.IndividualAggregator : Object
                   foreach (unowned string prop_name in
                       final_persona.linkable_properties)
                     {
+                      /* FIXME: can't be var because of bgo#638208 */
                       unowned ObjectClass pclass = final_persona.get_class ();
                       if (pclass.find_property (prop_name) == null)
                         {
@@ -465,7 +466,7 @@ public class Folks.IndividualAggregator : Object
 
           /* Remove the old Individuals. This has to be done here, as we need
            * the final_individual. */
-          foreach (unowned Individual i in candidate_inds)
+          foreach (var i in candidate_inds)
             {
               /* If the replaced individual was marked to be added to the
                * aggregator, unmark it. */
@@ -485,7 +486,7 @@ public class Folks.IndividualAggregator : Object
 
       /* Add the set of final individuals which weren't later replaced to the
        * aggregator. */
-      foreach (Individual i in almost_added_individuals)
+      foreach (var i in almost_added_individuals)
         {
           /* Add the new Individual to the aggregator */
           i.removed.connect (this._individual_removed_cb);
@@ -507,6 +508,7 @@ public class Folks.IndividualAggregator : Object
            * removed. */
           foreach (string prop_name in persona.linkable_properties)
             {
+              /* FIXME: can't be var because of bgo#638208 */
               unowned ObjectClass pclass = persona.get_class ();
               if (pclass.find_property (prop_name) == null)
                 {
@@ -535,20 +537,18 @@ public class Folks.IndividualAggregator : Object
       Persona? actor,
       Groupable.ChangeReason reason)
     {
-      GLib.List<Individual> added_individuals = new GLib.List<Individual> (),
-          removed_individuals = null;
-      HashMap<Individual, Individual> replaced_individuals =
-          new HashMap<Individual, Individual> ();
+      var added_individuals = new GLib.List<Individual> ();
+      GLib.List<Individual> removed_individuals = null;
+      var replaced_individuals = new HashMap<Individual, Individual> ();
       GLib.List<Persona> relinked_personas = null;
-      HashSet<Persona> relinked_personas_set =
-          new HashSet<Persona> (direct_hash, direct_equal);
-      HashSet<Persona> removed_personas = new HashSet<Persona> (direct_hash,
+      var relinked_personas_set = new HashSet<Persona> (direct_hash,
           direct_equal);
+      var removed_personas = new HashSet<Persona> (direct_hash, direct_equal);
 
       /* We store the value of this.user locally and only update it at the end
        * of the function to prevent spamming notifications of changes to the
        * property. */
-      Individual user = this.user;
+      var user = this.user;
 
       if (added != null)
         {
@@ -560,7 +560,7 @@ public class Folks.IndividualAggregator : Object
 
       removed.foreach ((p) =>
         {
-          unowned Persona persona = (Persona) p;
+          var persona = (Persona) p;
 
           debug ("    %s (is user: %s, IID: %s)", persona.uid,
               persona.is_user ? "yes" : "no", persona.iid);
@@ -572,7 +572,7 @@ public class Folks.IndividualAggregator : Object
           /* Find the Individual containing the Persona (if any) and mark them
            * for removal (any other Personas they have which aren't being
            * removed will be re-linked into other Individuals). */
-          Individual ind = this._link_map.lookup (persona.iid);
+          var ind = this._link_map.lookup (persona.iid);
           if (ind != null)
             removed_individuals.prepend (ind);
 
@@ -588,7 +588,7 @@ public class Folks.IndividualAggregator : Object
        * group together the IndividualAggregator.individuals_changed signals
        * for all the removed Individuals. */
       debug ("Removing Individuals due to removed links:");
-      foreach (Individual individual in removed_individuals)
+      foreach (var individual in removed_individuals)
         {
           /* Ensure we don't remove the same Individual twice */
           if (this.individuals.lookup (individual.id) == null)
@@ -598,7 +598,7 @@ public class Folks.IndividualAggregator : Object
 
           /* Build a list of Personas which need relinking. Ensure we don't
            * include any of the Personas which have just been removed. */
-          foreach (unowned Persona persona in individual.personas)
+          foreach (var persona in individual.personas)
             {
               if (removed_personas.contains (persona) == true ||
                   relinked_personas_set.contains (persona) == true)
@@ -619,7 +619,7 @@ public class Folks.IndividualAggregator : Object
         }
 
       debug ("Relinking Personas:");
-      foreach (unowned Persona persona in relinked_personas)
+      foreach (var persona in relinked_personas)
         {
           debug ("    %s (is user: %s, IID: %s)", persona.uid,
               persona.is_user ? "yes" : "no", persona.iid);
@@ -654,8 +654,7 @@ public class Folks.IndividualAggregator : Object
       /* Signal the replacement of various Individuals as a consequence of
        * linking. */
       debug ("Replacing Individuals due to linking:");
-      MapIterator<Individual, Individual> iter =
-          replaced_individuals.map_iterator ();
+      var iter = replaced_individuals.map_iterator ();
       while (iter.next () == true)
         {
           iter.get_key ().replace (iter.get_value ());
@@ -665,7 +664,7 @@ public class Folks.IndividualAggregator : Object
   private void _is_writeable_changed_cb (Object object, ParamSpec pspec)
     {
       /* Ensure that we only have one writeable PersonaStore */
-      unowned PersonaStore store = (PersonaStore) object;
+      var store = (PersonaStore) object;
       assert ((store.is_writeable == true && store == this._writeable_store) ||
           (store.is_writeable == false && store != this._writeable_store));
     }
@@ -674,7 +673,7 @@ public class Folks.IndividualAggregator : Object
     {
       /* FIXME: For the moment, assert that only the key-file backend's
        * singleton PersonaStore is trusted. */
-      unowned PersonaStore store = (PersonaStore) object;
+      var store = (PersonaStore) object;
       if (store.type_id == "key-file")
         assert (store.trust_level == PersonaStoreTrust.FULL);
       else
@@ -817,7 +816,7 @@ public class Folks.IndividualAggregator : Object
       unowned GLib.List<unowned Persona> i;
       for (i = individual.personas; i != null; i = i.next)
         {
-          unowned Persona persona = (Persona) i.data;
+          var persona = (Persona) i.data;
           yield persona.store.remove_persona (persona);
         }
     }
@@ -882,12 +881,12 @@ public class Folks.IndividualAggregator : Object
        * `protocols_addrs_set` is used to ensure we don't get duplicate IM
        * addresses in the ordered set of addresses for each protocol in
        * `protocols_addrs_list`. It's temporary. */
-      HashTable<string, GenericArray<string>> protocols_addrs_list =
+      var protocols_addrs_list =
           new HashTable<string, GenericArray<string>> (str_hash, str_equal);
-      HashTable<string, HashSet<string>> protocols_addrs_set =
+      var protocols_addrs_set =
           new HashTable<string, HashSet<string>> (str_hash, str_equal);
 
-      foreach (unowned Persona persona in personas)
+      foreach (var persona in personas)
         {
           if (!(persona is IMable))
             continue;
@@ -897,10 +896,8 @@ public class Folks.IndividualAggregator : Object
               unowned string protocol = (string) k;
               unowned GenericArray<string> addresses = (GenericArray<string>) v;
 
-              GenericArray<string> address_list =
-                  protocols_addrs_list.lookup (protocol);
-              HashSet<string> address_set = protocols_addrs_set.lookup (
-                protocol);
+              var address_list = protocols_addrs_list.lookup (protocol);
+              var address_set = protocols_addrs_set.lookup (protocol);
 
               if (address_list == null || address_set == null)
                 {
@@ -926,11 +923,10 @@ public class Folks.IndividualAggregator : Object
             });
         }
 
-      Value addresses_value = Value (typeof (HashTable));
+      var addresses_value = Value (typeof (HashTable));
       addresses_value.set_boxed (protocols_addrs_list);
 
-      HashTable<string, Value?> details =
-          new HashTable<string, Value?> (str_hash, str_equal);
+      var details = new HashTable<string, Value?> (str_hash, str_equal);
       details.insert ("im-addresses", addresses_value);
 
       yield this.add_persona_from_details (null, this._writeable_store.type_id,
@@ -974,11 +970,11 @@ public class Folks.IndividualAggregator : Object
        * Personas, as _personas_changed_cb() (which is called as a result of
        * calling _writeable_store.remove_persona()) messes around with Persona
        * lists. */
-      GLib.List<Persona> personas = individual.personas.copy ();
-      foreach (Persona p in personas)
+      var personas = individual.personas.copy ();
+      foreach (var p in personas)
         p.ref ();
 
-      foreach (unowned Persona persona in personas)
+      foreach (var persona in personas)
         {
           if (persona.store == this._writeable_store)
             {
diff --git a/folks/individual.vala b/folks/individual.vala
index 65356d0..e2542a0 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -184,7 +184,7 @@ public class Folks.Individual : Object,
           debug ("Setting alias of individual '%s' to '%s'â?¦", this.id, value);
 
           /* First, try to write it to only the writeable Personasâ?¦ */
-          bool alias_changed = false;
+          var alias_changed = false;
           this._persona_list.foreach ((p) =>
             {
               if (p is Aliasable && ((Persona) p).store.is_writeable == true)
@@ -381,10 +381,10 @@ public class Folks.Individual : Object,
   private void _store_removed_cb (PersonaStore store)
     {
       GLib.List<Persona> removed_personas = null;
-      Iterator<Persona> iter = this._persona_set.iterator ();
+      var iter = this._persona_set.iterator ();
       while (iter.next ())
         {
-          Persona persona = iter.get ();
+          var persona = iter.get ();
 
           removed_personas.prepend (persona);
           this._persona_list.remove (persona);
@@ -416,7 +416,7 @@ public class Folks.Individual : Object,
       GLib.List<Persona> removed_personas = null;
       removed.foreach ((data) =>
         {
-          unowned Persona p = (Persona) data;
+          var p = (Persona) data;
 
           if (this._persona_set.remove (p))
             {
@@ -465,7 +465,7 @@ public class Folks.Individual : Object,
         {
           if (p is Groupable)
             {
-              unowned Groupable persona = (Groupable) p;
+              var persona = (Groupable) p;
 
               persona.groups.foreach ((k, v) =>
                 {
@@ -517,7 +517,7 @@ public class Folks.Individual : Object,
         {
           if (p is HasPresence)
             {
-              unowned HasPresence presence = (HasPresence) p;
+              var presence = (HasPresence) p;
 
               if (HasPresence.typecmp (presence.presence_type,
                   presence_type) > 0)
@@ -541,7 +541,7 @@ public class Folks.Individual : Object,
 
   private void _update_is_favourite ()
     {
-      bool favourite = false;
+      var favourite = false;
 
       debug ("Running _update_is_favourite() on '%s'", this.id);
 
@@ -568,18 +568,18 @@ public class Folks.Individual : Object,
   private void _update_alias ()
     {
       string alias = null;
-      bool alias_is_display_id = false;
+      var alias_is_display_id = false;
 
       debug ("Updating alias for individual '%s'", this.id);
 
       /* Search for an alias from a writeable Persona, and use it as our first
        * choice if it's non-empty, since that's where the user-set alias is
        * stored. */
-      foreach (Persona p in this._persona_list)
+      foreach (var p in this._persona_list)
         {
           if (p is Aliasable && p.store.is_writeable == true)
             {
-              unowned Aliasable a = (Aliasable) p;
+              var a = (Aliasable) p;
 
               if (a.alias != null && a.alias.strip () != "")
                 {
@@ -597,11 +597,11 @@ public class Folks.Individual : Object,
        * one of those, fall back to one which is equal to the display ID. */
       if (alias == null)
         {
-          foreach (Persona p in this._persona_list)
+          foreach (var p in this._persona_list)
             {
               if (p is Aliasable)
                 {
-                  unowned Aliasable a = (Aliasable) p;
+                  var a = (Aliasable) p;
 
                   if (a.alias == null || a.alias.strip () == "")
                     continue;
@@ -669,9 +669,9 @@ public class Folks.Individual : Object,
 
   private void _update_trust_level ()
     {
-      TrustLevel trust_level = TrustLevel.PERSONAS;
+      var trust_level = TrustLevel.PERSONAS;
 
-      foreach (Persona p in this._persona_list)
+      foreach (var p in this._persona_list)
         {
           if (p.is_user == false &&
               p.store.trust_level == PersonaStoreTrust.NONE)
@@ -759,12 +759,12 @@ public class Folks.Individual : Object,
   private void _set_personas (GLib.List<Persona>? persona_list,
       Individual? replacement_individual)
     {
-      HashSet<Persona> persona_set = new HashSet<Persona> (null, null);
+      var persona_set = new HashSet<Persona> (null, null);
       GLib.List<Persona> added = null;
       GLib.List<Persona> removed = null;
 
       /* Determine which Personas have been added */
-      foreach (Persona p in persona_list)
+      foreach (var p in persona_list)
         {
           if (!this._persona_set.contains (p))
             {
@@ -778,8 +778,8 @@ public class Folks.Individual : Object,
               this._connect_to_persona (p);
 
               /* Increment the Persona count for this PersonaStore */
-              unowned PersonaStore store = p.store;
-              uint num_from_store = this._stores.get (store);
+              var store = p.store;
+              var num_from_store = this._stores.get (store);
               if (num_from_store == 0)
                 {
                   this._stores.set (store, num_from_store + 1);
@@ -798,7 +798,7 @@ public class Folks.Individual : Object,
         }
 
       /* Determine which Personas have been removed */
-      foreach (Persona p in this._persona_list)
+      foreach (var p in this._persona_list)
         {
           if (!persona_set.contains (p))
             {
@@ -809,8 +809,8 @@ public class Folks.Individual : Object,
               removed.prepend (p);
 
               /* Decrement the Persona count for this PersonaStore */
-              unowned PersonaStore store = p.store;
-              uint num_from_store = this._stores.get (store);
+              var store = p.store;
+              var num_from_store = this._stores.get (store);
               if (num_from_store > 1)
                 {
                   this._stores.set (store, num_from_store - 1);
@@ -837,7 +837,7 @@ public class Folks.Individual : Object,
       this.personas_changed (added, removed);
 
       /* Update this.is_user */
-      bool new_is_user = (this._persona_user_count > 0) ? true : false;
+      var new_is_user = (this._persona_user_count > 0) ? true : false;
       if (new_is_user != this.is_user)
         this.is_user = new_is_user;
 
diff --git a/folks/persona.vala b/folks/persona.vala
index 80e8dd8..e680dc2 100644
--- a/folks/persona.vala
+++ b/folks/persona.vala
@@ -214,7 +214,7 @@ public abstract class Folks.Persona : Object
       assert (uid.validate ());
 
       size_t backend_name_length = 0, persona_store_id_length = 0;
-      bool escaped = false;
+      var escaped = false;
       for (unowned string i = uid; i.get_char () != '\0'; i = i.next_char ())
         {
           if (i.get_char () == '\\')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]