[polari/wip/fmuellner/nickserv: 60/62] telepathyClient: Ask users whether to save "identify" passwords
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/nickserv: 60/62] telepathyClient: Ask users whether to save "identify" passwords
- Date: Mon, 29 Aug 2016 12:22:02 +0000 (UTC)
commit 18679283d6b64c8c3454fad686876a436f17c692
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Aug 2 21:49:13 2016 +0200
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
src/telepathyClient.js | 39 ++++++++++++++++++++++++++++++++++-----
1 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 07aab54..252fc1e 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -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,19 @@ const TelepathyClient = new Lang.Class({
password: password
};
this._pendingBotPasswords.set(accountPath, data);
+
+ if (this._app.isRoomFocused(room))
+ return;
+
+ let accountName = room.account.display_name;
+ 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]