# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
from debug import LogEvent, INFO, WARN, ERROR
from debug import LogEvent, INFO, WARN, ERROR
def makePhotoElement(self):
""" Returns an XML Element that can be put into the vCard. """
photo = Element((None, "PHOTO"))
def makePhotoElement(self):
""" Returns an XML Element that can be put into the vCard. """
photo = Element((None, "PHOTO"))
return photo
def makeDataElement(self):
""" Returns an XML Element that can be put into a jabber:x:avatar IQ stanza. """
data = Element((None, "data"))
data["mimetype"] = "image/png"
return photo
def makeDataElement(self):
""" Returns an XML Element that can be put into a jabber:x:avatar IQ stanza. """
data = Element((None, "data"))
data["mimetype"] = "image/png"
def dir(self, key):
""" Returns the full path to the directory that a
particular key is in. Creates that directory if it doesn't already exist. """
def dir(self, key):
""" Returns the full path to the directory that a
particular key is in. Creates that directory if it doesn't already exist. """
LogEvent(INFO, "", "Setting avatar %s" % (key))
prev_umask = os.umask(SPOOL_UMASK)
try:
LogEvent(INFO, "", "Setting avatar %s" % (key))
prev_umask = os.umask(SPOOL_UMASK)
try:
imageData = self.getAvatarData(key)
if imageData:
return Avatar(imageData, self)
imageData = self.getAvatarData(key)
if imageData:
return Avatar(imageData, self)
def getAvatarData(self, key):
""" Loads the avatar with SHA1 hash of 'key' from disk and returns the data """
def getAvatarData(self, key):
""" Loads the avatar with SHA1 hash of 'key' from disk and returns the data """
filename = self.dir(key) + key
if os.path.isfile(filename):
LogEvent(INFO, "Getting avatar.")
filename = self.dir(key) + key
if os.path.isfile(filename):
LogEvent(INFO, "Getting avatar.")