/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to seahorse.py

  • Committer: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This program is free software; you can redistribute it and/or modify
 
2
# it under the terms of the GNU General Public License as published by
 
3
# the Free Software Foundation; either version 2 of the License, or
 
4
# (at your option) any later version.
 
5
 
 
6
# This program is distributed in the hope that it will be useful,
 
7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
9
# GNU General Public License for more details.
 
10
 
 
11
# You should have received a copy of the GNU General Public License
 
12
# along with this program; if not, write to the Free Software
 
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
14
 
 
15
__copyright__ = 'Copyright (C) 2008 Daniel Schierbeck'
 
16
__author__ = 'Daniel Schierbeck <daniel.schierbeck@gmail.com>'
 
17
 
 
18
import dbus
 
19
 
 
20
BUS_NAME = 'org.gnome.seahorse'
 
21
 
 
22
CRYPTO_INTERFACE = 'org.gnome.seahorse.CryptoService'
 
23
CRYPTO_PATH = '/org/gnome/seahorse/crypto'
 
24
 
 
25
OPENPGP_INTERFACE = 'org.gnome.seahorse.Keys'
 
26
OPENPGP_PATH = '/org/gnome/seahorse/keys/openpgp'
 
27
 
 
28
KEY_TYPE_OPENPGP = 'openpgp'
 
29
KEY_TYPE_SSH = 'ssh'
 
30
 
 
31
try:
 
32
    dbus.validate_bus_name(BUS_NAME)
 
33
except ValueError:
 
34
    raise ImportError
 
35
 
 
36
bus = dbus.SessionBus()
 
37
 
 
38
crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH), 
 
39
                        CRYPTO_INTERFACE)
 
40
openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
 
41
                         OPENPGP_INTERFACE)
 
42
 
 
43
FLAG_VALID = 0x0001
 
44
FLAG_CAN_ENCRYPT = 0x0002
 
45
FLAG_CAN_SIGN = 0x0004
 
46
FLAG_EXPIRED = 0x0100
 
47
FLAG_REVOKED = 0x0200
 
48
FLAG_DISABLED = 0x0400
 
49
FLAG_TRUSTED = 0x1000
 
50
 
 
51
TRUST_NEVER = -1
 
52
TRUST_UNKNOWN = 0
 
53
TRUST_MARGINAL = 1
 
54
TRUST_FULL = 5
 
55
TRUST_ULTIMATE = 10
 
56
 
 
57
LOCATION_MISSING = 10
 
58
LOCATION_SEARCHING = 20
 
59
LOCATION_REMOTE = 50
 
60
LOCATION_LOCAL = 100
 
61
 
 
62
keyset = dict()
 
63
 
 
64
def verify(crypttext):
 
65
    (cleartext, key) = crypto.VerifyText(KEY_TYPE_OPENPGP, 1, crypttext)
 
66
 
 
67
    if key != "":
 
68
        if key not in keyset:
 
69
            keyset[key] = Key(key)
 
70
 
 
71
        return keyset[key]
 
72
 
 
73
class Key:
 
74
 
 
75
    def __init__(self, key):
 
76
        self.key = key
 
77
 
 
78
        (keys, unmatched) = openpgp.MatchKeys([self.get_id()], 0x00000010)
 
79
        self.available = (key in keys)
 
80
 
 
81
        if self.available:
 
82
            fields = openpgp.GetKeyFields(key, ['fingerprint', 'trust', 'flags', 'display-name', 'location'])
 
83
        else:
 
84
            fields = dict()
 
85
 
 
86
        self.fingerprint = fields.get('fingerprint', 'N/A')
 
87
        self.trust = fields.get('trust', TRUST_UNKNOWN)
 
88
        self.flags = fields.get('flags', 0)
 
89
        self.display_name = fields.get('display-name', '')
 
90
        self.location = fields.get('location', LOCATION_MISSING)
 
91
    
 
92
    def get_flags(self):
 
93
        return self.flags
 
94
 
 
95
    def get_display_name(self):
 
96
        return self.display_name
 
97
 
 
98
    def get_id(self):
 
99
        return self.key.split(':')[1][8:]
 
100
 
 
101
    def get_fingerprint(self):
 
102
        return self.fingerprint
 
103
 
 
104
    def get_trust(self):
 
105
        return self.trust
 
106
 
 
107
    def get_location(self):
 
108
        return self.location
 
109
 
 
110
    def is_available(self):
 
111
        return self.available
 
112
 
 
113
    def is_trusted(self):
 
114
        return self.flags & FLAG_TRUSTED != 0