Commit 3397da7d authored by Florian Müllner's avatar Florian Müllner
Browse files

telepathyClient: Ask users whether to save "identify" passwords

To identify with NickServ, users don't need to actually select the
corresponding room - they could use the /msg command or gnome-shell's
built-in chat notifications.  As the user likely won't see the info
bar added in the previous commit in that case, use a notification
to ask for confirmation when the bot's room isn't active.

https://bugzilla.gnome.org/show_bug.cgi?id=709982
parent 2ed6d7cb
......@@ -378,6 +378,7 @@ const TelepathyClient = new Lang.Class({
_discardIdentifyPassword: function(accountPath) {
this._pendingBotPasswords.delete(accountPath);
this._app.withdraw_notification(this._getIdentifyNotificationID(accountPath));
},
......@@ -459,16 +460,31 @@ const TelepathyClient = new Lang.Class({
return 'pending-message-%s-%d'.format(room.id, id);
},
_getIdentifyNotificationID: function(accountPath) {
return 'identify-password-%s'.format(accountPath);
},
_createNotification: function(room, summary, body) {
let notification = new Gio.Notification();
notification.set_title(summary);
notification.set_body(body);
let param = GLib.Variant.new('(ssu)',
[ room.account.object_path,
room.channel_name,
Utils.getTpEventTime() ]);
notification.set_default_action_and_target('app.join-room', param);
let params = [room.account.object_path,
room.channel_name,
Utils.getTpEventTime()];
let actionName, paramFormat;
if (room.type == Tp.HandleType.ROOM) {
actionName = 'app.join-room';
paramFormat = '(ssu)';
} else {
actionName = 'app.message-user';
paramFormat = '(sssu)';
params.splice(2, 0, '');
}
let param = GLib.Variant.new(paramFormat, params);
notification.set_default_action_and_target(actionName, param);
return notification;
},
......@@ -481,6 +497,21 @@ const TelepathyClient = new Lang.Class({
password: password
};
this._pendingBotPasswords.set(accountPath, data);
if (this._app.isRoomFocused(room))
return;
let accountName = room.account.display_name;
/* Translators: Those are a botname and an accountName, e.g.
"Save NickServ password for GNOME" */
let summary = _("Save %s password for %s?").format(data.botname, accountName);
let text = _("Identification will happen automatically the next time you connect to %s").format(accountName);
let notification = this._createNotification(room, summary, text);
notification.add_button_with_target(_("Save"), 'app.save-identify-password',
new GLib.Variant('o', accountPath));
this._app.send_notification(this._getIdentifyNotificationID(accountPath), notification);
},
_onMessageReceived: function(channel, msg) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment