Merge branch 'develop'

This commit is contained in:
Nathan Fritz 2010-02-15 21:44:50 -08:00
commit ed60867a63
3 changed files with 22 additions and 38 deletions

View file

@ -267,7 +267,7 @@ class basexmpp(object):
wasoffline = True wasoffline = True
self.roster[jid]['presence'][resource] = {'show': show, 'status': status, 'priority': priority} self.roster[jid]['presence'][resource] = {'show': show, 'status': status, 'priority': priority}
else: else:
if self.roster[jid]['presence'][resource].get('show', None) == 'unavailable': if self.roster[jid]['presence'][resource].get('show', 'unavailable') == 'unavailable':
wasoffline = True wasoffline = True
self.roster[jid]['presence'][resource] = {'show': show, 'status': status} self.roster[jid]['presence'][resource] = {'show': show, 'status': status}
self.roster[jid]['presence'][resource]['priority'] = priority self.roster[jid]['presence'][resource]['priority'] = priority
@ -276,6 +276,7 @@ class basexmpp(object):
self.event("got_online", presence) self.event("got_online", presence)
elif not wasoffline and show == 'unavailable': elif not wasoffline and show == 'unavailable':
self.event("got_offline", presence) self.event("got_offline", presence)
logging.debug("%s %s got offline" % (jid, resource))
if len(self.roster[jid]['presence']) > 1: if len(self.roster[jid]['presence']) > 1:
del self.roster[jid]['presence'][resource] del self.roster[jid]['presence'][resource]
else: else:

View file

@ -43,9 +43,9 @@ class xep_0060(base.base_plugin):
iq = self.xmpp.makeIqSet(pubsub) iq = self.xmpp.makeIqSet(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is False or result is None or result.get('type') == 'error': return False if result is False or result is None or result['type'] == 'error': return False
return True return True
def subscribe(self, jid, node, bare=True, subscribee=None): def subscribe(self, jid, node, bare=True, subscribee=None):
@ -65,7 +65,7 @@ class xep_0060(base.base_plugin):
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq['id'] id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is False or result is None or result.get('type') == 'error': return False if result is False or result is None or result['type'] == 'error': return False
return True return True
def unsubscribe(self, jid, node, bare=True, subscribee=None): def unsubscribe(self, jid, node, bare=True, subscribee=None):
@ -83,9 +83,9 @@ class xep_0060(base.base_plugin):
iq = self.xmpp.makeIqSet(pubsub) iq = self.xmpp.makeIqSet(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is False or result is None or result.get('type') == 'error': return False if result is False or result is None or result['type'] == 'error': return False
return True return True
def getNodeConfig(self, jid, node=None): # if no node, then grab default def getNodeConfig(self, jid, node=None): # if no node, then grab default
@ -101,10 +101,10 @@ class xep_0060(base.base_plugin):
iq.append(pubsub) iq.append(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
#self.xmpp.add_handler("<iq id='%s'/>" % id, self.handlerCreateNodeResponse) #self.xmpp.add_handler("<iq id='%s'/>" % id, self.handlerCreateNodeResponse)
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result == False or result.get('type') == 'error': if result is None or result == False or result['type'] == 'error':
logging.warning("got error instead of config") logging.warning("got error instead of config")
return False return False
if node is not None: if node is not None:
@ -125,9 +125,9 @@ class xep_0060(base.base_plugin):
iq.append(pubsub) iq.append(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result == False or result.get('type') == 'error': if result is None or result == False or result['type'] == 'error':
logging.warning("got error instead of config") logging.warning("got error instead of config")
return False return False
else: else:
@ -148,9 +148,9 @@ class xep_0060(base.base_plugin):
iq.append(pubsub) iq.append(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result == False or result.get('type') == 'error': if result is None or result == False or result['type'] == 'error':
logging.warning("got error instead of config") logging.warning("got error instead of config")
return False return False
else: else:
@ -171,7 +171,7 @@ class xep_0060(base.base_plugin):
iq.append(pubsub) iq.append(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is not None and result is not False and result.attrib.get('type', 'error') != 'error': if result is not None and result is not False and result.attrib.get('type', 'error') != 'error':
return True return True
@ -189,9 +189,9 @@ class xep_0060(base.base_plugin):
iq = self.xmpp.makeIqSet(pubsub) iq = self.xmpp.makeIqSet(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result.get('type') == 'error': if result is None or result['type'] == 'error':
return False return False
return True return True
@ -210,9 +210,9 @@ class xep_0060(base.base_plugin):
iq = self.xmpp.makeIqSet(pubsub) iq = self.xmpp.makeIqSet(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result is False or result.get('type') == 'error': return False if result is None or result is False or result['type'] == 'error': return False
return True return True
def deleteItem(self, jid, node, item): def deleteItem(self, jid, node, item):
@ -226,9 +226,9 @@ class xep_0060(base.base_plugin):
iq = self.xmpp.makeIqSet(pubsub) iq = self.xmpp.makeIqSet(pubsub)
iq.attrib['to'] = jid iq.attrib['to'] = jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result is False or result.get('type') == 'error': return False if result is None or result is False or result['type'] == 'error': return False
return True return True
def addItem(self, jid, node, items=[]): def addItem(self, jid, node, items=[]):
@ -280,9 +280,9 @@ class xep_0060(base.base_plugin):
iq = self.xmpp.makeIqSet(pubsub) iq = self.xmpp.makeIqSet(pubsub)
iq.attrib['to'] = ps_jid iq.attrib['to'] = ps_jid
iq.attrib['from'] = self.xmpp.fulljid iq.attrib['from'] = self.xmpp.fulljid
id = iq.get('id') id = iq['id']
result = self.xmpp.send(iq, "<iq id='%s'/>" % id) result = self.xmpp.send(iq, "<iq id='%s'/>" % id)
if result is None or result is False or result.get('type') == 'error': if result is None or result is False or result['type'] == 'error':
return False return False
return True return True

View file

@ -26,23 +26,6 @@ class Iq(RootStanza):
self['error']['text'] = 'No handlers registered for this request.' self['error']['text'] = 'No handlers registered for this request.'
self.send() self.send()
def result(self):
self['type'] = 'result'
return self
def set(self):
self['type'] = 'set'
return self
def error(self):
#TODO add error payloads
self['type'] = 'error'
return self
def get(self):
self['type'] = 'get'
return self
def setPayload(self, value): def setPayload(self, value):
self.clear() self.clear()
StanzaBase.setPayload(self, value) StanzaBase.setPayload(self, value)