Wix: added avatar in profile
- plugin XEP-0054: added getProfileFile bridge method
This commit is contained in:
parent
31df7d8557
commit
0dab325230
3 changed files with 27 additions and 2 deletions
|
|
@ -64,6 +64,9 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
def getProfile(self, target):
|
||||
return self.db_comm_iface.getProfile(target)
|
||||
|
||||
def getAvatarFile(self, hash):
|
||||
return self.db_comm_iface.getAvatarFile(hash)
|
||||
|
||||
def in_band_register(self, target):
|
||||
return self.db_comm_iface.in_band_register(target)
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ class Profile(wx.Frame):
|
|||
'birthday' : 'Birthday',
|
||||
'phone' : 'Phone #',
|
||||
'website' : 'Website',
|
||||
'email' : 'E-mail'
|
||||
'email' : 'E-mail',
|
||||
'avatar' : 'Avatar'
|
||||
}
|
||||
self.ctl_list = {} # usefull to access ctrl, key = (name)
|
||||
|
||||
|
|
@ -69,6 +70,15 @@ class Profile(wx.Frame):
|
|||
sizer.Add(label)
|
||||
self.ctl_list[field] = wx.TextCtrl(generaltab, -1, value, style = flags)
|
||||
sizer.Add(self.ctl_list[field], 1, flag = wx.EXPAND)
|
||||
#Avatar
|
||||
if data.has_key('avatar'):
|
||||
filename = self.host.bridge.getAvatarFile(data['avatar'])
|
||||
label=wx.StaticText(generaltab, -1, self.name_dict['avatar']+": ")
|
||||
sizer.Add(label)
|
||||
img = wx.Image(filename).ConvertToBitmap()
|
||||
self.ctl_list['avatar'] = wx.StaticBitmap(generaltab, -1, img)
|
||||
sizer.Add(self.ctl_list['avatar'], 0)
|
||||
|
||||
|
||||
|
||||
self.notebook.AddPage(generaltab, "General")
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class XEP_0054():
|
|||
if not os.path.exists(self.avatar_path):
|
||||
os.makedirs(self.avatar_path)
|
||||
host.bridge.addMethod("getProfile", ".communication", in_sign='s', out_sign='s', method=self.getProfile)
|
||||
host.bridge.addMethod("getAvatarFile", ".communication", in_sign='s', out_sign='s', method=self.getAvatarFile)
|
||||
|
||||
def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
|
||||
return [disco.DiscoFeature(NS_VCARD)]
|
||||
|
|
@ -110,7 +111,7 @@ class XEP_0054():
|
|||
d2 = defer.waitForDeferred(
|
||||
threads.deferToThread(self.save_photo, elem))
|
||||
yield d2
|
||||
dictionary["photo"] = d2.getResult()
|
||||
dictionary["avatar"] = d2.getResult()
|
||||
else:
|
||||
info ('FIXME: [%s] VCard tag is not managed yet' % elem.name)
|
||||
|
||||
|
|
@ -145,3 +146,14 @@ class XEP_0054():
|
|||
reg_request.send(to_jid.full()).addCallbacks(self.vcard_ok, self.vcard_err)
|
||||
return reg_request["id"]
|
||||
|
||||
def getAvatarFile(self, hash):
|
||||
"""Give the full path of avatar from hash
|
||||
@param hash: SHA1 hash
|
||||
@return full_path
|
||||
"""
|
||||
filename = self.avatar_path+'/'+hash
|
||||
if not os.path.exists(filename):
|
||||
error ("Asking for an uncached avatar [%s]" % hash)
|
||||
return ""
|
||||
return filename
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue