Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjs <js-gajim@webkeks.org>2008-05-19 21:41:51 +0400
committerjs <js-gajim@webkeks.org>2008-05-19 21:41:51 +0400
commit1cbe5678da8e453be1437026b1978a5929832503 (patch)
tree42592dddcff8edae5c67e7aaf18876931cd40470
parent0deebd859d6d57f8b25ee9a27714e7d1027878ef (diff)
* When we receive a plaintext, non-tagged message, don't append OTR
tag to outgoing messages anymore. Messages are not even passed to libotr anymore then. * If we don't support OTR, strip OTR tags from the message before displaying it.
-rw-r--r--src/common/connection.py3
-rw-r--r--src/message_control.py56
-rw-r--r--src/session.py14
3 files changed, 49 insertions, 24 deletions
diff --git a/src/common/connection.py b/src/common/connection.py
index c6daf899e..781c9dd57 100644
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -167,7 +167,8 @@ class Connection(ConnectionHandlers):
self.private_storage_supported = True
if gajim.otr_module:
- self.otr_userstates = gajim.otr_module.otrl_userstate_create()
+ self.otr_userstates = \
+ gajim.otr_module.otrl_userstate_create()
# END __init__
def put_event(self, ev):
diff --git a/src/message_control.py b/src/message_control.py
index d12f4ef4d..9b63aa60c 100644
--- a/src/message_control.py
+++ b/src/message_control.py
@@ -139,37 +139,47 @@ class MessageControl:
def send_message(self, message, keyID = '', type = 'chat',
chatstate = None, msg_id = None, composing_xep = None, resource = None,
user_nick = None):
- '''Send the given message to the active tab. Doesn't return None if error
- '''
+ # Send the given message to the active tab.
+ # Doesn't return None if error
jid = self.contact.jid
original_message = message
- if gajim.otr_module:
+ if gajim.otr_module and self.session.append_otr_tag:
if type == 'chat' and isinstance(message, unicode):
- d = {'kwargs':{'keyID':keyID, 'type':type,
- 'chatstate':chatstate, 'msg_id':msg_id,
- 'composing_xep':composing_xep, 'resource':self.resource,
- 'user_nick':user_nick, 'session':self.session,
- 'original_message':original_message}, 'account':self.account}
+ d = {'kwargs': {'keyID': keyID, 'type': type,
+ 'chatstate': chatstate,
+ 'msg_id': msg_id,
+ 'composing_xep': composing_xep,
+ 'resource': self.resource,
+ 'user_nick': user_nick,
+ 'session': self.session,
+ 'original_message': original_message},
+ 'account': self.account}
new_msg = gajim.otr_module.otrl_message_sending(
- gajim.connections[self.account].otr_userstates,
+ self.session.conn.otr_userstates,
(gajim.otr_ui_ops, d),
- gajim.get_jid_from_account(self.account).encode(),
- gajim.OTR_PROTO, self.contact.get_full_jid().encode(),
- message.encode(), None, (gajim.otr_add_appdata, self.account))
-
- context = gajim.otr_module.otrl_context_find(
- gajim.connections[self.account].otr_userstates,
- self.contact.get_full_jid().encode(),
- gajim.get_jid_from_account(self.account).encode(),
- gajim.OTR_PROTO, 1, (gajim.otr_add_appdata,
- self.account))[0]
-
- # we send all because inject_message can filter on HTML stuff then
+ gajim.get_jid_from_account(
+ self.account).encode(),
+ gajim.OTR_PROTO,
+ self.contact.get_full_jid().encode(),
+ message.encode(), None,
+ (gajim.otr_add_appdata, self.account))
+
+ ctx = gajim.otr_module.otrl_context_find(
+ self.session.conn.otr_userstates,
+ self.contact.get_full_jid().encode(),
+ gajim.get_jid_from_account(
+ self.account).encode(),
+ gajim.OTR_PROTO, 1,
+ (gajim.otr_add_appdata,
+ self.account))[0]
+
+ # we send all because inject_message can filter
+ # on HTML stuff then
gajim.otr_module.otrl_message_fragment_and_send(
- (gajim.otr_ui_ops, d),
- context, new_msg, gajim.otr_module.OTRL_FRAGMENT_SEND_ALL)
+ (gajim.otr_ui_ops, d), ctx, new_msg,
+ gajim.otr_module.OTRL_FRAGMENT_SEND_ALL)
return
# Send and update history
diff --git a/src/session.py b/src/session.py
index f7ce5d090..90afc5276 100644
--- a/src/session.py
+++ b/src/session.py
@@ -18,6 +18,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
stanza_session.EncryptedStanzaSession.__init__(self, conn, jid, thread_id, type = 'chat')
self.control = None
+ self.append_otr_tag = True
def acknowledge_termination(self):
# the other party terminated the session. we'll keep the control around, though.
@@ -151,6 +152,19 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if msgtxt == '':
return
+ else:
+ self.append_otr_tag = False
+
+ # We're also here if we just don't support OTR.
+ # Thus, we should strip the tags from plaintext
+ # messages since they look ugly.
+ msgtxt = msgtxt.replace('\x20\x09\x20\x20\x09' \
+ '\x09\x09\x09\x20\x09\x20\x09\x20\x09' \
+ '\x20\x20', '')
+ msgtxt = msgtxt.replace('\x20\x09\x20\x09\x20' \
+ '\x20\x09\x20', '')
+ msgtxt = msgtxt.replace('\x20\x20\x09\x09\x20' \
+ '\x20\x09\x20', '')
else:
log_type = 'single_msg_recv'