TelepathyClient: track added/removed accounts
(prep work for presence tracking) https://bugzilla.gnome.org/show_bug.cgi?id=611613
This commit is contained in:
parent
a3a09e6b2e
commit
fdd819e9f6
@ -262,6 +262,10 @@ const AccountManagerIface = {
|
|||||||
{ name: 'ValidAccounts',
|
{ name: 'ValidAccounts',
|
||||||
signature: 'ao',
|
signature: 'ao',
|
||||||
access: 'read' }
|
access: 'read' }
|
||||||
|
],
|
||||||
|
signals: [
|
||||||
|
{ name: 'AccountValidityChanged',
|
||||||
|
inSignature: 'ob' }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
let AccountManager = makeProxyClass(AccountManagerIface);
|
let AccountManager = makeProxyClass(AccountManagerIface);
|
||||||
|
@ -52,6 +52,7 @@ Client.prototype = {
|
|||||||
function (name) { /* FIXME: acquired */ },
|
function (name) { /* FIXME: acquired */ },
|
||||||
function (name) { /* FIXME: lost */ });
|
function (name) { /* FIXME: lost */ });
|
||||||
|
|
||||||
|
this._accounts = {};
|
||||||
this._channels = {};
|
this._channels = {};
|
||||||
|
|
||||||
contactManager = new ContactManager();
|
contactManager = new ContactManager();
|
||||||
@ -65,17 +66,31 @@ Client.prototype = {
|
|||||||
let accountManager = new Telepathy.AccountManager(DBus.session,
|
let accountManager = new Telepathy.AccountManager(DBus.session,
|
||||||
Telepathy.ACCOUNT_MANAGER_NAME,
|
Telepathy.ACCOUNT_MANAGER_NAME,
|
||||||
Telepathy.nameToPath(Telepathy.ACCOUNT_MANAGER_NAME));
|
Telepathy.nameToPath(Telepathy.ACCOUNT_MANAGER_NAME));
|
||||||
accountManager.GetRemote('ValidAccounts', Lang.bind(this, this._gotValidAccounts));
|
accountManager.GetRemote('ValidAccounts', Lang.bind(this,
|
||||||
},
|
function (accounts, err) {
|
||||||
|
|
||||||
_gotValidAccounts: function(accounts, err) {
|
|
||||||
if (!accounts)
|
if (!accounts)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (let i = 0; i < accounts.length; i++) {
|
for (let i = 0; i < accounts.length; i++)
|
||||||
|
this._gotAccount(accounts[i]);
|
||||||
|
}));
|
||||||
|
accountManager.connect('AccountValidityChanged', Lang.bind(this, this._accountValidityChanged));
|
||||||
|
},
|
||||||
|
|
||||||
|
_accountValidityChanged: function(accountManager, accountPath, valid) {
|
||||||
|
if (!valid) {
|
||||||
|
delete this._accounts[accountPath];
|
||||||
|
// We don't need to clean up connections, sources, etc; they'll
|
||||||
|
// get Closed and cleaned up independently.
|
||||||
|
} else
|
||||||
|
this._gotAccount(accountPath);
|
||||||
|
},
|
||||||
|
|
||||||
|
_gotAccount: function(accountPath) {
|
||||||
let account = new Telepathy.Account(DBus.session,
|
let account = new Telepathy.Account(DBus.session,
|
||||||
Telepathy.ACCOUNT_MANAGER_NAME,
|
Telepathy.ACCOUNT_MANAGER_NAME,
|
||||||
accounts[i]);
|
accountPath);
|
||||||
|
this._accounts[accountPath] = account;
|
||||||
account.GetRemote('Connection', Lang.bind(this,
|
account.GetRemote('Connection', Lang.bind(this,
|
||||||
function (connPath, err) {
|
function (connPath, err) {
|
||||||
if (!connPath || connPath == '/')
|
if (!connPath || connPath == '/')
|
||||||
@ -88,10 +103,10 @@ Client.prototype = {
|
|||||||
function(channels, err) {
|
function(channels, err) {
|
||||||
if (!channels)
|
if (!channels)
|
||||||
return;
|
return;
|
||||||
this._addChannels(account.getPath(), connPath, channels);
|
|
||||||
|
this._addChannels(accountPath, connPath, channels);
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get Interfaces() {
|
get Interfaces() {
|
||||||
|
Loading…
Reference in New Issue
Block a user