summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-11 21:47:52 +0100
committermathieui <mathieui@mathieui.net>2011-11-11 21:49:27 +0100
commitea5692544ad196b90d64e46d7b43ae8c68c34e64 (patch)
treed06fced6e8c982aa959ab093f699e15647c33cdf /src/core.py
parent50d5c6b8b26dd66342a66ccd84bc8f68709bc724 (diff)
downloadpoezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.tar.gz
poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.tar.bz2
poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.tar.xz
poezio-ea5692544ad196b90d64e46d7b43ae8c68c34e64.zip
Fixes presence handhake
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py18
1 files changed, 16 insertions, 2 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()