changeset f6197b419a24 in /home/hg/repos/gajim

author: Emmanuel Gil Peyrot <[email protected]>
branches: 
details:http://hg.gajim.org/gajim?cmd=changeset;node=f6197b419a24
description: Remove support for GNOME Keyring and KWalletCLI, instead always 
use libsecret.

diffstat:

 README.html                  |    3 +-
 src/common/config.py         |    2 -
 src/common/exceptions.py     |   12 --
 src/common/kwalletbinding.py |   80 ----------------
 src/common/passwords.py      |  208 ++----------------------------------------
 src/features_window.py       |   11 +-
 src/gui_interface.py         |    5 -
 7 files changed, 19 insertions(+), 302 deletions(-)

diffs (truncated from 432 to 300 lines):

diff -r b0962a4c0866 -r f6197b419a24 README.html
--- a/README.html       Sat Nov 19 17:31:23 2016 +0100
+++ b/README.html       Sun Nov 20 21:56:26 2016 +0000
@@ -28,8 +28,7 @@
 <li>For zeroconf (bonjour), the "enable link-local messaging" checkbox, you 
need dbus-glib, python-avahi</li>
 <li>dnsutils (or whatever package provides the nslookup binary) for SRV 
support</li>
 <li>gir1.2-gtkspell3-3.0 and aspell-LANG where lang is your locale eg. en, fr 
etc</li>
-<li>gir1.2-secret-1 or gir1.2-gnomekeyring-1.0 for GnomeKeyring support as 
password storage</li>
-<li>kwalletcli (for support of KDE Wallet as password storage)</li>
+<li>gir1.2-secret-1 for GNOME Keyring or KDE support as password storage</li>
 <li>gir1.2-notify-0.7 to get cooler popups</li>
 <li>D-Bus running to have gajim-remote working. Some distributions split 
dbus-x11, which is needed for dbus to work with Gajim. Version >= 0.80 is 
required.</li>
 <li>python3-dbus bindings (>=1.2.0)</li>
