[polari/wip/fmuellner/nickserv: 13/21] telepathyClient: Cache sent identify parameters for later saving



commit 21fe2a911c16fca71ef82a8766c3fe9daf466e7a
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 2 21:49:13 2016 +0200

    telepathyClient: Cache sent identify parameters for later saving
    
    We won't save passwords immediately when we detect an "identify" command,
    but only after confirmation from the user.  In order to have the data
    available for saving later, we need to keep it until the user makes a
    decision - the telepathy client is a reasonable place, as it will be
    available even when we don't show any UI (once we support that), and
    it will be one of the components asking for confirmation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709982

 src/telepathyClient.js |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 1e3b180..7be68b8 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -120,6 +120,7 @@ const TelepathyClient = new Lang.Class({
             [...this._pendingRequests.values()].forEach(r => { r.cancel(); });
         });
 
+        this._pendingBotPasswords = new Map();
         this._pendingRequests = new Map();
 
         this.parent(params);
@@ -132,6 +133,7 @@ const TelepathyClient = new Lang.Class({
         this._roomManager.connect('room-added', (mgr, room) => {
             if (room.account.connection)
                 this._connectRoom(room);
+            room.connect('identify-sent', Lang.bind(this, this._onIdentifySent));
         });
         this._accountsMonitor = AccountsMonitor.getDefault();
         this._accountsMonitor.prepare(Lang.bind(this, this._onPrepared));
@@ -426,6 +428,17 @@ const TelepathyClient = new Lang.Class({
         return notification;
     },
 
+    _onIdentifySent: function(room, username, password) {
+        let accountPath = room.account.object_path;
+
+        let data = {
+            botname: room.channel.target_contact.alias,
+            username: username || room.channel.connection.self_contact.alias,
+            password: password
+        };
+        this._pendingBotPasswords.set(accountPath, data);
+    },
+
     _onMessageReceived: function(channel, msg) {
         let [id, ] = msg.get_pending_message_id();
         let room = this._roomManager.lookupRoomByChannel(channel);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]