Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 799:7f2082b192ed
plugin XEP-0055, Primitivus: Directory search dialogs are now entirely done in plugin XEP-0055, specific code in frontend is not needed anymore
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 18:03:53 +0100 |
parents | 84214df2d837 |
children | 5174657b3378 |
comparison
equal
deleted
inserted
replaced
798:8f5479f8709a | 799:7f2082b192ed |
---|---|
293 menu.addMenu(contact, _("Add contact"), self.onAddContactRequest) | 293 menu.addMenu(contact, _("Add contact"), self.onAddContactRequest) |
294 menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest) | 294 menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest) |
295 communication = _("Communication") | 295 communication = _("Communication") |
296 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') | 296 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') |
297 menu.addMenu(communication, _("Find Gateways"), self.onFindGatewaysRequest, 'meta g') | 297 menu.addMenu(communication, _("Find Gateways"), self.onFindGatewaysRequest, 'meta g') |
298 menu.addMenu(communication, _("Search directory"), self.onSearchDirectory) | |
299 #additionals menus | 298 #additionals menus |
300 #FIXME: do this in a more generic way (in quickapp) | 299 #FIXME: do this in a more generic way (in quickapp) |
301 add_menus = self.bridge.getMenus('', Const.NO_SECURITY_LIMIT) | 300 add_menus = self.bridge.getMenus('', Const.NO_SECURITY_LIMIT) |
302 def add_menu_cb(callback_id): | 301 def add_menu_cb(callback_id): |
303 self.launchAction(callback_id, None, profile_key = self.profile) | 302 self.launchAction(callback_id, None, profile_key = self.profile) |
593 debug(_("Find gateways request")) | 592 debug(_("Find gateways request")) |
594 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile) | 593 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile) |
595 self.current_action_ids.add(id) | 594 self.current_action_ids.add(id) |
596 self.current_action_ids_cb[id] = self.onGatewaysFound | 595 self.current_action_ids_cb[id] = self.onGatewaysFound |
597 | 596 |
598 def onSearchDirectory(self, e): | |
599 debug(_("Search directory request")) | |
600 | |
601 def requestSearchUi(button, edit): | |
602 self.removePopUp() | |
603 search_jid = edit.get_edit_text() | |
604 if search_jid: | |
605 def success(xml): | |
606 self.addWindow(XMLUI(self,xml_data=xml, misc={'callback': self._onSearchRequest, 'callback_args': [search_jid,]})) | |
607 def failure(error): | |
608 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp)) | |
609 self.bridge.getSearchUI(search_jid, self.profile, callback=success, errback=failure) | |
610 | |
611 | |
612 # TODO: replace users.jabberfr.org by any XEP-0055 compatible service discovered on current server | |
613 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) | |
614 self.showPopUp(pop_up_widget) | |
615 | |
616 def onAddContactRequest(self, menu): | 597 def onAddContactRequest(self, menu): |
617 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) | 598 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) |
618 self.showPopUp(pop_up_widget) | 599 self.showPopUp(pop_up_widget) |
619 | 600 |
620 def onRemoveContactRequest(self, menu): | 601 def onRemoveContactRequest(self, menu): |
634 """Called when SàT has found the server gateways""" | 615 """Called when SàT has found the server gateways""" |
635 target = data['__private__']['target'] | 616 target = data['__private__']['target'] |
636 del data['__private__'] | 617 del data['__private__'] |
637 gatewayManager = GatewaysManager(self, data, server=target) | 618 gatewayManager = GatewaysManager(self, data, server=target) |
638 self.addWindow(gatewayManager) | 619 self.addWindow(gatewayManager) |
639 | |
640 def _onSearchRequest(self, data, search_jid): | |
641 def success(xml): | |
642 ui = XMLUI(self, title=_(u"Search result"), xml_data = xml) | |
643 ui.show('window') | |
644 def failure(error): | |
645 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp)) | |
646 self.bridge.searchRequest(search_jid, dict(data), self.profile, callback=success, errback=failure) | |
647 | 620 |
648 def chatStateReceived(self, from_jid_s, state, profile): | 621 def chatStateReceived(self, from_jid_s, state, profile): |
649 """Signal observer to display a contact chat state | 622 """Signal observer to display a contact chat state |
650 @param from_jid_s: contact who sent his new state | 623 @param from_jid_s: contact who sent his new state |
651 @state: state | 624 @state: state |