Merge branch 'master' into roster_refactor

Conflicts:
	dev.html
This commit is contained in:
JC Brand 2015-04-21 16:51:15 +02:00
commit 848c13eb62
5 changed files with 128 additions and 16 deletions

View File

@ -3084,7 +3084,13 @@
var contact_jid, $forwarded, $received, $sent, var contact_jid, $forwarded, $received, $sent,
msgid = $message.attr('id'), msgid = $message.attr('id'),
chatbox, resource, roster_item, chatbox, resource, roster_item,
message_from = $message.attr('from'); message_from = $message.attr('from'),
message_to = $message.attr('to');
if(!_.contains([converse.connection.jid, converse.bare_jid], message_to)) {
// Ignore messages sent to a different resource
return true;
}
if (message_from === converse.connection.jid) { if (message_from === converse.connection.jid) {
// FIXME: Forwarded messages should be sent to specific resources, // FIXME: Forwarded messages should be sent to specific resources,
// not broadcasted // not broadcasted
@ -4106,7 +4112,7 @@
if (contact.showInRoster()) { if (contact.showInRoster()) {
if (this.model.get('state') === CLOSED) { if (this.model.get('state') === CLOSED) {
if (view.$el[0].style.display !== "none") { view.$el.hide(); } if (view.$el[0].style.display !== "none") { view.$el.hide(); }
if (this.$el[0].style.display === "none") { this.$el.show(); } if (!this.$el.is(':visible')) { this.$el.show(); }
} else { } else {
if (this.$el[0].style.display !== "block") { this.show(); } if (this.$el[0].style.display !== "block") { this.show(); }
} }
@ -4131,10 +4137,12 @@
}, },
show: function () { show: function () {
// FIXME: There's a bug here, if show_only_online_users is true this.$el.show();
// Possible solution, get the group, call _.each and check _.each(this.getAll(), function (contactView) {
// showInRoster if (contactView.model.showInRoster()) {
this.$el.nextUntil('dt').addBack().show(); contactView.$el.show();
}
});
}, },
hide: function () { hide: function () {
@ -5179,11 +5187,19 @@
var $inputs = $(ev.target).find(':input:not([type=button]):not([type=submit])'), var $inputs = $(ev.target).find(':input:not([type=button]):not([type=submit])'),
iq = $iq({type: "set"}) iq = $iq({type: "set"})
.c("query", {xmlns:Strophe.NS.REGISTER}) .c("query", {xmlns:Strophe.NS.REGISTER})
.c("x", {xmlns: Strophe.NS.XFORM, type: 'submit'});
if (this.form_type == 'xform') {
iq.c("x", {xmlns: Strophe.NS.XFORM, type: 'submit'});
$inputs.each(function () { $inputs.each(function () {
iq.cnode(utils.webForm2xForm(this)).up(); iq.cnode(utils.webForm2xForm(this)).up();
}); });
} else {
$inputs.each(function () {
var $input = $(this);
iq.c($input.attr('name'), {}, $input.val());
});
}
converse.connection._addSysHandler(this._onRegisterIQ.bind(this), null, "iq", null, null); converse.connection._addSysHandler(this._onRegisterIQ.bind(this), null, "iq", null, null);
converse.connection.send(iq); converse.connection.send(iq);
this.setFields(iq.tree()); this.setFields(iq.tree());

View File

@ -52,8 +52,6 @@
<script> <script>
require(['converse'], function (converse) { require(['converse'], function (converse) {
converse.initialize({ converse.initialize({
allow_registration: false,
allow_logout: true,
bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes bosh_service_url: 'https://conversejs.org/http-bind/', // Please use this connection manager only for testing purposes
i18n: locales['en'], // Refer to ./locale/locales.js to see which locales are supported i18n: locales['en'], // Refer to ./locale/locales.js to see which locales are supported
keepalive: true, keepalive: true,

View File

@ -6,6 +6,7 @@ Changelog
* Add the ability to log in anonymously. [jcbrand] * Add the ability to log in anonymously. [jcbrand]
* Add the ability to log in automatically. [jcbrand] * Add the ability to log in automatically. [jcbrand]
* #374 Fix collapsed group visibility on page load. [floriancargoet]
0.9.2 (2015-04-09) 0.9.2 (2015-04-09)
------------------ ------------------

View File

@ -369,7 +369,7 @@ Similar to chats.get API
To open a single multi user chat box, provide the JID of the room:: To open a single multi user chat box, provide the JID of the room::
converse.room.open('group@muc.example.com') converse.rooms.open('group@muc.example.com')
To return an array of chat boxes, provide an array of JIDs:: To return an array of chat boxes, provide an array of JIDs::
@ -377,7 +377,7 @@ To return an array of chat boxes, provide an array of JIDs::
To setup a custom nickname when joining the room, provide the optionnal nick argument:: To setup a custom nickname when joining the room, provide the optionnal nick argument::
converse.room.open('group@muc.example.com', 'mycustomnick') converse.rooms.open('group@muc.example.com', 'mycustomnick')
"settings" grouping "settings" grouping

View File

@ -160,5 +160,102 @@
expect(registerview.$('input[type=button]').length).toBe(1); expect(registerview.$('input[type=button]').length).toBe(1);
}, converse)); }, converse));
it("will set form_type to legacy and submit it as legacy", $.proxy(function () {
var cbview = this.chatboxviews.get('controlbox');
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
var registerview = this.chatboxviews.get('controlbox').registerpanel;
spyOn(registerview, 'onProviderChosen').andCallThrough();
spyOn(registerview, 'getRegistrationFields').andCallThrough();
spyOn(registerview, 'onRegistrationFields').andCallThrough();
spyOn(registerview, 'renderRegistrationForm').andCallThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(this.connection, 'connect').andCallThrough();
registerview.$('input[name=domain]').val('conversejs.org');
registerview.$('input[type=submit]').click();
var stanza = new Strophe.Builder("stream:features", {
'xmlns:stream': "http://etherx.jabber.org/streams",
'xmlns': "jabber:client"
})
.c('register', {xmlns: "http://jabber.org/features/iq-register"}).up()
.c('mechanisms', {xmlns: "urn:ietf:params:xml:ns:xmpp-sasl"});
this.connection._connect_cb(test_utils.createRequest(stanza));
stanza = $iq({
'type': 'result',
'id': 'reg1'
}).c('query', {'xmlns': 'jabber:iq:register'})
.c('instructions')
.t('Please choose a username, password and provide your email address').up()
.c('username').up()
.c('password').up()
.c('email');
this.connection._dataRecv(test_utils.createRequest(stanza));
expect(registerview.form_type).toBe('legacy');
registerview.$('input[name=username]').val('testusername');
registerview.$('input[name=password]').val('testpassword');
registerview.$('input[name=email]').val('test@email.local');
spyOn(converse.connection, 'send');
registerview.$('input[type=submit]').click();
expect(converse.connection.send).toHaveBeenCalled();
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
expect($stanza.children('query').children().length).toBe(3);
expect($stanza.children('query').children()[0].tagName).toBe('username');
}, converse));
it("will set form_type to xform and submit it as xform", $.proxy(function () {
var cbview = this.chatboxviews.get('controlbox');
cbview.$('#controlbox-tabs').find('li').last().find('a').click(); // Click the Register tab
var registerview = this.chatboxviews.get('controlbox').registerpanel;
spyOn(registerview, 'onProviderChosen').andCallThrough();
spyOn(registerview, 'getRegistrationFields').andCallThrough();
spyOn(registerview, 'onRegistrationFields').andCallThrough();
spyOn(registerview, 'renderRegistrationForm').andCallThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
spyOn(this.connection, 'connect').andCallThrough();
registerview.$('input[name=domain]').val('conversejs.org');
registerview.$('input[type=submit]').click();
var stanza = new Strophe.Builder("stream:features", {
'xmlns:stream': "http://etherx.jabber.org/streams",
'xmlns': "jabber:client"
})
.c('register', {xmlns: "http://jabber.org/features/iq-register"}).up()
.c('mechanisms', {xmlns: "urn:ietf:params:xml:ns:xmpp-sasl"});
this.connection._connect_cb(test_utils.createRequest(stanza));
stanza = $iq({
'type': 'result',
'id': 'reg1'
}).c('query', {'xmlns': 'jabber:iq:register'})
.c('instructions')
.t('Using xform data').up()
.c('x', { 'xmlns': 'jabber:x:data', 'type': 'form' })
.c('instructions').t('xform instructions').up()
.c('field', {'type': 'text-single', 'var': 'username'}).c('required').up().up()
.c('field', {'type': 'text-private', 'var': 'password'}).c('required').up().up()
.c('field', {'type': 'text-single', 'var': 'email'}).c('required').up().up()
this.connection._dataRecv(test_utils.createRequest(stanza));
expect(registerview.form_type).toBe('xform');
registerview.$('input[name=username]').val('testusername');
registerview.$('input[name=password]').val('testpassword');
registerview.$('input[name=email]').val('test@email.local');
spyOn(converse.connection, 'send');
registerview.$('input[type=submit]').click();
expect(converse.connection.send).toHaveBeenCalled();
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
expect($stanza.children('query').children().length).toBe(1);
expect($stanza.children('query').children().children().length).toBe(3);
expect($stanza.children('query').children().children()[0].tagName).toBe('field');
}, converse));
}, converse, mock, test_utils)); }, converse, mock, test_utils));
})); }));