diff -r b0962a4c0866 -r f6197b419a24 src/common/config.py
--- a/src/common/config.py      Sat Nov 19 17:31:23 2016 +0100
+++ b/src/common/config.py      Sun Nov 20 21:56:26 2016 +0000
@@ -288,8 +288,6 @@
             'confirm_block': [ opt_str, '', _('Should we show the confirm 
block contact dialog or not? Empty string means we never show the dialog.')],
             'confirm_custom_status': [ opt_str, '', _('Should we show the 
confirm custom status dialog or not? Empty string means we never show the 
dialog.')],
             'enable_negative_priority': [ opt_bool, False, _('If True, you 
will be able to set a negative priority to your account in account modification 
window. BE CAREFUL, when you are logged in with a negative priority, you will 
NOT receive any message from your server.')],
-            'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use 
Gnome Keyring (if available) to store account passwords.')],
-            'use_kwalletcli': [opt_bool, True, _('If True, Gajim will use KDE 
Wallet (if kwalletcli is available) to store account passwords.')],
             'show_contacts_number': [opt_bool, True, _('If True, Gajim will 
show number of online and total contacts in account and group rows.')],
             'treat_incoming_messages': [ opt_str, '', _('Can be empty, 
\'chat\' or \'normal\'. If not empty, treat all incoming messages as if they 
were of this type')],
             'scroll_roster_to_last_message': [opt_bool, True, _('If True, 
Gajim will scroll and select the contact who sent you the last message, if chat 
window is not already opened.')],
diff -r b0962a4c0866 -r f6197b419a24 src/common/exceptions.py
--- a/src/common/exceptions.py  Sat Nov 19 17:31:23 2016 +0100
+++ b/src/common/exceptions.py  Sun Nov 20 21:56:26 2016 +0000
@@ -143,15 +143,3 @@
 
     def __str__(self):
         return self.text
-
-class GnomeKeyringError(Exception):
-    """
-    Error with Gnome Keyring
-    """
-
-    def __init__(self, error):
-        Exception.__init__(self)
-        self.error = error
-
-    def __str__(self):
-        return str(self.error)
diff -r b0962a4c0866 -r f6197b419a24 src/common/kwalletbinding.py
--- a/src/common/kwalletbinding.py      Sat Nov 19 17:31:23 2016 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-# -*- coding:utf-8 -*-
-## src/common/kwalletbinding.py
-##
-## Copyright (c) 2009 Thorsten Glaser <t.glaser AT tarent.de>
-##
-## This file is part of Gajim.
-##
-## Gajim is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published
-## by the Free Software Foundation; version 3 only. This file is
-## also available under the terms of The MirOS Licence.
-##
-## Gajim is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
-##
-
-__all__ = ['kwallet_available', 'kwallet_get', 'kwallet_put']
-
-import subprocess
-
-
-def kwallet_available():
-    """
-    Return True if kwalletcli can be run, False otherwise
-    """
-    try:
-        p = subprocess.Popen(["kwalletcli", "-qV"])
-    except Exception:
-        return False
-    p.communicate()
-    if p.returncode == 0:
-        return True
-    return False
-
-
-def kwallet_get(folder, entry):
-    """
-    Retrieve a passphrase from the KDE Wallet via kwalletcli
-
-    Arguments:
-    • folder: The top-level category to use (normally the programme name)
-    • entry: The key of the entry to retrieve
-
-    Returns the passphrase, False if it cannot be found,
-    or None if an error occured.
-    """
-    p = subprocess.Popen(["kwalletcli", "-q", "-f", folder.encode('utf-8'),
-     "-e", entry.encode('utf-8')], stdout=subprocess.PIPE)
-    pw = p.communicate()[0]
-    if p.returncode == 0:
-        return pw
-    if p.returncode == 1 or p.returncode == 4:
-        # ENOENT
-        return False
-    # error
-    return None
-
-
-def kwallet_put(folder, entry, passphrase):
-    """
-    Store a passphrase into the KDE Wallet via kwalletcli
-
-    Arguments:
-    • folder: The top-level category to use (normally the programme name)
-    • entry: The key of the entry to store
-    • passphrase: The value to store
-
-    Returns True on success, False otherwise.
-    """
-    p = subprocess.Popen(["kwalletcli", "-q", "-f", folder.encode('utf-8'),
-     "-e", entry.encode('utf-8'), "-P"], stdin=subprocess.PIPE)
-    p.communicate(passphrase.encode('utf-8'))
-    if p.returncode == 0:
-        return True
-    return False
diff -r b0962a4c0866 -r f6197b419a24 src/common/passwords.py
--- a/src/common/passwords.py   Sat Nov 19 17:31:23 2016 +0100
+++ b/src/common/passwords.py   Sun Nov 20 21:56:26 2016 +0000
@@ -28,15 +28,8 @@
 
 import warnings
 from common import gajim
-from common import kwalletbinding
-from common.exceptions import GnomeKeyringError
 import gi
 
-USER_HAS_LIBSECRET = False
-USER_HAS_GNOMEKEYRING = False
-USER_USES_GNOMEKEYRING = False
-USER_HAS_KWALLETCLI = False
-GnomeKeyring = None
 Secret = None
 
 class PasswordStorage(object):
@@ -49,10 +42,8 @@
 class SimplePasswordStorage(PasswordStorage):
     def get_password(self, account_name):
         passwd = gajim.config.get_per('accounts', account_name, 'password')
-        if passwd and (passwd.startswith('gnomekeyring:') or 
passwd.startswith('libsecret:') or \
-        passwd == '<kwallet>'):
-            # this is not a real password, it's either a gnome
-            # keyring token or stored in the KDE wallet
+        if passwd and passwd.startswith('libsecret:'):
+            # this is not a real password, it’s stored through libsecret.
             return None
         else:
             return passwd
@@ -63,98 +54,6 @@
             gajim.connections[account_name].password = password
 
 
-class GnomePasswordStorage(PasswordStorage):
-    def __init__(self):
-        (err, self.keyring) = GnomeKeyring.get_default_keyring_sync()
-        if err  != GnomeKeyring.Result.OK:
-            raise GnomeKeyringError(err)
-        if self.keyring is None:
-            self.keyring = 'login'
-        err = GnomeKeyring.create_sync(self.keyring, None)
-        if err not in (GnomeKeyring.Result.OK,
-        GnomeKeyring.Result.KEYRING_ALREADY_EXISTS):
-            raise GnomeKeyringError(err)
-
-    def get_password(self, account_name):
-        conf = gajim.config.get_per('accounts', account_name, 'password')
-        if conf is None or conf == '<kwallet>':
-            return None
-        if not (conf.startswith('gnomekeyring:') or 
conf.startswith('libsecret')):
-            password = conf
-            ## migrate the password over to keyring
-            try:
-                self.save_password(account_name, password)
-            except GnomeKeyringError as e:
-                if e.error == GnomeKeyring.Result.NO_KEYRING_DAEMON:
-                    ## no keyring daemon: in the future, stop using it
-                    set_storage(SimplePasswordStorage())
-            return password
-        server = gajim.config.get_per('accounts', account_name, 'hostname')
-        user = gajim.config.get_per('accounts', account_name, 'name')
-        attributes1 = GnomeKeyring.attribute_list_new()
-        GnomeKeyring.attribute_list_append_string(attributes1, 'server',
-            str(server))
-        GnomeKeyring.attribute_list_append_string(attributes1, 'user',
-            str(user))
-        GnomeKeyring.attribute_list_append_string(attributes1, 'protocol',
-            'xmpp')
-        attributes2 = GnomeKeyring.attribute_list_new()
-        GnomeKeyring.attribute_list_append_string(attributes2, 'account_name',
-            str(account_name))
-        GnomeKeyring.attribute_list_append_string(attributes2, 'gajim',
-            '1')
-        (err, items) = GnomeKeyring.find_items_sync(
-            GnomeKeyring.ItemType.NETWORK_PASSWORD, attributes1)
-        if err != GnomeKeyring.Result.OK:
-            (err, items) = GnomeKeyring.find_items_sync(
-                GnomeKeyring.ItemType.GENERIC_SECRET, attributes2)
-            if err == GnomeKeyring.Result.OK and len(items) > 0:
-                password = items[0].secret
-                self.save_password(account_name, password)
-                for item in items:
-                    GnomeKeyring.item_delete_sync(item.keyring,
-                        int(item.item_id))
-            else:
-                items = []
-        if len(items) > 1:
-            warnings.warn("multiple gnome keyring items found for account %s;"
-                " trying to use the first one..." % account_name)
-        if err == GnomeKeyring.Result.NO_KEYRING_DAEMON:
-            ## no keyring daemon: in the future, stop using it
-            set_storage(SimplePasswordStorage())
-        if items:
-            return items[0].secret
-        return None
-
-    def save_password(self, account_name, password, update=True):
-        server = gajim.config.get_per('accounts', account_name, 'hostname')
-        user = gajim.config.get_per('accounts', account_name, 'name')
-        display_name = _('XMPP account %s@%s') % (user, server)
-        attributes1 = GnomeKeyring.attribute_list_new()
-        GnomeKeyring.attribute_list_append_string(attributes1, 'server',
-            str(server))
-        GnomeKeyring.attribute_list_append_string(attributes1, 'user',
-            str(user))
-        GnomeKeyring.attribute_list_append_string(attributes1, 'protocol',
-            'xmpp')
-        if password is None:
-            password = str()
-        (err, auth_token) = GnomeKeyring.item_create_sync(self.keyring,
-            GnomeKeyring.ItemType.NETWORK_PASSWORD, display_name, attributes1,
-            password, update)
-        if err != GnomeKeyring.Result.OK:
-            if err in (GnomeKeyring.Result.DENIED,
-            GnomeKeyring.Result.CANCELLED):
-                set_storage(SimplePasswordStorage())
-                storage.save_password(account_name, password)
-                return
-            else:
-                raise GnomeKeyringError(err)
-        gajim.config.set_per('accounts', account_name, 'password',
-            'gnomekeyring:')
-        if account_name in gajim.connections:
-            gajim.connections[account_name].password = password
-
 class SecretPasswordStorage(PasswordStorage):
     def __init__(self):
         self.GAJIM_SCHEMA = 
Secret.Schema.new("org.gnome.keyring.NetworkPassword",
@@ -170,14 +69,7 @@
         conf = gajim.config.get_per('accounts', account_name, 'password')
         if conf is None:
             return None
-        if conf == '<kwallet>':
-            # Migrate from kwallet
-            if kwalletbinding.kwallet_available():
-                kw_storage = KWalletPasswordStorage()
-                password = kw_storage.get_password(account_name)
-                self.save_password(account_name, password)
-                return password
-        if not (conf.startswith('libsecret:') or 
conf.startswith('gnomekeyring:')):
+        if not conf.startswith('libsecret:'):
             password = conf
             ## migrate the password over to keyring
             try:
@@ -206,94 +98,22 @@
         if account_name in gajim.connections:
             gajim.connections[account_name].password = password
 
-class KWalletPasswordStorage(PasswordStorage):
-    def get_password(self, account_name):
-        pw = gajim.config.get_per('accounts', account_name, 'password')
-        if not pw or pw.startswith('gnomekeyring:'):
-            # unset, empty or not ours
-            return None
-        if pw != '<kwallet>':
-            # migrate the password
-            if kwalletbinding.kwallet_put('gajim', account_name, pw):
-                gajim.config.set_per('accounts', account_name, 'password',
-                 '<kwallet>')
-            else:
-                # stop using the KDE Wallet
-                set_storage(SimplePasswordStorage())
-            return pw
-        pw = kwalletbinding.kwallet_get('gajim', account_name)
-        if pw is None:
-            # stop using the KDE Wallet
-            set_storage(SimplePasswordStorage())
-        if not pw:
-            # False, None, or the empty string
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to