[polari/wip/fmuellner/nickserv: 27/29] telepathyClient: Ask users whether to save "identify" passwords



commit 9cb152ad87fa63c626f772042f05560e05e3cb26
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 |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 07aab54..78beecb 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,6 +460,10 @@ 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);
@@ -481,6 +486,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]