Merge remote branch 'fritzy/master'

This commit is contained in:
Brian Beggs 2010-05-12 07:46:07 -04:00
commit 1521a8b5c9
3 changed files with 18 additions and 22 deletions

View file

@ -65,7 +65,7 @@ class TestPubsubServer(unittest.TestCase):
"""Retrieving node config and reconfiguring""" """Retrieving node config and reconfiguring"""
nconfig = self.xmpp1['xep_0060'].getNodeConfig(self.pshost, 'testnode2') nconfig = self.xmpp1['xep_0060'].getNodeConfig(self.pshost, 'testnode2')
self.failUnless(nconfig, "No configuration returned") self.failUnless(nconfig, "No configuration returned")
#print("%s == %s" % (nconfig.getValues(), self.statev['defaultconfig'].getValues())) #print("\n%s ==\n %s" % (nconfig.getValues(), self.statev['defaultconfig'].getValues()))
self.failUnless(nconfig.getValues() == self.statev['defaultconfig'].getValues(), "Configuration does not match") self.failUnless(nconfig.getValues() == self.statev['defaultconfig'].getValues(), "Configuration does not match")
self.failUnless(self.xmpp1['xep_0060'].setNodeConfig(self.pshost, 'testnode2', nconfig)) self.failUnless(self.xmpp1['xep_0060'].setNodeConfig(self.pshost, 'testnode2', nconfig))

View file

@ -261,27 +261,23 @@ class basexmpp(object):
if not presence['from'].bare in self.roster: if not presence['from'].bare in self.roster:
self.roster[jid] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': False} self.roster[jid] = {'groups': [], 'name': '', 'subscription': 'none', 'presence': {}, 'in_roster': False}
if not resource in self.roster[jid]['presence']: if not resource in self.roster[jid]['presence']:
if (show == 'available' or show in presence.showtypes):
self.event("got_online", presence)
wasoffline = True wasoffline = True
self.roster[jid]['presence'][resource] = {'show': show, 'status': status, 'priority': priority} self.roster[jid]['presence'][resource] = {}
else: if self.roster[jid]['presence'][resource].get('show', 'unavailable') == 'unavailable':
if self.roster[jid]['presence'][resource].get('show', 'unavailable') == 'unavailable': wasoffline = True
wasoffline = True self.roster[jid]['presence'][resource] = {'show': show, 'status': status, 'priority': priority}
self.roster[jid]['presence'][resource] = {'show': show, 'status': status}
self.roster[jid]['presence'][resource]['priority'] = priority
name = self.roster[jid].get('name', '') name = self.roster[jid].get('name', '')
if wasoffline and (show == 'available' or show in presence.showtypes): if show == 'unavailable':
self.event("got_online", presence)
self.event("changed_status", presence)
elif show == 'unavailable':
logging.debug("%s %s got offline" % (jid, resource)) 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] del self.roster[jid]['presence'][resource]
else: else:
del self.roster[jid] del self.roster[jid]
self.event("got_offline", presence) if not wasoffline:
self.event("changed_status", presence) self.event("got_offline", presence)
elif oldroster != self.roster.get(jid, {'presence': {}})['presence'].get(resource, {}): self.event("changed_status", presence)
self.event("changed_status", presence)
name = '' name = ''
if name: if name:
name = "(%s) " % name name = "(%s) " % name

View file

@ -147,12 +147,12 @@ class xep_0045(base.base_plugin):
""" """
self.xmpp.event('groupchat_message', msg) self.xmpp.event('groupchat_message', msg)
def jidInRoom(self, room, jid): def jidInRoom(self, room, jid):
for nick in self.rooms[room]: for nick in self.rooms[room]:
entry = self.rooms[room][nick] entry = self.rooms[room][nick]
if entry is not None and entry['jid'].full == jid: if entry is not None and entry['jid'].full == jid:
return True return True
return False return False
def getRoomForm(self, room, ifrom=None): def getRoomForm(self, room, ifrom=None):
iq = self.xmpp.makeIqGet() iq = self.xmpp.makeIqGet()