Mercurial > libervia-backend
diff frontends/wix/main_window.py @ 42:874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
- new xep-0054 plugin, avatar are cached, new getProfile bridge method
- gateways plugin (XEP-0100): new __private__ key in resulting data, used to keep target jid
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Dec 2009 13:22:11 +1100 |
parents | 3e24753b9e0b |
children | 8c67ea98ab91 |
line wrap: on
line diff
--- a/frontends/wix/main_window.py Sat Dec 19 20:32:58 2009 +1100 +++ b/frontends/wix/main_window.py Mon Dec 21 13:22:11 2009 +1100 @@ -25,6 +25,7 @@ from param import Param from form import Form from gateways import GatewaysManager +from profile import Profile import gobject import os.path import pdb @@ -43,7 +44,8 @@ idPARAM = 4 idADD_CONTACT = 5 idREMOVE_CONTACT = 6 -idFIND_GATEWAYS = 7 +idSHOW_PROFILE = 7 +idFIND_GATEWAYS = 8 const_DEFAULT_GROUP = "Unclassed" const_STATUS = {"Online":"", "Want to discuss":"chat", @@ -208,6 +210,8 @@ contactMenu = wx.Menu() contactMenu.Append(idADD_CONTACT, "&Add contact"," Add a contact to your list") contactMenu.Append(idREMOVE_CONTACT, "&Remove contact"," Remove the selected contact from your list") + contactMenu.AppendSeparator() + contactMenu.Append(idSHOW_PROFILE, "&Show profile", " Show contact's profile") communicationMenu = wx.Menu() communicationMenu.Append(idFIND_GATEWAYS, "&Find Gateways"," Find gateways to legacy IM") menuBar = wx.MenuBar() @@ -223,6 +227,7 @@ wx.EVT_MENU(self, idEXIT, self.onExit) wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact) wx.EVT_MENU(self, idREMOVE_CONTACT, self.onRemoveContact) + wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile) wx.EVT_MENU(self, idFIND_GATEWAYS, self.onFindGateways) @@ -332,12 +337,18 @@ self.current_action_ids.remove(id) debug ("Form received") form=Form(self, title='Registration', target = data['target'], type = data['type'], xml_data = data['xml']) + elif type == "RESULT": + self.current_action_ids.remove(id) + if self.current_action_ids_cb.has_key(id): + callback = self.current_action_ids_cb[id] + del self.current_action_ids_cb[id] + callback(data) elif type == "DICT_DICT": self.current_action_ids.remove(id) if self.current_action_ids_cb.has_key(id): callback = self.current_action_ids_cb[id] del self.current_action_ids_cb[id] - callback(id,data) + callback(data) print ("Dict of dict found as result") else: error ("FIXME FIXME FIXME: type [%s] not implemented" % type) @@ -428,7 +439,7 @@ dlg.Destroy() return - dlg = wx.MessageDialog(self, "Are you sure you want to delete %s from your roster list ?" % target.short, + dlg = wx.MessageDialog(self, "Are you sure you want to delete %s from your roster list ?" % target.short, 'Contact suppression', wx.YES_NO | wx.ICON_QUESTION ) @@ -439,6 +450,27 @@ dlg.Destroy() + def onShowProfile(self, e): + debug("Show contact's profile request") + target = self.contactList.getSelection() + if not target: + dlg = wx.MessageDialog(self, "You haven't selected any contact !", + 'Error', + wx.OK | wx.ICON_ERROR + ) + dlg.ShowModal() + dlg.Destroy() + return + id = self.bridge.getProfile(target.short) + self.current_action_ids.add(id) + self.current_action_ids_cb[id] = self.onProfileReceived + + def onProfileReceived(self, data): + """Called when a profile is received""" + debug ('Profile received: [%s]' % data) + profile=Profile(self, data) + + def onFindGateways(self, e): debug("Find Gateways request") id = self.bridge.findGateways(self.whoami.domain) @@ -446,9 +478,11 @@ self.current_action_ids_cb[id] = self.onGatewaysFound print "Find Gateways id=", id - def onGatewaysFound(self, id, data): + def onGatewaysFound(self, data): """Called when SàT has found the server gateways""" - gatewayManager = GatewaysManager(self, data) + target = data['__private__']['target'] + del data['__private__'] + gatewayManager = GatewaysManager(self, data, server=target) def onClose(self, e): info("Exiting...")