# HG changeset patch # User Goffi # Date 1378656319 -7200 # Node ID 6a29a4d574bdde005840845043975520a36a950a # Parent 06f44f797a1bdb2eac6c4df29eeec97f97fb6b39 primitivus: menu to search directory (using XEP-0055) diff -r 06f44f797a1b -r 6a29a4d574bd frontends/src/primitivus/primitivus --- 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()