From beaa87758b054c836307653351da5e5c9463ed16 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 17 May 2012 11:28:15 +0200 Subject: [PATCH] Add signals "upgrade" and "upgrade_ended" --- src/qweechat/network.py | 14 ++++++++++---- src/qweechat/qweechat.py | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/qweechat/network.py b/src/qweechat/network.py index 55f01d9..e9f25bc 100644 --- a/src/qweechat/network.py +++ b/src/qweechat/network.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # -# Copyright (C) 2011 Sebastien Helleu +# Copyright (C) 2011-2012 Sebastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -28,8 +28,8 @@ import qt_compat QtCore = qt_compat.import_module('QtCore') QtNetwork = qt_compat.import_module('QtNetwork') -_PROTO_INIT_CMDS = ['init password=%(password)s,compression=gzip', - '(listbuffers) hdata buffer:gui_buffers(*) number,full_name,short_name,type,nicklist,title,local_variables', +_PROTO_INIT_CMD = ['init password=%(password)s,compression=gzip'] +_PROTO_SYNC_CMDS = ['(listbuffers) hdata buffer:gui_buffers(*) number,full_name,short_name,type,nicklist,title,local_variables', '(listlines) hdata buffer:gui_buffers(*)/own_lines/first_line(*)/data date,displayed,prefix,message', '(nicklist) nicklist', 'sync', @@ -61,7 +61,7 @@ class Network(QtCore.QObject): """Slot: socket connected.""" self.statusChanged.emit(self.status_connected, None) if self._password: - self._socket.write('\n'.join(_PROTO_INIT_CMDS) % {'password': str(self._password)}) + self._socket.write('\n'.join(_PROTO_INIT_CMD + _PROTO_SYNC_CMDS) % {'password': str(self._password)}) def _socket_error(self, error): """Slot: socket error.""" @@ -121,6 +121,12 @@ class Network(QtCore.QObject): def send_to_weechat(self, message): self._socket.write(str(message)) + def desync_weechat(self): + self._socket.write('desync\n') + + def sync_weechat(self): + self._socket.write('\n'.join(_PROTO_SYNC_CMDS)) + def status_icon(self, status): icon = {self.status_disconnected: 'dialog-close.png', self.status_connecting: 'dialog-close.png', diff --git a/src/qweechat/qweechat.py b/src/qweechat/qweechat.py index e40346d..f622c68 100755 --- a/src/qweechat/qweechat.py +++ b/src/qweechat/qweechat.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # -# Copyright (C) 2011 Sebastien Helleu +# Copyright (C) 2011-2012 Sebastien Helleu # # This file is part of QWeeChat, a Qt remote GUI for WeeChat. # @@ -322,6 +322,10 @@ class MainWindow(QtGui.QMainWindow): self.buffers[index].update_prompt() elif message.msgid == '_buffer_closing': self.remove_buffer(index) + elif message.msgid == '_upgrade': + self.network.desync_weechat() + elif message.msgid == '_upgrade_ended': + self.network.sync_weechat() def create_buffer(self, item): buf = Buffer(item)