diff options
author | Nathan Fritz <nathan@andyet.net> | 2011-04-14 16:27:27 -0700 |
---|---|---|
committer | Nathan Fritz <nathan@andyet.net> | 2011-04-14 16:27:27 -0700 |
commit | 46dc6eac887907109c97fc218498bcc894756659 (patch) | |
tree | adf05107e0cdf828443b470a233bc36c19678a4d /sleekxmpp/roster.py | |
parent | b9bf30e095da565f02f3ed20dab6b378dba4ab7d (diff) | |
download | slixmpp-46dc6eac887907109c97fc218498bcc894756659.tar.gz slixmpp-46dc6eac887907109c97fc218498bcc894756659.tar.bz2 slixmpp-46dc6eac887907109c97fc218498bcc894756659.tar.xz slixmpp-46dc6eac887907109c97fc218498bcc894756659.zip |
remove roster item state responsibility from clients
Diffstat (limited to 'sleekxmpp/roster.py')
-rw-r--r-- | sleekxmpp/roster.py | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/sleekxmpp/roster.py b/sleekxmpp/roster.py index 043981e3..23764f88 100644 --- a/sleekxmpp/roster.py +++ b/sleekxmpp/roster.py @@ -658,12 +658,16 @@ class RosterItem(object): | "Both" | no * | no state change | +------------------------------------------------------------------+ """ - if not self['from'] and not self['pending_in']: - self['pending_in'] = True + if self.xmpp.is_component: + if not self['from'] and not self['pending_in']: + self['pending_in'] = True + self.xmpp.event('roster_subscription_request', presence) + elif self['from']: + self._subscribed() + self.save() + else: + #server shouldn't send an invalid subscription request self.xmpp.event('roster_subscription_request', presence) - elif self['from']: - self._subscribed() - self.save() def handle_subscribed(self, presence): """ @@ -681,11 +685,14 @@ class RosterItem(object): | "Both" | no | no state change | +------------------------------------------------------------------+ """ - if not self['to'] and self['pending_out']: - self['pending_out'] = False - self['to'] = True + if self.xmpp.is_component: + if not self['to'] and self['pending_out']: + self['pending_out'] = False + self['to'] = True + self.xmpp.event('roster_subscription_authorized', presence) + self.save() + else: self.xmpp.event('roster_subscription_authorized', presence) - self.save() def handle_unsubscribe(self, presence): """ @@ -703,14 +710,17 @@ class RosterItem(object): | "Both" | yes * | "To" | +------------------------------------------------------------------+ """ - if not self['from'] and self['pending_in']: - self['pending_in'] = False - self._unsubscribed() - elif self['from']: - self['from'] = False - self._unsubscribed() + if self.xmpp.is_component: + if not self['from'] and self['pending_in']: + self['pending_in'] = False + self._unsubscribed() + elif self['from']: + self['from'] = False + self._unsubscribed() + self.xmpp.event('roster_subscription_remove', presence) + self.save() + else: self.xmpp.event('roster_subscription_remove', presence) - self.save() def handle_unsubscribed(self, presence): """ @@ -728,12 +738,15 @@ class RosterItem(object): | "Both" | yes | "From" | +------------------------------------------------------------------ """ - if not self['to'] and self['pending_out']: - self['pending_out'] = False - elif self['to'] and not self['pending_out']: - self['to'] = False + if self.xmpp.is_component: + if not self['to'] and self['pending_out']: + self['pending_out'] = False + elif self['to'] and not self['pending_out']: + self['to'] = False + self.xmpp.event('roster_subscription_removed', presence) + self.save() + else: self.xmpp.event('roster_subscription_removed', presence) - self.save() def handle_probe(self, presence): if self['to']: |