~ubuntu-branches/ubuntu/saucy/folks/saucy

« back to all changes in this revision

Viewing changes to folks/backend-store.vala

  • Committer: Package Import Robot
  • Author(s): Sjoerd Simons
  • Date: 2012-03-30 20:03:30 UTC
  • mfrom: (32.1.2 precise)
  • Revision ID: package-import@ubuntu.com-20120330200330-l61hwayt5vjz1zcf
Tags: 0.6.8-2
* d/p/0001-tpf-persona-use-tp_connection_get_account.patch
  + Added, fixes crash when accounts are disconnecting/connecting
* Target unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
254
254
   */
255
255
  public async void prepare ()
256
256
    {
257
 
      Internal.profiling_start ("preparing BackendStore");
258
 
 
259
257
      /* (re-)load the list of disabled backends */
260
258
      yield this._load_disabled_backend_names ();
261
259
 
262
 
      if (this._is_prepared == false)
263
 
        {
264
 
          this._is_prepared = true;
265
 
          this.notify_property ("is-prepared");
266
 
        }
 
260
      if (this._is_prepared == true)
 
261
        return;
 
262
      this._is_prepared = true;
267
263
 
268
 
      Internal.profiling_end ("preparing BackendStore");
 
264
      this.notify_property ("is-prepared");
269
265
    }
270
266
 
271
267
  /**
274
270
   * Backends will be searched for in the path given by the `FOLKS_BACKEND_PATH`
275
271
   * environment variable, if it's set. If it's not set, backends will be
276
272
   * searched for in a path set at compilation time.
277
 
   *
278
 
   * @throws GLib.Error currently unused
279
273
   */
280
274
  public async void load_backends () throws GLib.Error
281
275
    {
282
276
      assert (Module.supported());
283
277
 
284
 
      Internal.profiling_start ("loading backends in BackendStore");
285
 
 
286
278
      yield this.prepare ();
287
279
 
288
280
      /* unload backends that have been disabled since they were loaded */
291
283
          yield this._backend_unload_if_needed (backend_existing);
292
284
        }
293
285
 
294
 
      Internal.profiling_point ("unloaded backends in BackendStore");
295
 
 
296
286
      string? _path = Environment.get_variable ("FOLKS_BACKEND_PATH");
297
287
      string path;
298
288
 
344
334
            }
345
335
        }
346
336
 
347
 
      Internal.profiling_point ("found modules in BackendStore");
348
 
 
349
337
      /* this will load any new modules found in the backends dir and will
350
338
       * prepare and unprepare backends such that they match the state in the
351
339
       * backend store key file */
352
340
      foreach (var module in modules.values)
353
341
        this._load_module_from_file (module);
354
342
 
355
 
      Internal.profiling_point ("loaded modules in BackendStore");
356
 
 
357
343
      /* this is populated indirectly from _load_module_from_file(), above */
358
 
      var backends_remaining = 1;
359
344
      foreach (var backend in this._backend_hash.values)
360
 
        {
361
 
          backends_remaining++;
362
 
          this._backend_load_if_needed.begin (backend, (o, r) =>
363
 
            {
364
 
              this._backend_load_if_needed.end (r);
365
 
              backends_remaining--;
366
 
 
367
 
              if (backends_remaining == 0)
368
 
                {
369
 
                  this.load_backends.callback ();
370
 
                }
371
 
            });
372
 
        }
373
 
      backends_remaining--;
374
 
      if (backends_remaining > 0)
375
 
        {
376
 
          yield;
377
 
        }
378
 
 
379
 
      Internal.profiling_end ("loading backends in BackendStore");
 
345
        yield this._backend_load_if_needed (backend);
380
346
    }
381
347
 
382
348
  private async void _backend_load_if_needed (Backend backend)
763
729
      this._backends_key_file = new GLib.KeyFile ();
764
730
      try
765
731
        {
766
 
          uint8[] contents;
 
732
          uint8 *contents = null;
767
733
 
768
734
          yield file.load_contents_async (null, out contents, null);
769
 
          unowned string contents_s = (string) contents;
 
735
          var contents_s = (string) contents;
770
736
 
771
737
          if (contents_s.length > 0)
772
738
            {