Bug 920801 - Port chat/ changes from Instantbird to comm-central - 6 - Bio 608 - Exception from buddies of an unknown account type, r=clokep.
This commit is contained in:
Родитель
b16092fd67
Коммит
71ba7ecc92
|
@ -5,6 +5,7 @@
|
||||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||||
Cu.import("resource:///modules/imXPCOMUtils.jsm");
|
Cu.import("resource:///modules/imXPCOMUtils.jsm");
|
||||||
Cu.import("resource:///modules/imServices.jsm");
|
Cu.import("resource:///modules/imServices.jsm");
|
||||||
|
Cu.import("resource:///modules/jsProtoHelper.jsm");
|
||||||
|
|
||||||
const kPrefAutologinPending = "messenger.accounts.autoLoginPending";
|
const kPrefAutologinPending = "messenger.accounts.autoLoginPending";
|
||||||
const kPrefMessengerAccounts = "messenger.accounts";
|
const kPrefMessengerAccounts = "messenger.accounts";
|
||||||
|
@ -99,6 +100,11 @@ UnknownProtocol.prototype = {
|
||||||
get usePurpleProxy() false
|
get usePurpleProxy() false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function UnknownAccountBuddy(aAccount, aBuddy, aTag) {
|
||||||
|
this._init({imAccount: aAccount}, aBuddy, aTag);
|
||||||
|
}
|
||||||
|
UnknownAccountBuddy.prototype = GenericAccountBuddyPrototype;
|
||||||
|
|
||||||
// aName and aPrplId are provided as parameter only if this is a new
|
// aName and aPrplId are provided as parameter only if this is a new
|
||||||
// account that doesn't exist in the preferences. In this case, these
|
// account that doesn't exist in the preferences. In this case, these
|
||||||
// 2 values should be stored.
|
// 2 values should be stored.
|
||||||
|
@ -440,7 +446,10 @@ imAccount.prototype = {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
get normalizedName() this._ensurePrplAccount.normalizedName,
|
// If the protocol plugin is missing, we can't access the normalizedName,
|
||||||
|
// but in lots of cases this.name is equivalent.
|
||||||
|
get normalizedName()
|
||||||
|
this.prplAccount ? this.prplAccount.normalizedName : this.name,
|
||||||
|
|
||||||
_sendUpdateNotification: function() {
|
_sendUpdateNotification: function() {
|
||||||
this._sendNotification("account-updated");
|
this._sendNotification("account-updated");
|
||||||
|
@ -596,11 +605,9 @@ imAccount.prototype = {
|
||||||
let login = Cc["@mozilla.org/login-manager/loginInfo;1"]
|
let login = Cc["@mozilla.org/login-manager/loginInfo;1"]
|
||||||
.createInstance(Ci.nsILoginInfo);
|
.createInstance(Ci.nsILoginInfo);
|
||||||
let passwordURI = "im://" + this.protocol.id;
|
let passwordURI = "im://" + this.protocol.id;
|
||||||
// The password is stored with the normalizedName. If the protocol
|
// Note: the normalizedName may not be exactly right if the
|
||||||
// plugin is missing, we can't access the normalizedName, but in
|
// protocol plugin is missing.
|
||||||
// lots of cases this.name is equivalent.
|
login.init(passwordURI, null, passwordURI, this.normalizedName, "", "", "");
|
||||||
let name = this.prplAccount ? this.normalizedName : this.name;
|
|
||||||
login.init(passwordURI, null, passwordURI, name, "", "", "");
|
|
||||||
let logins = Services.logins.findLogins({}, passwordURI, null, passwordURI);
|
let logins = Services.logins.findLogins({}, passwordURI, null, passwordURI);
|
||||||
for each (let l in logins) {
|
for each (let l in logins) {
|
||||||
if (login.matches(l, true)) {
|
if (login.matches(l, true)) {
|
||||||
|
@ -737,8 +744,12 @@ imAccount.prototype = {
|
||||||
addBuddy: function(aTag, aName) {
|
addBuddy: function(aTag, aName) {
|
||||||
this._ensurePrplAccount.addBuddy(aTag, aName);
|
this._ensurePrplAccount.addBuddy(aTag, aName);
|
||||||
},
|
},
|
||||||
loadBuddy: function(aBuddy, aTag)
|
loadBuddy: function(aBuddy, aTag) {
|
||||||
this._ensurePrplAccount.loadBuddy(aBuddy, aTag), // FIXME for unknown proto
|
if (this.prplAccount)
|
||||||
|
return this.prplAccount.loadBuddy(aBuddy, aTag);
|
||||||
|
// Generate dummy account buddies for unknown protocols.
|
||||||
|
return new UnknownAccountBuddy(this, aBuddy, aTag);
|
||||||
|
},
|
||||||
requestBuddyInfo: function(aBuddyName) {
|
requestBuddyInfo: function(aBuddyName) {
|
||||||
this._ensurePrplAccount.requestBuddyInfo(aBuddyName);
|
this._ensurePrplAccount.requestBuddyInfo(aBuddyName);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1287,13 +1287,9 @@ ContactsService.prototype = {
|
||||||
let account = Services.accounts.getAccountByNumericId(accountId);
|
let account = Services.accounts.getAccountByNumericId(accountId);
|
||||||
let tag = TagsById[tagId];
|
let tag = TagsById[tagId];
|
||||||
try {
|
try {
|
||||||
let accountBuddy = account.loadBuddy(buddy, tag);
|
buddy._addAccount(account.loadBuddy(buddy, tag), tag);
|
||||||
if (accountBuddy)
|
|
||||||
buddy._addAccount(accountBuddy, tag);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// FIXME accountBuddy shouldn't be NULL (once imAccounts.js is finished)
|
Cu.reportError(e);
|
||||||
// It currently doesn't work right with unknown protocols.
|
|
||||||
Components.utils.reportError(e);
|
|
||||||
dump(e + "\n");
|
dump(e + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ function run_test() {
|
||||||
let account = Services.accounts.getAccountByNumericId(1);
|
let account = Services.accounts.getAccountByNumericId(1);
|
||||||
do_check_true(account instanceof Ci.imIAccount);
|
do_check_true(account instanceof Ci.imIAccount);
|
||||||
do_check_eq(account.name, kAccountName);
|
do_check_eq(account.name, kAccountName);
|
||||||
|
do_check_eq(account.normalizedName, kAccountName);
|
||||||
do_check_eq(account.protocol.id, kPrplId);
|
do_check_eq(account.protocol.id, kPrplId);
|
||||||
do_check_eq(account.connectionErrorReason, Ci.imIAccount.ERROR_UNKNOWN_PRPL);
|
do_check_eq(account.connectionErrorReason, Ci.imIAccount.ERROR_UNKNOWN_PRPL);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче