Remove UI references from xmpp-related modules

Conflicts:
	modules/xmpp/JingleSession.js
	service/xmpp/XMPPEvents.js
This commit is contained in:
Devin Wilson 2015-06-18 11:49:43 -06:00
parent ca5a1001a1
commit 156b218bfc
9 changed files with 19213 additions and 19106 deletions

File diff suppressed because it is too large Load Diff

View File

@ -27,6 +27,7 @@ var RTCEvents = require("../../service/RTC/RTCEvents");
var RTCBrowserType = require("../RTC/RTCBrowserType");
var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var UIEvents = require("../../service/UI/UIEvents");
var MemberEvents = require("../../service/members/Events");
var eventEmitter = new EventEmitter();
@ -273,9 +274,66 @@ function registerListeners() {
APP.xmpp.addListener(XMPPEvents.VIDEO_MUTED, VideoLayout.onVideoMute);
APP.members.addListener(MemberEvents.DTMF_SUPPORT_CHANGED,
onDtmfSupportChanged);
APP.xmpp.addListener(XMPPEvents.START_MUTED, function (audio, video) {
APP.xmpp.addListener(XMPPEvents.START_MUTED_SETTING_CHANGED, function (audio, video) {
SettingsMenu.setStartMuted(audio, video);
});
APP.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS, function (audio, video) {
UI.setInitialMuteFromFocus(audio, video);
});
APP.xmpp.addListener(XMPPEvents.JINGLE_FATAL_ERROR, function (session, error) {
UI.messageHandler.showError("dialog.sorry",
"dialog.internalError");
});
APP.xmpp.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR, function() {
messageHandler.showError("dialog.error",
"dialog.SLDFailure");
});
APP.xmpp.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_ERROR, function() {
messageHandler.showError("dialog.error",
"dialog.SRDFailure");
});
APP.xmpp.addListener(XMPPEvents.CREATE_ANSWER_ERROR, function() {
messageHandler.showError();
});
APP.xmpp.addListener(XMPPEvents.CREATE_ANSWER_ERROR, function() {
messageHandler.showError();
});
APP.xmpp.addListener(XMPPEvents.PROMPT_FOR_LOGIN, function() {
// FIXME: re-use LoginDialog which supports retries
UI.showLoginPopup(connect);
});
APP.xmpp.addListener(XMPPEvents.FOCUS_DISCONNECTED, function(focusComponent, retrySec) {
UI.messageHandler.notify(
null, "notify.focus",
'disconnected', "notify.focusFail",
{component: focusComponent, ms: retrySec});
});
APP.xmpp.addListener(XMPPEvents.ROOM_JOIN_ERROR, function(pres) {
UI.messageHandler.openReportDialog(null,
"dialog.joinError", pres);
});
APP.xmpp.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function(pres) {
UI.messageHandler.openReportDialog(null,
"dialog.connectError", pres);
});
APP.xmpp.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS, function(doMuteAudio) {
UI.setAudioMuted(doMuteAudio);
});
APP.xmpp.addListener(XMPPEvents.READY_TO_JOIN, function() {
var roomName = UI.generateRoomName();
APP.xmpp.allocateConferenceFocus(roomName, UI.checkForNicknameAndJoin);
});
//NicknameHandler emits this event
UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
APP.xmpp.addToPresence("displayName", nickname);
});
}

View File

