| Index: remoting/webapp/crd/js/me2me_activity.js
|
| diff --git a/remoting/webapp/crd/js/me2me_activity.js b/remoting/webapp/crd/js/me2me_activity.js
|
| index 7d2b090e1b6095b86fdb3fa4ebd46ff7ca05bacb..1a7ec539ea23423bba8c0729e88e8accb194b361 100644
|
| --- a/remoting/webapp/crd/js/me2me_activity.js
|
| +++ b/remoting/webapp/crd/js/me2me_activity.js
|
| @@ -11,14 +11,17 @@ var remoting = remoting || {};
|
|
|
| /**
|
| * @param {remoting.Host} host
|
| + * @param {remoting.HostList} hostList
|
| *
|
| * @constructor
|
| * @implements {remoting.Activity}
|
| */
|
| -remoting.Me2MeActivity = function(host) {
|
| +remoting.Me2MeActivity = function(host, hostList) {
|
| /** @private */
|
| this.host_ = host;
|
| /** @private */
|
| + this.hostList_ = hostList;
|
| + /** @private */
|
| this.pinDialog_ =
|
| new remoting.PinDialog(document.getElementById('pin-dialog'), host);
|
| /** @private */
|
| @@ -48,11 +51,11 @@ remoting.Me2MeActivity.prototype.start = function() {
|
| return that.host_.options.load();
|
| }).then(function() {
|
| that.connect_(true);
|
| - }).catch(function(/** remoting.Error */ error) {
|
| + }).catch(remoting.Error.handler(function(/** remoting.Error */ error) {
|
| if (error.hasTag(remoting.Error.Tag.CANCELLED)) {
|
| remoting.setMode(remoting.AppMode.HOME);
|
| }
|
| - });
|
| + }));
|
| };
|
|
|
| remoting.Me2MeActivity.prototype.stop = function() {
|
| @@ -69,9 +72,9 @@ remoting.Me2MeActivity.prototype.getDesktopActivity = function() {
|
| * @private
|
| */
|
| remoting.Me2MeActivity.prototype.connect_ = function(suppressHostOfflineError) {
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| base.dispose(this.desktopActivity_);
|
| this.desktopActivity_ = new remoting.DesktopRemotingActivity(this);
|
| + this.desktopActivity_.getConnectingDialog().show();
|
| remoting.app.setConnectionMode(remoting.Application.Mode.ME2ME);
|
| this.desktopActivity_.start(this.host_, this.createCredentialsProvider_(),
|
| suppressHostOfflineError);
|
| @@ -104,13 +107,15 @@ remoting.Me2MeActivity.prototype.createCredentialsProvider_ = function() {
|
| * @param {function(string):void} onPinFetched
|
| */
|
| var requestPin = function(supportsPairing, onPinFetched) {
|
| + that.desktopActivity_.getConnectingDialog().hide();
|
| that.pinDialog_.show(supportsPairing).then(function(/** string */ pin) {
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| + that.desktopActivity_.getConnectingDialog().show();
|
| onPinFetched(pin);
|
| - }).catch(function(/** remoting.Error */ error) {
|
| + }).catch(remoting.Error.handler(function(/** remoting.Error */ error) {
|
| base.debug.assert(error.hasTag(remoting.Error.Tag.CANCELLED));
|
| remoting.setMode(remoting.AppMode.HOME);
|
| - });
|
| + that.stop();
|
| + }));
|
| };
|
|
|
| return new remoting.CredentialsProvider({
|
| @@ -131,19 +136,22 @@ remoting.Me2MeActivity.prototype.onConnectionFailed = function(error) {
|
| var onHostListRefresh = function(/** boolean */ success) {
|
| if (success) {
|
| // Get the host from the hostList for the refreshed JID.
|
| - that.host_ = remoting.hostList.getHostForId(that.host_.hostId);
|
| + that.host_ = that.hostList_.getHostForId(that.host_.hostId);
|
| that.connect_(false);
|
| return;
|
| }
|
| - that.onError(error);
|
| + that.showErrorMessage_(error);
|
| };
|
| this.retryOnHostOffline_ = false;
|
|
|
| // The plugin will be re-created when the host finished refreshing
|
| remoting.hostList.refresh(onHostListRefresh);
|
| - } else {
|
| - this.onError(error);
|
| + } else if (!error.isNone()) {
|
| + this.showErrorMessage_(error);
|
| }
|
| +
|
| + base.dispose(this.desktopActivity_);
|
| + this.desktopActivity_ = null;
|
| };
|
|
|
| /**
|
| @@ -162,19 +170,29 @@ remoting.Me2MeActivity.prototype.onConnected = function(connectionInfo) {
|
|
|
| base.dispose(this.reconnector_);
|
| this.reconnector_ = new remoting.SmartReconnector(
|
| + this.desktopActivity_.getConnectingDialog(),
|
| this.connect_.bind(this, false),
|
| this.stop.bind(this),
|
| connectionInfo.session());
|
| };
|
|
|
| -remoting.Me2MeActivity.prototype.onDisconnected = function() {
|
| - this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
|
| +remoting.Me2MeActivity.prototype.onDisconnected = function(error) {
|
| + if (error.isNone()) {
|
| + this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
|
| + } else {
|
| + this.reconnector_.onConnectionDropped(error);
|
| + this.showErrorMessage_(error);
|
| + }
|
| +
|
| + base.dispose(this.desktopActivity_);
|
| + this.desktopActivity_ = null;
|
| };
|
|
|
| /**
|
| * @param {!remoting.Error} error
|
| + * @private
|
| */
|
| -remoting.Me2MeActivity.prototype.onError = function(error) {
|
| +remoting.Me2MeActivity.prototype.showErrorMessage_ = function(error) {
|
| var errorDiv = document.getElementById('connect-error-message');
|
| l10n.localizeElementFromTag(errorDiv, error.getTag());
|
| this.showFinishDialog_(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
|
|
|