* Implemented XEP-0184 section 5.
* Added NS_RECEIPTS to protocol namespace list. * Show our support of XEP-0184 in caps. * Added a big, fat warning to get_contact as this does not work as expected. * There was some strangeness in our XEP-0022, it added an id tag to the x tag, which isn't mentioned anywhere in the XEP. And for some strange reason, that id even was the same all the time. * Fixed a typo.
This commit is contained in:
parent
5e5733e40a
commit
9634f98250
|
@ -311,7 +311,7 @@ class Config:
|
||||||
'zeroconf_jabber_id': [ opt_str, '', '', True ],
|
'zeroconf_jabber_id': [ opt_str, '', '', True ],
|
||||||
'zeroconf_email': [ opt_str, '', '', True ],
|
'zeroconf_email': [ opt_str, '', '', True ],
|
||||||
'use_env_http_proxy' : [opt_bool, False],
|
'use_env_http_proxy' : [opt_bool, False],
|
||||||
'answer_receipt' : [opt_bool, True, _('Answer to receipt requests')],
|
'answer_receipts' : [opt_bool, True, _('Answer to receipt requests')],
|
||||||
'request_receipt' : [opt_bool, True, _('Sent receipt requests')],
|
'request_receipt' : [opt_bool, True, _('Sent receipt requests')],
|
||||||
'publish_mood': [opt_bool, True],
|
'publish_mood': [opt_bool, True],
|
||||||
'publish_activity': [opt_bool, True],
|
'publish_activity': [opt_bool, True],
|
||||||
|
|
|
@ -1096,11 +1096,6 @@ class Connection(ConnectionHandlers):
|
||||||
# XEP-0022
|
# XEP-0022
|
||||||
chatstate_node = msg_iq.setTag('x',
|
chatstate_node = msg_iq.setTag('x',
|
||||||
namespace = common.xmpp.NS_EVENT)
|
namespace = common.xmpp.NS_EVENT)
|
||||||
if not msgtxt: # when no <body>, add <id>
|
|
||||||
if not msg_id: # avoid putting 'None' in <id> tag
|
|
||||||
msg_id = ''
|
|
||||||
chatstate_node.setTagData('id', msg_id)
|
|
||||||
# when msgtxt, requests XEP-0022 composing notification
|
|
||||||
if chatstate is 'composing' or msgtxt:
|
if chatstate is 'composing' or msgtxt:
|
||||||
chatstate_node.addChild(name = 'composing')
|
chatstate_node.addChild(name = 'composing')
|
||||||
|
|
||||||
|
@ -1110,12 +1105,20 @@ class Connection(ConnectionHandlers):
|
||||||
addresses.addChild('address', attrs = {'type': 'ofrom',
|
addresses.addChild('address', attrs = {'type': 'ofrom',
|
||||||
'jid': forward_from})
|
'jid': forward_from})
|
||||||
|
|
||||||
# TODO: We should also check if the other end supports it
|
# XEP-0184
|
||||||
# as XEP 0184 says checking is a SHOULD. Maybe we should
|
if resource:
|
||||||
# implement section 6 of the XEP as well?
|
contact = gajim.contacts.get_contact(self.name, jid,
|
||||||
|
resource)
|
||||||
|
else:
|
||||||
|
contact = gajim.contacts. \
|
||||||
|
get_contact_with_highest_priority(self.name,
|
||||||
|
jid)
|
||||||
if msgtxt and gajim.config.get_per('accounts', self.name,
|
if msgtxt and gajim.config.get_per('accounts', self.name,
|
||||||
'request_receipt'):
|
'request_receipt') and common.xmpp.NS_RECEIPTS in \
|
||||||
msg_iq.setTag('request', namespace='urn:xmpp:receipts')
|
gajim.capscache[(contact.caps_hash_method,
|
||||||
|
contact.caps_hash)].features:
|
||||||
|
msg_iq.setTag('request',
|
||||||
|
namespace=common.xmpp.NS_RECEIPTS)
|
||||||
|
|
||||||
if session:
|
if session:
|
||||||
# XEP-0201
|
# XEP-0201
|
||||||
|
|
|
@ -1693,11 +1693,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
|
|
||||||
# Receipt requested
|
# Receipt requested
|
||||||
# TODO: We shouldn't answer if we're invisible!
|
# TODO: We shouldn't answer if we're invisible!
|
||||||
cont = gajim.contacts.get_contact(self.name,
|
contact = gajim.contacts.get_contact(self.name,
|
||||||
common.gajim.get_room_and_nick_from_fjid(frm)[0])
|
common.gajim.get_room_and_nick_from_fjid(frm)[0])
|
||||||
if msg.getTag('request', namespace='urn:xmpp:receipts') and \
|
if msg.getTag('request', namespace='urn:xmpp:receipts') and \
|
||||||
gajim.config.get_per('accounts', self.name, 'answer_receipt') \
|
gajim.config.get_per('accounts', self.name, 'answer_receipts') \
|
||||||
and cont and cont.sub not in (u'to', u'none'):
|
and contact and contact.sub not in (u'to', u'none'):
|
||||||
receipt = common.xmpp.Message(to = jid, typ = 'chat')
|
receipt = common.xmpp.Message(to = jid, typ = 'chat')
|
||||||
receipt.setID(msg.getID())
|
receipt.setID(msg.getID())
|
||||||
receipt.setTag('received',
|
receipt.setTag('received',
|
||||||
|
|
|
@ -248,6 +248,11 @@ class Contacts:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def get_contact(self, account, jid, resource = None):
|
def get_contact(self, account, jid, resource = None):
|
||||||
|
### WARNING ###
|
||||||
|
# This function returns a *RANDOM* resource if resource = None!
|
||||||
|
# Do *NOT* use if you need to get the contact to which you
|
||||||
|
# send a message for example, as a bare JID in Jabber means
|
||||||
|
# highest available resource, which this function ignores!
|
||||||
'''Returns the contact instance for the given resource if it's given else
|
'''Returns the contact instance for the given resource if it's given else
|
||||||
the first contact is no resource is given or None if there is not'''
|
the first contact is no resource is given or None if there is not'''
|
||||||
if jid in self._contacts[account]:
|
if jid in self._contacts[account]:
|
||||||
|
|
|
@ -1346,6 +1346,8 @@ def update_optional_features(account = None):
|
||||||
gajim.gajim_optional_features[a].append(xmpp.NS_XHTML_IM)
|
gajim.gajim_optional_features[a].append(xmpp.NS_XHTML_IM)
|
||||||
if gajim.HAVE_PYCRYPTO:
|
if gajim.HAVE_PYCRYPTO:
|
||||||
gajim.gajim_optional_features[a].append(xmpp.NS_ESESSION_INIT)
|
gajim.gajim_optional_features[a].append(xmpp.NS_ESESSION_INIT)
|
||||||
|
if gajim.config.get_per('accounts', a, 'answer_receipts'):
|
||||||
|
gajim.gajim_optional_features[a].append(xmpp.NS_RECEIPTS)
|
||||||
gajim.caps_hash[a] = compute_caps_hash([gajim.gajim_identity],
|
gajim.caps_hash[a] = compute_caps_hash([gajim.gajim_identity],
|
||||||
gajim.gajim_common_features + gajim.gajim_optional_features[a])
|
gajim.gajim_common_features + gajim.gajim_optional_features[a])
|
||||||
# re-send presence with new hash
|
# re-send presence with new hash
|
||||||
|
|
|
@ -111,6 +111,7 @@ NS_XHTML = 'http://www.w3.org/1999/xhtml' # "
|
||||||
NS_DATA_LAYOUT ='http://jabber.org/protocol/xdata-layout' # XEP-0141
|
NS_DATA_LAYOUT ='http://jabber.org/protocol/xdata-layout' # XEP-0141
|
||||||
NS_DATA_VALIDATE='http://jabber.org/protocol/xdata-validate' # XEP-0122
|
NS_DATA_VALIDATE='http://jabber.org/protocol/xdata-validate' # XEP-0122
|
||||||
NS_XMPP_STREAMS ='urn:ietf:params:xml:ns:xmpp-streams'
|
NS_XMPP_STREAMS ='urn:ietf:params:xml:ns:xmpp-streams'
|
||||||
|
NS_RECEIPTS ='urn:xmpp:receipt'
|
||||||
|
|
||||||
xmpp_stream_error_conditions="""
|
xmpp_stream_error_conditions="""
|
||||||
bad-format -- -- -- The entity has sent XML that cannot be processed.
|
bad-format -- -- -- The entity has sent XML that cannot be processed.
|
||||||
|
|
Loading…
Reference in New Issue