Philipp Hörist pushed to branch gajim_0.16 at gajim / gajim
Commits: 69f487ae by Philipp Hörist at 2017-03-28T16:59:02+02:00 Add version check for python-gnupg - - - - - 6e6896de by Philipp Hörist at 2017-03-28T18:15:29+02:00 Make PGP encoding configurable python-gnupg uses latin1 as default encoding because GPG itself uses latin1 as default. We should not override this default with getpreferredencoding, because getpreferredencoding maybe returns something else than what GPG is configured on that system. Example: On Windows GPG is run in default mode with 'latin1' getpreferredencoding returns 'cp1252' The approach would be now to default to latin1 as it is GPGs default. And if the User sets a different ecoding for GPG he has to set it in Gajim aswell. - - - - - d826d940 by Philipp Hörist at 2017-03-30T11:43:14+02:00 Merge branch 'fixpgp' into 'gajim_0.16' Fix some PGP issues See merge request !75 - - - - - 3 changed files: - src/common/config.py - src/common/gajim.py - src/common/gpg.py Changes: ===================================== src/common/config.py ===================================== --- a/src/common/config.py +++ b/src/common/config.py @@ -314,6 +314,7 @@ class Config: 'ignore_incoming_attention': [opt_bool, False, _('If True, Gajim will ignore incoming attention requestd ("wizz").')], 'remember_opened_chat_controls': [ opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')], 'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')], + 'pgp_encoding': [ opt_str, '', _('Sets the encoding used by python-gnupg'), True], }, {}) __options_per_key = { ===================================== src/common/gajim.py ===================================== --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -31,6 +31,7 @@ import os import logging import locale import uuid +from distutils.version import LooseVersion as V import config import nbxmpp @@ -160,7 +161,19 @@ except ImportError: HAVE_GPG = True GPG_BINARY = 'gpg' try: - __import__('gnupg') + import gnupg + ''' + We need https://pypi.python.org/pypi/python-gnupg + but https://pypi.python.org/pypi/gnupg shares the same package name. + It cannot be used as a drop-in replacement. + We test with a version check if python-gnupg is installed as it is + on a much lower version number than gnupg + Also we need at least python-gnupg 0.3.8 + ''' + v_gnupg = gnupg.__version__ + if V(v_gnupg) < V('0.3.8') or V(v_gnupg) > V('1.0.0'): + log.info('Gajim needs python-gnupg >= 0.3.8') + HAVE_GPG = False except ImportError: HAVE_GPG = False else: ===================================== src/common/gpg.py ===================================== --- a/src/common/gpg.py +++ b/src/common/gpg.py @@ -22,19 +22,21 @@ ## along with Gajim. If not, see <http://www.gnu.org/licenses/>. ## -from gajim import HAVE_GPG, GPG_BINARY import os import locale import logging +import gajim -if HAVE_GPG: +if gajim.HAVE_GPG: import gnupg gnupg.logger = logging.getLogger('gajim.c.gnupg') class GnuPG(gnupg.GPG): def __init__(self, use_agent=False): - gnupg.GPG.__init__(self, gpgbinary=GPG_BINARY) - self.encoding = locale.getpreferredencoding() + gnupg.GPG.__init__(self, gpgbinary=gajim.GPG_BINARY) + encoding = gajim.config.get('pgp_encoding') + if encoding: + self.encoding = encoding self.decode_errors = 'replace' self.passphrase = None self.use_agent = use_agent View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/a6cb72301c5461e7f3930565198e124d5a7e3c54...d826d9402b887bb0b8d06d0e493a483ad4506977
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits