[polari] accountsMonitor: Make primary owner of accountManager
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] accountsMonitor: Make primary owner of accountManager
- Date: Thu, 17 Jul 2014 14:44:41 +0000 (UTC)
commit 5bfc81cce27cf6a8ea68edcafc9da209f6328c2c
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Oct 18 19:01:55 2013 +0200
accountsMonitor: Make primary owner of accountManager
Currently, both ChatroomManager and AccountsMonitor take a reference
on AccountsManager, with the former setting up the required features,
so it needs to be initialized first. Instead, handle AccountManager
initialization in AccountsMonitor and port ChatroomManager to use
it, so we can start to make use of AccountsMonitor's account tracking
in the future.
https://bugzilla.gnome.org/show_bug.cgi?id=732905
src/accountsMonitor.js | 15 ++++++++++++++-
src/chatroomManager.js | 21 +++++----------------
2 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index b669d12..d9bf63c 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -23,6 +23,12 @@ const AccountsMonitor = new Lang.Class({
Lang.bind(this, this._onPrepareShutdown));
this._accountManager = Tp.AccountManager.dup();
+
+ let factory = this._accountManager.get_factory();
+ factory.add_channel_features([Tp.Channel.get_feature_quark_group()]);
+ factory.add_channel_features([Tp.Channel.get_feature_quark_contacts()]);
+ factory.add_contact_features([Tp.ContactFeature.ALIAS]);
+
this._accountManager.prepare_async(null,
Lang.bind(this, this._onPrepared));
},
@@ -32,7 +38,12 @@ const AccountsMonitor = new Lang.Class({
},
_onPrepared: function(am, res) {
- am.prepare_finish(res);
+ try {
+ am.prepare_finish(res);
+ } catch(e) {
+ this._app.release();
+ return; // no point in carrying on
+ }
am.dup_valid_accounts().forEach(Lang.bind(this, this._addAccount));
@@ -51,6 +62,8 @@ const AccountsMonitor = new Lang.Class({
Lang.bind(this, this._accountEnabledChanged));
am.connect('account-disabled',
Lang.bind(this, this._accountEnabledChanged));
+
+ this.emit('account-manager-prepared', am);
},
_onPrepareShutdown: function() {
diff --git a/src/chatroomManager.js b/src/chatroomManager.js
index 3f82d50..f4ef024 100644
--- a/src/chatroomManager.js
+++ b/src/chatroomManager.js
@@ -3,6 +3,7 @@ const GLib = imports.gi.GLib;
const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
+const AccountsMonitor = imports.accountsMonitor;
const Lang = imports.lang;
const Signals = imports.signals;
@@ -47,25 +48,13 @@ const _ChatroomManager = new Lang.Class({
this._app = Gio.Application.get_default();
- this._accountManager = Tp.AccountManager.dup();
this._networkMonitor = Gio.NetworkMonitor.get_default();
-
- let factory = this._accountManager.get_factory();
- factory.add_channel_features([Tp.Channel.get_feature_quark_group()]);
- factory.add_channel_features([Tp.Channel.get_feature_quark_contacts()]);
- factory.add_contact_features([Tp.ContactFeature.ALIAS]);
-
- this._accountManager.prepare_async(null,
- Lang.bind(this, this._onPrepared));
+ this._accountsMonitor = AccountsMonitor.getDefault();
+ this._accountsMonitor.connect('account-manager-prepared',
+ Lang.bind(this, this._onPrepared));
},
- _onPrepared: function(am, res) {
- try {
- am.prepare_finish(res);
- } catch(e) {
- this._app.release(); // no point in carrying on
- }
-
+ _onPrepared: function(mon, am) {
let joinAction = this._app.lookup_action('join-room');
joinAction.connect('activate', Lang.bind(this, this._onJoinActivated));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]