Merge pull request #323 from pstros/remove-ui-refs-from-xmpp-upstream

Remove UI refs from xmpp and RTC
This commit is contained in:
hristoterezov 2015-07-22 18:19:15 -05:00
commit 03902de511
13 changed files with 19228 additions and 19117 deletions

View File

@ -22,7 +22,7 @@
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib --> <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
<script src="libs/toastr.js?v=1"></script><!-- notifications lib --> <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
<script src="interface_config.js?v=5"></script> <script src="interface_config.js?v=5"></script>
<script src="libs/app.bundle.js?v=110"></script> <script src="libs/app.bundle.js?v=111"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin --> <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
<link rel="stylesheet" href="css/font.css?v=7"/> <link rel="stylesheet" href="css/font.css?v=7"/>
<link rel="stylesheet" href="css/toastr.css?v=1"> <link rel="stylesheet" href="css/toastr.css?v=1">

File diff suppressed because it is too large Load Diff

View File

@ -32,14 +32,7 @@ var DataChannels =
// Sends 12 bytes binary message to the bridge // Sends 12 bytes binary message to the bridge
//dataChannel.send(new ArrayBuffer(12)); //dataChannel.send(new ArrayBuffer(12));
// when the data channel becomes available, tell the bridge about video eventEmitter.emit(RTCEvents.DATA_CHANNEL_OPEN);
// selections so that it can do adaptive simulcast,
// we want the notification to trigger even if userJid is undefined,
// or null.
var userJid = APP.UI.getLargeVideoJid();
// we want the notification to trigger even if userJid is undefined,
// or null.
onSelectedEndpointChanged(userJid);
}; };
dataChannel.onerror = function (error) { dataChannel.onerror = function (error) {

View File

@ -207,7 +207,10 @@ var RTC = {
if(this.localVideo.isMuted() && this.localVideo.videoType !== type) if(this.localVideo.isMuted() && this.localVideo.videoType !== type)
{ {
localCallback = function() { localCallback = function() {
APP.xmpp.setVideoMute(false, APP.UI.setVideoMuteButtonsState); APP.xmpp.setVideoMute(false, function(mute) {
eventEmitter.emit(RTCEvents.VIDEO_MUTE, mute);
});
callback(); callback();
}; };
} }

View File

@ -27,6 +27,7 @@ var RTCEvents = require("../../service/RTC/RTCEvents");
var RTCBrowserType = require("../RTC/RTCBrowserType"); var RTCBrowserType = require("../RTC/RTCBrowserType");
var StreamEventTypes = require("../../service/RTC/StreamEventTypes"); var StreamEventTypes = require("../../service/RTC/StreamEventTypes");
var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var UIEvents = require("../../service/UI/UIEvents");
var MemberEvents = require("../../service/members/Events"); var MemberEvents = require("../../service/members/Events");
var eventEmitter = new EventEmitter(); var eventEmitter = new EventEmitter();
@ -172,7 +173,16 @@ function registerListeners() {
APP.RTC.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, APP.RTC.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED,
function (devices) { function (devices) {
VideoLayout.setDeviceAvailabilityIcons(null, devices); VideoLayout.setDeviceAvailabilityIcons(null, devices);
}) });
APP.RTC.addListener(RTCEvents.VIDEO_MUTE, UI.setVideoMuteButtonsState);
APP.RTC.addListener(RTCEvents.DATA_CHANNEL_OPEN, function() {
// when the data channel becomes available, tell the bridge about video
// selections so that it can do adaptive simulcast,
// we want the notification to trigger even if userJid is undefined,
// or null.
var userJid = APP.UI.getLargeVideoJid();
eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, userJid);
});
APP.statistics.addAudioLevelListener(function(jid, audioLevel) APP.statistics.addAudioLevelListener(function(jid, audioLevel)
{ {
var resourceJid; var resourceJid;
@ -271,11 +281,64 @@ function registerListeners() {
APP.xmpp.addListener(XMPPEvents.AUDIO_MUTED, VideoLayout.onAudioMute); APP.xmpp.addListener(XMPPEvents.AUDIO_MUTED, VideoLayout.onAudioMute);
APP.xmpp.addListener(XMPPEvents.VIDEO_MUTED, VideoLayout.onVideoMute); APP.xmpp.addListener(XMPPEvents.VIDEO_MUTED, VideoLayout.onVideoMute);
APP.xmpp.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS, function(doMuteAudio) {
UI.setAudioMuted(doMuteAudio);
});
APP.members.addListener(MemberEvents.DTMF_SUPPORT_CHANGED, APP.members.addListener(MemberEvents.DTMF_SUPPORT_CHANGED,
onDtmfSupportChanged); 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); 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.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.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.ice_config = {};
this.drip_container = []; this.drip_container = [];
this.service = service; this.service = service;
this.eventEmitter = eventEmitter;
this.usetrickle = true; this.usetrickle = true;
this.usepranswer = false; // early transport warmup -- mind you, this might fail. depends on webrtc issue 1718 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(); this.stopTime = new Date();
break; break;
case 'failed': case 'failed':
self.eventEmitter(XMPPEvents.CONFERENCE_SETUP_FAILED); self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
break; break;
} }
onIceConnectionStateChange(self.sid, self); onIceConnectionStateChange(self.sid, self);
@ -1283,9 +1284,8 @@ JingleSession.onJingleFatalError = function (session, error)
{ {
this.service.sessionTerminated = true; this.service.sessionTerminated = true;
this.connection.emuc.doLeave(); this.connection.emuc.doLeave();
APP.UI.messageHandler.showError("dialog.sorry",
"dialog.internalError");
this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED); this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
} }
JingleSession.prototype.setLocalDescription = function () { JingleSession.prototype.setLocalDescription = function () {
@ -1348,19 +1348,19 @@ function sendKeyframe(pc) {
}, },
function (error) { function (error) {
console.log('triggerKeyframe setLocalDescription failed', error); console.log('triggerKeyframe setLocalDescription failed', error);
APP.UI.messageHandler.showError(); eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
} }
); );
}, },
function (error) { function (error) {
console.log('triggerKeyframe createAnswer failed', error); console.log('triggerKeyframe createAnswer failed', error);
APP.UI.messageHandler.showError(); eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
} }
); );
}, },
function (error) { function (error) {
console.log('triggerKeyframe setRemoteDescription failed', 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 */ roomName, sessionTerminated, Strophe, Util */
var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var Settings = require("../settings/Settings"); var Settings = require("../settings/Settings");
@ -333,10 +333,7 @@ var Moderator = {
// Do not show in case of session invalid // Do not show in case of session invalid
// which means just a retry // which means just a retry
if (!invalidSession) { if (!invalidSession) {
APP.UI.messageHandler.notify( eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED, focusComponent, retrySec);
null, "notify.focus",
'disconnected', "notify.focusFail",
{component: focusComponent, ms: retrySec});
} }
// Reset response timeout // Reset response timeout
getNextTimeout(true); getNextTimeout(true);

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
var RTCEvents = { var RTCEvents = {
RTC_READY: "rtc.ready", RTC_READY: "rtc.ready",
DATA_CHANNEL_OPEN: "rtc.data_channel_open",
LASTN_CHANGED: "rtc.lastn_changed", LASTN_CHANGED: "rtc.lastn_changed",
DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed", DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed", LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",

View File

@ -28,10 +28,22 @@ var XMPPEvents = {
CHAT_ERROR_RECEIVED: "xmpp.chat_error_received", CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
ETHERPAD: "xmpp.etherpad", ETHERPAD: "xmpp.etherpad",
DEVICE_AVAILABLE: "xmpp.device_available", DEVICE_AVAILABLE: "xmpp.device_available",
START_MUTED: "xmpp.start_muted",
PEERCONNECTION_READY: "xmpp.peerconnection_ready", PEERCONNECTION_READY: "xmpp.peerconnection_ready",
CONFERENCE_SETUP_FAILED: "xmpp.conference_setup_failed", CONFERENCE_SETUP_FAILED: "xmpp.conference_setup_failed",
AUDIO_MUTED: "xmpp.audio_muted", 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; module.exports = XMPPEvents;