Remove trailing whitespaces.
This commit is contained in:
parent
310e2cc347
commit
27b3592e16
1 changed files with 899 additions and 899 deletions
|
|
@ -90,9 +90,9 @@ class XEP_0054():
|
|||
x_elt = domish.Element((NS_VCARD_UPDATE, 'x'))
|
||||
x_elt.addElement('photo', content=self.avatars_cache[client.jid.userhost()])
|
||||
presence_elt.addChild(x_elt)
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def _fillCachedValues(self, result, client):
|
||||
#FIXME: this is really suboptimal, need to be reworked
|
||||
# the current naive approach keeps a map between all jids of all profiles
|
||||
|
|
@ -101,11 +101,11 @@ class XEP_0054():
|
|||
for _jid in client.roster.getBareJids() + [client.jid.userhost()]:
|
||||
if _jid in self.avatars_cache:
|
||||
self.host.memory.updateEntityData(jid.JID(_jid), "avatar", self.avatars_cache[_jid], client.profile)
|
||||
|
||||
|
||||
def profileConnected(self, profile):
|
||||
client = self.host.getClient(profile)
|
||||
client.roster.got_roster.addCallback(self._fillCachedValues, client)
|
||||
|
||||
|
||||
def update_cache(self, jid, name, value, profile):
|
||||
"""update cache value
|
||||
- save value in memory in case of change
|
||||
|
|
@ -122,7 +122,7 @@ class XEP_0054():
|
|||
self.host.memory.updateEntityData(jid, name, value, profile)
|
||||
if name == "avatar":
|
||||
self.avatars_cache[jid.userhost()] = value
|
||||
|
||||
|
||||
def get_cache(self, jid, name, profile):
|
||||
"""return cached value for jid
|
||||
@param jid: target contact
|
||||
|
|
@ -158,7 +158,7 @@ class XEP_0054():
|
|||
"""Convert a VCard to a dict, and save binaries"""
|
||||
debug (_("parsing vcard"))
|
||||
dictionary = {}
|
||||
|
||||
|
||||
for elem in vcard.elements():
|
||||
if elem.name == 'FN':
|
||||
dictionary['fullname'] = unicode(elem)
|
||||
|
|
@ -170,7 +170,7 @@ class XEP_0054():
|
|||
elif elem.name == 'EMAIL':
|
||||
dictionary['email'] = unicode(elem)
|
||||
elif elem.name == 'BDAY':
|
||||
dictionary['birthday'] = unicode(elem)
|
||||
dictionary['birthday'] = unicode(elem)
|
||||
elif elem.name == 'PHOTO':
|
||||
dictionary["avatar"] = yield threads.deferToThread(self.save_photo, elem)
|
||||
if not dictionary["avatar"]: #can happen in case of e.g. empty photo elem
|
||||
|
|
@ -202,7 +202,7 @@ class XEP_0054():
|
|||
"""Called when something is wrong with registration"""
|
||||
error (_("Can't find VCard of %s") % failure.value.stanza['from'])
|
||||
self.host.bridge.actionResult("SUPPRESS", failure.value.stanza['id'], {}, profile) #FIXME: maybe an error message would be better
|
||||
|
||||
|
||||
def getCard(self, target_s, profile_key='@DEFAULT@'):
|
||||
"""Ask server for VCard
|
||||
@param target_s: jid from which we want the VCard
|
||||
|
|
@ -219,7 +219,7 @@ class XEP_0054():
|
|||
reg_request["to"] = to_jid.userhost()
|
||||
reg_request.addElement('vCard', NS_VCARD)
|
||||
reg_request.send(to_jid.userhost()).addCallbacks(self.vcard_ok, self.vcard_err, callbackArgs=[profile], errbackArgs=[profile])
|
||||
return reg_request["id"]
|
||||
return reg_request["id"]
|
||||
|
||||
def getAvatarFile(self, avatar_hash):
|
||||
"""Give the full path of avatar from hash
|
||||
|
|
@ -258,38 +258,38 @@ class XEP_0054():
|
|||
client = self.host.getClient(profile_key)
|
||||
if not client:
|
||||
raise exceptions.NotConnectedProfileError(_('Trying to set avatar for a non-existant or not connected profile'))
|
||||
|
||||
|
||||
vcard_set = IQ(client.xmlstream,'set')
|
||||
d = threads.deferToThread(self._buildSetAvatar, vcard_set, filepath)
|
||||
|
||||
|
||||
def elementBuilt(result):
|
||||
"""Called once the image is at the right size/format, and the vcard set element is build"""
|
||||
set_avatar_elt, img_hash = result
|
||||
self.avatars_cache[client.jid.userhost()] = img_hash # we need to update the hash, so we can send a new presence
|
||||
# element with the right hash
|
||||
# element with the right hash
|
||||
return set_avatar_elt.send().addCallback(lambda ignore: client.presence.available())
|
||||
|
||||
|
||||
d.addCallback(elementBuilt)
|
||||
|
||||
|
||||
return d
|
||||
|
||||
|
||||
class XEP_0054_handler(XMPPHandler):
|
||||
implements(iwokkel.IDisco)
|
||||
|
||||
|
||||
def __init__(self, plugin_parent):
|
||||
self.plugin_parent = plugin_parent
|
||||
self.host = plugin_parent.host
|
||||
|
||||
def connectionInitialized(self):
|
||||
self.xmlstream.addObserver(VCARD_UPDATE, self.update)
|
||||
|
||||
|
||||
def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
|
||||
return [disco.DiscoFeature(NS_VCARD)]
|
||||
|
||||
def getDiscoItems(self, requestor, target, nodeIdentifier=''):
|
||||
return []
|
||||
|
||||
|
||||
def update(self, presence):
|
||||
"""Request for VCard's nickname
|
||||
return the cached nickname if exists, else get VCard
|
||||
|
|
|
|||
Loading…
Reference in a new issue