[folks] Remove use of GLib.List in public BackendStore API.



commit eca4e5453097b76557533eadab8d21b7aca90c1a
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Thu Feb 3 11:41:38 2011 -0800

    Remove use of GLib.List in public BackendStore API.
    
    Helps bgo#640092 - Folks should minimize use of GLib.List (including its public
    API)

 NEWS                                           |    4 ++
 folks/backend-store.vala                       |   16 ++------
 tests/folks/backend-loading.vala               |   44 ++++++++++--------------
 tests/telepathy/individual-retrieval.vala      |    2 +-
 tests/tracker/add-persona.vala                 |    2 +-
 tests/tracker/duplicated-emails.vala           |    2 +-
 tests/tracker/duplicated-phones.vala           |    2 +-
 tests/tracker/link-personas-via-local-ids.vala |    2 +-
 tests/tracker/link-personas.vala               |    2 +-
 tests/tracker/match-all.vala                   |    2 +-
 tests/tracker/match-email-addresses.vala       |    2 +-
 tests/tracker/match-im-addresses.vala          |    2 +-
 tests/tracker/match-known-emails.vala          |    2 +-
 tests/tracker/match-name.vala                  |    2 +-
 tests/tracker/match-phone-number.vala          |    2 +-
 tests/tracker/remove-persona.vala              |    2 +-
 tests/tracker/set-duplicate-email.vala         |    2 +-
 17 files changed, 40 insertions(+), 52 deletions(-)
---
diff --git a/NEWS b/NEWS
index 56aef5e..8776f97 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,10 @@ API changes:
 * EmailDetails.email_addresses is now of type Set<FieldDetails>
 * PhoneDetails.phone_numbers is now of type Set<FieldDetails>
 * UrlDetails.urls is now of type Set<FieldDetails>
+* BackendStore.enabled_backends now has type Map<string, Backend>
+  - The corresponding C function folks_backend_store_dup_enabled_backends()
+    has been renamed folks_backend_store_get_enabled_backends(), and no longer
+    returns an owned variable.
 
 Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
 =========================================================
diff --git a/folks/backend-store.vala b/folks/backend-store.vala
index b36a334..8fa7dcc 100644
--- a/folks/backend-store.vala
+++ b/folks/backend-store.vala
@@ -43,7 +43,7 @@ public class Folks.BackendStore : Object {
 
   /* this contains all backends, regardless of enabled or prepared state */
   private HashMap<string,Backend> _backend_hash;
-  private HashMap<string,Backend> _prepared_backends;
+  private HashMap<string, Backend> _prepared_backends;
   private File _config_file;
   private GLib.KeyFile _backends_key_file;
   private HashMap<string,unowned Module> _modules;
@@ -87,19 +87,11 @@ public class Folks.BackendStore : Object {
    *
    * The backends in this list have been prepared and are ready to use.
    *
-   * @since 0.3.5
+   * @since UNRELEASED
    */
-  public GLib.List<Backend> enabled_backends
+  public Map<string, Backend> enabled_backends
     {
-      [CCode (cname = "folks_backend_store_dup_enabled_backends")]
-      owned get
-        {
-          var backends = new GLib.List<Backend> ();
-          foreach (var backend in this._prepared_backends.values)
-            backends.prepend (backend);
-
-          return backends;
-        }
+      get { return this._prepared_backends; }
 
       private set {}
     }
diff --git a/tests/folks/backend-loading.vala b/tests/folks/backend-loading.vala
index 3fd9adb..92ecc9b 100644
--- a/tests/folks/backend-loading.vala
+++ b/tests/folks/backend-loading.vala
@@ -83,13 +83,11 @@ public class BackendLoadingTests : Folks.TestCase
             {
               store.load_backends.end (r);
 
-              store.enabled_backends.foreach ((i) =>
+              foreach (var backend in store.enabled_backends.values)
                 {
-                  var backend = (Backend) i;
-
                   assert (backends_expected.contains (backend.name));
                   backends_expected.remove (backend.name);
-                });
+                }
 
               assert (backends_expected.size == 0);
               main_loop.quit ();
@@ -129,12 +127,11 @@ public class BackendLoadingTests : Folks.TestCase
         {
           yield store.load_backends ();
 
-          store.enabled_backends.foreach ((i) =>
+          foreach (var backend in store.enabled_backends.values)
             {
-              var backend = (Backend) i;
               assert (backends_expected.contains (backend.name));
               backends_expected.remove (backend.name);
-            });
+            }
 
           assert (backends_expected.size == 0);
           this.main_loop.quit ();
@@ -173,12 +170,11 @@ public class BackendLoadingTests : Folks.TestCase
         {
           yield store.load_backends ();
 
-          store.enabled_backends.foreach ((i) =>
+          foreach (var backend1 in store.enabled_backends.values)
             {
-              var backend = (Backend) i;
-              assert (backends_expected.contains (backend.name));
-              backends_expected.remove (backend.name);
-            });
+              assert (backends_expected.contains (backend1.name));
+              backends_expected.remove (backend1.name);
+            }
 
           assert (backends_expected.size == 0);
         }
@@ -201,12 +197,11 @@ public class BackendLoadingTests : Folks.TestCase
         {
           yield store.load_backends ();
 
-          store.enabled_backends.foreach ((i) =>
+          foreach (var backend2 in store.enabled_backends.values)
             {
-              var backend = (Backend) i;
-              assert (backends_expected.contains (backend.name));
-              backends_expected.remove (backend.name);
-            });
+              assert (backends_expected.contains (backend2.name));
+              backends_expected.remove (backend2.name);
+            }
 
           assert (backends_expected.size == 0);
         }
