Author: js Date: 2008-06-17 18:03:21 +0200 (Tue, 17 Jun 2008) New Revision: 9815
Modified: trunk/src/common/config.py trunk/src/common/connection.py trunk/src/common/connection_handlers.py trunk/src/common/contacts.py trunk/src/common/helpers.py trunk/src/common/xmpp/protocol.py Log: * 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.
Modified: trunk/src/common/config.py =================================================================== --- trunk/src/common/config.py 2008-06-17 05:39:20 UTC (rev 9814) +++ trunk/src/common/config.py 2008-06-17 16:03:21 UTC (rev 9815) @@ -311,7 +311,7 @@ '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],
Modified: trunk/src/common/connection.py =================================================================== --- trunk/src/common/connection.py 2008-06-17 05:39:20 UTC (rev 9814) +++ trunk/src/common/connection.py 2008-06-17 16:03:21 UTC (rev 9815) @@ -1096,11 +1096,6 @@ # 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 @@ 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
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2008-06-17 05:39:20 UTC (rev 9814) +++ trunk/src/common/connection_handlers.py 2008-06-17 16:03:21 UTC (rev 9815) @@ -1693,11 +1693,11 @@ # 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',
Modified: trunk/src/common/contacts.py =================================================================== --- trunk/src/common/contacts.py 2008-06-17 05:39:20 UTC (rev 9814) +++ trunk/src/common/contacts.py 2008-06-17 16:03:21 UTC (rev 9815) @@ -248,6 +248,11 @@ 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]:
Modified: trunk/src/common/helpers.py =================================================================== --- trunk/src/common/helpers.py 2008-06-17 05:39:20 UTC (rev 9814) +++ trunk/src/common/helpers.py 2008-06-17 16:03:21 UTC (rev 9815) @@ -1346,6 +1346,8 @@ 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
Modified: trunk/src/common/xmpp/protocol.py =================================================================== --- trunk/src/common/xmpp/protocol.py 2008-06-17 05:39:20 UTC (rev 9814) +++ trunk/src/common/xmpp/protocol.py 2008-06-17 16:03:21 UTC (rev 9815) @@ -111,6 +111,7 @@ 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.