Bug 1127596 - Allow XMPP conversations with non-contacts. r=aleth

This commit is contained in:
Abdelrhman Ahmed 2015-03-01 09:33:00 +01:00
Родитель e192b84762
Коммит 6051d0d179
1 изменённых файлов: 10 добавлений и 20 удалений

Просмотреть файл

@ -190,13 +190,10 @@ const XMPPConversationPrototype = {
supportChatStateNotifications: true, supportChatStateNotifications: true,
_typingState: "active", _typingState: "active",
_init: function(aAccount, aBuddy) { get buddy() this._account._buddies.get(this.name),
this.buddy = aBuddy; get title() this.contactDisplayName,
GenericConvIMPrototype._init.call(this, aAccount, aBuddy.normalizedName); get contactDisplayName() this.buddy ? this.buddy.contactDisplayName : this.name,
}, get userName() this.buddy ? this.buddy.userName : this.name,
get title() this.buddy.contactDisplayName,
get normalizedName() this.buddy.normalizedName,
get shouldSendTypingNotifications() get shouldSendTypingNotifications()
this.supportChatStateNotifications && this.supportChatStateNotifications &&
@ -243,7 +240,7 @@ const XMPPConversationPrototype = {
_targetResource: "", _targetResource: "",
get to() { get to() {
let to = this.buddy.userName; let to = this.userName;
if (this._targetResource) if (this._targetResource)
to += "/" + this._targetResource; to += "/" + this._targetResource;
return to; return to;
@ -291,7 +288,7 @@ const XMPPConversationPrototype = {
flags.error = true; flags.error = true;
} }
else else
flags = {incoming: true, _alias: this.buddy.contactDisplayName}; flags = {incoming: true, _alias: this.contactDisplayName};
if (aDate) { if (aDate) {
flags.time = aDate / 1000; flags.time = aDate / 1000;
flags.delayed = true; flags.delayed = true;
@ -305,14 +302,13 @@ const XMPPConversationPrototype = {
GenericConvIMPrototype.close.call(this); GenericConvIMPrototype.close.call(this);
}, },
unInit: function() { unInit: function() {
this._account.removeConversation(this.buddy.normalizedName); this._account.removeConversation(this.normalizedName);
delete this.buddy;
GenericConvIMPrototype.unInit.call(this); GenericConvIMPrototype.unInit.call(this);
} }
}; };
function XMPPConversation(aAccount, aBuddy) function XMPPConversation(aAccount, aName)
{ {
this._init(aAccount, aBuddy); this._init(aAccount, aName);
} }
XMPPConversation.prototype = XMPPConversationPrototype; XMPPConversation.prototype = XMPPConversationPrototype;
@ -1293,15 +1289,9 @@ const XMPPAccountPrototype = {
/* Create a new conversation */ /* Create a new conversation */
createConversation: function(aNormalizedName) { createConversation: function(aNormalizedName) {
if (!this._buddies.has(aNormalizedName)) {
this.ERROR("Trying to create a conversation; buddy not present: " + aNormalizedName);
return null;
}
if (!this._conv.has(aNormalizedName)) { if (!this._conv.has(aNormalizedName)) {
this._conv.set(aNormalizedName, this._conv.set(aNormalizedName,
new this._conversationConstructor(this, new this._conversationConstructor(this, aNormalizedName));
this._buddies.get(aNormalizedName)));
} }
return this._conv.get(aNormalizedName); return this._conv.get(aNormalizedName);