mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
remove roster item state responsibility from clients
This commit is contained in:
parent
b9bf30e095
commit
46dc6eac88
3 changed files with 41 additions and 28 deletions
|
@ -146,8 +146,6 @@ class BaseXMPP(XMLStream):
|
||||||
self._handle_unsubscribe)
|
self._handle_unsubscribe)
|
||||||
self.add_event_handler('presence_unsubscribed',
|
self.add_event_handler('presence_unsubscribed',
|
||||||
self._handle_unsubscribed)
|
self._handle_unsubscribed)
|
||||||
self.add_event_handler('presence_probe',
|
|
||||||
self._handle_probe)
|
|
||||||
self.add_event_handler('roster_subscription_request',
|
self.add_event_handler('roster_subscription_request',
|
||||||
self._handle_new_subscription)
|
self._handle_new_subscription)
|
||||||
|
|
||||||
|
@ -663,11 +661,6 @@ class BaseXMPP(XMLStream):
|
||||||
pfrom = presence['from'].bare
|
pfrom = presence['from'].bare
|
||||||
self.roster[pto][pfrom].handle_unsubscribed(presence)
|
self.roster[pto][pfrom].handle_unsubscribed(presence)
|
||||||
|
|
||||||
def _handle_probe(self, presence):
|
|
||||||
pto = presence['to'].bare
|
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_probe(presence)
|
|
||||||
|
|
||||||
def _handle_presence(self, presence):
|
def _handle_presence(self, presence):
|
||||||
"""
|
"""
|
||||||
Process incoming presence stanzas.
|
Process incoming presence stanzas.
|
||||||
|
|
|
@ -78,6 +78,8 @@ class ComponentXMPP(BaseXMPP):
|
||||||
Callback('Handshake',
|
Callback('Handshake',
|
||||||
MatchXPath('{jabber:component:accept}handshake'),
|
MatchXPath('{jabber:component:accept}handshake'),
|
||||||
self._handle_handshake))
|
self._handle_handshake))
|
||||||
|
self.add_event_handler('presence_probe',
|
||||||
|
self._handle_probe)
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""
|
"""
|
||||||
|
@ -139,3 +141,8 @@ class ComponentXMPP(BaseXMPP):
|
||||||
xml -- The reply handshake stanza.
|
xml -- The reply handshake stanza.
|
||||||
"""
|
"""
|
||||||
self.event("session_start")
|
self.event("session_start")
|
||||||
|
|
||||||
|
def _handle_probe(self, presence):
|
||||||
|
pto = presence['to'].bare
|
||||||
|
pfrom = presence['from'].bare
|
||||||
|
self.roster[pto][pfrom].handle_probe(presence)
|
||||||
|
|
|
@ -658,12 +658,16 @@ class RosterItem(object):
|
||||||
| "Both" | no * | no state change |
|
| "Both" | no * | no state change |
|
||||||
+------------------------------------------------------------------+
|
+------------------------------------------------------------------+
|
||||||
"""
|
"""
|
||||||
|
if self.xmpp.is_component:
|
||||||
if not self['from'] and not self['pending_in']:
|
if not self['from'] and not self['pending_in']:
|
||||||
self['pending_in'] = True
|
self['pending_in'] = True
|
||||||
self.xmpp.event('roster_subscription_request', presence)
|
self.xmpp.event('roster_subscription_request', presence)
|
||||||
elif self['from']:
|
elif self['from']:
|
||||||
self._subscribed()
|
self._subscribed()
|
||||||
self.save()
|
self.save()
|
||||||
|
else:
|
||||||
|
#server shouldn't send an invalid subscription request
|
||||||
|
self.xmpp.event('roster_subscription_request', presence)
|
||||||
|
|
||||||
def handle_subscribed(self, presence):
|
def handle_subscribed(self, presence):
|
||||||
"""
|
"""
|
||||||
|
@ -681,11 +685,14 @@ class RosterItem(object):
|
||||||
| "Both" | no | no state change |
|
| "Both" | no | no state change |
|
||||||
+------------------------------------------------------------------+
|
+------------------------------------------------------------------+
|
||||||
"""
|
"""
|
||||||
|
if self.xmpp.is_component:
|
||||||
if not self['to'] and self['pending_out']:
|
if not self['to'] and self['pending_out']:
|
||||||
self['pending_out'] = False
|
self['pending_out'] = False
|
||||||
self['to'] = True
|
self['to'] = True
|
||||||
self.xmpp.event('roster_subscription_authorized', presence)
|
self.xmpp.event('roster_subscription_authorized', presence)
|
||||||
self.save()
|
self.save()
|
||||||
|
else:
|
||||||
|
self.xmpp.event('roster_subscription_authorized', presence)
|
||||||
|
|
||||||
def handle_unsubscribe(self, presence):
|
def handle_unsubscribe(self, presence):
|
||||||
"""
|
"""
|
||||||
|
@ -703,6 +710,7 @@ class RosterItem(object):
|
||||||
| "Both" | yes * | "To" |
|
| "Both" | yes * | "To" |
|
||||||
+------------------------------------------------------------------+
|
+------------------------------------------------------------------+
|
||||||
"""
|
"""
|
||||||
|
if self.xmpp.is_component:
|
||||||
if not self['from'] and self['pending_in']:
|
if not self['from'] and self['pending_in']:
|
||||||
self['pending_in'] = False
|
self['pending_in'] = False
|
||||||
self._unsubscribed()
|
self._unsubscribed()
|
||||||
|
@ -711,6 +719,8 @@ class RosterItem(object):
|
||||||
self._unsubscribed()
|
self._unsubscribed()
|
||||||
self.xmpp.event('roster_subscription_remove', presence)
|
self.xmpp.event('roster_subscription_remove', presence)
|
||||||
self.save()
|
self.save()
|
||||||
|
else:
|
||||||
|
self.xmpp.event('roster_subscription_remove', presence)
|
||||||
|
|
||||||
def handle_unsubscribed(self, presence):
|
def handle_unsubscribed(self, presence):
|
||||||
"""
|
"""
|
||||||
|
@ -728,12 +738,15 @@ class RosterItem(object):
|
||||||
| "Both" | yes | "From" |
|
| "Both" | yes | "From" |
|
||||||
+------------------------------------------------------------------
|
+------------------------------------------------------------------
|
||||||
"""
|
"""
|
||||||
|
if self.xmpp.is_component:
|
||||||
if not self['to'] and self['pending_out']:
|
if not self['to'] and self['pending_out']:
|
||||||
self['pending_out'] = False
|
self['pending_out'] = False
|
||||||
elif self['to'] and not self['pending_out']:
|
elif self['to'] and not self['pending_out']:
|
||||||
self['to'] = False
|
self['to'] = False
|
||||||
self.xmpp.event('roster_subscription_removed', presence)
|
self.xmpp.event('roster_subscription_removed', presence)
|
||||||
self.save()
|
self.save()
|
||||||
|
else:
|
||||||
|
self.xmpp.event('roster_subscription_removed', presence)
|
||||||
|
|
||||||
def handle_probe(self, presence):
|
def handle_probe(self, presence):
|
||||||
if self['to']:
|
if self['to']:
|
||||||
|
|
Loading…
Reference in a new issue