@ -28,6 +28,7 @@ function JingleSession(me, sid, connection, service, eventEmitter) {
this.ice_config = {};
this.drip_container = [];
this.service = service;
this.eventEmitter = eventEmitter;
this.usetrickle = true;
this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718
@ -131,7 +132,7 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
this.stopTime = new Date();
break;
case 'failed':
self.eventEmitter(XMPPEvents.CONFERENCE_SETUP_FAILED);
self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
break;
}
onIceConnectionStateChange(self.sid, self);
@ -1283,9 +1284,8 @@ JingleSession.onJingleFatalError = function (session, error)
{
this.service.sessionTerminated = true;
this.connection.emuc.doLeave();
APP.UI.messageHandler.showError("dialog.sorry",
"dialog.internalError");
this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
}
JingleSession.prototype.setLocalDescription = function () {
@ -1348,19 +1348,19 @@ function sendKeyframe(pc) {
},
function (error) {
console.log('triggerKeyframe setLocalDescription failed', error);
APP.UI.messageHandler.showError();
eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
}
);
},
function (error) {
console.log('triggerKeyframe createAnswer failed', error);
APP.UI.messageHandler.showError();
eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
}
);
},
function (error) {
console.log('triggerKeyframe setRemoteDescription failed', error);
APP.UI.messageHandler.showError();
eventEmitter.emit(XMPPEvents.SET_REMOTE_DESCRIPTION_ERROR);
}
);
}

View File

@ -1,4 +1,4 @@
/* global $, $iq, APP, config, connection, UI, messageHandler,
/* global $, $iq, APP, config, connection, messageHandler,
roomName, sessionTerminated, Strophe, Util */
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var Settings = require("../settings/Settings");
@ -333,10 +333,7 @@ var Moderator = {
// Do not show in case of session invalid
// which means just a retry
if (!invalidSession) {
APP.UI.messageHandler.notify(
null, "notify.focus",
'disconnected', "notify.focusFail",
{component: focusComponent, ms: retrySec});
eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED, focusComponent, retrySec);
}
// Reset response timeout
getNextTimeout(true);

View File

@ -155,7 +155,7 @@ module.exports = function(XMPP, eventEmitter) {
var startMuted = $(pres).find('>startmuted');
if (startMuted.length)
{
eventEmitter.emit(XMPPEvents.START_MUTED,
eventEmitter.emit(XMPPEvents.START_MUTED_SETTING_CHANGED,
startMuted.attr("audio") === "true", startMuted.attr("video") === "true");
}
@ -321,19 +321,15 @@ module.exports = function(XMPP, eventEmitter) {
// We're either missing Jicofo/Prosody config for anonymous
// domains or something is wrong.
// XMPP.promptLogin();
APP.UI.messageHandler.openReportDialog(null,
"dialog.joinError", pres);
eventEmitter.emit(XMPPEvents.ROOM_JOIN_ERROR, pres);
} else {
console.warn('onPresError ', pres);
APP.UI.messageHandler.openReportDialog(null,
"dialog.connectError",
pres);
eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
}
} else {
console.warn('onPresError ', pres);
APP.UI.messageHandler.openReportDialog(null,
"dialog.connectError",
pres);
eventEmitter.emit(XMPPEvents.ROOM_CONNECT_ERROR, pres);
}
return true;
},

View File

