summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2011-01-02 15:50:01 +0000
committerlouiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13>2011-01-02 15:50:01 +0000
commit11357165186dce6614b03399f025febd4c48183e (patch)
tree1001faabe80a6637d9ac89beb1131fca7395dd0c /src
parent15f7340661e0ef4b375e54dabc1f3c1f6f885c38 (diff)
downloadpoezio-11357165186dce6614b03399f025febd4c48183e.tar.gz
poezio-11357165186dce6614b03399f025febd4c48183e.tar.bz2
poezio-11357165186dce6614b03399f025febd4c48183e.tar.xz
poezio-11357165186dce6614b03399f025febd4c48183e.zip
fix /list with new SleekXMPP xep_0030 version. Also add some error handling and a '(loading)' information while waiting for the answer
Diffstat (limited to 'src')
-rw-r--r--src/core.py6
-rw-r--r--src/tabs.py29
-rw-r--r--src/windows.py15
3 files changed, 41 insertions, 9 deletions
diff --git a/src/core.py b/src/core.py
index bb9ee444..87aa5007 100644
--- a/src/core.py
+++ b/src/core.py
@@ -890,11 +890,7 @@ class Core(object):
server = arg.strip()
list_tab = tabs.MucListTab(self, server)
self.add_tab(list_tab, True)
- res = self.xmpp.plugin['xep_0030'].getItems(server)
- items = [{'node-part':JID(item[0]).user,
- 'jid': item[0],
- 'name': item[2]} for item in res['disco_items'].getItems()]
- list_tab.listview.add_lines(items)
+ self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received)
def command_whois(self, arg):
"""
diff --git a/src/tabs.py b/src/tabs.py
index b106592b..b8fe9d84 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1010,6 +1010,7 @@ class MucListTab(Tab):
self._color_state = theme.COLOR_TAB_NORMAL
self.name = server
self.upper_message = windows.Topic()
+ self.upper_message.set_message('Chatroom list on server %s (Loading)' % self.name)
columns = ('node-part','name', 'users')
self.list_header = windows.ColumnHeaderWin(columns)
self.listview = windows.ListWin(columns)
@@ -1026,7 +1027,7 @@ class MucListTab(Tab):
self.resize()
def refresh(self, tabs, informations, roster):
- self.upper_message.refresh('Chatroom list on server %s' % self.name)
+ self.upper_message.refresh()
self.list_header.refresh()
self.listview.refresh()
self.tab_win.refresh(tabs, tabs[0])
@@ -1057,6 +1058,32 @@ class MucListTab(Tab):
def join_selected_no_focus(self):
return
+ def set_error(self, msg, code, body):
+ """
+ If there's an error (retrieving the values etc)
+ """
+ self._error_message = _('Error: %(code)s - %(msg)s: %(body)s') % {'msg':msg, 'body':body, 'code':code}
+ self.upper_message.set_message(self._error_message)
+ self.upper_message.refresh()
+ curses.doupdate()
+
+ def on_muc_list_item_received(self, iq):
+ """
+ Callback called when a disco#items result is received
+ Used with command_list
+ """
+ log.debug('res: %s\n\n' % iq)
+ if iq['type'] == 'error':
+ self.set_error(iq['error']['type'], iq['error']['code'], iq['error']['text'])
+ return
+ items = [{'node-part':JID(item[0]).user,
+ 'jid': item[0],
+ 'name': item[2]} for item in iq['disco_items'].get_items()]
+ self.listview.add_lines(items)
+ self.upper_message.set_message('Chatroom list on server %s' % self.name)
+ self.upper_message.refresh()
+ curses.doupdate()
+
def join_selected(self):
row = self.listview.get_selected_row()
if not row:
diff --git a/src/windows.py b/src/windows.py
index 315ef84d..682d6487 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -154,14 +154,19 @@ class UserList(Win):
class Topic(Win):
def __init__(self):
Win.__init__(self)
+ self._message = ''
def resize(self, height, width, y, x, stdscr):
self._resize(height, width, y, x, stdscr)
- def refresh(self, topic):
+ def refresh(self, topic=None):
with g_lock:
self._win.erase()
- self.addstr(0, 0, topic[:self.width-1], curses.color_pair(theme.COLOR_TOPIC_BAR))
+ if topic:
+ msg = topic[:self.width-1]
+ else:
+ msg = self._message[:self.width-1]
+ self.addstr(0, 0, msg, curses.color_pair(theme.COLOR_TOPIC_BAR))
(y, x) = self._win.getyx()
remaining_size = self.width - x
if remaining_size:
@@ -169,6 +174,9 @@ class Topic(Win):
curses.color_pair(theme.COLOR_INFORMATION_BAR))
self._refresh()
+ def set_message(self, message):
+ self._message = message
+
class GlobalInfoBar(Win):
def __init__(self):
Win.__init__(self)
@@ -1362,12 +1370,13 @@ class ListWin(Win):
return
self.lines += lines
self.refresh()
+ curses.doupdate()
def get_selected_row(self):
"""
Return the tuple representing the selected row
"""
- if self._selected_row is not None:
+ if self._selected_row is not None and self.lines:
return self.lines[self._selected_row]
return None