# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
-import utils
-import config
+from debug import LogEvent, INFO, WARN, ERROR
+
from twisted.internet import reactor
from tlib.xmlw import Element
-from debug import LogEvent, INFO, WARN, ERROR
+
+import sha, base64, os, os.path
+
+import utils
import config
-import lang
-import sha
-import base64
-import os
-import os.path
+
SPOOL_UMASK = 0077
def makePhotoElement(self):
""" Returns an XML Element that can be put into the vCard. """
photo = Element((None, "PHOTO"))
- type = photo.addElement("TYPE")
- type.addContent("image/png")
+ cType = photo.addElement("TYPE")
+ cType.addContent("image/png")
binval = photo.addElement("BINVAL")
binval.addContent(base64.encodestring(self.getImageData()))
return photo
imageData = self.getAvatarData(key)
if imageData:
return Avatar(imageData, self)
+ else:
+ return None
def getAvatarData(self, key):
""" Loads the avatar with SHA1 hash of 'key' from disk and returns the data """
return data
else:
LogEvent(INFO, "", "Avatar not found.")
- except IOError, e:
+ except IOError:
LogEvent(WARN, "", "IOError reading avatar.")
+ else:
+ return None
pid = ""
debugLevel = "0" # 0->None, 1->Traceback, 2->WARN,ERROR, 3->INFO,WARN,ERROR
+_debugLevel = 0 # Maintained by debug.reloadConfig as an int
debugFile = ""
# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
-import utils
+from debug import LogEvent, INFO, WARN, ERROR
+
from twisted.internet import reactor
from tlib.xmlw import Element
-from debug import LogEvent, INFO, WARN, ERROR
+
import disco
import legacy
-import jabw
-import config
-import lang
-import sha
class Contact:
# Licensed for distribution under the GPL version 2, check COPYING for details
from twisted.python import log
+
import sys, time
import config
# Copyright 2004-2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
-import utils
-from tlib.xmlw import Element, jid
+from debug import LogEvent, INFO, WARN, ERROR
+
from twisted.internet.defer import Deferred
from twisted.internet import reactor
-from debug import LogEvent, INFO, WARN, ERROR
+from tlib.xmlw import Element, jid
+
import sys
-import config
-import legacy
+
import lang
+import utils
+import config
XMPP_STANZAS = "urn:ietf:params:xml:ns:xmpp-stanzas"
DISCO = "http://jabber.org/protocol/disco"
try: # Stringprep
froj = jid.intern(fro)
to = jid.intern(to).full()
- except Exception, e:
+ except Exception:
LogEvent(WARN, "", "Dropping IQ because of stringprep error")
# Check if it's a response to a send IQ
self.legacycon.updateAvatar() # Default avatar
return
avatarSet = False
+ name = ""
for e in vCard.elements():
if e.name == "NICKNAME":
- self.updateNickname(e.__str__())
+ name = e.__str__()
+ if not name and e.name == "FN":
+ # Give priority to nickname
+ name = e.__str__()
if e.name == "PHOTO":
imageData = avatar.parsePhotoEl(e)
if not imageData:
self.avatar = self.pytrans.avatarCache.setAvatar(imageData)
self.legacycon.updateAvatar(self.avatar)
avatarSet = True
+ if name:
+ self.updateNickname(e.__str__())
if not avatarSet:
self.legacycon.updateAvatar() # Default avatar
from twisted.internet.protocol import ClientFactory
# System imports
-import math, base64, binascii, math
+import math, base64, binascii
# Local imports
from debug import LogEvent, INFO, WARN, ERROR
if hasattr(config, o):
setattr(config, o, options[0])
else:
- print "Option %s is not a defined option. Ignoring!" % (tag)
+ print "Option %s is not a defined option. Ignoring!" % (o)
def reloadConfig(file=None, options=None):
if file: