diff --git a/app/ui.js b/app/ui.js index f6615674..7ab82f5a 100644 --- a/app/ui.js +++ b/app/ui.js @@ -532,10 +532,6 @@ var UI = { document.getElementById('noVNC_status').classList.remove("noVNC_open"); }, - notification: function (e) { - UI.showStatus(e.detail.message, e.detail.level); - }, - activateControlbar: function(event) { clearTimeout(UI.idleControlbarTimeout); // We manipulate the anchor instead of the actual control @@ -1038,7 +1034,6 @@ var UI = { { shared: UI.getSetting('shared'), repeaterID: UI.getSetting('repeaterID'), credentials: { password: password } }); - UI.rfb.addEventListener("notification", UI.notification); UI.rfb.addEventListener("updatestate", UI.updateState); UI.rfb.addEventListener("disconnect", UI.disconnectFinished); UI.rfb.addEventListener("credentialsrequired", UI.credentials); diff --git a/core/rfb.js b/core/rfb.js index caa59634..a95b1326 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -1,7 +1,7 @@ /* * noVNC: HTML5 VNC client * Copyright (C) 2012 Joel Martin - * Copyright (C) 2016 Samuel Mannehed for Cendio AB + * Copyright (C) 2017 Samuel Mannehed for Cendio AB * Licensed under MPL 2.0 (see LICENSE.txt) * * See README.md for usage and integration instructions. @@ -589,30 +589,6 @@ RFB.prototype = { return false; }, - /* - * Send a notification to the UI. Valid levels are: - * 'normal'|'warn'|'error' - * - * NOTE: If this function is called multiple times, remember that the - * interface could be only showing the latest notification. - */ - _notification: function(msg, level) { - switch (level) { - case 'normal': - case 'warn': - case 'error': - Log.Debug("Notification[" + level + "]:" + msg); - break; - default: - Log.Error("Invalid notification level: " + level); - return; - } - - var event = new CustomEvent("notification", - { detail: { message: msg, level: level } }); - this.dispatchEvent(event); - }, - _setCapability: function (cap, val) { this._capabilities[cap] = val; var event = new CustomEvent("capabilities", @@ -1262,8 +1238,7 @@ RFB.prototype = { switch (xvp_msg) { case 0: // XVP_FAIL - Log.Error("Operation Failed"); - this._notification("XVP Operation Failed", 'error'); + Log.Error("XVP Operation Failed"); break; case 1: // XVP_INIT this._rfb_xvp_ver = xvp_ver; @@ -2350,8 +2325,8 @@ RFB.encodingHandlers = { msg = "Unknown reason"; break; } - this._notification("Server did not accept the resize request: " - + msg, 'normal'); + Log.Warn("Server did not accept the resize request: " + + msg); } else { this._resize(this._FBU.width, this._FBU.height); } diff --git a/docs/API.md b/docs/API.md index 8f565e93..7d34b07b 100644 --- a/docs/API.md +++ b/docs/API.md @@ -67,10 +67,6 @@ protocol stream. - The `updatestate` event is fired when the connection state of the `RFB` object changes. -[`notification`](#notification) - - The `notification` event is fired when the `RFB` usage has a - message to display to the user. - [`disconnect`](#disconnected) - The `disconnect` event is fired when the `RFB` object disconnects. @@ -200,23 +196,6 @@ Note that a `RFB` objects can not transition from the disconnected state in any way, a new instance of the object has to be created for new connections. -#### notification - -The `notification` event is fired when the `RFB` object wants a message -displayed to the user. The `detail` property is an `Object` containing -the following properties: - -| Property | Type | Description -| --------- | ----------- | ----------- -| `message` | `DOMString` | The message to display -| `level` | `DOMString` | The severity of the message - -The following levels are currently defined: - - - `"normal"` - - `"warn"` - - `"error"` - #### disconnect The `disconnect` event is fired when the connection has been diff --git a/tests/playback-ui.js b/tests/playback-ui.js index 5e10d773..03b08fe1 100644 --- a/tests/playback-ui.js +++ b/tests/playback-ui.js @@ -52,10 +52,6 @@ function enableUI() { encoding = VNC_frame_encoding; } -const notification = function (rfb, mesg, level, options) { - document.getElementById('VNC_status').textContent = mesg; -} - function IterationPlayer (iterations, frames, encoding) { this._iterations = iterations; @@ -72,7 +68,6 @@ function IterationPlayer (iterations, frames, encoding) { this.onfinish = function() {}; this.oniterationfinish = function() {}; this.rfbdisconnected = function() {}; - this.rfbnotification = function() {}; } IterationPlayer.prototype = { @@ -87,7 +82,7 @@ IterationPlayer.prototype = { }, _nextIteration: function () { - const player = new RecordingPlayer(this._frames, this._encoding, this._disconnected.bind(this), this._notification.bind(this)); + const player = new RecordingPlayer(this._frames, this._encoding, this._disconnected.bind(this)); player.onfinish = this._iterationFinish.bind(this); if (this._state !== 'running') { return; } @@ -131,15 +126,6 @@ IterationPlayer.prototype = { this.onrfbdisconnected(evt); }, - - _notification: function (rfb, msg, level, options) { - var evt = new Event('rfbnotification'); - evt.message = msg; - evt.level = level; - evt.options = options; - - this.onrfbnotification(evt); - }, }; function start() { @@ -167,9 +153,6 @@ function start() { message(`noVNC sent disconnected during iteration ${evt.iteration} frame ${evt.frame}`); } }; - player.onrfbnotification = function (evt) { - document.getElementById('VNC_status').textContent = evt.message; - }; player.onfinish = function (evt) { const iterTime = parseInt(evt.duration / evt.iterations, 10); message(`${evt.iterations} iterations took ${evt.duration}ms (average ${iterTime}ms / iteration)`); diff --git a/tests/playback.js b/tests/playback.js index 2cd74998..9199eba0 100644 --- a/tests/playback.js +++ b/tests/playback.js @@ -44,12 +44,11 @@ if (setImmediate === undefined) { window.addEventListener("message", _onMessage); } -export default function RecordingPlayer (frames, encoding, disconnected, notification) { +export default function RecordingPlayer (frames, encoding, disconnected) { this._frames = frames; this._encoding = encoding; this._disconnected = disconnected; - this._notification = notification; if (this._encoding === undefined) { let frame = this._frames[0]; @@ -80,7 +79,6 @@ RecordingPlayer.prototype = { this._rfb = new RFB(document.getElementById('VNC_canvas'), 'wss://test'); this._rfb.viewOnly = true; this._rfb.ondisconnected = this._handleDisconnect.bind(this); - this._rfb.onnotification = this._notification; this._enablePlaybackMode(); // reset the frame index and timer diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 4dbe1840..a3746402 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -400,27 +400,6 @@ describe('Remote Frame Buffer Protocol Client', function() { }); }); - - describe('#_notification', function () { - var client; - beforeEach(function () { client = make_rfb(); }); - - it('should call the notification callback', function () { - var spy = sinon.spy(); - client.addEventListener("notification", spy); - client._notification('notify!', 'warn'); - expect(spy).to.have.been.calledOnce; - expect(spy.args[0][0].detail.message).to.equal('notify!'); - expect(spy.args[0][0].detail.level).to.equal('warn'); - }); - - it('should not call the notification callback when level is invalid', function () { - var spy = sinon.spy(); - client.addEventListener("notification", spy); - client._notification('notify!', 'invalid'); - expect(spy).to.not.have.been.called; - }); - }); }); describe('Connection States', function () { @@ -1589,14 +1568,6 @@ describe('Remote Frame Buffer Protocol Client', function() { }); describe('XVP Message Handling', function () { - it('should send a notification on XVP_FAIL', function () { - var spy = sinon.spy(); - client.addEventListener("notification", spy); - client._sock._websocket._receive_data(new Uint8Array([250, 0, 10, 0])); - expect(spy).to.have.been.calledOnce; - expect(spy.args[0][0].detail.message).to.equal('XVP Operation Failed'); - }); - it('should set the XVP version and fire the callback with the version on XVP_INIT', function () { var spy = sinon.spy(); client.addEventListener("capabilities", spy); diff --git a/tests/vnc_perf.html b/tests/vnc_perf.html index 001ac286..6e4f4a31 100644 --- a/tests/vnc_perf.html +++ b/tests/vnc_perf.html @@ -85,10 +85,6 @@ } } - notification = function (rfb, mesg, level, options) { - document.getElementById('VNC_status').textContent = mesg; - } - function do_test() { document.getElementById('startButton').value = "Running"; document.getElementById('startButton').disabled = true; diff --git a/vnc_lite.html b/vnc_lite.html index d817885d..e93efcfd 100644 --- a/vnc_lite.html +++ b/vnc_lite.html @@ -188,9 +188,6 @@ status(e.detail.reason, "error"); } } - function notification(e) { - status(e.detail.message, e.detail.level); - } window.onresize = function () { // When the window has been resized, wait until the size remains @@ -272,8 +269,7 @@ { repeaterID: WebUtil.getConfigVar('repeaterID', ''), shared: WebUtil.getConfigVar('shared', true), credentials: { password: password } }); - rfb.viewOnly = WebUtil.getConfigVar('view_only', false); - rfb.addEventListener("notification", notification); + rfb.viewOnly = WebUtil.getConfigVar('view_only', false); rfb.addEventListener("updatestate", updateState); rfb.addEventListener("disconnect", disconnect); rfb.addEventListener("capabilities", function () { updatePowerButtons(); initialResize(); });