summaryrefslogtreecommitdiff
path: root/src/tabs.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-02-27 22:09:14 +0100
committermathieui <mathieui@mathieui.net>2013-02-27 22:09:14 +0100
commitde11a00a8e6d448dbe909d5f96f04bdda9d8e8ec (patch)
treee47da2a0ac33ac591c7e5f550ab8a34dfa21a2e7 /src/tabs.py
parentf1831cc0ec51c6b09f43fab67f7f0940fb931039 (diff)
downloadpoezio-de11a00a8e6d448dbe909d5f96f04bdda9d8e8ec.tar.gz
poezio-de11a00a8e6d448dbe909d5f96f04bdda9d8e8ec.tar.bz2
poezio-de11a00a8e6d448dbe909d5f96f04bdda9d8e8ec.tar.xz
poezio-de11a00a8e6d448dbe909d5f96f04bdda9d8e8ec.zip
Improve XEP-0308 support
- Prevent correction of delayed messages - Prevent correction of messages by someone else in a MUC (and in a private tab) - Messages with unauthorized corrections (above) or wrong message id will be displayed as normal messages TODO: restrict the corrections to the same fullJID (only in direct "normal" conversations, because we can know in private an muc tabs, via the User object)
Diffstat (limited to 'src/tabs.py')
-rw-r--r--src/tabs.py53
1 files changed, 21 insertions, 32 deletions
diff --git a/src/tabs.py b/src/tabs.py
index b81bce8b..db840911 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -482,6 +482,23 @@ class ChatTab(Tab):
if time is None and self.joined: # don't log the history messages
logger.log_message(self.name, nickname, txt)
+ def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None):
+ self._text_buffer.add_message(txt, time=time,
+ nickname=nickname,
+ nick_color=nick_color,
+ history=None,
+ user=forced_user,
+ identifier=identifier)
+
+ def modify_message(self, txt, old_id, new_id, user=None):
+ self.log_message(txt, time, self.name)
+ message = self._text_buffer.modify_message(txt, old_id, new_id, time=time, user=user)
+ if message:
+ self.text_win.modify_message(old_id, message)
+ self.core.refresh_window()
+ return True
+ return False
+
def last_words_completion(self):
"""
Complete the input with words recently said
@@ -1733,14 +1750,15 @@ class MucTab(ChatTab):
self._text_buffer.add_message(txt, time, nickname, nick_color, history, user, highlight=highlight, identifier=identifier)
return highlight
- def modify_message(self, txt, old_id, new_id, time=None, nickname=None):
+ def modify_message(self, txt, old_id, new_id, time=None, nickname=None, user=None):
self.log_message(txt, time, nickname)
highlight = self.do_highlight(txt, time, nickname)
- message = self._text_buffer.modify_message(txt, old_id, new_id, highlight=highlight, time=time)
+ message = self._text_buffer.modify_message(txt, old_id, new_id, highlight=highlight, time=time, user=user)
if message:
self.text_win.modify_message(old_id, message)
self.core.refresh_window()
return highlight
+ return False
def matching_names(self):
return [safeJID(self.get_name()).user]
@@ -1826,6 +1844,7 @@ class PrivateTab(ChatTab):
else:
self.add_message(msg['body'],
nickname=self.core.own_nick or self.own_nick,
+ forced_user=self.parent_muc.get_user_by_name(self.own_nick),
nick_color=get_theme().COLOR_OWN_NICK,
identifier=msg['id'])
if msg['body'].find('\x19') != -1:
@@ -2013,21 +2032,6 @@ class PrivateTab(ChatTab):
if reason:
self.add_message(txt=reason)
- def modify_message(self, txt, old_id, new_id):
- self.log_message(txt, time, self.name)
- message = self._text_buffer.modify_message(txt, old_id, new_id, time=time)
- if message:
- self.text_win.modify_message(old_id, message)
- self.core.refresh_window()
-
- def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None):
- self._text_buffer.add_message(txt, time=time,
- nickname=nickname,
- nick_color=nick_color,
- history=None,
- user=forced_user,
- identifier=identifier)
-
def matching_names(self):
return [safeJID(self.get_name()).resource]
@@ -3175,21 +3179,6 @@ class ConversationTab(ChatTab):
if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true':
self.send_chat_state('gone')
- def modify_message(self, txt, old_id, new_id):
- self.log_message(txt, time, self.name)
- message = self._text_buffer.modify_message(txt, old_id, new_id, time=time)
- if message:
- self.text_win.modify_message(old_id, message)
- self.core.refresh_window()
-
- def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None):
- self._text_buffer.add_message(txt, time=time,
- nickname=nickname,
- nick_color=nick_color,
- history=None,
- user=forced_user,
- identifier=identifier)
-
def matching_names(self):
contact = roster[self.get_name()]
res = [contact.bare_jid if contact else safeJID(self.get_name()).bare]