def update_context_list(self): self.config_dialog.fpr_model.clear() for us in self.us.itervalues(): for uid, ctx in us.ctxs.iteritems(): for fpr, trust in ctx.trust.iteritems(): trust = False if ctx.state == potr.context.STATE_ENCRYPTED: if ctx.getCurrentKey().cfingerprint() == fpr: state = "encrypted" tip = enc_tip trust = bool(ctx.getCurrentTrust()) else: state = "unused" tip = unused_tip elif ctx.state == potr.context.STATE_FINISHED: state = "finished" tip = ended_tip else: state = 'inactive' tip = inactive_tip human_hash = potr.human_hash(fpr) self.config_dialog.fpr_model.append((uid, state, trust, '<tt>%s</tt>' % human_hash, us.name, tip, fpr))
def clipboard_button_cb(self, menuitem): mod, paths = self.fpr_view.get_selection().get_selected_rows() fprs = [] for path in paths: it = mod.get_iter(path) jid, fpr = mod.get(it, 0, 6) fprs.append('%s: %s' % (jid, potr.human_hash(fpr))) gtk.Clipboard().set_text('\n'.join(fprs)) gtk.Clipboard(selection='PRIMARY').set_text('\n'.join(fprs))
def update_context_list(self): self.config_dialog.fpr_model.clear() for us in self.us.itervalues(): usedFpr = set() for fjid, ctx in us.ctxs.iteritems(): # get active contexts first key = ctx.getCurrentKey() if not key: continue fpr = key.cfingerprint() usedFpr.add(fpr) human_hash = potr.human_hash(fpr) trust = bool(us.getTrust(ctx.trustName, fpr)) if ctx.state == potr.context.STATE_ENCRYPTED: state = "encrypted" tip = enc_tip elif ctx.state == potr.context.STATE_FINISHED: state = "finished" tip = ended_tip else: state = 'inactive' tip = inactive_tip self.config_dialog.fpr_model.append( (fjid, state, trust, '<tt>%s</tt>' % human_hash, us.name, tip, fpr)) for uid, trusts in us.trusts.iteritems(): for fpr, trust in trusts.iteritems(): if fpr in usedFpr: continue state = 'inactive' tip = inactive_tip human_hash = potr.human_hash(fpr) self.config_dialog.fpr_model.append( (uid, state, bool(trust), '<tt>%s</tt>' % human_hash, us.name, tip, fpr))
def update_context_list(self): self.config_dialog.fpr_model.clear() for us in self.us.itervalues(): usedFpr = set() for fjid, ctx in us.ctxs.iteritems(): # get active contexts first key = ctx.getCurrentKey() if not key: continue fpr = key.cfingerprint() usedFpr.add(fpr) human_hash = potr.human_hash(fpr) trust = bool(us.getTrust(ctx.trustName, fpr)) if ctx.state == potr.context.STATE_ENCRYPTED: state = "encrypted" tip = enc_tip elif ctx.state == potr.context.STATE_FINISHED: state = "finished" tip = ended_tip else: state = 'inactive' tip = inactive_tip self.config_dialog.fpr_model.append((fjid, state, trust, '<tt>%s</tt>' % human_hash, us.name, tip, fpr)) for uid, trusts in us.trusts.iteritems(): for fpr, trust in trusts.iteritems(): if fpr in usedFpr: continue state = 'inactive' tip = inactive_tip human_hash = potr.human_hash(fpr) self.config_dialog.fpr_model.append((uid, state, bool(trust), '<tt>%s</tt>' % human_hash, us.name, tip, fpr))
def verify_instructions(self): """Generate verification instructions for user.""" return """You can verify that this contact is who they claim to be in one of the following ways: 1) Verify each other's fingerprints using a secure channel: Your fingerprint : %(your_fingerprint)s %(peer)s's fingerprint : %(peer_fingerprint)s then use the command: /otr trust %(peer_nick)s %(peer_server)s 2) SMP pre-shared secret that you both know: /otr smp ask %(peer_nick)s %(peer_server)s <secret> 3) SMP pre-shared secret that you both know with a question: /otr smp ask %(peer_nick)s %(peer_server)s <secret> <question> """ % dict( your_fingerprint=self.user.getPrivkey(), peer=self.peer, peer_fingerprint=potr.human_hash( self.crypto.theirPubkey.cfingerprint()), peer_nick=self.peer_nick, peer_server=self.peer_server, )
def __init__(self, plugin, ctx, fpr=None, parent=None): fjid = ctx.peer gtk.Dialog.__init__(self, title=_('OTR settings for %s') % fjid, parent=parent, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.ctx = ctx self.fjid = fjid self.jid = gajim.get_room_and_nick_from_fjid(self.fjid)[0] self.account = ctx.user.accountname self.fpr = fpr self.plugin = plugin if self.fpr is None: key = self.ctx.getCurrentKey() if key is not None: self.fpr = key.cfingerprint() self.GTK_BUILDER_FILE_PATH = \ self.plugin.local_file_path('contact_otr_window.ui') self.xml = gtk.Builder() self.xml.set_translation_domain('gajim_plugins') self.xml.add_from_file(self.GTK_BUILDER_FILE_PATH) self.notebook = self.gw('otr_settings_notebook') self.child.pack_start(self.notebook) self.connect('response', self.on_response) self.gw('otr_default_checkbutton').connect('toggled', self._otr_default_checkbutton_toggled) # always set the label containing our fingerprint self.gw('our_fp_label').set_markup(our_fp_text % ctx.user.getPrivkey()) if self.fpr is None: # make the fingerprint widgets insensitive # when not encrypted for widget in self.gw('otr_fp_vbox').get_children(): widget.set_sensitive(False) # show that the fingerprint is unknown self.gw('their_fp_label').set_markup(their_fp_text % { 'jid': self.fjid, 'fp': _('unknown')}) self.gw('verified_combobox').set_active(-1) else: # make the fingerprint widgets sensitive when encrypted for widget in self.gw('otr_fp_vbox').get_children(): widget.set_sensitive(True) # show their fingerprint fp = potr.human_hash(self.fpr) self.gw('their_fp_label').set_markup(their_fp_text % { 'jid': self.fjid, 'fp': fp}) # set the trust combobox if ctx.getCurrentTrust(): self.gw('verified_combobox').set_active(1) else: self.gw('verified_combobox').set_active(0) otr_flags = self.plugin.get_flags(self.account, self.jid, fallback=False) if otr_flags is not None: self.gw('otr_default_checkbutton').set_active(0) for w in self.gw('otr_settings_vbox').get_children(): w.set_sensitive(True) else: # per-user settings not available, # using default settings otr_flags = self.plugin.get_flags(self.account) self.gw('otr_default_checkbutton').set_active(1) for w in self.gw('otr_settings_vbox').get_children(): w.set_sensitive(False) self.gw('otr_policy_allow_v2_checkbutton').set_active( otr_flags['ALLOW_V2']) self.gw('otr_policy_require_checkbutton').set_active( otr_flags['REQUIRE_ENCRYPTION']) self.gw('otr_policy_send_tag_checkbutton').set_active( otr_flags['SEND_TAG']) self.gw('otr_policy_start_on_tag_checkbutton').set_active( otr_flags['WHITESPACE_START_AKE']) self.child.show_all()
def __init__(self, plugin, ctx, fpr=None, parent=None): fjid = ctx.peer gtk.Dialog.__init__(self, title=_('OTR settings for %s') % fjid, parent=parent, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) self.ctx = ctx self.fjid = fjid self.jid = gajim.get_room_and_nick_from_fjid(self.fjid)[0] self.account = ctx.user.accountname self.fpr = fpr self.plugin = plugin if self.fpr is None: key = self.ctx.getCurrentKey() if key is not None: self.fpr = key.cfingerprint() self.GTK_BUILDER_FILE_PATH = \ self.plugin.local_file_path('contact_otr_window.ui') self.xml = gtk.Builder() self.xml.set_translation_domain('gajim_plugins') self.xml.add_from_file(self.GTK_BUILDER_FILE_PATH) self.notebook = self.gw('otr_settings_notebook') self.child.pack_start(self.notebook) self.connect('response', self.on_response) self.gw('otr_default_checkbutton').connect( 'toggled', self._otr_default_checkbutton_toggled) # always set the label containing our fingerprint self.gw('our_fp_label').set_markup(our_fp_text % ctx.user.getPrivkey()) if self.fpr is None: # make the fingerprint widgets insensitive # when not encrypted for widget in self.gw('otr_fp_vbox').get_children(): widget.set_sensitive(False) # show that the fingerprint is unknown self.gw('their_fp_label').set_markup(their_fp_text % { 'jid': self.fjid, 'fp': _('unknown') }) self.gw('verified_combobox').set_active(-1) else: # make the fingerprint widgets sensitive when encrypted for widget in self.gw('otr_fp_vbox').get_children(): widget.set_sensitive(True) # show their fingerprint fp = potr.human_hash(self.fpr) self.gw('their_fp_label').set_markup(their_fp_text % { 'jid': self.fjid, 'fp': fp }) # set the trust combobox if ctx.getCurrentTrust(): self.gw('verified_combobox').set_active(1) else: self.gw('verified_combobox').set_active(0) otr_flags = self.plugin.get_flags(self.account, self.jid, fallback=False) if otr_flags is not None: self.gw('otr_default_checkbutton').set_active(0) for w in self.gw('otr_settings_vbox').get_children(): w.set_sensitive(True) else: # per-user settings not available, # using default settings otr_flags = self.plugin.get_flags(self.account) self.gw('otr_default_checkbutton').set_active(1) for w in self.gw('otr_settings_vbox').get_children(): w.set_sensitive(False) self.gw('otr_policy_allow_v2_checkbutton').set_active( otr_flags['ALLOW_V2']) self.gw('otr_policy_require_checkbutton').set_active( otr_flags['REQUIRE_ENCRYPTION']) self.gw('otr_policy_send_tag_checkbutton').set_active( otr_flags['SEND_TAG']) self.gw('otr_policy_start_on_tag_checkbutton').set_active( otr_flags['WHITESPACE_START_AKE']) self.child.show_all()