Mercurial > libervia-backend
changeset 633:6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 08 Sep 2013 18:05:19 +0200 (2013-09-08) |
parents | 06f44f797a1b |
children | ca2cae6b2c6d |
files | frontends/src/primitivus/primitivus |
diffstat | 1 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus Sun Sep 08 18:05:19 2013 +0200 +++ b/frontends/src/primitivus/primitivus Sun Sep 08 18:05:19 2013 +0200 @@ -194,6 +194,7 @@ communication = _("Communication") menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') menu.addMenu(communication, _("Find Gateways"), self.onFindGatewaysRequest, 'meta g') + menu.addMenu(communication, _("Search directory"), self.onSearchDirectory) #additionals menus #FIXME: do this in a more generic way (in quickapp) add_menus = self.bridge.getMenus() @@ -519,11 +520,29 @@ self.showPopUp(pop_up_widget) def onFindGatewaysRequest(self, e): - debug(_("Find Gateways request")) + debug(_("Find gateways request")) id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile) self.current_action_ids.add(id) self.current_action_ids_cb[id] = self.onGatewaysFound + def onSearchDirectory(self, e): + debug(_("Search directory request")) + + def requestSearchUi(button, edit): + self.removePopUp() + search_jid = edit.get_edit_text() + if search_jid: + def success(xml): + self.addWindow(XMLUI(self,xml_data=xml, misc={'callback': self._onSearchRequest, 'callback_args': [search_jid,]})) + def failure(error): + self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp)) + self.bridge.getSearchUI(search_jid, self.profile, callback=success, errback=failure) + + + # TODO: replace users.jabberfr.org by any XEP-0055 compatible service discovered on current server + pop_up_widget = sat_widgets.InputDialog(_("Search directory"), _("Please enter the search jid: "), default_txt="users.jabberfr.org", cancel_cb=lambda ignore: self.removePopUp(), ok_cb=requestSearchUi) + self.showPopUp(pop_up_widget) + def onAddContactRequest(self, menu): pop_up_widget = sat_widgets.InputDialog(_("Adding a contact"), _("Please enter new contact JID"), default_txt = 'name@server.tld', cancel_cb=self.removePopUp, ok_cb=self.onAddContact) self.showPopUp(pop_up_widget) @@ -548,6 +567,14 @@ gatewayManager = GatewaysManager(self, data, server=target) self.addWindow(gatewayManager) + def _onSearchRequest(self, data, search_jid): + def success(xml): + ui = XMLUI(self, title=_(u"Search result"), xml_data = xml) + ui.show('window') + def failure(error): + self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp)) + self.bridge.searchRequest(search_jid, dict(data), self.profile, callback=success, errback=failure) + sat = PrimitivusApp() sat.start()