2 from model
import SafeException
11 for x
in range(4, len(fp
), 4):
12 s
+= ' ' + fp
[x
:x
+ 4]
15 class TrustBox(dialog
.Dialog
):
18 interfaces
= None # Interface -> (xml, [Keys])
21 dialog
.Dialog
.__init
__(self
)
22 self
.set_title('Confirm trust')
25 label
= gtk
.Label('Please confirm that you trust '
26 'these keys to sign software updates:')
27 label
.set_padding(8, 8)
28 self
.vbox
.pack_start(label
, False, True, 0)
30 swin
= gtk
.ScrolledWindow()
31 self
.vbox
.pack_start(swin
, True, True, 0)
32 swin
.set_policy(gtk
.POLICY_NEVER
, gtk
.POLICY_AUTOMATIC
)
33 swin
.set_shadow_type(gtk
.SHADOW_IN
)
34 swin
.set_border_width(8)
36 self
.model
= gtk
.ListStore(str, object)
37 self
.tree_view
= gtk
.TreeView(self
.model
)
38 self
.tree_view
.get_selection().set_mode(gtk
.SELECTION_NONE
)
39 swin
.add(self
.tree_view
)
41 self
.tree_view
.set_size_request(-1, 100)
43 text
= gtk
.CellRendererText()
45 for column
in [gtk
.TreeViewColumn('Key fingerprint', text
, text
= 0)]:
46 self
.tree_view
.append_column(column
)
50 self
.add_button(gtk
.STOCK_CANCEL
, gtk
.RESPONSE_CANCEL
)
51 self
.add_button(gtk
.STOCK_ADD
, gtk
.RESPONSE_OK
)
52 self
.set_default_response(gtk
.RESPONSE_OK
)
54 def response(box
, resp
):
55 if resp
== gtk
.RESPONSE_OK
:
58 self
.connect('response', response
)
60 self
.connect('delete-event', lambda box
, ev
: True)
62 def confirm_trust(self
, interface
, sigs
, iface_xml
):
63 valid_sigs
= [s
for s
in sigs
if isinstance(s
, gpg
.ValidSig
)]
65 raise SafeException('No valid signatures found')
67 self
.interfaces
[interface
] = (iface_xml
, valid_sigs
)
70 self
.tree_view
.expand_all()
73 def rebuild_model(self
):
74 ifaces
= self
.interfaces
.keys()
75 ifaces
.sort() # Keep the order stable
78 for sig
in self
.interfaces
[i
][1]:
79 titer
= self
.model
.append()
80 self
.model
[titer
][0] = pretty_fp(sig
.fingerprint
)
81 self
.model
[titer
][1] = sig
84 for row
in self
.model
:
86 print "Trusing", sig
.fingerprint
87 trust
.trust_db
.trust_key(sig
.fingerprint
)
89 ifaces
= self
.interfaces
93 iface_xml
, sigs
= ifaces
[i
]
94 if not gui
.policy
.update_interface_if_trusted(i
, sigs
, iface_xml
):
95 raise Exception('Bug: still not trusted!!')
97 # Singleton, to avoid opening too many windows at once
98 trust_box
= TrustBox()