def init(self): self.contacts = {} # a dict of {full-JID: 'signed'/'valid'/'invalid'/'disabled'} # Whenever we receive a signed presence from a JID, we add it to this # dict, this way we know if we can encrypt the messages we will send to # this JID. # If that resource sends a non-signed presence, then we remove it # from that dict and stop encrypting our messages. # 'disabled' means that the user do NOT want to encrypt its messages # even if the key is valid. self.gpg = gnupg.GPG() self.keyid = self.config.get('keyid', '') or None self.passphrase = self.config.get('passphrase', '') or None if not self.keyid: self.api.information('No GPG keyid provided in the configuration', 'Warning') self.api.add_event_handler('send_normal_presence', self.sign_presence) self.api.add_slix_event_handler('presence', self.on_normal_presence) self.api.add_event_handler('conversation_say_after', self.on_conversation_say) self.api.add_event_handler('conversation_msg', self.on_conversation_msg) self.api.add_tab_command(ConversationTab, 'gpg', self.command_gpg, usage='<force|disable|setkey> [jid] [keyid]', help='Force or disable gpg encryption with the fulljid of the current conversation. The setkey argument lets you associate a keyid with the given bare JID.', short='Manage the GPG status', completion=self.gpg_completion) ConversationTab.add_information_element('gpg', self.display_encryption_status)
def init(self): self.contacts = {} # a dict of {full-JID: OTR object} self.add_event_handler('conversation_say_after', self.on_conversation_say) self.add_event_handler('conversation_msg', self.on_conversation_msg) self.add_tab_command(ConversationTab, 'otr', self.command_otr, "Usage: /otr <start|end>\notr: Start or stop OTR for the current conversation", self.otr_completion) ConversationTab.add_information_element('otr', self.display_encryption_status)
def init(self): # set the default values from the config global OTR_DIR OTR_DIR = os.path.expanduser(self.config.get('keys_dir', '') or OTR_DIR) try: os.makedirs(OTR_DIR) except OSError as e: if e.errno != 17: self.api.information('The OTR-specific folder could not ' 'be created. Poezio will be unable ' 'to save keys and trusts', 'OTR') except: self.api.information('The OTR-specific folder could not ' 'be created. Poezio will be unable ' 'to save keys and trusts', 'OTR') self.api.add_event_handler('conversation_msg', self.on_conversation_msg) self.api.add_event_handler('private_msg', self.on_conversation_msg) self.api.add_event_handler('conversation_say_after', self.on_conversation_say) self.api.add_event_handler('private_say_after', self.on_conversation_say) ConversationTab.add_information_element('otr', self.display_encryption_status) PrivateTab.add_information_element('otr', self.display_encryption_status) self.account = PoezioAccount(self.core.xmpp.boundjid.bare, OTR_DIR) self.account.load_trusts() self.contexts = {} usage = '<start|refresh|end|fpr|ourfpr|drop|trust|untrust>' shortdesc = 'Manage an OTR conversation' desc = ('Manage an OTR conversation.\n' 'start/refresh: Start or refresh a conversation\n' 'end: End a conversation\n' 'fpr: Show the fingerprint of the key of the remote user\n' 'ourfpr: Show the fingerprint of your own key\n' 'drop: Remove the current key (FOREVER)\n' 'trust: Set this key for this contact as trusted\n' 'untrust: Remove the trust for the key of this contact\n') smp_usage = '<abort|ask|answer> [question] [answer]' smp_short = 'Identify a contact' smp_desc = ('Verify the identify of your contact by using a pre-defined secret.\n' 'abort: Abort an ongoing verification\n' 'ask: Start a verification, with a question or not\n' 'answer: Finish a verification\n') self.api.add_tab_command(ConversationTab, 'otrsmp', self.command_smp, help=smp_desc, usage=smp_usage, short=smp_short, completion=self.completion_smp) self.api.add_tab_command(PrivateTab, 'otrsmp', self.command_smp, help=smp_desc, usage=smp_usage, short=smp_short, completion=self.completion_smp) self.api.add_tab_command(ConversationTab, 'otr', self.command_otr, help=desc, usage=usage, short=shortdesc, completion=self.completion_otr) self.api.add_tab_command(PrivateTab, 'otr', self.command_otr, help=desc, usage=usage, short=shortdesc, completion=self.completion_otr)
def init(self): self.contacts = {} # a dict of {full-JID: OTR object} self.add_event_handler('conversation_say_after', self.on_conversation_say) self.add_event_handler('conversation_msg', self.on_conversation_msg) self.add_tab_command( ConversationTab, 'otr', self.command_otr, "Usage: /otr <start|end>\notr: Start or stop OTR for the current conversation", self.otr_completion) ConversationTab.add_information_element('otr', self.display_encryption_status)
def init(self): # set the default values from the config allow_v2 = self.config.get('allow_v2', True) POLICY_FLAGS['ALLOW_V2'] = allow_v2 allow_v1 = self.config.get('allow_v1', False) POLICY_FLAGS['ALLOW_v1'] = allow_v1 global OTR_DIR OTR_DIR = os.path.expanduser(self.config.get('keys_dir', '') or OTR_DIR) try: os.makedirs(OTR_DIR) except OSError as e: if e.errno != 17: self.api.information('The OTR-specific folder could not be created' ' poezio will be unable to save keys and trusts', 'OTR') except: self.api.information('The OTR-specific folder could not be created' ' poezio will be unable to save keys and trusts', 'OTR') self.api.add_event_handler('conversation_msg', self.on_conversation_msg) self.api.add_event_handler('private_msg', self.on_conversation_msg) self.api.add_event_handler('conversation_say_after', self.on_conversation_say) self.api.add_event_handler('private_say_after', self.on_conversation_say) ConversationTab.add_information_element('otr', self.display_encryption_status) PrivateTab.add_information_element('otr', self.display_encryption_status) self.account = PoezioAccount(self.core.xmpp.boundjid.bare, OTR_DIR) self.account.load_trusts() self.contexts = {} usage = '[start|refresh|end|fpr|ourfpr|drop|trust|untrust]' shortdesc = 'Manage an OTR conversation' desc = ('Manage an OTR conversation.\n' 'start/refresh: Start or refresh a conversation\n' 'end: End a conversation\n' 'fpr: Show the fingerprint of the key of the remote user\n' 'ourfpr: Show the fingerprint of your own key\n' 'drop: Remove the current key (FOREVER)\n' 'trust: Set this key for this contact as trusted\n' 'untrust: Remove the trust for the key of this contact\n') self.api.add_tab_command(ConversationTab, 'otr', self.command_otr, help=desc, usage=usage, short=shortdesc, completion=self.completion_otr) self.api.add_tab_command(PrivateTab, 'otr', self.command_otr, help=desc, usage=usage, short=shortdesc, completion=self.completion_otr)
def cleanup(self): ConversationTab.remove_information_element('otr') self.del_tab_command(ConversationTab, 'otr')
def cleanup(self): self.send_unsigned_presence() ConversationTab.remove_information_element('gpg') self.del_tab_command(ConversationTab, 'gpg')
def cleanup(self): for context in self.contexts.values(): context.disconnect() ConversationTab.remove_information_element('otr') PrivateTab.remove_information_element('otr')
def init(self): # set the default values from the config allow_v2 = self.config.get('allow_v2', True) POLICY_FLAGS['ALLOW_V2'] = allow_v2 allow_v1 = self.config.get('allow_v1', False) POLICY_FLAGS['ALLOW_v1'] = allow_v1 global OTR_DIR OTR_DIR = os.path.expanduser( self.config.get('keys_dir', '') or OTR_DIR) try: os.makedirs(OTR_DIR) except OSError as e: if e.errno != 17: self.api.information( 'The OTR-specific folder could not be created' ' poezio will be unable to save keys and trusts', 'OTR') except: self.api.information( 'The OTR-specific folder could not be created' ' poezio will be unable to save keys and trusts', 'OTR') self.api.add_event_handler('conversation_msg', self.on_conversation_msg) self.api.add_event_handler('private_msg', self.on_conversation_msg) self.api.add_event_handler('conversation_say_after', self.on_conversation_say) self.api.add_event_handler('private_say_after', self.on_conversation_say) ConversationTab.add_information_element('otr', self.display_encryption_status) PrivateTab.add_information_element('otr', self.display_encryption_status) self.account = PoezioAccount(self.core.xmpp.boundjid.bare, OTR_DIR) self.account.load_trusts() self.contexts = {} usage = '[start|refresh|end|fpr|ourfpr|drop|trust|untrust]' shortdesc = 'Manage an OTR conversation' desc = ('Manage an OTR conversation.\n' 'start/refresh: Start or refresh a conversation\n' 'end: End a conversation\n' 'fpr: Show the fingerprint of the key of the remote user\n' 'ourfpr: Show the fingerprint of your own key\n' 'drop: Remove the current key (FOREVER)\n' 'trust: Set this key for this contact as trusted\n' 'untrust: Remove the trust for the key of this contact\n') self.api.add_tab_command(ConversationTab, 'otr', self.command_otr, help=desc, usage=usage, short=shortdesc, completion=self.completion_otr) self.api.add_tab_command(PrivateTab, 'otr', self.command_otr, help=desc, usage=usage, short=shortdesc, completion=self.completion_otr)