~ubuntu-branches/ubuntu/precise/folks/precise

« back to all changes in this revision

Viewing changes to backends/key-file/kf-backend.vala

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2011-06-10 11:28:11 UTC
  • mfrom: (1.2.11 upstream) (4.2.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110610112811-whyeodbo9mjezxfp
Tags: 0.5.2-1ubuntu1
* Merge with Debian experimental, remaining Ubuntu changes:
  - debian/control:
    + Add Vcs-Bzr link

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
using GLib;
 
22
using Gee;
22
23
using Folks;
23
24
using Folks.Backends.Kf;
24
25
 
34
35
public class Folks.Backends.Kf.Backend : Folks.Backend
35
36
{
36
37
  private bool _is_prepared = false;
37
 
  private HashTable<string, PersonaStore> _persona_stores;
 
38
  private HashMap<string, PersonaStore> _persona_stores;
 
39
  private Map<string, PersonaStore> _persona_stores_ro;
38
40
 
39
41
  /**
40
42
   * Whether this Backend has been prepared.
56
58
  /**
57
59
   * {@inheritDoc}
58
60
   */
59
 
  public override HashTable<string, PersonaStore> persona_stores
 
61
  public override Map<string, PersonaStore> persona_stores
60
62
    {
61
 
      get { return this._persona_stores; }
 
63
      get { return this._persona_stores_ro; }
62
64
    }
63
65
 
64
66
  /**
66
68
   */
67
69
  public Backend ()
68
70
    {
69
 
      this._persona_stores = new HashTable<string, PersonaStore> (str_hash,
70
 
          str_equal);
 
71
      this._persona_stores = new HashMap<string, PersonaStore> ();
 
72
      this._persona_stores_ro = this._persona_stores.read_only_view;
71
73
    }
72
74
 
73
75
  /**
103
105
              /* Create the PersonaStore for the key file */
104
106
              PersonaStore store = new Kf.PersonaStore (file);
105
107
 
106
 
              this._persona_stores.insert (store.id, store);
 
108
              this._persona_stores.set (store.id, store);
107
109
              store.removed.connect (this._store_removed_cb);
108
110
              this.notify_property ("persona-stores");
109
111
 
120
122
   */
121
123
  public override async void unprepare () throws GLib.Error
122
124
    {
123
 
      this._persona_stores.foreach ((k, v) =>
 
125
      foreach (var persona_store in this._persona_stores.values)
124
126
        {
125
 
          this.persona_store_removed ((PersonaStore) v);
126
 
        });
 
127
          this.persona_store_removed (persona_store);
 
128
        }
127
129
 
128
 
      this._persona_stores.remove_all ();
 
130
      this._persona_stores.clear ();
129
131
      this.notify_property ("persona-stores");
130
132
 
131
133
      this._is_prepared = false;
134
136
 
135
137
  private void _store_removed_cb (Folks.PersonaStore store)
136
138
    {
 
139
      store.removed.disconnect (this._store_removed_cb);
137
140
      this.persona_store_removed (store);
138
 
      this._persona_stores.remove (store.id);
 
141
      this._persona_stores.unset (store.id);
139
142
      this.notify_property ("persona-stores");
140
143
    }
141
144
}