summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-03-20 01:46:44 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-03-20 01:46:44 +0100
commitcba3adcced7f6fa0670ba5012bcd59974c05ea09 (patch)
tree614e3c90d45349037d8b988394db55928aef1b47
parent6e14fce61f12dc35d0f0a88f12f1cbf58fd58d7a (diff)
downloadpoezio-cba3adcced7f6fa0670ba5012bcd59974c05ea09.tar.gz
poezio-cba3adcced7f6fa0670ba5012bcd59974c05ea09.tar.bz2
poezio-cba3adcced7f6fa0670ba5012bcd59974c05ea09.tar.xz
poezio-cba3adcced7f6fa0670ba5012bcd59974c05ea09.zip
Command connect, to reconnect if needed. Fixed #1149
-rw-r--r--src/core.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/core.py b/src/core.py
index 031c4127..803cbe38 100644
--- a/src/core.py
+++ b/src/core.py
@@ -120,6 +120,7 @@ class Core(object):
'list': (self.command_list, _('Usage: /list\nList: get the list of public chatrooms on the specified server'), self.completion_list),
'message': (self.command_message, _('Usage: /message <jid> [optional message]\nMessage: Open a conversation with the specified JID (even if it is not in our roster), and send a message to it, if specified'), None),
'version': (self.command_version, _('Usage: /version <jid>\nVersion: get the software version of the given JID (usually its XMPP client and Operating System)'), None),
+ 'connect': (self.command_reconnect, _('Usage: /connect\nConnect: disconnect from the remote server if you are currently connected and then connect to it again'), None),
}
self.key_func = {
@@ -970,6 +971,12 @@ class Core(object):
res.get('os') or _('on an unknown platform'))
self.information(version)
+ def command_reconnect(self, args):
+ """
+ /reconnect
+ """
+ self.disconnect(True)
+
def command_list(self, arg):
"""
/list <server>
@@ -1247,6 +1254,17 @@ class Core(object):
# TODO: refresh only the correct window in the current tab
self.refresh_window()
+ def disconnect(self, msg=None):
+ """
+ Disconnect from remote server and correctly set the states of all
+ parts of the client (for example, set the MucTabs as not joined, etc)
+ """
+ for tab in self.tabs:
+ if isinstance(tab, tabs.MucTab):
+ muc.leave_groupchat(self.xmpp, tab.get_room().name, tab.get_room().own_nick, msg)
+ self.save_config()
+ self.xmpp.disconnect(False)
+
def command_quit(self, arg):
"""
/quit
@@ -1255,11 +1273,7 @@ class Core(object):
msg = arg
else:
msg = None
- for tab in self.tabs:
- if isinstance(tab, tabs.MucTab):
- muc.leave_groupchat(self.xmpp, tab.get_room().name, tab.get_room().own_nick, msg)
- self.save_config()
- self.xmpp.disconnect()
+ self.disconnect(msg)
self.running = False
self.reset_curses()
sys.exit()