deprecated jid, fulljid, server, user, resource properties and added boundjid JID

This commit is contained in:
Nathan Fritz 2010-10-14 15:50:54 -07:00
parent 0d0b963fe5
commit dc001bb201
4 changed files with 72 additions and 14 deletions

View file

@ -25,7 +25,7 @@ import sys
#
# 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).'
LONG_DESCRIPTION = """
SleekXMPP is an elegant Python library for XMPP (aka Jabber, Google Talk, etc).

View file

@ -113,12 +113,7 @@ class BaseXMPP(XMLStream):
self.default_ns = default_ns
self.stream_ns = 'http://etherx.jabber.org/streams'
self.jid = ''
self.fulljid = ''
self.resource = ''
self.jid = ''
self.username = ''
self.server = ''
self.boundjid = JID("")
self.plugin = {}
self.roster = {}
@ -440,13 +435,75 @@ class BaseXMPP(XMLStream):
presence.append(nick)
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):
"""Rip a JID apart and claim it as our own."""
self.fulljid = jid
self.resource = self.getjidresource(jid)
self.jid = self.getjidbare(jid)
self.username = jid.split('@', 1)[0]
self.server = jid.split('@', 1)[-1].split('/', 1)[0]
logging.debug("setting jid to %s" % jid)
self.boundjid.full = jid
def getjidresource(self, fulljid):
if '/' in fulljid:

View file

@ -175,6 +175,7 @@ class ClientXMPP(BaseXMPP):
if not address:
# If all else fails, use the server from the JID.
address = (self.server, 5222)
logging.debug("The server is %s" % self.server)
return XMLStream.connect(self, address[0], address[1], use_tls=True)

View file

@ -266,8 +266,8 @@ class XMLStream(object):
self.event("connected", direct=True)
return True
except Socket.error as serr:
error_msg = "Could not connect. Socket Error #%s: %s"
logging.error(error_msg % (serr.errno, serr.strerror))
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
logging.error(error_msg % (self.address[0], self.address[1], serr.errno, serr.strerror))
time.sleep(1)
return False