summaryrefslogtreecommitdiff
path: root/sleekxmpp/basexmpp.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-05-11 15:12:13 -0700
committerNathan Fritz <nathan@andyet.net>2010-05-11 15:12:13 -0700
commit8515cef11734613267b1b31f543bca620beac864 (patch)
tree0a20647846cd46a886cf093306d34b90781fd176 /sleekxmpp/basexmpp.py
parent9d76e7353a9654d20be617e12fbaf329b5908794 (diff)
downloadslixmpp-8515cef11734613267b1b31f543bca620beac864.tar.gz
slixmpp-8515cef11734613267b1b31f543bca620beac864.tar.bz2
slixmpp-8515cef11734613267b1b31f543bca620beac864.tar.xz
slixmpp-8515cef11734613267b1b31f543bca620beac864.zip
refactored presence tracking and fixed jidInRoom
Diffstat (limited to 'sleekxmpp/basexmpp.py')
-rw-r--r--sleekxmpp/basexmpp.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index cc0f1087..fef8538a 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -261,27 +261,23 @@ class basexmpp(object):
if not presence['from'].bare in self.roster:
self.roster[jid] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': False}
if not resource in self.roster[jid]['presence']:
+ if (show == 'available' or show in presence.showtypes):
+ self.event("got_online", presence)
wasoffline = True
- self.roster[jid]['presence'][resource] = {'show': show, 'status': status, 'priority': priority}
- else:
- if self.roster[jid]['presence'][resource].get('show', 'unavailable') == 'unavailable':
- wasoffline = True
- self.roster[jid]['presence'][resource] = {'show': show, 'status': status}
- self.roster[jid]['presence'][resource]['priority'] = priority
+ self.roster[jid]['presence'][resource] = {}
+ if self.roster[jid]['presence'][resource].get('show', 'unavailable') == 'unavailable':
+ wasoffline = True
+ self.roster[jid]['presence'][resource] = {'show': show, 'status': status, 'priority': priority}
name = self.roster[jid].get('name', '')
- if wasoffline and (show == 'available' or show in presence.showtypes):
- self.event("got_online", presence)
- self.event("changed_status", presence)
- elif show == 'unavailable':
+ if show == 'unavailable':
logging.debug("%s %s got offline" % (jid, resource))
- if len(self.roster[jid]['presence']) > 1:
+ if len(self.roster[jid]['presence']):
del self.roster[jid]['presence'][resource]
else:
del self.roster[jid]
- self.event("got_offline", presence)
- self.event("changed_status", presence)
- elif oldroster != self.roster.get(jid, {'presence': {}})['presence'].get(resource, {}):
- self.event("changed_status", presence)
+ if not wasoffline:
+ self.event("got_offline", presence)
+ self.event("changed_status", presence)
name = ''
if name:
name = "(%s) " % name