mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
deprecated jid, fulljid, server, user, resource properties and added boundjid JID
This commit is contained in:
parent
0d0b963fe5
commit
dc001bb201
4 changed files with 72 additions and 14 deletions
2
setup.py
2
setup.py
|
@ -25,7 +25,7 @@ import sys
|
||||||
#
|
#
|
||||||
# from setuptools import setup, find_packages, Extension, Feature
|
# from setuptools import setup, find_packages, Extension, Feature
|
||||||
|
|
||||||
VERSION = '0.2.3.1'
|
VERSION = '1.0.0.0'
|
||||||
DESCRIPTION = 'SleekXMPP is an elegant Python library for XMPP (aka Jabber, Google Talk, etc).'
|
DESCRIPTION = 'SleekXMPP is an elegant Python library for XMPP (aka Jabber, Google Talk, etc).'
|
||||||
LONG_DESCRIPTION = """
|
LONG_DESCRIPTION = """
|
||||||
SleekXMPP is an elegant Python library for XMPP (aka Jabber, Google Talk, etc).
|
SleekXMPP is an elegant Python library for XMPP (aka Jabber, Google Talk, etc).
|
||||||
|
|
|
@ -113,12 +113,7 @@ class BaseXMPP(XMLStream):
|
||||||
self.default_ns = default_ns
|
self.default_ns = default_ns
|
||||||
self.stream_ns = 'http://etherx.jabber.org/streams'
|
self.stream_ns = 'http://etherx.jabber.org/streams'
|
||||||
|
|
||||||
self.jid = ''
|
self.boundjid = JID("")
|
||||||
self.fulljid = ''
|
|
||||||
self.resource = ''
|
|
||||||
self.jid = ''
|
|
||||||
self.username = ''
|
|
||||||
self.server = ''
|
|
||||||
|
|
||||||
self.plugin = {}
|
self.plugin = {}
|
||||||
self.roster = {}
|
self.roster = {}
|
||||||
|
@ -440,13 +435,75 @@ class BaseXMPP(XMLStream):
|
||||||
presence.append(nick)
|
presence.append(nick)
|
||||||
presence.send()
|
presence.send()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def jid(self):
|
||||||
|
"""
|
||||||
|
Attribute accessor for bare jid
|
||||||
|
"""
|
||||||
|
logging.warning("jid property deprecated. Use boundjid.bare")
|
||||||
|
return self.boundjid.bare
|
||||||
|
|
||||||
|
@jid.setter
|
||||||
|
def jid(self, value):
|
||||||
|
logging.warning("jid property deprecated. Use boundjid.bare")
|
||||||
|
self.boundjid.bare = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def fulljid(self):
|
||||||
|
"""
|
||||||
|
Attribute accessor for full jid
|
||||||
|
"""
|
||||||
|
logging.warning("fulljid property deprecated. Use boundjid.full")
|
||||||
|
return self.boundjid.full
|
||||||
|
|
||||||
|
@fulljid.setter
|
||||||
|
def fulljid(self, value):
|
||||||
|
logging.warning("fulljid property deprecated. Use boundjid.full")
|
||||||
|
self.boundjid.full = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def resource(self):
|
||||||
|
"""
|
||||||
|
Attribute accessor for jid resource
|
||||||
|
"""
|
||||||
|
logging.warning("resource property deprecated. Use boundjid.resource")
|
||||||
|
return self.boundjid.resource
|
||||||
|
|
||||||
|
@resource.setter
|
||||||
|
def resource(self, value):
|
||||||
|
logging.warning("fulljid property deprecated. Use boundjid.full")
|
||||||
|
self.boundjid.resource = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def username(self):
|
||||||
|
"""
|
||||||
|
Attribute accessor for jid usernode
|
||||||
|
"""
|
||||||
|
logging.warning("username property deprecated. Use boundjid.user")
|
||||||
|
return self.boundjid.user
|
||||||
|
|
||||||
|
@username.setter
|
||||||
|
def username(self, value):
|
||||||
|
logging.warning("username property deprecated. Use boundjid.user")
|
||||||
|
self.boundjid.user = value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def server(self):
|
||||||
|
"""
|
||||||
|
Attribute accessor for jid host
|
||||||
|
"""
|
||||||
|
logging.warning("server property deprecated. Use boundjid.host")
|
||||||
|
return self.boundjid.server
|
||||||
|
|
||||||
|
@server.setter
|
||||||
|
def server(self, value):
|
||||||
|
logging.warning("server property deprecated. Use boundjid.host")
|
||||||
|
self.boundjid.server = value
|
||||||
|
|
||||||
def set_jid(self, jid):
|
def set_jid(self, jid):
|
||||||
"""Rip a JID apart and claim it as our own."""
|
"""Rip a JID apart and claim it as our own."""
|
||||||
self.fulljid = jid
|
logging.debug("setting jid to %s" % jid)
|
||||||
self.resource = self.getjidresource(jid)
|
self.boundjid.full = jid
|
||||||
self.jid = self.getjidbare(jid)
|
|
||||||
self.username = jid.split('@', 1)[0]
|
|
||||||
self.server = jid.split('@', 1)[-1].split('/', 1)[0]
|
|
||||||
|
|
||||||
def getjidresource(self, fulljid):
|
def getjidresource(self, fulljid):
|
||||||
if '/' in fulljid:
|
if '/' in fulljid:
|
||||||
|
|
|
@ -175,6 +175,7 @@ class ClientXMPP(BaseXMPP):
|
||||||
if not address:
|
if not address:
|
||||||
# If all else fails, use the server from the JID.
|
# If all else fails, use the server from the JID.
|
||||||
address = (self.server, 5222)
|
address = (self.server, 5222)
|
||||||
|
logging.debug("The server is %s" % self.server)
|
||||||
|
|
||||||
return XMLStream.connect(self, address[0], address[1], use_tls=True)
|
return XMLStream.connect(self, address[0], address[1], use_tls=True)
|
||||||
|
|
||||||
|
|
|
@ -266,8 +266,8 @@ class XMLStream(object):
|
||||||
self.event("connected", direct=True)
|
self.event("connected", direct=True)
|
||||||
return True
|
return True
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
error_msg = "Could not connect. Socket Error #%s: %s"
|
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
|
||||||
logging.error(error_msg % (serr.errno, serr.strerror))
|
logging.error(error_msg % (self.address[0], self.address[1], serr.errno, serr.strerror))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue