telepathyClient: notify only once per account for connection error
https://bugzilla.gnome.org/show_bug.cgi?id=659050
This commit is contained in:
parent
6e32c97c43
commit
1d14488a4f
@ -83,6 +83,9 @@ Client.prototype = {
|
||||
this._chatSources = {};
|
||||
this._chatState = Tp.ChannelChatState.ACTIVE;
|
||||
|
||||
// account path -> AccountNotification
|
||||
this._accountNotifications = {};
|
||||
|
||||
// Set up a SimpleObserver, which will call _observeChannels whenever a
|
||||
// channel matching its filters is detected.
|
||||
// The second argument, recover, means _observeChannels will be run
|
||||
@ -420,7 +423,6 @@ Client.prototype = {
|
||||
|
||||
/* Display notification to ask user to accept/reject request */
|
||||
let source = this._ensureSubscriptionSource();
|
||||
Main.messageTray.add(source);
|
||||
|
||||
let notif = new SubscriptionRequestNotification(source, contact);
|
||||
source.notify(notif);
|
||||
@ -430,6 +432,7 @@ Client.prototype = {
|
||||
if (this._subscriptionSource == null) {
|
||||
this._subscriptionSource = new MultiNotificationSource(
|
||||
_("Subscription request"), 'gtk-dialog-question');
|
||||
Main.messageTray.add(this._subscriptionSource);
|
||||
this._subscriptionSource.connect('destroy', Lang.bind(this, function () {
|
||||
this._subscriptionSource = null;
|
||||
}));
|
||||
@ -446,11 +449,18 @@ Client.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
let notif = this._accountNotifications[account.get_object_path()];
|
||||
if (notif)
|
||||
return;
|
||||
|
||||
/* Display notification that account failed to connect */
|
||||
let source = this._ensureAccountSource();
|
||||
Main.messageTray.add(source);
|
||||
|
||||
let notif = new AccountNotification(source, account, connectionError);
|
||||
notif = new AccountNotification(source, account, connectionError);
|
||||
this._accountNotifications[account.get_object_path()] = notif;
|
||||
notif.connect('destroy', Lang.bind(this, function() {
|
||||
delete this._accountNotifications[account.get_object_path()];
|
||||
}));
|
||||
source.notify(notif);
|
||||
},
|
||||
|
||||
@ -458,6 +468,7 @@ Client.prototype = {
|
||||
if (this._accountSource == null) {
|
||||
this._accountSource = new MultiNotificationSource(
|
||||
_("Connection error"), 'gtk-dialog-error');
|
||||
Main.messageTray.add(this._accountSource);
|
||||
this._accountSource.connect('destroy', Lang.bind(this, function () {
|
||||
this._accountSource = null;
|
||||
}));
|
||||
@ -1448,17 +1459,12 @@ AccountNotification.prototype = {
|
||||
_("Connection to %s failed").format(account.get_display_name()),
|
||||
null, { customContent: true });
|
||||
|
||||
let message;
|
||||
if (connectionError in _connectionErrorMessages) {
|
||||
message = _connectionErrorMessages[connectionError];
|
||||
} else {
|
||||
message = _("Unknown reason");
|
||||
}
|
||||
this._label = new St.Label();
|
||||
this.addActor(this._label);
|
||||
this._updateMessage(connectionError);
|
||||
|
||||
this._account = account;
|
||||
|
||||
this.addBody(message);
|
||||
|
||||
this.addButton('reconnect', _("Reconnect"));
|
||||
this.addButton('edit', _("Edit account"));
|
||||
|
||||
@ -1492,11 +1498,25 @@ AccountNotification.prototype = {
|
||||
|
||||
this._connectionStatusId = account.connect('notify::connection-status',
|
||||
Lang.bind(this, function() {
|
||||
if (account.connection_status != Tp.ConnectionStatus.DISCONNECTED)
|
||||
let status = account.connection_status;
|
||||
if (status == Tp.ConnectionStatus.CONNECTED) {
|
||||
this.destroy();
|
||||
} else if (status == Tp.ConnectionStatus.DISCONNECTED) {
|
||||
this._updateMessage(account.connection_error);
|
||||
}
|
||||
}));
|
||||
},
|
||||
|
||||
_updateMessage: function(connectionError) {
|
||||
let message;
|
||||
if (connectionError in _connectionErrorMessages) {
|
||||
message = _connectionErrorMessages[connectionError];
|
||||
} else {
|
||||
message = _("Unknown reason");
|
||||
}
|
||||
this._label.set_text(message);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if (this._enabledId != 0) {
|
||||
this._account.disconnect(this._enabledId);
|
||||
|
Loading…
Reference in New Issue
Block a user