[polari/gnome-3-24] telepathyClient: Always include username when it's known to work



commit 39dc5ef3f19c9b2e1ae696be4730be65a0c0352c
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Jun 21 16:26:33 2017 +0200

    telepathyClient: Always include username when it's known to work
    
    In addition to NickServ bots that don't support the username parameter
    and those that optionally support it, there are also bots that require
    it. To support those as well, store whether the user included the
    username in the identify command - if it was, we know the parameter
    is supported and we can always send it regardless of the currently
    used nick.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772915

 data/org.gnome.Polari.gschema.xml |    7 +++++++
 src/telepathyClient.js            |    5 ++++-
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.Polari.gschema.xml b/data/org.gnome.Polari.gschema.xml
index ce531bc..2d561e8 100644
--- a/data/org.gnome.Polari.gschema.xml
+++ b/data/org.gnome.Polari.gschema.xml
@@ -44,5 +44,12 @@
       <summary>Identify username</summary>
       <description>Username to use in identify command</description>
     </key>
+    <key type="b" name="identify-username-supported">
+      <default>false</default>
+      <summary>Identify username supported</summary>
+      <description>
+        Whether the identify command is known to support the username parameter
+      </description>
+    </key>
   </schema>
 </schemalist>
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index f57affc..8b98169 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -302,6 +302,7 @@ const TelepathyClient = new Lang.Class({
         let params = account.dup_parameters_vardict().deep_unpack();
         let username = settings.get_string('identify-username') ||
                        params.username.deep_unpack();
+        let alwaysSendUsername = settings.get_boolean('identify-username-supported');
         let contactName = settings.get_string('identify-botname');
         let command = settings.get_string('identify-command');
         this._requestChannel(account, Tp.HandleType.CONTACT, contactName,
@@ -313,7 +314,7 @@ const TelepathyClient = new Lang.Class({
                 let activeNick = room.channel.connection.self_contact.alias;
                 // Omit username parameter when it matches the default, to
                 // support NickServ bots that don't support the parameter at all
-                if (activeNick == username)
+                if (!alwaysSendUsername && activeNick == username)
                     username = null;
                 room.send_identify_message_async(command, username, password, (r, res) => {
                     try {
@@ -444,6 +445,7 @@ const TelepathyClient = new Lang.Class({
             settings.set_string('identify-command', data.command);
 
         settings.set_string('identify-username', data.username);
+        settings.set_boolean('identify-username-supported', data.usernameSupported);
     },
 
     _onDiscardIdentifyPasswordActivated: function(action, parameter) {
@@ -566,6 +568,7 @@ const TelepathyClient = new Lang.Class({
             botname: room.channel.target_contact.alias,
             command: command,
             username: username || room.channel.connection.self_contact.alias,
+            usernameSupported: username != null,
             password: password
         };
         this._pendingBotPasswords.set(accountPath, data);


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