fix zeroconf to handle parameters of send_message (xhtml, forward_from, delayed). Fixes #4514

This commit is contained in:
Yann Leboulanger 2008-11-25 12:51:31 +00:00
parent 3b13665574
commit d155b90c3c
1 changed files with 28 additions and 8 deletions

View File

@ -360,11 +360,16 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
def get_status(self): def get_status(self):
return STATUS_LIST[self.connected] return STATUS_LIST[self.connected]
def send_message(self, jid, msg, keyID, type_ = 'chat', subject='', def send_message(self, jid, msg, keyID, type_='chat', subject='',
chatstate = None, msg_id = None, composing_xep = None, resource = None, chatstate=None, msg_id=None, composing_xep=None, resource=None,
user_nick = None, session=None, forward_from=None, form_node=None, original_message=None): user_nick=None, xhtml=None, session=None, forward_from=None, form_node=None,
original_message=None, delayed=None):
fjid = jid 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: if not self.connection:
return return
if not msg and chatstate is None: if not msg and chatstate is None:
@ -397,15 +402,16 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
return 3 return 3
if type_ == 'chat': 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: else:
if subject: if subject:
msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, msg_iq = common.xmpp.Message(to=fjid, body=msgtxt, typ='normal',
typ = 'normal', subject = subject) subject=subject, xhtml=xhtml)
else: else:
msg_iq = common.xmpp.Message(to = fjid, body = msgtxt, msg_iq = common.xmpp.Message(to=fjid, body=msgtxt, typ='normal',
typ = 'normal') xhtml=xhtml)
if msgenc: if msgenc:
msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc) msg_iq.setTag(common.xmpp.NS_ENCRYPTED + ' x').setData(msgenc)
@ -428,6 +434,20 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
if chatstate is 'composing' or msgtxt: if chatstate is 'composing' or msgtxt:
chatstate_node.addChild(name = 'composing') 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: if session:
session.last_send = time.time() session.last_send = time.time()
msg_iq.setThread(session.thread_id) msg_iq.setThread(session.thread_id)