* 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:
js 2008-06-17 16:03:21 +00:00
parent 5e5733e40a
commit 9634f98250
6 changed files with 25 additions and 14 deletions

View File

@ -311,7 +311,7 @@ class Config:
'zeroconf_jabber_id': [ opt_str, '', '', True ],
'zeroconf_email': [ opt_str, '', '', True ],
'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')],
'publish_mood': [opt_bool, True],
'publish_activity': [opt_bool, True],

View File

@ -1096,11 +1096,6 @@ class Connection(ConnectionHandlers):
# XEP-0022
chatstate_node = msg_iq.setTag('x',
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:
chatstate_node.addChild(name = 'composing')
@ -1110,12 +1105,20 @@ class Connection(ConnectionHandlers):
addresses.addChild('address', attrs = {'type': 'ofrom',
'jid': forward_from})
# TODO: We should also check if the other end supports it
# as XEP 0184 says checking is a SHOULD. Maybe we should
# implement section 6 of the XEP as well?
# XEP-0184
if resource:
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,
'request_receipt'):
msg_iq.setTag('request', namespace='urn:xmpp:receipts')
'request_receipt') and common.xmpp.NS_RECEIPTS in \
gajim.capscache[(contact.caps_hash_method,
contact.caps_hash)].features:
msg_iq.setTag('request',
namespace=common.xmpp.NS_RECEIPTS)
if session:
# XEP-0201

View File

@ -1693,11 +1693,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
# Receipt requested
# 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])
if msg.getTag('request', namespace='urn:xmpp:receipts') and \
gajim.config.get_per('accounts', self.name, 'answer_receipt') \
and cont and cont.sub not in (u'to', u'none'):
gajim.config.get_per('accounts', self.name, 'answer_receipts') \
and contact and contact.sub not in (u'to', u'none'):
receipt = common.xmpp.Message(to = jid, typ = 'chat')
receipt.setID(msg.getID())
receipt.setTag('received',

View File

@ -248,6 +248,11 @@ class Contacts:
return []
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
the first contact is no resource is given or None if there is not'''
if jid in self._contacts[account]:

View File

@ -1346,6 +1346,8 @@ def update_optional_features(account = None):
gajim.gajim_optional_features[a].append(xmpp.NS_XHTML_IM)
if gajim.HAVE_PYCRYPTO:
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.gajim_common_features + gajim.gajim_optional_features[a])
# re-send presence with new hash

View File

@ -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_VALIDATE='http://jabber.org/protocol/xdata-validate' # XEP-0122
NS_XMPP_STREAMS ='urn:ietf:params:xml:ns:xmpp-streams'
NS_RECEIPTS ='urn:xmpp:receipt'
xmpp_stream_error_conditions="""
bad-format -- -- -- The entity has sent XML that cannot be processed.