Commit 26f6ec98 authored by JC Brand's avatar JC Brand

Merge branch 'session-issues'

parents 108a57c5 041d5aca
...@@ -430,7 +430,7 @@ ...@@ -430,7 +430,7 @@
}); });
} }
if (errback) { if (errback) {
errback(iq); errback(jid, iq);
} }
} }
); );
...@@ -453,14 +453,11 @@ ...@@ -453,14 +453,11 @@
} }
}; };
this.showLoginForm = function () { this.renderLoginPanel = function () {
converse._tearDown();
var view = converse.chatboxviews.get('controlbox'); var view = converse.chatboxviews.get('controlbox');
view.model.set({connected:false}); view.model.set({connected:false});
if (typeof view.loginpanel !== 'undefined' && view.loginpanel.$el.is(':visible')) { view.renderLoginPanel();
view.loginpanel.showLoginButton();
} else {
view.render();
}
}; };
this.onConnect = function (status, condition, reconnect) { this.onConnect = function (status, condition, reconnect) {
...@@ -479,22 +476,25 @@ ...@@ -479,22 +476,25 @@
if (converse.auto_reconnect) { if (converse.auto_reconnect) {
converse.reconnect(); converse.reconnect();
} else { } else {
converse.showLoginForm(); converse.renderLoginPanel();
} }
} else if (status === Strophe.Status.Error) { } else if (status === Strophe.Status.Error) {
converse.showLoginForm(); converse.renderLoginPanel();
converse.giveFeedback(__('Error'), 'error'); converse.giveFeedback(__('Error'), 'error');
} else if (status === Strophe.Status.CONNECTING) { } else if (status === Strophe.Status.CONNECTING) {
converse.giveFeedback(__('Connecting')); converse.giveFeedback(__('Connecting'));
} else if (status === Strophe.Status.CONNFAIL) { } else if (status === Strophe.Status.CONNFAIL) {
converse.showLoginForm(); converse.renderLoginPanel();
converse.giveFeedback(__('Connection Failed'), 'error'); converse.giveFeedback(__('Connection Failed'), 'error');
} else if (status === Strophe.Status.AUTHENTICATING) { } else if (status === Strophe.Status.AUTHENTICATING) {
converse.giveFeedback(__('Authenticating')); converse.giveFeedback(__('Authenticating'));
} else if (status === Strophe.Status.AUTHFAIL) { } else if (status === Strophe.Status.AUTHFAIL) {
converse.showLoginForm(); converse.renderLoginPanel();
converse.giveFeedback(__('Authentication Failed'), 'error'); converse.giveFeedback(__('Authentication Failed'), 'error');
} else if (status === Strophe.Status.DISCONNECTING) { } else if (status === Strophe.Status.DISCONNECTING) {
if (!converse.connection.connected) {
converse.renderLoginPanel();
}
converse.giveFeedback(__('Disconnecting'), 'error'); converse.giveFeedback(__('Disconnecting'), 'error');
} }
}; };
...@@ -1917,8 +1917,8 @@ ...@@ -1917,8 +1917,8 @@
initialize: function () { initialize: function () {
this.$el.insertAfter(converse.controlboxtoggle.$el); this.$el.insertAfter(converse.controlboxtoggle.$el);
this.model.on('change:connected', $.proxy(function (item) { this.model.on('change:connected', $.proxy(function (item) {
this.render();
if (this.model.get('connected')) { if (this.model.get('connected')) {
this.render();
this.initRoster(); this.initRoster();
converse.features.off('add', this.featureAdded, this); converse.features.off('add', this.featureAdded, this);
converse.features.on('add', this.featureAdded, this); converse.features.on('add', this.featureAdded, this);
...@@ -1963,7 +1963,12 @@ ...@@ -1963,7 +1963,12 @@
renderLoginPanel: function () { renderLoginPanel: function () {
this.$el.html(converse.templates.controlbox(this.model.toJSON())); this.$el.html(converse.templates.controlbox(this.model.toJSON()));
this.loginpanel = new converse.LoginPanel({'$parent': this.$el.find('.controlbox-panes'), 'model': this}); var cfg = {'$parent': this.$el.find('.controlbox-panes'), 'model': this};
if (!this.loginpanel) {
this.loginpanel = new converse.LoginPanel(cfg);
} else {
this.loginpanel.delegateEvents().initialize(cfg);
}
this.loginpanel.render(); this.loginpanel.render();
this.initDragResize(); this.initDragResize();
}, },
...@@ -3540,15 +3545,15 @@ ...@@ -3540,15 +3545,15 @@
vcard_updated: moment().format() vcard_updated: moment().format()
}); });
}, this), }, this),
$.proxy(function (jid, fullname, img, img_type, url) { $.proxy(function (jid, iq) {
converse.log("Error while retrieving vcard"); converse.log("Error while retrieving vcard");
// XXX: Should vcard_updated be set here as well?
this.add({ this.add({
jid: bare_jid, jid: bare_jid,
subscription: 'none', subscription: 'none',
ask: null, ask: null,
requesting: true, requesting: true,
fullname: jid fullname: bare_jid,
vcard_updated: moment().format()
}); });
}, this) }, this)
); );
...@@ -4534,14 +4539,16 @@ ...@@ -4534,14 +4539,16 @@
}; };
this._tearDown = function () { this._tearDown = function () {
this.features.off().remove(); /* Remove those views which are only allowed with a valid
this.otr.destroy(); * connection.
this.chatboxes.off().remove(); */
this.chatboxviews.off().remove(); if (this.features) {
this.controlboxtoggle.off().remove(); this.features.off().remove();
this.minimized_chats.off().remove(); }
delete this.chatboxes; if (this.minimized_chats) {
delete this.features; this.minimized_chats.off().remove();
}
return this;
}; };
this._initialize = function () { this._initialize = function () {
...@@ -4551,6 +4558,7 @@ ...@@ -4551,6 +4558,7 @@
this.otr = new this.OTR(); this.otr = new this.OTR();
this.initSession(); this.initSession();
this.initConnection(); this.initConnection();
return this;
}; };
// Initialization // Initialization
......
<form id="converse-login"> <form id="converse-login" method="post">
<label>{{label_username}}</label> <label>{{label_username}}</label>
<input type="username" name="jid" placeholder="Username"> <input type="username" name="jid" placeholder="Username">
<label>{{label_password}}</label> <label>{{label_password}}</label>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment