diff options
author | mathieui <mathieui@mathieui.net> | 2011-11-11 21:47:52 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2011-11-11 21:49:27 +0100 |
commit | ea5692544ad196b90d64e46d7b43ae8c68c34e64 (patch) | |
tree | d06fced6e8c982aa959ab093f699e15647c33cdf | |
parent | 50d5c6b8b26dd66342a66ccd84bc8f68709bc724 (diff) | |
download | poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.tar.gz poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.tar.bz2 poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.tar.xz poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.zip |
Fixes presence handhake
-rw-r--r-- | src/core.py | 18 | ||||
-rw-r--r-- | src/tabs.py | 8 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/core.py b/src/core.py index 993b40ca..50acf784 100644 --- a/src/core.py +++ b/src/core.py @@ -697,16 +697,30 @@ class Core(object): """ Triggered whenever a presence stanza with a type of subscribe, subscribed, unsubscribe, or unsubscribed is received. """ + jid = presence['from'].bare + contact = roster.get_contact_by_jid(jid) if presence['type'] == 'subscribe': - jid = presence['from'].bare - contact = roster.get_contact_by_jid(jid) if not contact: contact = Contact(jid) roster.add_contact(contact, jid) + log.debug("CONTACT: %s" % contact) + if contact.subscription in ('from', 'both'): + log.debug('FROM OR BOTH') + return + elif contact.subscription in ('to'): + log.debug('TO') + self.xmpp.sendPresence(pto=jid, ptype='subscribed') + self.xmpp.sendPresence(pto=jid, ptype='') + return roster.edit_groups_of_contact(contact, []) contact.ask = 'asked' self.get_tab_by_number(0).state = 'highlight' self.information('%s wants to subscribe to your presence'%jid, 'Roster') + elif presence['type'] == 'unsubscribed': + self.information('%s unsubscribed you from his presence'%jid, 'Roster') + elif presence['type'] == 'unsubscribe': + self.information('%s unsubscribed from your presence'%jid, 'Roster') + if isinstance(self.current_tab(), tabs.RosterInfoTab): self.refresh_window() diff --git a/src/tabs.py b/src/tabs.py index 1e5775fc..5a1a33a3 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -1491,7 +1491,6 @@ class RosterInfoTab(Tab): self.core.information(_('No JID specified'), 'Error') return self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') - self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') def command_name(self, args): """ @@ -1588,6 +1587,7 @@ class RosterInfoTab(Tab): else: self.core.information('No roster item to remove') return + self.core.xmpp.sendPresence(pto=jid, ptype='unavailable') self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribe') self.core.xmpp.sendPresence(pto=jid, ptype='unsubscribed') self.core.xmpp.del_roster_item(jid=jid) @@ -1719,6 +1719,12 @@ class RosterInfoTab(Tab): else: jid = args[0] self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') + self.core.xmpp.sendPresence(pto=jid, ptype='') + contact = roster.get_contact_by_jid(jid) + if not contact: + return + if contact.subscription in ('to', 'none'): + self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') def refresh(self): if self.need_resize: |