summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-02-29 20:31:46 +0100
committermathieui <mathieui@mathieui.net>2012-02-29 20:31:46 +0100
commit63805e59f6765917bbc03637362711c2d0157376 (patch)
tree98a1d03049933eec85f214f2b5580c947585a6a0
parent73c8206cc7926757ccc963ede581989078e6c780 (diff)
downloadpoezio-63805e59f6765917bbc03637362711c2d0157376.tar.gz
poezio-63805e59f6765917bbc03637362711c2d0157376.tar.bz2
poezio-63805e59f6765917bbc03637362711c2d0157376.tar.xz
poezio-63805e59f6765917bbc03637362711c2d0157376.zip
Fixes #2327 (used "seconds" instead)
-rw-r--r--src/core.py3
-rw-r--r--src/multiuserchat.py20
-rw-r--r--src/tabs.py3
3 files changed, 23 insertions, 3 deletions
diff --git a/src/core.py b/src/core.py
index b9b40929..96cc1454 100644
--- a/src/core.py
+++ b/src/core.py
@@ -1755,8 +1755,9 @@ class Core(object):
room = room[1:]
current_status = self.get_status()
if tab and not tab.joined:
+ seconds = (int(time.time()) - tab.last_connection) if tab.last_connection != 0 else 0
muc.join_groupchat(self.xmpp, room, nick, password,
- histo_length, current_status.message, current_status.show)
+ histo_length, current_status.message, current_status.show, seconds=seconds)
if not tab:
self.open_new_room(room, nick)
muc.join_groupchat(self.xmpp, room, nick, password,
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index 3f0c80b8..53bf4987 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -56,8 +56,24 @@ def change_nick(xmpp, jid, nick, status=None, show=None):
"""
xmpp.make_presence(pshow=show, pstatus=status, pto='%s/%s' % (jid, nick)).send()
-def join_groupchat(xmpp, jid, nick, passwd='', maxhistory=None, status=None, show=None):
- xmpp.plugin['xep_0045'].joinMUC(jid, nick, maxhistory=maxhistory, password=passwd, pstatus=status, pshow=show)
+def join_groupchat(xmpp, jid, nick, passwd='', maxhistory=None, status=None, show=None, seconds=0):
+ if not seconds:
+ xmpp.plugin['xep_0045'].joinMUC(jid, nick, maxhistory=maxhistory, password=passwd, pstatus=status, pshow=show)
+ else:
+ # hackish but modifying the plugin is not worth it (since it is bound to be rewritten)
+ stanza = xmpp.makePresence(pto="%s/%s" % (jid, nick), pstatus=status, pshow=show)
+ x = ET.Element('{http://jabber.org/protocol/muc}x')
+ if passwd:
+ passelement = ET.Element('password')
+ passelement.text = passwd
+ x.append(passelement)
+ history = ET.Element('history')
+ history.attrib['seconds'] = str(seconds)
+ x.append(history)
+ stanza.append(x)
+ stanza.send()
+ xmpp.plugin['xep_0045'].rooms[jid] = {}
+ xmpp.plugin['xep_0045'].our_nicks[jid] = nick
def leave_groupchat(xmpp, jid, own_nick, msg):
"""
diff --git a/src/tabs.py b/src/tabs.py
index 2f384e22..ebf490f3 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -33,6 +33,7 @@ import xhtml
import weakref
import timed_events
import os
+import time
import multiuserchat as muc
@@ -584,6 +585,7 @@ 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
@@ -1354,6 +1356,7 @@ 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'