Permalink
Browse files

Merge branch 'master' of git+ssh://gitorious.process-one.net/oneteam/…

…oneteam

Conflicts:
	po/es.po
	po/fr.po
	po/oneteam.pot
	po/pl.po
  • Loading branch information...
2 parents 6138b5e + 167bfd4 commit b0c8f2cfb389f76fe7b5131630efc93fb88d159c François-Xavier Deltombe committed Aug 17, 2011
@@ -515,6 +515,7 @@ _DECL_(HistoryManager, null, CallbacksList, Model).prototype =
addMessage: function(msg)
{
+dump("addMessage:\n");
var oldFormatEditMessage = !!oldFormatEditMessageRegex.test(msg.text);
if (oldFormatEditMessage || msg.replaceMessageId) {
var lastMsg = this.getLastMessageFromContact(msg.contact);
@@ -526,10 +527,11 @@ _DECL_(HistoryManager, null, CallbacksList, Model).prototype =
tryToConvertOldFormatEditMessage(msg, lastMsg);
}
- var archivedThread, idx = this._sessionThreads.indexOf(msg.thread);
+ var archivedThread, idx = this._sessionThreads.indexOf(msg.threadID);
if (idx < 0) {
var stmt = this.addThreadStmt;
- var threadContact = msg.thread.contact;
+ //var threadContact = msg.thread.contact;
+ var threadContact = msg.messagesManager;
if (threadContact.contact && (!threadContact.contact.exitRoom || !msg.isMucMessage))
threadContact = threadContact.contact;
@@ -541,7 +543,7 @@ _DECL_(HistoryManager, null, CallbacksList, Model).prototype =
archivedThread = this._archivedThreads[rowId] =
new ArchivedMessagesThread(threadContact, rowId, msg.time);
- this._sessionThreads.push(msg.thread);
+ this._sessionThreads.push(msg.threadID);
this._sessionArchivedThreads.push(archivedThread)
for (var observer in this._iterateCallbacks("threads-"+threadContact.jid))
@@ -693,6 +695,7 @@ _DECL_(HistoryManager, null, CallbacksList, Model).prototype =
},
getLastMessagesFromContact: function(contact, count, token) {
+dump("getLastMessagesFromContact:("+contact.jid+", "+count+", "+token+")\n");
var olderThan = Infinity;
if (typeof(token) == "number") {
@@ -721,6 +724,7 @@ _DECL_(HistoryManager, null, CallbacksList, Model).prototype =
var lastThread = token.threads[token.threads.length-1];
if (lastThread) {
+dump("lastThread = " + lastThread + "\n");
lastThread.getNewMessages();
token.lastIndex = lastThread.allMessages.length-1;
}
@@ -35,7 +35,20 @@ ML.importMod("filetransfer.js");
function Account()
{
- this._initialize();
+ this.groups = []
+ this.allGroups = {}
+ this.contacts = {};
+ this.allContacts = {};
+ this.resources = {};
+ this.myResources = {};
+ this.conferences = [];
+ this.allConferences = {};
+ this.gateways = {};
+ this._presenceObservers = [];
+ this.avatarHash = this.avatar = null;
+ this.avatarRetrieved = false;
+ this._initConnectionState = 0;
+ this.reconnectStep = 0;
this.currentPresence = {show: "unavailable"};
this.cache = new PersistentCache("oneteamCache");
@@ -209,20 +222,25 @@ _DECL_(Account, null, Model, DiscoItem, vCardDataAccessor).prototype =
getOrCreateContact: function(jid, showInRoster, name, groups)
{
+try {
jid = new JID(jid);
- var normalizedJID = jid.normalizedJID;
- if (this.allContacts[normalizedJID])
- return this.allContacts[normalizedJID];
- if (this.allConferences[normalizedJID])
- return this.allConferences[normalizedJID];
+ if (jid.resource && this.allConferences[jid.shortJID])
+ return this.allContacts[jid.longJID] || new ConferenceMember(jid)
+
+ if (this.allContacts[jid.shortJID])
+ return this.allContacts[jid.shortJID];
+ if (this.allConferences[jid.shortJID])
+ return this.allConferences[jid.shortJID];
+
if (showInRoster) {
var contact = new Contact(jid, name, groups||[this.notInRosterGroup],
null, null);
contact.newItem = true;
return contact;
- } else
- return new Contact(jid, name, groups, null, null, true);
+ }
+ return new Contact(jid, name, groups, null, null, true);
+} catch(ex) {dump("account.getOrCreateContact: " + ex + "\n");}
},
getOrCreateResource: function(jid)
@@ -955,24 +973,6 @@ _DECL_(Account, null, Model, DiscoItem, vCardDataAccessor).prototype =
this._initConnectionStep(1);
},
- _initialize: function()
- {
- this.groups = []
- this.allGroups = {}
- this.contacts = {};
- this.allContacts = {};
- this.resources = {};
- this.myResources = {};
- this.conferences = [];
- this.allConferences = {};
- this.gateways = {};
- this._presenceObservers = [];
- this.avatarHash = this.avatar = null;
- this.avatarRetrieved = false;
- this._initConnectionState = 0;
- this.reconnectStep = 0;
- },
-
_reconnectTimeoutFun: function(token) {
if (token.time == 0) {
token.model.connect();
@@ -363,7 +363,7 @@ _DECL_(Conference, Contact).prototype =
this.joinRoom(null, newNick);
},
- sendMessage: function(msg)
+ /*sendMessage: function(msg)
{
if (!msg)
return;
@@ -374,7 +374,7 @@ _DECL_(Conference, Contact).prototype =
msg.fillPacket(message);
account.connection.send(message);
- },
+ },*/
changeSubject: function(subject)
{
@@ -530,10 +530,10 @@ _DECL_(Conference, Contact).prototype =
subject = pkt.getChild("subject");
if (!subject)
return true;
- if ((subject = subject.textContent) == this.subject)
+ if (subject.textContent == this.subject)
return false;
- this.subject = subject;
+ this.subject = subject.textContent;
if (!pkt.getBody() || (new JID(pkt.getFrom())).resource) {
var resource = this.getOrCreateResource(pkt.getFrom());
@@ -5,6 +5,8 @@ ML.importMod("modeltypes.js");
ML.importMod("dateutils.js");
ML.importMod("views/chattabs.js");
+ML.importMod("model/messagesManager.js"); // temporary
+
function MessagesRouter(parentRouter)
{
this.parentRouter = parentRouter; // defined for resources: parentRouter is the Contact
@@ -186,7 +188,7 @@ _DECL_(MessagesRouter).prototype =
return shown;
},
- recoverResourceThreads: function(resource)
+ /*recoverResourceThreads: function(resource)
{
for each (var thr in this.threads) {
if (thr.contact.jid == resource.jid) {
@@ -200,7 +202,7 @@ _DECL_(MessagesRouter).prototype =
if (thr.chatPane)
thr.chatPane.thread = thr;
}
- },
+ },*/
_markThreadAsActive: function(thread, contact)
{
@@ -257,7 +259,7 @@ function MessagesThread(threadID, contact)
this.messages = [];
this._threadID = threadID;
- this._contactIds = [];
+ //this._contactIds = [];
this.unseenCount = 0;
this.contact = contact;
if (contact && contact.hasDiscoFeature) {
@@ -330,7 +332,7 @@ _DECL_(MessagesThread, Model).prototype =
return this.chatState == "gone" || this.peerChatState == "gone";
},
- getContactID: function(contact)
+ /*getContactID: function(contact)
{
if (contact.representsMe)
return 0;
@@ -341,7 +343,7 @@ _DECL_(MessagesThread, Model).prototype =
this._contactIds.push(contact);
return this._contactIds.length;
- },
+ },*/
get peerHandlesHtmlIM() {
if (this.contact instanceof Conference)
@@ -424,7 +426,7 @@ _DECL_(MessagesThread, Model).prototype =
var len = this.messages.length;
- msg.queues.push(this);
+ //msg.queues.push(this);
this.messages.push(msg);
this.modelUpdated("messages", {added: [msg]});
account.historyMgr.addMessage(msg);
@@ -490,7 +492,7 @@ _DECL_(MessagesThread, Model).prototype =
this._afterFirstOurMessage = true;
if (!(this.contact instanceof Conference) && msg.text) {
- msg.queues.push(this);
+ //msg.queues.push(this);
this.messages.push(msg);
this.modelUpdated("messages", {added: [msg]});
account.historyMgr.addMessage(msg);
@@ -526,7 +528,7 @@ _DECL_(MessagesThread, Model).prototype =
}
}
-function Message(body, body_html, contact, type, time, thread, chatState, myNick, messageId)
+function Message(body, body_html, contact, type, time, threadID, chatState, myNick, messageId)
{
this.contact = contact;
this.type = type;
@@ -556,8 +558,8 @@ function Message(body, body_html, contact, type, time, thread, chatState, myNick
"http://jabber.org/protocol/chatstates", "*")[0];
if (cs)
this.chatState = cs.localName;
- if (!thread)
- thread = body.getThread();
+ if (!threadID)
+ threadID = body.getThread();
var remoteDebug = body.getNode().
getElementsByTagNameNS("http://process-one.net/remote-debug", "enabled")[0];
@@ -606,12 +608,13 @@ function Message(body, body_html, contact, type, time, thread, chatState, myNick
this.messageId = messageId ? messageId : generateRandomName(12);
}
- if (thread instanceof MessagesThread)
+ /*if (thread instanceof MessagesThread)
this.thread = thread;
else
- this._threadID = thread;
+ this._threadID = thread;*/
+ this.threadID = threadID;
- this.queues = [];
+ //this.queues = [];
this.unseen = true;
}
@@ -620,18 +623,18 @@ _DECL_(Message).prototype =
epoch: 0,
dontGroup: false,
- get contactId() {
+ /*get contactId() {
if (this._contactId == null)
this._contactId = this.thread.getContactID(this.contact)
return this._contactId;
- },
+ },*/
- get threadID() {
+ /*get threadID() {
if (!this._threadID && this.thread)
this._threadID = this.thread.threadID;
return this._threadID;
- },
+ },*/
get isNormalMessage() {
return (this.type & 3) == 0;
@@ -779,12 +782,12 @@ _DECL_(Message).prototype =
delete this._msgEl;
},
- msgDelivered: function()
+ /*msgDelivered: function()
{
for (var i = 0; i < this.queues.length; i++)
this.queues[i].removeMessage(this);
this.queues = [];
- },
+ },*/
markAsSeen: function()
{
@@ -793,7 +796,8 @@ _DECL_(Message).prototype =
fillPacket: function(pkt)
{
- if (!this.isMucMessage && (this.thread || this._threadID))
+ //if (!this.isMucMessage && (this.thread || this._threadID))
+ if (!this.isMucMessage && this.threadID)
pkt.setThread(this.threadID);
if (this.chatState)
Oops, something went wrong.

0 comments on commit b0c8f2c

Please sign in to comment.