summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/gpg/__init__.py13
-rw-r--r--src/tabs.py16
-rw-r--r--src/windows.py24
3 files changed, 43 insertions, 10 deletions
diff --git a/plugins/gpg/__init__.py b/plugins/gpg/__init__.py
index a2742d3c..873aa285 100644
--- a/plugins/gpg/__init__.py
+++ b/plugins/gpg/__init__.py
@@ -7,6 +7,7 @@ log = logging.getLogger(__name__)
from plugin import BasePlugin
+from tabs import ConversationTab
NS_SIGNED = "jabber:x:signed"
NS_ENCRYPTED = "jabber:x:encrypted"
@@ -51,8 +52,11 @@ class Plugin(BasePlugin):
self.add_event_handler('conversation_say_after', self.on_conversation_say)
self.add_event_handler('conversation_msg', self.on_conversation_msg)
+ ConversationTab.add_information_element('gpg', self.display_encryption_status)
+
def cleanup(self):
self.send_unsigned_presence()
+ ConversationTab.remove_information_element('gpg')
def sign_presence(self, presence):
"""
@@ -138,6 +142,15 @@ class Plugin(BasePlugin):
return
message['body'] = str(decrypted)
+ def display_encryption_status(self, jid):
+ """
+ Returns the status of encryption for the associated jid. This is to be used
+ in the ConversationTab’s InfoWin.
+ """
+ if jid.full not in self.contacts.keys():
+ return ''
+ return ' GPG Key: %s' % self.contacts[jid.full]
+
def remove_gpg_headers(self, text):
lines = text.splitlines()
while lines[0].strip() != '':
diff --git a/src/tabs.py b/src/tabs.py
index d7f1323b..472a15fa 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1921,6 +1921,7 @@ class ConversationTab(ChatTab):
The tab containg a normal conversation (not from a MUC)
"""
plugin_commands = {}
+ additional_informations = {}
message_type = 'chat'
def __init__(self, jid):
ChatTab.__init__(self)
@@ -1941,6 +1942,17 @@ class ConversationTab(ChatTab):
self.resize()
self.update_commands()
+ @staticmethod
+ def add_information_element(plugin_name, callback):
+ """
+ Lets a plugin add its own information to the ConversationInfoWin
+ """
+ ConversationTab.additional_informations[plugin_name] = callback
+
+ @staticmethod
+ def remove_information_element(plugin_name):
+ del ConversationTab.additional_informations[plugin_name]
+
def completion(self):
self.complete_commands(self.input)
@@ -2013,13 +2025,13 @@ class ConversationTab(ChatTab):
log.debug(' TAB Refresh: %s'%self.__class__.__name__)
self.text_win.refresh()
self.upper_bar.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()))
- self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate)
+ self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate, ConversationTab.additional_informations)
self.info_win.refresh()
self.tab_win.refresh()
self.input.refresh()
def refresh_info_header(self):
- self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate)
+ self.info_header.refresh(self.get_name(), roster.get_contact_by_jid(self.get_name()), self.text_win, self.chatstate, ConversationTab.additional_informations)
self.input.refresh()
def get_name(self):
diff --git a/src/windows.py b/src/windows.py
index ed5dfca2..d7471d40 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -368,19 +368,19 @@ class ConversationInfoWin(InfoWin):
about the user we are talking to
"""
color_show = {'xa': lambda: get_theme().COLOR_STATUS_XA,
- 'none': lambda: get_theme().COLOR_STATUS_ONLINE,
- '': lambda: get_theme().COLOR_STATUS_ONLINE,
- 'available': lambda: get_theme().COLOR_STATUS_ONLINE,
- 'dnd': lambda: get_theme().COLOR_STATUS_DND,
- 'away': lambda: get_theme().COLOR_STATUS_AWAY,
- 'chat': lambda: get_theme().COLOR_STATUS_CHAT,
- 'unavailable': lambda: get_theme().COLOR_STATUS_UNAVAILABLE
+ 'none': lambda: get_theme().COLOR_STATUS_ONLINE,
+ '': lambda: get_theme().COLOR_STATUS_ONLINE,
+ 'available': lambda: get_theme().COLOR_STATUS_ONLINE,
+ 'dnd': lambda: get_theme().COLOR_STATUS_DND,
+ 'away': lambda: get_theme().COLOR_STATUS_AWAY,
+ 'chat': lambda: get_theme().COLOR_STATUS_CHAT,
+ 'unavailable': lambda: get_theme().COLOR_STATUS_UNAVAILABLE
}
def __init__(self):
InfoWin.__init__(self)
- def refresh(self, jid, contact, window, chatstate):
+ def refresh(self, jid, contact, window, chatstate, informations):
# contact can be None, if we receive a message
# from someone not in our roster. In this case, we display
# only the maximum information from the message we can get.
@@ -405,9 +405,17 @@ class ConversationInfoWin(InfoWin):
self.write_resource_information(resource)
self.print_scroll_position(window)
self.write_chatstate(chatstate)
+ self.write_additional_informations(informations, jid)
self.finish_line(get_theme().COLOR_INFORMATION_BAR)
self._refresh()
+ def write_additional_informations(self, informations, jid):
+ """
+ Write all informations added by plugins by getting the
+ value returned by the callbacks.
+ """
+ for key in informations:
+ self.addstr(informations[key](jid), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
def write_resource_information(self, resource):
"""
Write the informations about the resource