/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: Jelmer Vernooij
  • Date: 2008-06-29 19:07:23 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629190723-l8mzg9x4oec0lhsl
Return cleartext from seahorse module

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
KEY_TYPE_OPENPGP = 'openpgp'
29
29
KEY_TYPE_SSH = 'ssh'
30
30
 
31
 
bus = dbus.SessionBus()
32
 
 
33
 
try: 
34
 
    crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH), 
35
 
                            CRYPTO_INTERFACE)
36
 
    openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
37
 
                             OPENPGP_INTERFACE)
 
31
try:
 
32
    bus = dbus.SessionBus()
38
33
except dbus.exceptions.DBusException, e:
39
 
    if e.get_dbus_name() == 'org.freedesktop.DBus.Error.ServiceUnknown':
 
34
    get_name = getattr(e, 'get_dbus_name', None)
 
35
    if get_name is not None:
 
36
        name = get_name()
 
37
    else:
 
38
        name = getattr(e, '_dbus_error_name', None)
 
39
    # DBus sometimes fails like this, just treat it as if seahorse is not
 
40
    # available rather than crashing.
 
41
    if name == "org.freedesktop.DBus.Error.Spawn.ExecFailed":
40
42
        raise ImportError
41
 
    raise
 
43
    else:
 
44
        raise
 
45
 
 
46
if hasattr(bus, 'list_activatable_names'):
 
47
    bus_names = bus.list_activatable_names()
 
48
else:
 
49
    bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
 
50
    bus_names = bus_object.ListNames(dbus_interface='org.freedesktop.DBus')
 
51
 
 
52
if BUS_NAME not in bus_names:
 
53
    raise ImportError
 
54
 
 
55
crypto = dbus.Interface(bus.get_object(BUS_NAME, CRYPTO_PATH), 
 
56
                        CRYPTO_INTERFACE)
 
57
openpgp = dbus.Interface(bus.get_object(BUS_NAME, OPENPGP_PATH),
 
58
                         OPENPGP_INTERFACE)
42
59
 
43
60
FLAG_VALID = 0x0001
44
61
FLAG_CAN_ENCRYPT = 0x0002
68
85
        if key not in keyset:
69
86
            keyset[key] = Key(key)
70
87
 
71
 
        return keyset[key]
 
88
        return (cleartext, keyset[key])
 
89
 
 
90
    return (cleartext, None)
 
91
 
72
92
 
73
93
class Key:
74
94