LogEvent(INFO, "", "Setting avatar %s" % (key))
prev_umask = os.umask(SPOOL_UMASK)
try:
- f = open(self.dir(key) + key, 'w')
+ f = open(self.dir(key) + key, 'wb')
f.write(imageData)
f.close()
except IOError, e:
filename = self.dir(key) + key
if os.path.isfile(filename):
LogEvent(INFO, "Getting avatar.")
- f = open(filename)
+ f = open(filename, "rb")
data = f.read()
f.close()
return data
# Load the default avatars
-f = open(os.path.join("data", "defaultJabberAvatar.png"))
+f = open(os.path.join("data", "defaultJabberAvatar.png"), "rb")
defaultJabberAvatarData = f.read()
f.close()
-f = open(os.path.join("data", "defaultMSNAvatar.png"))
+f = open(os.path.join("data", "defaultMSNAvatar.png"), "rb")
defaultAvatarData = f.read()
f.close()
defaultAvatar = avatar.AvatarCache().setAvatar(defaultAvatarData)
fro = el.getAttribute("from")
froj = jid.intern(fro)
to = el.getAttribute("to")
+ toj = jid.intern(to)
ID = el.getAttribute("id")
- if(itype != "get" and itype != "error"):
+ if itype != "get" and itype != "error":
self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="cancel", condition="feature-not-implemented")
return
toGateway = not (to.find('@') > 0)
- if(not toGateway):
- if(not self.pytrans.sessions.has_key(froj.userhost())):
+ if not toGateway:
+ if not self.pytrans.sessions.has_key(froj.userhost()):
self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="auth", condition="not-authorized")
return
s = self.pytrans.sessions[froj.userhost()]
- if(not s.ready):
+ if not s.ready:
self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="auth", condition="not-authorized")
return
- c = s.contactList.findContact(to)
- if(not c):
+ c = s.contactList.findContact(toj.userhost())
+ if not c:
self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns="vcard-temp", etype="cancel", condition="recipient-unavailable")
return
iq.attributes["type"] = "result"
vCard = iq.addElement("vCard")
vCard.attributes["xmlns"] = "vcard-temp"
- if(toGateway):
+ if toGateway:
FN = vCard.addElement("FN")
FN.addContent(legacy.name)
DESC = vCard.addElement("DESC")
URL = vCard.addElement("URL")
URL.addContent(legacy.url)
else:
- if(c.nickname):
+ if c.nickname:
NICKNAME = vCard.addElement("NICKNAME")
NICKNAME.addContent(c.nickname)
- if(c.avatar):
+ if c.avatar:
PHOTO = c.avatar.makePhotoElement()
vCard.addChild(PHOTO)
fro = el.getAttribute("from")
froj = jid.intern(fro)
to = el.getAttribute("to")
+ toj = jid.intern(to)
ID = el.getAttribute("id")
if(itype != "get" and itype != "error"):
self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns=disco.IQAVATAR, etype="auth", condition="not-authorized")
return
- c = s.contactList.findContact(to)
+ c = s.contactList.findContact(toj.userhost())
if(not c):
self.pytrans.discovery.sendIqError(to=fro, fro=config.jid, ID=ID, xmlns=disco.IQAVATAR, etype="cancel", condition="recipient-unavailable")
return
froj = jid.intern(el.getAttribute("from"))
query = el.query
- if not (query and query.getAttribute("mode") == "tcp"):
+ if not (query and query.getAttribute("mode", "tcp") == "tcp"):
return errOut()
sid = query.getAttribute("sid")
consumer = self.sessions.pop((froj.full(), sid), None)