@@ -230,12 +225,11 @@ public class BackendLoadingTests : Folks.TestCase
         {
           yield store.load_backends ();
 
-          store.enabled_backends.foreach ((i) =>
+          foreach (var backend3 in store.enabled_backends.values)
             {
-              var backend = (Backend) i;
-              assert (backends_expected.contains (backend.name));
-              backends_expected.remove (backend.name);
-            });
+              assert (backends_expected.contains (backend3.name));
+              backends_expected.remove (backend3.name);
+            }
 
           assert (backends_expected.size == 0);
         }
@@ -257,13 +251,11 @@ public class BackendLoadingTests : Folks.TestCase
         {
           yield store.load_backends ();
 
-          store.enabled_backends.foreach ((i) =>
+          foreach (var backend in store.enabled_backends.values)
             {
-              var backend = (Backend) i;
-
               assert (backends_expected.contains (backend.name));
               backends_expected.remove (backend.name);
-            });
+            }
 
           assert (backends_expected.size == 0);
         }
diff --git a/tests/telepathy/individual-retrieval.vala b/tests/telepathy/individual-retrieval.vala
index 416ae7d..48bde9e 100644
--- a/tests/telepathy/individual-retrieval.vala
+++ b/tests/telepathy/individual-retrieval.vala
@@ -175,7 +175,7 @@ public class IndividualRetrievalTests : Folks.TestCase
 
               /* once we see a valid Tpf.PersonaStore, add our new personas */
               var backend_store = BackendStore.dup ();
