summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-11-17 19:17:02 +0100
committermathieui <mathieui@mathieui.net>2012-11-17 19:17:02 +0100
commitac806cbb4149cd3684b9b297667876a5dd84dc52 (patch)
tree530983e222bff6fb1354798d539e118cc2466352 /src
parent6781f67e80aa5ec86c84b49ef4526dcef9feceda (diff)
downloadpoezio-ac806cbb4149cd3684b9b297667876a5dd84dc52.tar.gz
poezio-ac806cbb4149cd3684b9b297667876a5dd84dc52.tar.bz2
poezio-ac806cbb4149cd3684b9b297667876a5dd84dc52.tar.xz
poezio-ac806cbb4149cd3684b9b297667876a5dd84dc52.zip
Fix the history numbers when re-joining a room
the <history/> element had a xmlns="" instead of the proper namespace.
Diffstat (limited to 'src')
-rw-r--r--src/core.py3
-rw-r--r--src/multiuserchat.py2
-rw-r--r--src/tabs.py9
-rw-r--r--src/text_buffer.py5
4 files changed, 15 insertions, 4 deletions
diff --git a/src/core.py b/src/core.py
index 6636a5d6..74b12d0c 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1682,7 +1682,8 @@ class Core(object):
if histo_length is not None:
histo_length= str(histo_length)
if tab and not tab.joined:
- seconds = (int(time.time()) - tab.last_connection) if tab.last_connection != 0 else 0
+ seconds = (datetime.now() - tab.last_connection).total_seconds() if tab.last_connection is not None else 0
+ seconds = int(seconds)
muc.join_groupchat(self.xmpp, room, nick, password,
histo_length, current_status.message, current_status.show, seconds=seconds)
if not tab:
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index 273a8dea..d3eb70ca 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -73,7 +73,7 @@ def join_groupchat(xmpp, jid, nick, passwd='', maxhistory=None, status=None, sho
passelement = ET.Element('password')
passelement.text = passwd
x.append(passelement)
- history = ET.Element('history')
+ history = ET.Element('{http://jabber.org/protocol/muc}history')
history.attrib['seconds'] = str(seconds)
x.append(history)
stanza.append(x)
diff --git a/src/tabs.py b/src/tabs.py
index d98382d9..b14f1b04 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -654,7 +654,6 @@ class MucTab(ChatTab):
self.info_header = windows.MucInfoWin()
self.input = windows.MessageInput()
self.ignores = [] # set of Users
- self.last_connection = 0
# keys
self.key_func['^I'] = self.completion
self.key_func['M-u'] = self.scroll_user_list_down
@@ -691,6 +690,13 @@ class MucTab(ChatTab):
def general_jid(self):
return self.get_name()
+ @property
+ def last_connection(self):
+ last_message = self._text_buffer.last_message
+ if last_message:
+ return last_message.time
+ return None
+
@refresh_wrapper.always
def go_to_next_hl(self):
"""
@@ -1538,7 +1544,6 @@ class MucTab(ChatTab):
Set the state of the room as not joined, so
we can know if we can join it, send messages to it, etc
"""
- self.last_connection = int(time.time())
self.users = []
if self is not self.core.current_tab():
self.state = 'disconnected'
diff --git a/src/text_buffer.py b/src/text_buffer.py
index f20c0cb9..8430a230 100644
--- a/src/text_buffer.py
+++ b/src/text_buffer.py
@@ -35,6 +35,11 @@ class TextBuffer(object):
def add_window(self, win):
self.windows.append(win)
+ @property
+ def last_message(self):
+ return self.messages[-1] if self.messages else None
+
+
def make_message(self, txt, time, nickname, nick_color, history, user, identifier, str_time=None):
time = time or datetime.now()
if txt.startswith('/me '):