Jabberpy V0.5
This commit is contained in:
parent
cf2c7b5037
commit
fa49d30545
|
@ -194,7 +194,7 @@ class NodeProcessed(Exception): pass # currently only for Connection._expectedIq
|
|||
class Connection(xmlstream.Client):
|
||||
"""Forms the base for both Client and Component Classes"""
|
||||
def __init__(self, host, port, namespace,
|
||||
debug=False, log=False, connection=xmlstream.TCP, hostIP=None, proxy=None):
|
||||
debug=[], log=False, connection=xmlstream.TCP, hostIP=None, proxy=None):
|
||||
|
||||
xmlstream.Client.__init__(self, host, port, namespace,
|
||||
debug=debug, log=log,
|
||||
|
@ -410,7 +410,7 @@ class Connection(xmlstream.Client):
|
|||
|
||||
class Client(Connection):
|
||||
"""Class for managing a client connection to a jabber server."""
|
||||
def __init__(self, host, port=5222, debug=False, log=False,
|
||||
def __init__(self, host, port=5222, debug=[], log=False,
|
||||
connection=xmlstream.TCP, hostIP=None, proxy=None):
|
||||
|
||||
Connection.__init__(self, host, port, NS_CLIENT, debug, log,
|
||||
|
@ -592,7 +592,6 @@ class Client(Connection):
|
|||
if groups != None:
|
||||
for group in groups:
|
||||
item.insertTag('group').insertData(group)
|
||||
# self.send(iq)
|
||||
dummy = self.SendAndWaitForResponse(iq) # Do we need to wait??
|
||||
|
||||
|
||||
|
@ -656,14 +655,16 @@ class Client(Connection):
|
|||
Note that you must be authorised before attempting to deregister.
|
||||
"""
|
||||
if agent:
|
||||
agent = agent + '.'
|
||||
self.send(Presence(to=agent+self._host,type='unsubscribed')) # This is enough f.e. for icqv7t or jit
|
||||
# agent = agent + '.'
|
||||
# self.send(Presence(to=agent+self._host,type='unsubscribed')) # This is enough f.e. for icqv7t or jit
|
||||
self.send(Presence(to=agent,type='unsubscribed')) # This is enough f.e. for icqv7t or jit
|
||||
if agent is None: agent = ''
|
||||
q = self.requestRegInfo()
|
||||
kids = q.getQueryPayload()
|
||||
keyTag = kids.getTag("key")
|
||||
|
||||
iq = Iq(to=agent+self._host, type="set")
|
||||
# iq = Iq(to=agent+self._host, type="set")
|
||||
iq = Iq(to=agent, type="set")
|
||||
iq.setQuery(NS_REGISTER)
|
||||
iq.setQueryNode("")
|
||||
q = iq.getQueryNode()
|
||||
|
@ -808,7 +809,7 @@ class Protocol(xmlstream.Node):
|
|||
def getX(self,index=0):
|
||||
"""Returns the x namespace, optionally passed an index if there are
|
||||
multiple tags."""
|
||||
try: return self.getXNodes('x')[index].namespace
|
||||
try: return self.getXNodes()[index].namespace
|
||||
except: return None
|
||||
|
||||
|
||||
|
@ -1395,7 +1396,7 @@ class JID:
|
|||
class Component(Connection):
|
||||
"""docs to come soon... """
|
||||
def __init__(self, host, port, connection=xmlstream.TCP,
|
||||
debug=False, log=False, ns=NS_COMP_ACCEPT, hostIP=None, proxy=None):
|
||||
debug=[], log=False, ns=NS_COMP_ACCEPT, hostIP=None, proxy=None):
|
||||
Connection.__init__(self, host, port, namespace=ns, debug=debug,
|
||||
log=log, connection=connection, hostIP=hostIP, proxy=proxy)
|
||||
self._auth_OK = False
|
||||
|
|
|
@ -28,7 +28,7 @@ case.
|
|||
|
||||
"""
|
||||
|
||||
# $Id: xmlstream.py,v 1.42 2004/01/08 15:47:40 snakeru Exp $
|
||||
# $Id$
|
||||
|
||||
import time, sys, re, socket
|
||||
from select import select
|
||||
|
@ -37,7 +37,7 @@ import xml.parsers.expat
|
|||
import debug
|
||||
_debug=debug
|
||||
|
||||
VERSION = "0.5-rc1"
|
||||
VERSION = "0.5"
|
||||
|
||||
False = 0
|
||||
True = 1
|
||||
|
@ -199,12 +199,13 @@ class Node:
|
|||
s = s + "</" + self.name + ">"
|
||||
return s
|
||||
|
||||
def getTag(self, name):
|
||||
def getTag(self, name, index=None):
|
||||
"""Returns a child node with tag name. Returns None
|
||||
if not found."""
|
||||
for node in self.kids:
|
||||
if node.getName() == name:
|
||||
return node
|
||||
if not index: return node
|
||||
if index is not None: index-=1
|
||||
return None
|
||||
|
||||
def getTags(self, name):
|
||||
|
|
Loading…
Reference in New Issue