summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-10-14 15:51:30 +0200
committermathieui <mathieui@mathieui.net>2014-10-14 15:51:30 +0200
commit545ad1bd71e87a482b357f5b49a0898be73478d8 (patch)
treee513febd81f0c3d338b047f0672e5353e92534d4 /src
parent37fe4be7ec35278f23c9f5c07607c3a14e6b6753 (diff)
parent088c6c6a0b46309d17c4b0ba5939a2dd200c7002 (diff)
downloadpoezio-545ad1bd71e87a482b357f5b49a0898be73478d8.tar.gz
poezio-545ad1bd71e87a482b357f5b49a0898be73478d8.tar.bz2
poezio-545ad1bd71e87a482b357f5b49a0898be73478d8.tar.xz
poezio-545ad1bd71e87a482b357f5b49a0898be73478d8.zip
Merge branch 'master' of git.poez.io:poezio into slix
Conflicts: src/core/handlers.py src/tabs/xmltab.py
Diffstat (limited to 'src')
-rw-r--r--src/core/commands.py2
-rw-r--r--src/core/handlers.py72
-rw-r--r--src/tabs/conversationtab.py28
-rw-r--r--src/tabs/muctab.py7
-rw-r--r--src/tabs/xmltab.py17
-rw-r--r--src/windows/input_placeholders.py6
6 files changed, 87 insertions, 45 deletions
diff --git a/src/core/commands.py b/src/core/commands.py
index 07b0cb1e..c27263e2 100644
--- a/src/core/commands.py
+++ b/src/core/commands.py
@@ -943,7 +943,7 @@ def command_xml_tab(self, arg=''):
def command_adhoc(self, arg):
arg = arg.split()
if len(arg) > 1:
- return self.command_help('list')
+ return self.command_help('ad-hoc')
elif arg:
jid = safeJID(arg[0])
else:
diff --git a/src/core/handlers.py b/src/core/handlers.py
index fe0865d3..b46b949f 100644
--- a/src/core/handlers.py
+++ b/src/core/handlers.py
@@ -9,7 +9,7 @@ import curses
import ssl
import time
import functools
-from hashlib import sha1
+from hashlib import sha1, sha512
from gettext import gettext as _
from slixmpp import InvalidJID
@@ -891,24 +891,25 @@ def on_session_start(self, event):
def _join_initial_rooms(bookmarks):
"""Join all rooms given in the iterator `bookmarks`"""
for bm in bookmarks:
- tab = self.get_tab_by_name(bm.jid, tabs.MucTab)
- nick = bm.nick if bm.nick else self.own_nick
- if not tab:
- self.open_new_room(bm.jid, nick, False)
- self.initial_joins.append(bm.jid)
- histo_length = config.get('muc_history_length', 20)
- if histo_length == -1:
- histo_length = None
- if histo_length is not None:
- histo_length = str(histo_length)
- # do not join rooms that do not have autojoin
- # but display them anyway
- if bm.autojoin:
- muc.join_groupchat(self, bm.jid, nick,
- passwd=bm.password,
- maxhistory=histo_length,
- status=self.status.message,
- show=self.status.show)
+ if bm.autojoin or config.get('open_all_bookmarks', False):
+ tab = self.get_tab_by_name(bm.jid, tabs.MucTab)
+ nick = bm.nick if bm.nick else self.own_nick
+ if not tab:
+ self.open_new_room(bm.jid, nick, False)
+ self.initial_joins.append(bm.jid)
+ histo_length = config.get('muc_history_length', 20)
+ if histo_length == -1:
+ histo_length = None
+ if histo_length is not None:
+ histo_length = str(histo_length)
+ # do not join rooms that do not have autojoin
+ # but display them anyway
+ if bm.autojoin:
+ muc.join_groupchat(self, bm.jid, nick,
+ passwd=bm.password,
+ maxhistory=histo_length,
+ status=self.status.message,
+ show=self.status.show)
def _join_remote_only():
remote_bookmarks = (bm for bm in bookmark.bookmarks if (bm.method in ("pep", "privatexml")))
_join_initial_rooms(remote_bookmarks)
@@ -1101,16 +1102,27 @@ def validate_ssl(self, pem):
config.set_and_save('certificate', cert)
der = ssl.PEM_cert_to_DER_cert(pem)
- digest = sha1(der).hexdigest().upper()
- found_cert = ':'.join(i + j for i, j in zip(digest[::2], digest[1::2]))
+ sha1_digest = sha1(der).hexdigest().upper()
+ sha1_found_cert = ':'.join(i + j for i, j in zip(sha1_digest[::2], sha1_digest[1::2]))
+ sha2_digest = sha512(der).hexdigest().upper()
+ sha2_found_cert = ':'.join(i + j for i, j in zip(sha2_digest[::2], sha2_digest[1::2]))
if cert:
- if found_cert == cert:
- log.debug('Cert %s OK', found_cert)
+ if sha1_found_cert == cert:
+ log.debug('Cert %s OK', sha1_found_cert)
+ log.debug('Current hash is SHA-1, moving to SHA-2 (%s)',
+ sha2_found_cert)
+ config.set_and_save('certificate', sha2_found_cert)
+ return
+ elif sha2_found_cert == cert:
+ log.debug('Cert %s OK', sha2_found_cert)
return
else:
saved_input = self.current_tab().input
- log.debug('\nWARNING: CERTIFICATE CHANGED old: %s, new: %s\n', cert, found_cert)
- input = windows.YesNoInput(text="WARNING! Server certificate has changed, accept? (y/n) (%s)" % found_cert)
+ log.debug('\nWARNING: CERTIFICATE CHANGED old: %s, new: %s\n', cert, sha2_found_cert)
+ self.information('New certificate found (sha-2 hash:'
+ ' %s)\nPlease validate or abort' % sha2_found_cert,
+ 'Warning')
+ input = windows.YesNoInput(text="WARNING! Server certificate has changed, accept? (y/n)")
self.current_tab().input = input
input.resize(1, self.current_tab().width, self.current_tab().height-1, 0)
input.refresh()
@@ -1121,16 +1133,16 @@ def validate_ssl(self, pem):
self.current_tab().input = saved_input
self.paused = False
if input.value:
- self.information('Setting new certificate: old: %s, new: %s' % (cert, found_cert), 'Info')
- log.debug('Setting certificate to %s', found_cert)
- if not config.silent_set('certificate', found_cert):
+ self.information('Setting new certificate: old: %s, new: %s' % (cert, sha2_found_cert), 'Info')
+ log.debug('Setting certificate to %s', sha2_found_cert)
+ if not config.silent_set('certificate', sha2_found_cert):
self.information(_('Unable to write in the config file'), 'Error')
else:
self.information('You refused to validate the certificate. You are now disconnected', 'Info')
self.xmpp.disconnect()
else:
- log.debug('First time. Setting certificate to %s', found_cert)
- if not config.silent_set('certificate', found_cert):
+ log.debug('First time. Setting certificate to %s', sha2_found_cert)
+ if not config.silent_set('certificate', sha2_found_cert):
self.information(_('Unable to write in the config file'), 'Error')
def _composing_tab_state(tab, state):
diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py
index a6cb0d59..cc9e6b2e 100644
--- a/src/tabs/conversationtab.py
+++ b/src/tabs/conversationtab.py
@@ -385,11 +385,15 @@ class DynamicConversationTab(ConversationTab):
assert(resource)
if resource != self.locked_resource:
self.locked_resource = resource
-
- message = _('\x19%s}Conversation locked to %s/%s.') % (
- dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
- self.name,
- resource)
+ info = '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ jid_c = '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID)
+
+ message = _('%(info)sConversation locked to '
+ '%(jid_c)s%(jid)s/%(resource)s%(info)s.') % {
+ 'info': info,
+ 'jid_c': jid_c,
+ 'jid': self.name,
+ 'resource': resource}
self.add_message(message, typ=0)
self.check_features()
@@ -405,16 +409,18 @@ class DynamicConversationTab(ConversationTab):
self.remote_wants_chatstates = None
if self.locked_resource != None:
self.locked_resource = None
+ info = '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ jid_c = '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID)
if from_:
- message = _('\x19%s}Conversation unlocked '
- '(received activity from %s).') % (
- dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
- from_)
+ message = _('%(info)sConversation unlocked (received activity'
+ ' from %(jid_c)s%(jid)s%(info)s).') % {
+ 'info': info,
+ 'jid_c': jid_c,
+ 'jid': from_}
self.add_message(message, typ=0)
else:
- message = _('\x19%s}Conversation unlocked.') % (
- dump_tuple(get_theme().COLOR_INFORMATION_TEXT))
+ message = _('%sConversation unlocked.') % info
self.add_message(message, typ=0)
def get_dest_jid(self):
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index 5ebaf522..f526ec80 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -355,7 +355,8 @@ class MucTab(ChatTab):
dump_tuple(theme.color_role(user.role)),
user.role or 'None',
'\n%s' % user.status if user.status else '')
- self.core.information(info, 'Info')
+ self.add_message(info, typ=0)
+ self.core.refresh_window()
def command_configure(self, arg):
"""
@@ -1525,11 +1526,11 @@ class MucTab(ChatTab):
config.get_by_tabname('notify_messages',
True, self.name)):
self.state = 'message'
- if time:
+ if time and not txt.startswith('/me'):
txt = '\x19%(info_col)s}%(txt)s' % {
'txt': txt,
'info_col': dump_tuple(get_theme().COLOR_LOG_MSG)}
- elif (not nickname or time) and not txt.startswith('/me '):
+ elif not nickname:
txt = '\x19%(info_col)s}%(txt)s' % {
'txt': txt,
'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}
diff --git a/src/tabs/xmltab.py b/src/tabs/xmltab.py
index 7cbc9fb6..083e97c5 100644
--- a/src/tabs/xmltab.py
+++ b/src/tabs/xmltab.py
@@ -11,12 +11,14 @@ import logging
log = logging.getLogger(__name__)
import curses
+import os
from slixmpp.xmlstream import matcher
from slixmpp.xmlstream.handler import Callback
from . import Tab
import windows
+from xhtml import clean_text
class XMLTab(Tab):
def __init__(self):
@@ -45,6 +47,10 @@ class XMLTab(Tab):
usage=_('<xml mask>'),
desc=_('Show only the stanzas matching the given xml mask.'),
shortdesc=_('Filter by xml mask.'))
+ self.register_command('dump', self.command_dump,
+ usage=_('<filename>'),
+ desc=_('Writes the content of the XML buffer into a file.'),
+ shortdesc=_('Write in a file.'))
self.input = self.default_help_message
self.key_func['^T'] = self.close
self.key_func['^I'] = self.completion
@@ -111,6 +117,17 @@ class XMLTab(Tab):
self.filter = ''
self.refresh()
+ def command_dump(self, arg):
+ """/dump <filename>"""
+ xml = self.core.xml_buffer.messages[:]
+ text = '\n'.join(('%s %s' % (msg.str_time, clean_text(msg.txt)) for msg in xml))
+ filename = os.path.expandvars(os.path.expanduser(arg))
+ try:
+ with open(filename, 'w') as fd:
+ fd.write(text)
+ except Exception as e:
+ self.core.information('Could not write the XML dump: %s' % e, 'Error')
+
def on_slash(self):
"""
'/' is pressed, activate the input
diff --git a/src/windows/input_placeholders.py b/src/windows/input_placeholders.py
index 0887cfc5..8bcf1524 100644
--- a/src/windows/input_placeholders.py
+++ b/src/windows/input_placeholders.py
@@ -33,6 +33,9 @@ class HelpText(Win):
def do_command(self, key, raw=False):
return False
+ def on_delete(self):
+ return
+
class YesNoInput(Win):
"""
A Window just displaying a Yes/No input
@@ -77,3 +80,6 @@ class YesNoInput(Win):
keyboard.continuation_keys_callback = cb
keyboard.continuation_keys_callback = cb
+ def on_delete(self):
+ return
+