-              foreach (var backend in backend_store.enabled_backends)
+              foreach (var backend in backend_store.enabled_backends.values)
                 {
                   /* PersonaStores can be added after the backend is prepared */
                   backend.persona_store_added.connect ((store) =>
diff --git a/tests/tracker/add-persona.vala b/tests/tracker/add-persona.vala
index e1c2cc0..40e173b 100644
--- a/tests/tracker/add-persona.vala
+++ b/tests/tracker/add-persona.vala
@@ -156,7 +156,7 @@ public class AddPersonaTests : Folks.TestCase
           yield this._aggregator.prepare ();
 
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/duplicated-emails.vala b/tests/tracker/duplicated-emails.vala
index 6aa33f4..d7fbeff 100644
--- a/tests/tracker/duplicated-emails.vala
+++ b/tests/tracker/duplicated-emails.vala
@@ -83,7 +83,7 @@ public class DuplicatedEmailsTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/duplicated-phones.vala b/tests/tracker/duplicated-phones.vala
index 24ff061..cbecc44 100644
--- a/tests/tracker/duplicated-phones.vala
+++ b/tests/tracker/duplicated-phones.vala
@@ -83,7 +83,7 @@ public class DuplicatedPhonesTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/link-personas-via-local-ids.vala b/tests/tracker/link-personas-via-local-ids.vala
index 6280637..0046f49 100644
--- a/tests/tracker/link-personas-via-local-ids.vala
+++ b/tests/tracker/link-personas-via-local-ids.vala
@@ -135,7 +135,7 @@ public class LinkPersonasViaLocalIDsTests : Folks.TestCase
           yield this._aggregator.prepare ();
 
           PersonaStore pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               pstore = backend.persona_stores.get ("tracker");
               if (pstore != null)
diff --git a/tests/tracker/link-personas.vala b/tests/tracker/link-personas.vala
index 8c19082..e966a52 100644
--- a/tests/tracker/link-personas.vala
+++ b/tests/tracker/link-personas.vala
@@ -139,7 +139,7 @@ public class LinkPersonasTests : Folks.TestCase
           yield this._aggregator.prepare ();
 
           PersonaStore pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               pstore = backend.persona_stores.get ("tracker");
               if (pstore != null)
diff --git a/tests/tracker/match-all.vala b/tests/tracker/match-all.vala
index c9c8f35..7c8a4ac 100644
--- a/tests/tracker/match-all.vala
+++ b/tests/tracker/match-all.vala
@@ -109,7 +109,7 @@ public class MatchAllTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/match-email-addresses.vala b/tests/tracker/match-email-addresses.vala
index 6b7727d..528be46 100644
--- a/tests/tracker/match-email-addresses.vala
+++ b/tests/tracker/match-email-addresses.vala
@@ -84,7 +84,7 @@ public class MatchEmailAddressesTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/match-im-addresses.vala b/tests/tracker/match-im-addresses.vala
index 1e2ede2..c2b9784 100644
--- a/tests/tracker/match-im-addresses.vala
+++ b/tests/tracker/match-im-addresses.vala
@@ -84,7 +84,7 @@ public class MatchIMAddressesTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/match-known-emails.vala b/tests/tracker/match-known-emails.vala
index f0068f8..31a7557 100644
--- a/tests/tracker/match-known-emails.vala
+++ b/tests/tracker/match-known-emails.vala
@@ -92,7 +92,7 @@ public class MatchKnownEmailsTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/match-name.vala b/tests/tracker/match-name.vala
index f7b67d2..702488b 100644
--- a/tests/tracker/match-name.vala
+++ b/tests/tracker/match-name.vala
@@ -147,7 +147,7 @@ public class MatchNameTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/match-phone-number.vala b/tests/tracker/match-phone-number.vala
index 2b718ba..2bd0d07 100644
--- a/tests/tracker/match-phone-number.vala
+++ b/tests/tracker/match-phone-number.vala
@@ -86,7 +86,7 @@ public class MatchPhoneNumberTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");
diff --git a/tests/tracker/remove-persona.vala b/tests/tracker/remove-persona.vala
index 2ca4484..0214dae 100644
--- a/tests/tracker/remove-persona.vala
+++ b/tests/tracker/remove-persona.vala
@@ -90,7 +90,7 @@ public class RemovePersonaTests : Folks.TestCase
           yield this._aggregator.prepare ();
 
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore = backend.persona_stores.get ("tracker");
               if (this._pstore != null)
diff --git a/tests/tracker/set-duplicate-email.vala b/tests/tracker/set-duplicate-email.vala
index 7ff76a9..fe3a51e 100644
--- a/tests/tracker/set-duplicate-email.vala
+++ b/tests/tracker/set-duplicate-email.vala
@@ -84,7 +84,7 @@ public class SetDuplicateEmailTests : Folks.TestCase
         {
           yield this._aggregator.prepare ();
           this._pstore = null;
-          foreach (var backend in store.enabled_backends)
+          foreach (var backend in store.enabled_backends.values)
             {
               this._pstore =
                 (Trf.PersonaStore) backend.persona_stores.get ("tracker");



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