[polari/wip/fmuellner/nickserv: 56/62] accountsMonitor: Manage account-specific settings



commit d5f3c5fdb558af4a63d42f05b271a404e2374b07
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Aug 3 03:03:39 2016 +0200

    accountsMonitor: Manage account-specific settings
    
    Identifying with NickServ and compatible bots requires more information
    than just the password, namely the username that is identified and the
    name of the bot itself. Account parameters are limited to a fixed set
    of settings defined by telepathy itself and the protocol, so use a
    relocatable GSettings schema to store the additional parameters.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709982

 data/org.gnome.Polari.gschema.xml |   13 +++++++++++++
 src/accountsMonitor.js            |   14 ++++++++++++++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Polari.gschema.xml b/data/org.gnome.Polari.gschema.xml
index 39907c1..839983c 100644
--- a/data/org.gnome.Polari.gschema.xml
+++ b/data/org.gnome.Polari.gschema.xml
@@ -22,4 +22,17 @@
       <description>Last active (selected) channel</description>
     </key>
   </schema>
+
+  <schema id="org.gnome.Polari.Account">
+    <key type="s" name="identify-botname">
+      <default>"NickServ"</default>
+      <summary>Identify botname</summary>
+      <description>Nickname of the bot to identify with</description>
+    </key>
+    <key type="s" name="identify-username">
+      <default>""</default>
+      <summary>Identify username</summary>
+      <description>Username to use in identify command</description>
+    </key>
+  </schema>
 </schemalist>
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 5cc9220..2aedb7a 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -17,6 +17,7 @@ const AccountsMonitor = new Lang.Class({
 
     _init: function() {
         this._accounts = new Map();
+        this._accountSettings = new Map();
 
         this._app = Gio.Application.get_default();
         this._app.connect('prepare-shutdown',
@@ -50,6 +51,19 @@ const AccountsMonitor = new Lang.Class({
         return this._accounts.get(accountPath);
     },
 
+    getAccountSettings: function(account) {
+        let accountPath = account.object_path;
+        let settings = this._accountSettings.get(accountPath);
+        if (settings)
+            return settings;
+
+        let path = '/org/gnome/Polari/Accounts/%s/'.format(account.get_path_suffix());
+        settings = new Gio.Settings({ schema_id: 'org.gnome.Polari.Account',
+                                      path: path });
+        this._accountSettings.set(accountPath, settings);
+        return settings;
+    },
+
     prepare: function(callback) {
         let quark = Tp.AccountManager.get_feature_quark_core();
         if (this._accountManager.is_prepared(quark))


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