changeset 79a998b4324a in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=79a998b4324a
description: rename GnuPG.py to gpg.py. Fixes #6055
diffstat:
src/common/GnuPG.py | 131 -----------------------------------------------
src/common/connection.py | 8 +-
src/common/gpg.py | 130 ++++++++++++++++++++++++++++++++++++++++++++++
src/config.py | 4 +-
4 files changed, 136 insertions(+), 137 deletions(-)
diffs (truncated from 329 to 300 lines):
diff -r 481f8f5151a2 -r 79a998b4324a src/common/GnuPG.py
--- a/src/common/GnuPG.py Tue Nov 30 11:10:37 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-## src/common/GnuPG.py
-##
-## Copyright (C) 2003-2010 Yann Leboulanger <asterix AT lagaule.org>
-## Copyright (C) 2005 Alex Mauer <hawke AT hawkesnest.net>
-## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
-## Copyright (C) 2007 Stephan Erb <steve-e AT h3c.de>
-## Copyright (C) 2008 Jean-Marie Traissard <jim AT lapin.org>
-## Jonathan Schleifer <js-gajim AT webkeks.org>
-##
-## 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.
-##
-## 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/>.
-##
-
-import gajim
-import os
-from os import tmpfile
-
-if gajim.HAVE_GPG:
- import gnupg
-
- class GnuPG(gnupg.GPG):
- def __init__(self, use_agent=False):
- gnupg.GPG.__init__(self)
- self.passphrase = None
- self.use_agent = use_agent
- self.always_trust = False
-
- def _setup_my_options(self):
- self.options.armor = 1
- self.options.meta_interactive = 0
- self.options.extra_args.append('--no-secmem-warning')
- # disable photo viewer when verifying keys
- self.options.extra_args.append('--verify-options')
- self.options.extra_args.append('no-show-photo')
- if self.use_agent:
- self.options.extra_args.append('--use-agent')
-
- def encrypt(self, str_, recipients, always_trust=False):
- result = super(GnuPG, self).encrypt(str_, recipients,
- always_trust=always_trust, passphrase=self.passphrase)
-
- if result.status == 'invalid recipient':
- return '', 'NOT_TRUSTED'
-
- if result.ok:
- error = ''
- else:
- error = result.status
-
- return self._stripHeaderFooter(str(result)), error
-
- def decrypt(self, str_, keyID):
- data = self._addHeaderFooter(str_, 'MESSAGE')
- result = super(GnuPG, self).decrypt(data,
- passphrase=self.passphrase)
-
- return str(result)
-
- def sign(self, str_, keyID):
- result = super(GnuPG, self).sign(str_, keyid=keyID, detach=True,
- passphrase=self.passphrase)
-
- if result.fingerprint:
- return self._stripHeaderFooter(str(result))
-# if 'KEYEXPIRED' in resp:
-# return 'KEYEXPIRED'
- return 'BAD_PASSPHRASE'
-
- def verify(self, str_, sign):
- if str_ is None:
- return ''
- data = '-----BEGIN PGP SIGNED MESSAGE-----' + os.linesep
- data = data + 'Hash: SHA1' + os.linesep + os.linesep
- data = data + str_ + os.linesep
- data = data + self._addHeaderFooter(sign, 'SIGNATURE')
- result = super(GnuPG, self).verify(data)
-
- if result.valid:
- return result.key_id
- return ''
-
- def get_keys(self, secret=False):
- keys = {}
- result = super(GnuPG, self).list_keys(secret=secret)
- for key in result:
- # Take first not empty uid
- keys[key['keyid'][8:]] = [uid for uid in key['uids'] if uid][0]
- return keys
-
- def get_secret_keys(self):
- return self.get_keys(True)
-
- def _stripHeaderFooter(self, data):
- """
- Remove header and footer from data
- """
- if not data: return ''
- lines = data.splitlines()
- while lines[0] != '':
- lines.remove(lines[0])
- while lines[0] == '':
- lines.remove(lines[0])
- i = 0
- for line in lines:
- if line:
- if line[0] == '-': break
- i = i+1
- line = '\n'.join(lines[0:i])
- return line
-
- def _addHeaderFooter(self, data, type_):
- """
- Add header and footer from data
- """
- out = "-----BEGIN PGP %s-----" % type_ + os.linesep
- out = out + "Version: PGP" + os.linesep
- out = out + os.linesep
- out = out + data + os.linesep
- out = out + "-----END PGP %s-----" % type_ + os.linesep
- return out
diff -r 481f8f5151a2 -r 79a998b4324a src/common/connection.py
--- a/src/common/connection.py Tue Nov 30 11:10:37 2010 +0100
+++ b/src/common/connection.py Tue Nov 30 11:41:14 2010 +0100
@@ -54,7 +54,7 @@
import common.xmpp
from common import helpers
from common import gajim
-from common import GnuPG
+from common import gpg
from common import passwords
from common import exceptions
@@ -123,7 +123,7 @@
self.USE_GPG = False
if gajim.HAVE_GPG:
self.USE_GPG = True
- self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent'))
+ self.gpg = gpg.GnuPG(gajim.config.get('use_gpg_agent'))
self.status = ''
self.old_show = ''
self.priority = gajim.get_priority(name, 'offline')
@@ -633,7 +633,7 @@
self.server_resource = self._compute_resource()
if gajim.HAVE_GPG:
self.USE_GPG = True
- self.gpg = GnuPG.GnuPG(gajim.config.get('use_gpg_agent'))
+ self.gpg = gpg.GnuPG(gajim.config.get('use_gpg_agent'))
self.connect_and_init(show, msg, sign_msg)
return
@@ -853,7 +853,7 @@
return
if gajim.HAVE_GPG:
self.USE_GPG = True
- self.gpg = GnuPG.GnuPG(gajim.config.get(
+ self.gpg = gpg.GnuPG(gajim.config.get(
'use_gpg_agent'))
gajim.nec.push_incoming_event(
AccountCreatedEvent(None, conn=self,
diff -r 481f8f5151a2 -r 79a998b4324a src/common/gpg.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/common/gpg.py Tue Nov 30 11:41:14 2010 +0100
@@ -0,0 +1,130 @@
+## src/common/gpg.py
+##
+## Copyright (C) 2003-2010 Yann Leboulanger <asterix AT lagaule.org>
+## Copyright (C) 2005 Alex Mauer <hawke AT hawkesnest.net>
+## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
+## Copyright (C) 2007 Stephan Erb <steve-e AT h3c.de>
+## Copyright (C) 2008 Jean-Marie Traissard <jim AT lapin.org>
+## Jonathan Schleifer <js-gajim AT webkeks.org>
+##
+## 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.
+##
+## 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/>.
+##
+
+from gajim import HAVE_GPG
+import os
+
+if HAVE_GPG:
+ import gnupg
+
+ class GnuPG(gnupg.GPG):
+ def __init__(self, use_agent=False):
+ gnupg.GPG.__init__(self)
+ self.passphrase = None
+ self.use_agent = use_agent
+ self.always_trust = False
+
+ def _setup_my_options(self):
+ self.options.armor = 1
+ self.options.meta_interactive = 0
+ self.options.extra_args.append('--no-secmem-warning')
+ # disable photo viewer when verifying keys
+ self.options.extra_args.append('--verify-options')
+ self.options.extra_args.append('no-show-photo')
+ if self.use_agent:
+ self.options.extra_args.append('--use-agent')
+
+ def encrypt(self, str_, recipients, always_trust=False):
+ result = super(GnuPG, self).encrypt(str_, recipients,
+ always_trust=always_trust, passphrase=self.passphrase)
+
+ if result.status == 'invalid recipient':
+ return '', 'NOT_TRUSTED'
+
+ if result.ok:
+ error = ''
+ else:
+ error = result.status
+
+ return self._stripHeaderFooter(str(result)), error
+
+ def decrypt(self, str_, keyID):
+ data = self._addHeaderFooter(str_, 'MESSAGE')
+ result = super(GnuPG, self).decrypt(data,
+ passphrase=self.passphrase)
+
+ return str(result)
+
+ def sign(self, str_, keyID):
+ result = super(GnuPG, self).sign(str_, keyid=keyID, detach=True,
+ passphrase=self.passphrase)
+
+ if result.fingerprint:
+ return self._stripHeaderFooter(str(result))
+# if 'KEYEXPIRED' in resp:
+# return 'KEYEXPIRED'
+ return 'BAD_PASSPHRASE'
+
+ def verify(self, str_, sign):
+ if str_ is None:
+ return ''
+ data = '-----BEGIN PGP SIGNED MESSAGE-----' + os.linesep
+ data = data + 'Hash: SHA1' + os.linesep + os.linesep
+ data = data + str_ + os.linesep
+ data = data + self._addHeaderFooter(sign, 'SIGNATURE')
+ result = super(GnuPG, self).verify(data)
+
+ if result.valid:
+ return result.key_id
+ return ''
+
+ def get_keys(self, secret=False):
+ keys = {}
+ result = super(GnuPG, self).list_keys(secret=secret)
+ for key in result:
+ # Take first not empty uid
+ keys[key['keyid'][8:]] = [uid for uid in key['uids'] if uid][0]
+ return keys
+
+ def get_secret_keys(self):
+ return self.get_keys(True)
+
+ def _stripHeaderFooter(self, data):
+ """
+ Remove header and footer from data
+ """
+ if not data: return ''
+ lines = data.splitlines()
+ while lines[0] != '':
+ lines.remove(lines[0])
+ while lines[0] == '':
+ lines.remove(lines[0])
+ i = 0
+ for line in lines:
+ if line:
+ if line[0] == '-': break
+ i = i+1
+ line = '\n'.join(lines[0:i])
+ return line
+
+ def _addHeaderFooter(self, data, type_):
+ """
changeset 084c0947d75a in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=084c0947d75a
description: fix var name
diffstat:
src/groupchat_control.py | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diffs (42 lines):
diff -r b14e72db6e7a -r 084c0947d75a src/groupchat_control.py
--- a/src/groupchat_control.py Mon Nov 29 18:44:22 2010 +0100
+++ b/src/groupchat_control.py Mon Nov 29 21:15:54 2010 +0100
@@ -1201,29 +1201,29 @@
# http://www.xmpp.org/extensions/xep-0045.html#registrar-statuscodes...
# -init
changes = []
- if '100' in obj.statusCode:
+ if '100' in obj.status_code:
# Can be a presence (see chg_contact_status in groupchat_control.py)
changes.append(_('Any occupant is allowed to see your full JID'))
gc_control.is_anonymous = False
- if '102' in statusCode:
+ if '102' in obj.status_code:
changes.append(_('Room now shows unavailable member'))
- if '103' in statusCode:
+ if '103' in obj.status_code:
changes.append(_('room now does not show unavailable members'))
- if '104' in statusCode:
+ if '104' in obj.status_code:
changes.append(_('A non-privacy-related room configuration change '
'has occurred'))
- if '170' in statusCode:
+ if '170' in obj.status_code:
# Can be a presence (see chg_contact_status in groupchat_control.py)
changes.append(_('Room logging is now enabled'))
- if '171' in statusCode:
+ if '171' in obj.status_code:
changes.append(_('Room logging is now disabled'))
- if '172' in statusCode:
+ if '172' in obj.status_code:
changes.append(_('Room is now non-anonymous'))
gc_control.is_anonymous = False
- if '173' in statusCode:
+ if '173' in obj.status_code:
changes.append(_('Room is now semi-anonymous'))
gc_control.is_anonymous = True
- if '174' in statusCode:
+ if '174' in obj.status_code:
changes.append(_('Room is now fully-anonymous'))
gc_control.is_anonymous = True