diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index c3e01de1b..1e48c962a 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -360,11 +360,16 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): def get_status(self): return STATUS_LIST[self.connected] - def send_message(self, jid, msg, keyID, type_ = 'chat', subject='', - chatstate = None, msg_id = None, composing_xep = None, resource = None, - user_nick = None, session=None, forward_from=None, form_node=None, original_message=None): + def send_message(self, jid, msg, keyID, type_='chat', subject='', + chatstate=None, msg_id=None, composing_xep=None, resource=None, + user_nick=None, xhtml=None, session=None, forward_from=None, form_node=None, + original_message=None, delayed=None): fjid = jid + if msg and not xhtml and gajim.config.get( + 'rst_formatting_outgoing_messages'): + from common.rst_xhtml_generator import create_xhtml + xhtml = create_xhtml(msg) if not self.connection: return if not msg and chatstate is None: @@ -397,15 +402,16 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): return 3 if type_ == 'chat': - msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, typ = type_) + msg_iq = common.xmpp.Message(to=fjid, body=msgtxt, typ=type_i, + xhtml=xhtml) else: if subject: - msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, - typ = 'normal', subject = subject) + msg_iq = common.xmpp.Message(to=fjid, body=msgtxt, typ='normal', + subject=subject, xhtml=xhtml) else: - msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, - typ = 'normal') + msg_iq = common.xmpp.Message(to=fjid, body=msgtxt, typ='normal', + xhtml=xhtml) if msgenc: msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc) @@ -428,6 +434,20 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): if chatstate is 'composing' or msgtxt: chatstate_node.addChild(name = 'composing') + if forward_from: + addresses = msg_iq.addChild('addresses', + namespace=common.xmpp.NS_ADDRESS) + addresses.addChild('address', attrs = {'type': 'ofrom', + 'jid': forward_from}) + + # XEP-0203 + if delayed: + our_jid = gajim.get_jid_from_account(self.name) + '/' + \ + self.server_resource + timestamp = time.strftime('%Y-%m-%dT%TZ', time.gmtime(delayed)) + msg_iq.addChild('delay', namespace=common.xmpp.NS_DELAY2, + attrs={'from': our_jid, 'stamp': timestamp}) + if session: session.last_send = time.time() msg_iq.setThread(session.thread_id)