Removes UI dependancies in the xmpp module.
This commit is contained in:
parent
29b3ea07e0
commit
899f0ee83d
|
@ -27,14 +27,14 @@
|
|||
<script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
|
||||
<script src="libs/modules/simulcast.bundle.js?v=5"></script>
|
||||
<script src="libs/modules/connectionquality.bundle.js?v=2"></script>
|
||||
<script src="libs/modules/UI.bundle.js?v=10"></script>
|
||||
<script src="libs/modules/UI.bundle.js?v=11"></script>
|
||||
<script src="libs/modules/statistics.bundle.js?v=4"></script>
|
||||
<script src="libs/modules/RTC.bundle.js?v=6"></script>
|
||||
<script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
|
||||
<script src="libs/modules/xmpp.bundle.js?v=5"></script>
|
||||
<script src="libs/modules/xmpp.bundle.js?v=6"></script>
|
||||
<script src="libs/modules/keyboardshortcut.bundle.js?v=1"></script>
|
||||
<script src="app.js?v=30"></script><!-- application logic -->
|
||||
<script src="libs/modules/API.bundle.js?v=1"></script>
|
||||
<script src="libs/modules/API.bundle.js?v=2"></script>
|
||||
|
||||
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
||||
<link rel="stylesheet" href="css/font.css?v=6"/>
|
||||
|
|
|
@ -133,6 +133,20 @@ function processMessage(event)
|
|||
|
||||
}
|
||||
|
||||
function setupListeners() {
|
||||
xmpp.addListener(XMPPEvents.MUC_ENTER, function (from) {
|
||||
API.triggerEvent("participantJoined", {jid: from});
|
||||
});
|
||||
xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid) {
|
||||
if (from != myjid)
|
||||
API.triggerEvent("incomingMessage",
|
||||
{"from": from, "nick": nick, "message": txt});
|
||||
});
|
||||
xmpp.addListener(XMPPEvents.MUC_LEFT, function (jid) {
|
||||
API.triggerEvent("participantLeft", {jid: jid});
|
||||
});
|
||||
}
|
||||
|
||||
var API = {
|
||||
/**
|
||||
* Check whether the API should be enabled or not.
|
||||
|
@ -161,6 +175,7 @@ var API = {
|
|||
window.attachEvent('onmessage', processMessage);
|
||||
}
|
||||
sendMessage({type: "system", loaded: true});
|
||||
setupListeners();
|
||||
},
|
||||
/**
|
||||
* Checks whether the event is enabled ot not.
|
||||
|
|
|
@ -140,6 +140,16 @@ function registerListeners() {
|
|||
});
|
||||
xmpp.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, onDisplayNameChanged);
|
||||
xmpp.addListener(XMPPEvents.MUC_JOINED, onMucJoined);
|
||||
xmpp.addListener(XMPPEvents.LOCALROLE_CHANGED, onLocalRoleChange);
|
||||
xmpp.addListener(XMPPEvents.MUC_ENTER, onMucEntered);
|
||||
xmpp.addListener(XMPPEvents.MUC_ROLE_CHANGED, onMucRoleChanged);
|
||||
xmpp.addListener(XMPPEvents.PRESENCE_STATUS, onMucPresenceStatus);
|
||||
xmpp.addListener(XMPPEvents.SUBJECT_CHANGED, chatSetSubject);
|
||||
xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, updateChatConversation);
|
||||
xmpp.addListener(XMPPEvents.MUC_LEFT, onMucLeft);
|
||||
xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, onPasswordReqiured);
|
||||
xmpp.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, chatAddError);
|
||||
xmpp.addListener(XMPPEvents.ETHERPAD, initEtherpad);
|
||||
}
|
||||
|
||||
function bindEvents()
|
||||
|
@ -291,17 +301,17 @@ UI.toggleSmileys = function () {
|
|||
Chat.toggleSmileys();
|
||||
};
|
||||
|
||||
UI.chatAddError = function(errorMessage, originalText)
|
||||
function chatAddError(errorMessage, originalText)
|
||||
{
|
||||
return Chat.chatAddError(errorMessage, originalText);
|
||||
};
|
||||
|
||||
UI.chatSetSubject = function(text)
|
||||
function chatSetSubject(text)
|
||||
{
|
||||
return Chat.chatSetSubject(text);
|
||||
};
|
||||
|
||||
UI.updateChatConversation = function (from, displayName, message) {
|
||||
function updateChatConversation(from, displayName, message) {
|
||||
return Chat.updateChatConversation(from, displayName, message);
|
||||
};
|
||||
|
||||
|
@ -329,11 +339,11 @@ function onMucJoined(jid, info) {
|
|||
onDisplayNameChanged('localVideoContainer', displayName + ' (me)');
|
||||
}
|
||||
|
||||
UI.initEtherpad = function (name) {
|
||||
function initEtherpad(name) {
|
||||
Etherpad.init(name);
|
||||
};
|
||||
|
||||
UI.onMucLeft = function (jid) {
|
||||
function onMucLeft(jid) {
|
||||
console.log('left.muc', jid);
|
||||
var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
|
||||
'>.displayname').html();
|
||||
|
@ -375,23 +385,23 @@ UI.toggleContactList = function () {
|
|||
return BottomToolbar.toggleContactList();
|
||||
};
|
||||
|
||||
UI.onLocalRoleChange = function (jid, info, pres) {
|
||||
function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
|
||||
{
|
||||
|
||||
console.info("My role changed, new role: " + info.role);
|
||||
var isModerator = xmpp.isModerator();
|
||||
|
||||
onModeratorStatusChanged(isModerator);
|
||||
VideoLayout.showModeratorIndicator();
|
||||
Toolbar.showAuthenticateButton(
|
||||
xmpp.isExternalAuthEnabled() && !isModerator);
|
||||
isExternalAuthEnabled && !isModerator);
|
||||
|
||||
if (isModerator) {
|
||||
Authentication.closeAuthenticationWindow();
|
||||
messageHandler.notify(
|
||||
'Me', 'connected', 'Moderator rights granted !');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
UI.onModeratorStatusChanged = function (isModerator) {
|
||||
function onModeratorStatusChanged(isModerator) {
|
||||
|
||||
Toolbar.showSipCallButton(isModerator);
|
||||
Toolbar.showRecordingButton(
|
||||
|
@ -406,7 +416,7 @@ UI.onModeratorStatusChanged = function (isModerator) {
|
|||
}
|
||||
};
|
||||
|
||||
UI.onPasswordReqiured = function (callback) {
|
||||
function onPasswordReqiured(callback) {
|
||||
// password is required
|
||||
Toolbar.lockLockButton();
|
||||
|
||||
|
@ -429,7 +439,35 @@ UI.onPasswordReqiured = function (callback) {
|
|||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
function onMucEntered(jid, id, displayName) {
|
||||
messageHandler.notify(displayName || 'Somebody',
|
||||
'connected',
|
||||
'connected');
|
||||
|
||||
// Add Peer's container
|
||||
VideoLayout.ensurePeerContainerExists(jid,id);
|
||||
}
|
||||
|
||||
function onMucPresenceStatus( jid, info) {
|
||||
VideoLayout.setPresenceStatus(
|
||||
'participant_' + Strophe.getResourceFromJid(jid), info.status);
|
||||
}
|
||||
|
||||
function onMucRoleChanged(role, displayName) {
|
||||
VideoLayout.showModeratorIndicator();
|
||||
|
||||
if (role === 'moderator') {
|
||||
var displayName = displayName;
|
||||
if (!displayName) {
|
||||
displayName = 'Somebody';
|
||||
}
|
||||
messageHandler.notify(
|
||||
displayName,
|
||||
'connected',
|
||||
'Moderator rights granted to ' + displayName + '!');
|
||||
}
|
||||
}
|
||||
|
||||
UI.onAuthenticationRequired = function (intervalCallback) {
|
||||
Authentication.openAuthenticationDialog(
|
||||
|
@ -446,35 +484,6 @@ UI.inputDisplayNameHandler = function (value) {
|
|||
VideoLayout.inputDisplayNameHandler(value);
|
||||
};
|
||||
|
||||
UI.onMucEntered = function (jid, id, displayName) {
|
||||
messageHandler.notify(displayName || 'Somebody',
|
||||
'connected',
|
||||
'connected');
|
||||
|
||||
// Add Peer's container
|
||||
VideoLayout.ensurePeerContainerExists(jid,id);
|
||||
};
|
||||
|
||||
UI.onMucPresenceStatus = function ( jid, info) {
|
||||
VideoLayout.setPresenceStatus(
|
||||
'participant_' + Strophe.getResourceFromJid(jid), info.status);
|
||||
};
|
||||
|
||||
UI.onMucRoleChanged = function (role, displayName) {
|
||||
VideoLayout.showModeratorIndicator();
|
||||
|
||||
if (role === 'moderator') {
|
||||
var displayName = displayName;
|
||||
if (!displayName) {
|
||||
displayName = 'Somebody';
|
||||
}
|
||||
messageHandler.notify(
|
||||
displayName,
|
||||
'connected',
|
||||
'Moderator rights granted to ' + displayName + '!');
|
||||
}
|
||||
};
|
||||
|
||||
UI.updateLocalConnectionStats = function(percent, stats)
|
||||
{
|
||||
VideoLayout.updateLocalConnectionStats(percent, stats);
|
||||
|
@ -2464,10 +2473,10 @@ function setVisualNotification(show) {
|
|||
|
||||
var chatBottomButtonElement
|
||||
= document.getElementById('chatBottomButton').parentNode;
|
||||
var bottomLeftIndent = (Util.getTextWidth(chatBottomButtonElement) -
|
||||
Util.getTextWidth(unreadMsgBottomElement)) / 2;
|
||||
var bottomTopIndent = (Util.getTextHeight(chatBottomButtonElement) -
|
||||
Util.getTextHeight(unreadMsgBottomElement)) / 2 - 2;
|
||||
var bottomLeftIndent = (UIUtil.getTextWidth(chatBottomButtonElement) -
|
||||
UIUtil.getTextWidth(unreadMsgBottomElement)) / 2;
|
||||
var bottomTopIndent = (UIUtil.getTextHeight(chatBottomButtonElement) -
|
||||
UIUtil.getTextHeight(unreadMsgBottomElement)) / 2 - 2;
|
||||
|
||||
unreadMsgBottomElement.setAttribute(
|
||||
'style',
|
||||
|
|
|
@ -2855,9 +2855,6 @@ var Moderator = {
|
|||
|
||||
init: function (xmpp) {
|
||||
this.xmppService = xmpp;
|
||||
this.onLocalRoleChange = function (from, member, pres) {
|
||||
UI.onModeratorStatusChanged(Moderator.isModerator());
|
||||
};
|
||||
},
|
||||
|
||||
onMucLeft: function (jid) {
|
||||
|
@ -3333,7 +3330,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
var etherpad = $(pres).find('>etherpad');
|
||||
if (etherpad.length) {
|
||||
if (config.etherpad_base && !Moderator.isModerator()) {
|
||||
UI.initEtherpad(etherpad.text());
|
||||
eventEmitter.emit(XMPPEvents.ETHERPAD, etherpad.text());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3410,9 +3407,10 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (member.affiliation == 'owner') this.isOwner = true;
|
||||
if (this.role !== member.role) {
|
||||
this.role = member.role;
|
||||
if (Moderator.onLocalRoleChange)
|
||||
Moderator.onLocalRoleChange(from, member, pres);
|
||||
UI.onLocalRoleChange(from, member, pres);
|
||||
|
||||
eventEmitter.emit(XMPPEvents.LOCALROLE_CHANGED,
|
||||
from, member, pres, Moderator.isModerator(),
|
||||
Moderator.isExternalAuthEnabled());
|
||||
}
|
||||
if (!this.joined) {
|
||||
this.joined = true;
|
||||
|
@ -3434,25 +3432,24 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (email.length > 0) {
|
||||
id = email.text();
|
||||
}
|
||||
UI.onMucEntered(from, id, member.displayName);
|
||||
API.triggerEvent("participantJoined", {jid: from});
|
||||
eventEmitter.emit(XMPPEvents.MUC_ENTER, from, id, member.displayName);
|
||||
}
|
||||
} else {
|
||||
// Presence update for existing participant
|
||||
// Watch role change:
|
||||
if (this.members[from].role != member.role) {
|
||||
this.members[from].role = member.role;
|
||||
UI.onMucRoleChanged(member.role, member.displayName);
|
||||
eventEmitter.emit(XMPPEvents.MUC_ROLE_CHANGED,
|
||||
member.role, member.displayName);
|
||||
}
|
||||
}
|
||||
|
||||
// Always trigger presence to update bindings
|
||||
$(document).trigger('presence.muc', [from, member, pres]);
|
||||
this.parsePresence(from, member, pres);
|
||||
|
||||
// Trigger status message update
|
||||
if (member.status) {
|
||||
UI.onMucPresenceStatus(from, member);
|
||||
eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3489,7 +3486,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
|
||||
console.log('on password required', from);
|
||||
var self = this;
|
||||
UI.onPasswordReqiured(function (value) {
|
||||
eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED, function (value) {
|
||||
self.doJoin(from, value);
|
||||
});
|
||||
} else if ($(pres).find(
|
||||
|
@ -3538,12 +3535,16 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
onMessage: function (msg) {
|
||||
// FIXME: this is a hack. but jingle on muc makes nickchanges hard
|
||||
var from = msg.getAttribute('from');
|
||||
var nick = $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]').text() || Strophe.getResourceFromJid(from);
|
||||
var nick =
|
||||
$(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]')
|
||||
.text() ||
|
||||
Strophe.getResourceFromJid(from);
|
||||
|
||||
var txt = $(msg).find('>body').text();
|
||||
var type = msg.getAttribute("type");
|
||||
if (type == "error") {
|
||||
UI.chatAddError($(msg).find('>text').text(), txt);
|
||||
eventEmitter.emit(XMPPEvents.CHAT_ERROR_RECEIVED,
|
||||
$(msg).find('>text').text(), txt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3551,7 +3552,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (subject.length) {
|
||||
var subjectText = subject.text();
|
||||
if (subjectText || subjectText == "") {
|
||||
UI.chatSetSubject(subjectText);
|
||||
eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
|
||||
console.log("Subject is changed to " + subjectText);
|
||||
}
|
||||
}
|
||||
|
@ -3559,10 +3560,8 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
|
||||
if (txt) {
|
||||
console.log('chat', nick, txt);
|
||||
UI.updateChatConversation(from, nick, txt);
|
||||
if (from != this.myroomjid)
|
||||
API.triggerEvent("incomingMessage",
|
||||
{"from": from, "nick": nick, "message": txt});
|
||||
eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
|
||||
from, nick, txt, this.myroomjid);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
@ -3689,7 +3688,6 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
}
|
||||
|
||||
pres.up();
|
||||
// console.debug(pres.toString());
|
||||
this.connection.send(pres);
|
||||
},
|
||||
addDisplayNameToPresence: function (displayName) {
|
||||
|
@ -3774,9 +3772,8 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
return null;
|
||||
},
|
||||
onParticipantLeft: function (jid) {
|
||||
UI.onMucLeft(jid);
|
||||
|
||||
API.triggerEvent("participantLeft", {jid: jid});
|
||||
eventEmitter.emit(XMPPEvents.MUC_LEFT, jid);
|
||||
|
||||
this.connection.jingle.terminateByJid(jid);
|
||||
|
||||
|
|
|
@ -132,6 +132,20 @@ function processMessage(event)
|
|||
|
||||
}
|
||||
|
||||
function setupListeners() {
|
||||
xmpp.addListener(XMPPEvents.MUC_ENTER, function (from) {
|
||||
API.triggerEvent("participantJoined", {jid: from});
|
||||
});
|
||||
xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, function (from, nick, txt, myjid) {
|
||||
if (from != myjid)
|
||||
API.triggerEvent("incomingMessage",
|
||||
{"from": from, "nick": nick, "message": txt});
|
||||
});
|
||||
xmpp.addListener(XMPPEvents.MUC_LEFT, function (jid) {
|
||||
API.triggerEvent("participantLeft", {jid: jid});
|
||||
});
|
||||
}
|
||||
|
||||
var API = {
|
||||
/**
|
||||
* Check whether the API should be enabled or not.
|
||||
|
@ -160,6 +174,7 @@ var API = {
|
|||
window.attachEvent('onmessage', processMessage);
|
||||
}
|
||||
sendMessage({type: "system", loaded: true});
|
||||
setupListeners();
|
||||
},
|
||||
/**
|
||||
* Checks whether the event is enabled ot not.
|
||||
|
|
|
@ -139,6 +139,16 @@ function registerListeners() {
|
|||
});
|
||||
xmpp.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, onDisplayNameChanged);
|
||||
xmpp.addListener(XMPPEvents.MUC_JOINED, onMucJoined);
|
||||
xmpp.addListener(XMPPEvents.LOCALROLE_CHANGED, onLocalRoleChange);
|
||||
xmpp.addListener(XMPPEvents.MUC_ENTER, onMucEntered);
|
||||
xmpp.addListener(XMPPEvents.MUC_ROLE_CHANGED, onMucRoleChanged);
|
||||
xmpp.addListener(XMPPEvents.PRESENCE_STATUS, onMucPresenceStatus);
|
||||
xmpp.addListener(XMPPEvents.SUBJECT_CHANGED, chatSetSubject);
|
||||
xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, updateChatConversation);
|
||||
xmpp.addListener(XMPPEvents.MUC_LEFT, onMucLeft);
|
||||
xmpp.addListener(XMPPEvents.PASSWORD_REQUIRED, onPasswordReqiured);
|
||||
xmpp.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, chatAddError);
|
||||
xmpp.addListener(XMPPEvents.ETHERPAD, initEtherpad);
|
||||
}
|
||||
|
||||
function bindEvents()
|
||||
|
@ -290,17 +300,17 @@ UI.toggleSmileys = function () {
|
|||
Chat.toggleSmileys();
|
||||
};
|
||||
|
||||
UI.chatAddError = function(errorMessage, originalText)
|
||||
function chatAddError(errorMessage, originalText)
|
||||
{
|
||||
return Chat.chatAddError(errorMessage, originalText);
|
||||
};
|
||||
|
||||
UI.chatSetSubject = function(text)
|
||||
function chatSetSubject(text)
|
||||
{
|
||||
return Chat.chatSetSubject(text);
|
||||
};
|
||||
|
||||
UI.updateChatConversation = function (from, displayName, message) {
|
||||
function updateChatConversation(from, displayName, message) {
|
||||
return Chat.updateChatConversation(from, displayName, message);
|
||||
};
|
||||
|
||||
|
@ -328,11 +338,11 @@ function onMucJoined(jid, info) {
|
|||
onDisplayNameChanged('localVideoContainer', displayName + ' (me)');
|
||||
}
|
||||
|
||||
UI.initEtherpad = function (name) {
|
||||
function initEtherpad(name) {
|
||||
Etherpad.init(name);
|
||||
};
|
||||
|
||||
UI.onMucLeft = function (jid) {
|
||||
function onMucLeft(jid) {
|
||||
console.log('left.muc', jid);
|
||||
var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
|
||||
'>.displayname').html();
|
||||
|
@ -374,23 +384,23 @@ UI.toggleContactList = function () {
|
|||
return BottomToolbar.toggleContactList();
|
||||
};
|
||||
|
||||
UI.onLocalRoleChange = function (jid, info, pres) {
|
||||
function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
|
||||
{
|
||||
|
||||
console.info("My role changed, new role: " + info.role);
|
||||
var isModerator = xmpp.isModerator();
|
||||
|
||||
onModeratorStatusChanged(isModerator);
|
||||
VideoLayout.showModeratorIndicator();
|
||||
Toolbar.showAuthenticateButton(
|
||||
xmpp.isExternalAuthEnabled() && !isModerator);
|
||||
isExternalAuthEnabled && !isModerator);
|
||||
|
||||
if (isModerator) {
|
||||
Authentication.closeAuthenticationWindow();
|
||||
messageHandler.notify(
|
||||
'Me', 'connected', 'Moderator rights granted !');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
UI.onModeratorStatusChanged = function (isModerator) {
|
||||
function onModeratorStatusChanged(isModerator) {
|
||||
|
||||
Toolbar.showSipCallButton(isModerator);
|
||||
Toolbar.showRecordingButton(
|
||||
|
@ -405,7 +415,7 @@ UI.onModeratorStatusChanged = function (isModerator) {
|
|||
}
|
||||
};
|
||||
|
||||
UI.onPasswordReqiured = function (callback) {
|
||||
function onPasswordReqiured(callback) {
|
||||
// password is required
|
||||
Toolbar.lockLockButton();
|
||||
|
||||
|
@ -428,7 +438,35 @@ UI.onPasswordReqiured = function (callback) {
|
|||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
function onMucEntered(jid, id, displayName) {
|
||||
messageHandler.notify(displayName || 'Somebody',
|
||||
'connected',
|
||||
'connected');
|
||||
|
||||
// Add Peer's container
|
||||
VideoLayout.ensurePeerContainerExists(jid,id);
|
||||
}
|
||||
|
||||
function onMucPresenceStatus( jid, info) {
|
||||
VideoLayout.setPresenceStatus(
|
||||
'participant_' + Strophe.getResourceFromJid(jid), info.status);
|
||||
}
|
||||
|
||||
function onMucRoleChanged(role, displayName) {
|
||||
VideoLayout.showModeratorIndicator();
|
||||
|
||||
if (role === 'moderator') {
|
||||
var displayName = displayName;
|
||||
if (!displayName) {
|
||||
displayName = 'Somebody';
|
||||
}
|
||||
messageHandler.notify(
|
||||
displayName,
|
||||
'connected',
|
||||
'Moderator rights granted to ' + displayName + '!');
|
||||
}
|
||||
}
|
||||
|
||||
UI.onAuthenticationRequired = function (intervalCallback) {
|
||||
Authentication.openAuthenticationDialog(
|
||||
|
@ -445,35 +483,6 @@ UI.inputDisplayNameHandler = function (value) {
|
|||
VideoLayout.inputDisplayNameHandler(value);
|
||||
};
|
||||
|
||||
UI.onMucEntered = function (jid, id, displayName) {
|
||||
messageHandler.notify(displayName || 'Somebody',
|
||||
'connected',
|
||||
'connected');
|
||||
|
||||
// Add Peer's container
|
||||
VideoLayout.ensurePeerContainerExists(jid,id);
|
||||
};
|
||||
|
||||
UI.onMucPresenceStatus = function ( jid, info) {
|
||||
VideoLayout.setPresenceStatus(
|
||||
'participant_' + Strophe.getResourceFromJid(jid), info.status);
|
||||
};
|
||||
|
||||
UI.onMucRoleChanged = function (role, displayName) {
|
||||
VideoLayout.showModeratorIndicator();
|
||||
|
||||
if (role === 'moderator') {
|
||||
var displayName = displayName;
|
||||
if (!displayName) {
|
||||
displayName = 'Somebody';
|
||||
}
|
||||
messageHandler.notify(
|
||||
displayName,
|
||||
'connected',
|
||||
'Moderator rights granted to ' + displayName + '!');
|
||||
}
|
||||
};
|
||||
|
||||
UI.updateLocalConnectionStats = function(percent, stats)
|
||||
{
|
||||
VideoLayout.updateLocalConnectionStats(percent, stats);
|
||||
|
|
|
@ -41,10 +41,10 @@ function setVisualNotification(show) {
|
|||
|
||||
var chatBottomButtonElement
|
||||
= document.getElementById('chatBottomButton').parentNode;
|
||||
var bottomLeftIndent = (Util.getTextWidth(chatBottomButtonElement) -
|
||||
Util.getTextWidth(unreadMsgBottomElement)) / 2;
|
||||
var bottomTopIndent = (Util.getTextHeight(chatBottomButtonElement) -
|
||||
Util.getTextHeight(unreadMsgBottomElement)) / 2 - 2;
|
||||
var bottomLeftIndent = (UIUtil.getTextWidth(chatBottomButtonElement) -
|
||||
UIUtil.getTextWidth(unreadMsgBottomElement)) / 2;
|
||||
var bottomTopIndent = (UIUtil.getTextHeight(chatBottomButtonElement) -
|
||||
UIUtil.getTextHeight(unreadMsgBottomElement)) / 2 - 2;
|
||||
|
||||
unreadMsgBottomElement.setAttribute(
|
||||
'style',
|
||||
|
|
|
@ -54,9 +54,6 @@ var Moderator = {
|
|||
|
||||
init: function (xmpp) {
|
||||
this.xmppService = xmpp;
|
||||
this.onLocalRoleChange = function (from, member, pres) {
|
||||
UI.onModeratorStatusChanged(Moderator.isModerator());
|
||||
};
|
||||
},
|
||||
|
||||
onMucLeft: function (jid) {
|
||||
|
|
|
@ -104,7 +104,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
var etherpad = $(pres).find('>etherpad');
|
||||
if (etherpad.length) {
|
||||
if (config.etherpad_base && !Moderator.isModerator()) {
|
||||
UI.initEtherpad(etherpad.text());
|
||||
eventEmitter.emit(XMPPEvents.ETHERPAD, etherpad.text());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,9 +181,10 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (member.affiliation == 'owner') this.isOwner = true;
|
||||
if (this.role !== member.role) {
|
||||
this.role = member.role;
|
||||
if (Moderator.onLocalRoleChange)
|
||||
Moderator.onLocalRoleChange(from, member, pres);
|
||||
UI.onLocalRoleChange(from, member, pres);
|
||||
|
||||
eventEmitter.emit(XMPPEvents.LOCALROLE_CHANGED,
|
||||
from, member, pres, Moderator.isModerator(),
|
||||
Moderator.isExternalAuthEnabled());
|
||||
}
|
||||
if (!this.joined) {
|
||||
this.joined = true;
|
||||
|
@ -205,25 +206,24 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (email.length > 0) {
|
||||
id = email.text();
|
||||
}
|
||||
UI.onMucEntered(from, id, member.displayName);
|
||||
API.triggerEvent("participantJoined", {jid: from});
|
||||
eventEmitter.emit(XMPPEvents.MUC_ENTER, from, id, member.displayName);
|
||||
}
|
||||
} else {
|
||||
// Presence update for existing participant
|
||||
// Watch role change:
|
||||
if (this.members[from].role != member.role) {
|
||||
this.members[from].role = member.role;
|
||||
UI.onMucRoleChanged(member.role, member.displayName);
|
||||
eventEmitter.emit(XMPPEvents.MUC_ROLE_CHANGED,
|
||||
member.role, member.displayName);
|
||||
}
|
||||
}
|
||||
|
||||
// Always trigger presence to update bindings
|
||||
$(document).trigger('presence.muc', [from, member, pres]);
|
||||
this.parsePresence(from, member, pres);
|
||||
|
||||
// Trigger status message update
|
||||
if (member.status) {
|
||||
UI.onMucPresenceStatus(from, member);
|
||||
eventEmitter.emit(XMPPEvents.PRESENCE_STATUS, from, member);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -260,7 +260,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if ($(pres).find('>error[type="auth"]>not-authorized[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]').length) {
|
||||
console.log('on password required', from);
|
||||
var self = this;
|
||||
UI.onPasswordReqiured(function (value) {
|
||||
eventEmitter.emit(XMPPEvents.PASSWORD_REQUIRED, function (value) {
|
||||
self.doJoin(from, value);
|
||||
});
|
||||
} else if ($(pres).find(
|
||||
|
@ -309,12 +309,16 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
onMessage: function (msg) {
|
||||
// FIXME: this is a hack. but jingle on muc makes nickchanges hard
|
||||
var from = msg.getAttribute('from');
|
||||
var nick = $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]').text() || Strophe.getResourceFromJid(from);
|
||||
var nick =
|
||||
$(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]')
|
||||
.text() ||
|
||||
Strophe.getResourceFromJid(from);
|
||||
|
||||
var txt = $(msg).find('>body').text();
|
||||
var type = msg.getAttribute("type");
|
||||
if (type == "error") {
|
||||
UI.chatAddError($(msg).find('>text').text(), txt);
|
||||
eventEmitter.emit(XMPPEvents.CHAT_ERROR_RECEIVED,
|
||||
$(msg).find('>text').text(), txt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -322,7 +326,7 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
if (subject.length) {
|
||||
var subjectText = subject.text();
|
||||
if (subjectText || subjectText == "") {
|
||||
UI.chatSetSubject(subjectText);
|
||||
eventEmitter.emit(XMPPEvents.SUBJECT_CHANGED, subjectText);
|
||||
console.log("Subject is changed to " + subjectText);
|
||||
}
|
||||
}
|
||||
|
@ -330,10 +334,8 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
|
||||
if (txt) {
|
||||
console.log('chat', nick, txt);
|
||||
UI.updateChatConversation(from, nick, txt);
|
||||
if (from != this.myroomjid)
|
||||
API.triggerEvent("incomingMessage",
|
||||
{"from": from, "nick": nick, "message": txt});
|
||||
eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
|
||||
from, nick, txt, this.myroomjid);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
@ -460,7 +462,6 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
}
|
||||
|
||||
pres.up();
|
||||
// console.debug(pres.toString());
|
||||
this.connection.send(pres);
|
||||
},
|
||||
addDisplayNameToPresence: function (displayName) {
|
||||
|
@ -545,9 +546,8 @@ module.exports = function(XMPP, eventEmitter) {
|
|||
return null;
|
||||
},
|
||||
onParticipantLeft: function (jid) {
|
||||
UI.onMucLeft(jid);
|
||||
|
||||
API.triggerEvent("participantLeft", {jid: jid});
|
||||
eventEmitter.emit(XMPPEvents.MUC_LEFT, jid);
|
||||
|
||||
this.connection.jingle.terminateByJid(jid);
|
||||
|
||||
|
|
|
@ -8,7 +8,17 @@ var XMPPEvents = {
|
|||
USER_ID_CHANGED: "xmpp.user_id_changed",
|
||||
CHANGED_STREAMS: "xmpp.changed_streams",
|
||||
MUC_JOINED: "xmpp.muc_joined",
|
||||
MUC_ENTER: "xmpp.muc_enter",
|
||||
MUC_ROLE_CHANGED: "xmpp.muc_role_changed",
|
||||
MUC_LEFT: "xmpp.muc_left",
|
||||
DISPLAY_NAME_CHANGED: "xmpp.display_name_changed",
|
||||
REMOTE_STATS: "xmpp.remote_stats"
|
||||
REMOTE_STATS: "xmpp.remote_stats",
|
||||
LOCALROLE_CHANGED: "xmpp.localrole_changed",
|
||||
PRESENCE_STATUS: "xmpp.presence_status",
|
||||
SUBJECT_CHANGED: "xmpp.subject_changed",
|
||||
MESSAGE_RECEIVED: "xmpp.message_received",
|
||||
PASSWORD_REQUIRED: "xmpp.password_required",
|
||||
CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
|
||||
ETHERPAD: "xmpp.etherpad"
|
||||
};
|
||||
//module.exports = XMPPEvents;
|
Loading…
Reference in New Issue