Commit 9eba9989 authored by JC Brand's avatar JC Brand

OTR stuff has been moved to a component/plugin in src/converse-otr.js

Also fixed errors with converse obj not being defined in the MUC plugin.
parent 576efc48
...@@ -9,6 +9,7 @@ define("converse", [ ...@@ -9,6 +9,7 @@ define("converse", [
* Any of the following components can be removed if they're not needed. * Any of the following components can be removed if they're not needed.
*/ */
"converse-muc", // XEP-0045 Multi-user chat "converse-muc", // XEP-0045 Multi-user chat
"converse-otr", // Off-the-record encryption for one-on-one messages
/* End: Removable components */ /* End: Removable components */
"converse-core" "converse-core"
......
...@@ -46,6 +46,7 @@ require.config({ ...@@ -46,6 +46,7 @@ require.config({
// Converse // Converse
"converse-core": "src/converse-core", "converse-core": "src/converse-core",
"converse-muc": "src/converse-muc", "converse-muc": "src/converse-muc",
"converse-otr": "src/converse-otr",
"converse-dependencies": "src/deps-full", "converse-dependencies": "src/deps-full",
"converse-templates": "src/templates", "converse-templates": "src/templates",
......
This diff is collapsed.
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
// //
/*global converse, utils, Backbone, define, window, setTimeout */ /*global converse, utils, Backbone, define, window, setTimeout */
/* This is a Converse.js plugin which add support for multi-user chat rooms, as
* specified in XEP-0045 Multi-user chat.
*/
(function (root, factory) { (function (root, factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// AMD module loading // AMD module loading
...@@ -44,8 +47,6 @@ ...@@ -44,8 +47,6 @@
Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + "#user"); Strophe.addNamespace('MUC_USER', Strophe.NS.MUC + "#user");
converse_api.plugins.add('muc', { converse_api.plugins.add('muc', {
/* This plugin adds support for XEP-0045 Multi-user chat
*/
overrides: { overrides: {
// Overrides mentioned here will be picked up by converse.js's // Overrides mentioned here will be picked up by converse.js's
...@@ -53,6 +54,69 @@ ...@@ -53,6 +54,69 @@
// relevant objects or classes. // relevant objects or classes.
// //
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
Features: {
addClientFeatures: function () {
var converse = this._super.converse;
this._super.addClientFeatures.apply(this, arguments);
if (converse.allow_muc) {
converse.connection.disco.addFeature(Strophe.NS.MUC);
}
}
},
ControlBoxView: {
renderContactsPanel: function () {
var converse = this._super.converse;
this._super.renderContactsPanel.apply(this, arguments);
if (converse.allow_muc) {
this.roomspanel = new converse.RoomsPanel({
'$parent': this.$el.find('.controlbox-panes'),
'model': new (Backbone.Model.extend({
id: b64_sha1('converse.roomspanel'+converse.bare_jid), // Required by sessionStorage
browserStorage: new Backbone.BrowserStorage[converse.storage](
b64_sha1('converse.roomspanel'+converse.bare_jid))
}))()
});
this.roomspanel.render().model.fetch();
if (!this.roomspanel.model.get('nick')) {
this.roomspanel.model.save({
nick: Strophe.getNodeFromJid(converse.bare_jid)
});
}
}
},
onConnected: function () {
var converse = this._super.converse;
this._super.onConnected.apply(this, arguments);
if (this.model.get('connected')) {
converse.features.off('add', this.featureAdded, this);
converse.features.on('add', this.featureAdded, this);
// Features could have been added before the controlbox was
// initialized. We're only interested in MUC
var feature = converse.features.findWhere({
'var': Strophe.NS.MUC
});
if (feature) {
this.featureAdded(feature);
}
}
},
featureAdded: function (feature) {
var converse = this._super.converse;
if ((feature.get('var') === Strophe.NS.MUC) && (converse.allow_muc)) {
this.roomspanel.model.save({muc_domain: feature.get('from')});
var $server= this.$el.find('input.new-chatroom-server');
if (! $server.is(':focus')) {
$server.val(this.roomspanel.model.get('muc_domain'));
}
}
}
},
ChatBoxView: { ChatBoxView: {
clearChatRoomMessages: function (ev) { clearChatRoomMessages: function (ev) {
/* New method added to the ChatBox model which allows all /* New method added to the ChatBox model which allows all
...@@ -72,7 +136,7 @@ ...@@ -72,7 +136,7 @@
/* Override so that we can register a handler /* Override so that we can register a handler
* for chat room invites. * for chat room invites.
*/ */
this._super.registerMessageHandler(); // First call the original this._super.registerMessageHandler.apply(this, arguments); // First call the original
this._super.converse.connection.addHandler( this._super.converse.connection.addHandler(
function (message) { function (message) {
this.onInvite(message); this.onInvite(message);
...@@ -134,10 +198,11 @@ ...@@ -134,10 +198,11 @@
var converse = this.converse; var converse = this.converse;
// Configuration values for this plugin // Configuration values for this plugin
var settings = { var settings = {
allow_muc: true,
auto_join_on_invite: false // Auto-join chatroom on invite auto_join_on_invite: false // Auto-join chatroom on invite
}; };
_.extend(this, settings); _.extend(converse, settings);
_.extend(this, _.pick(converse.user_settings, Object.keys(settings))); _.extend(converse, _.pick(converse.user_settings, Object.keys(settings)));
converse.ChatRoomView = converse.ChatBoxView.extend({ converse.ChatRoomView = converse.ChatBoxView.extend({
/* Backbone View which renders a chat room, based upon the view /* Backbone View which renders a chat room, based upon the view
......
This diff is collapsed.
...@@ -3,7 +3,6 @@ define("converse-dependencies", [ ...@@ -3,7 +3,6 @@ define("converse-dependencies", [
"underscore", "underscore",
"polyfill", "polyfill",
"utils", "utils",
"otr",
"moment_with_locales", "moment_with_locales",
"strophe", "strophe",
"strophe.disco", "strophe.disco",
...@@ -14,11 +13,10 @@ define("converse-dependencies", [ ...@@ -14,11 +13,10 @@ define("converse-dependencies", [
"backbone.overview", "backbone.overview",
"jquery.browser", "jquery.browser",
"typeahead" "typeahead"
], function($, _, dummy, utils, otr, moment, Strophe) { ], function($, _, dummy, utils, moment, Strophe) {
return _.extend({ return _.extend({
'underscore': _, 'underscore': _,
'jQuery': $, 'jQuery': $,
'otr': otr,
'moment': moment, 'moment': moment,
'utils': utils 'utils': utils
}, Strophe); }, Strophe);
......
{[ if (allow_otr) { ]}
<li class="toggle-otr {{otr_status_class}}" title="{{otr_tooltip}}">
<span class="chat-toolbar-text">{{otr_translated_status}}</span>
{[ if (otr_status == UNENCRYPTED) { ]}
<span class="icon-unlocked"></span>
{[ } ]}
{[ if (otr_status == UNVERIFIED) { ]}
<span class="icon-lock"></span>
{[ } ]}
{[ if (otr_status == VERIFIED) { ]}
<span class="icon-lock"></span>
{[ } ]}
{[ if (otr_status == FINISHED) { ]}
<span class="icon-unlocked"></span>
{[ } ]}
<ul>
{[ if (otr_status == UNENCRYPTED) { ]}
<li><a class="start-otr" href="#">{{label_start_encrypted_conversation}}</a></li>
{[ } ]}
{[ if (otr_status != UNENCRYPTED) { ]}
<li><a class="start-otr" href="#">{{label_refresh_encrypted_conversation}}</a></li>
<li><a class="end-otr" href="#">{{label_end_encrypted_conversation}}</a></li>
<li><a class="auth-otr" data-scheme="smp" href="#">{{label_verify_with_smp}}</a></li>
{[ } ]}
{[ if (otr_status == UNVERIFIED) { ]}
<li><a class="auth-otr" data-scheme="fingerprint" href="#">{{label_verify_with_fingerprints}}</a></li>
{[ } ]}
<li><a href="http://www.cypherpunks.ca/otr/help/3.2.0/levels.php" target="_blank">{{label_whats_this}}</a></li>
</ul>
</li>
{[ } ]}
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