#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2011-2012 Sebastien Helleu <flashcode@flashtux.org>
+# qweechat.py - WeeChat remote GUI using Qt toolkit
+#
+# Copyright (C) 2011-2013 Sebastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#
#
#
-# QWeeChat - WeeChat remote GUI using Qt toolkit.
-# (this script requires WeeChat 0.3.7 or newer, running on local or remote host)
+# This script requires WeeChat 0.3.7 or newer, running on local or remote host.
#
# History:
#
if self.config.getboolean('relay', 'autoconnect'):
self.network.connect_weechat(self.config.get('relay', 'server'),
self.config.get('relay', 'port'),
+ self.config.get('relay', 'ssl') == 'on',
self.config.get('relay', 'password'))
self.show()
def open_about_dialog(self):
messages = ['<b>%s</b> %s' % (NAME, VERSION),
- '© 2011-2012 %s <<a href="mailto:%s">%s</a>>' % (AUTHOR, AUTHOR_MAIL, AUTHOR_MAIL),
+ '© 2011-2013 %s <<a href="mailto:%s">%s</a>>' % (AUTHOR, AUTHOR_MAIL, AUTHOR_MAIL),
+ '',
+ 'Running with %s' % ('PySide' if qt_compat.uses_pyside else 'PyQt4'),
'',
'WeeChat site: <a href="%s">%s</a>' % (WEECHAT_SITE, WEECHAT_SITE),
'']
def open_connection_dialog(self):
values = {}
- for option in ('server', 'port', 'password'):
+ for option in ('server', 'port', 'ssl', 'password'):
values[option] = self.config.get('relay', option)
self.connection_dialog = ConnectionDialog(values, self)
self.connection_dialog.dialog_buttons.accepted.connect(self.connect_weechat)
def connect_weechat(self):
self.network.connect_weechat(self.connection_dialog.fields['server'].text(),
self.connection_dialog.fields['port'].text(),
+ self.connection_dialog.fields['ssl'].isChecked(),
self.connection_dialog.fields['password'].text())
self.connection_dialog.close()
def network_status_set(self, status, extra):
pal = self.network_status.palette()
- if self.network.is_connected():
+ if status == self.network.status_connected:
pal.setColor(self.network_status.foregroundRole(), QtGui.QColor('green'))
else:
pal.setColor(self.network_status.foregroundRole(), QtGui.QColor('#aa0000'))
+ ssl = ' (SSL)' if status != self.network.status_disconnected and self.network.is_ssl() else ''
self.network_status.setPalette(pal)
icon = self.network.status_icon(status)
if icon:
- self.network_status.setText('<img src="data/icons/%s"> %s' % (icon, status.capitalize()))
+ self.network_status.setText('<img src="data/icons/%s"> %s' % (icon, status.capitalize() + ssl))
else:
self.network_status.setText(status.capitalize())
if status == self.network.status_disconnected:
'message (%d bytes):\n%s'
% (len(message), protocol.hex_and_ascii(message, 20)),
forcecolor='#008800')
- proto = protocol.Protocol()
- message = proto.decode(str(message))
- if message.uncompressed:
- self.debug_display(0, '==>',
- 'message uncompressed (%d bytes):\n%s'
- % (message.size_uncompressed,
- protocol.hex_and_ascii(message.uncompressed, 20)),
- forcecolor='#008800')
- self.debug_display(0, '', 'Message: %s' % message)
- self.parse_message(message)
+ try:
+ proto = protocol.Protocol()
+ message = proto.decode(str(message))
+ if message.uncompressed:
+ self.debug_display(0, '==>',
+ 'message uncompressed (%d bytes):\n%s'
+ % (message.size_uncompressed,
+ protocol.hex_and_ascii(message.uncompressed, 20)),
+ forcecolor='#008800')
+ self.debug_display(0, '', 'Message: %s' % message)
+ self.parse_message(message)
+ except:
+ print("Error while decoding message from WeeChat")
+ self.network.disconnect_weechat()
def parse_message(self, message):
if message.msgid.startswith('debug'):