@ -119,8 +119,8 @@ module.exports = function(XMPP, eventEmitter)
{
var audioMuted = startMuted.attr("audio");
var videoMuted = startMuted.attr("video");
APP.UI.setInitialMuteFromFocus((audioMuted === "true"),
(videoMuted === "true"));
eventEmitter.emit(XMPPEvents.START_MUTED_FROM_FOCUS,
startMuted.attr("audio") === "true", startMuted.attr("video") === "true");
}
sess = new JingleSession(
$(iq).attr('to'), $(iq).find('jingle').attr('sid'),

View File

@ -3,7 +3,9 @@
/**
* Moderate connection plugin.
*/
module.exports = function (XMPP) {
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
module.exports = function (XMPP, eventEmitter) {
Strophe.addConnectionPlugin('moderate', {
connection: null,
init: function (conn) {
@ -44,7 +46,7 @@ module.exports = function (XMPP) {
var mute = $(iq).find('mute');
if (mute.length) {
var doMuteAudio = mute.text() === "true";
APP.UI.setAudioMuted(doMuteAudio);
eventEmitter.emit(XMPPEvents.AUDIO_MUTED_BY_FOCUS, doMuteAudio);
XMPP.forceMuted = doMuteAudio;
}
return true;

View File

@ -7,7 +7,6 @@ var Settings = require("../settings/Settings");
var Pako = require("pako");
var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
var RTCEvents = require("../../service/RTC/RTCEvents");
var UIEvents = require("../../service/UI/UIEvents");
var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var retry = require('retry');
@ -163,17 +162,14 @@ function maybeDoJoin() {
}
function doJoin() {
var roomName = APP.UI.generateRoomName();
Moderator.allocateConferenceFocus(
roomName, APP.UI.checkForNicknameAndJoin);
eventEmitter.emit(XMPPEvents.READY_TO_JOIN);
}
function initStrophePlugins()
{
require("./strophe.emuc")(XMPP, eventEmitter);
require("./strophe.jingle")(XMPP, eventEmitter);
require("./strophe.moderate")(XMPP);
require("./strophe.moderate")(XMPP, eventEmitter);
require("./strophe.util")();
require("./strophe.rayo")();
require("./strophe.logger")();
@ -184,9 +180,6 @@ function registerListeners() {
StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);
APP.RTC.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
XMPP.addToPresence("devices", devices);
})
APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
XMPP.addToPresence("displayName", nickname);
});
}
@ -279,8 +272,7 @@ var XMPP = {
return Strophe.getStatusString(status);
},
promptLogin: function () {
// FIXME: re-use LoginDialog which supports retries
APP.UI.showLoginPopup(connect);
eventEmitter.emit(XMPPEvents.PROMPT_FOR_LOGIN);
},
joinRoom: function(roomName, useNicks, nick)
{
@ -459,22 +451,19 @@ var XMPP = {
},
function (error) {
console.log('mute SLD error');
APP.UI.messageHandler.showError("dialog.error",
"dialog.SLDFailure");
eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
}
);
},
function (error) {
console.log(error);
APP.UI.messageHandler.showError();
eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
}
);
},
function (error) {
console.log('muteVideo SRD error');
APP.UI.messageHandler.showError("dialog.error",
"dialog.SRDFailure");
eventEmitter.emit(XMPPEvents.SET_REMOTE_DESCRIPTION_ERROR);
}
);
},

View File

@ -28,10 +28,22 @@ var XMPPEvents = {
CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
ETHERPAD: "xmpp.etherpad",
DEVICE_AVAILABLE: "xmpp.device_available",
START_MUTED: "xmpp.start_muted",
PEERCONNECTION_READY: "xmpp.peerconnection_ready",
CONFERENCE_SETUP_FAILED: "xmpp.conference_setup_failed",
AUDIO_MUTED: "xmpp.audio_muted",
VIDEO_MUTED: "xmpp.video_muted"
VIDEO_MUTED: "xmpp.video_muted",
AUDIO_MUTED_BY_FOCUS: "xmpp.audio_muted_by_focus",
START_MUTED_SETTING_CHANGED: "xmpp.start_muted_setting_changed",
START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",
SET_LOCAL_DESCRIPTION_ERROR: 'xmpp.set_local_description_error',
SET_REMOTE_DESCRIPTION_ERROR: 'xmpp.set_remote_description_error',
CREATE_ANSWER_ERROR: 'xmpp.create_answer_error',
JINGLE_FATAL_ERROR: 'xmpp.jingle_fatal_error',
PROMPT_FOR_LOGIN: 'xmpp.prompt_for_login',
FOCUS_DISCONNECTED: 'xmpp.focus_disconnected',
ROOM_JOIN_ERROR: 'xmpp.room_join_error',
ROOM_CONNECT_ERROR: 'xmpp.room_connect_error',
// xmpp is connected and obtained user media
READY_TO_JOIN: 'xmpp.ready_to_join'
};
module.exports = XMPPEvents;