comparison frontends/src/primitivus/primitivus @ 633:6a29a4d574bd

primitivus: menu to search directory (using XEP-0055)
author Goffi <goffi@goffi.org>
date Sun, 08 Sep 2013 18:05:19 +0200
parents 84a6e83157c2
children ca2cae6b2c6d
comparison
equal deleted inserted replaced
632:06f44f797a1b 633:6a29a4d574bd
192 menu.addMenu(contact, _("Add contact"), self.onAddContactRequest) 192 menu.addMenu(contact, _("Add contact"), self.onAddContactRequest)
193 menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest) 193 menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest)
194 communication = _("Communication") 194 communication = _("Communication")
195 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') 195 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j')
196 menu.addMenu(communication, _("Find Gateways"), self.onFindGatewaysRequest, 'meta g') 196 menu.addMenu(communication, _("Find Gateways"), self.onFindGatewaysRequest, 'meta g')
197 menu.addMenu(communication, _("Search directory"), self.onSearchDirectory)
197 #additionals menus 198 #additionals menus
198 #FIXME: do this in a more generic way (in quickapp) 199 #FIXME: do this in a more generic way (in quickapp)
199 add_menus = self.bridge.getMenus() 200 add_menus = self.bridge.getMenus()
200 def add_menu_cb(menu): 201 def add_menu_cb(menu):
201 category, item = menu 202 category, item = menu
517 """User wants to join a MUC room""" 518 """User wants to join a MUC room"""
518 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom) 519 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
519 self.showPopUp(pop_up_widget) 520 self.showPopUp(pop_up_widget)
520 521
521 def onFindGatewaysRequest(self, e): 522 def onFindGatewaysRequest(self, e):
522 debug(_("Find Gateways request")) 523 debug(_("Find gateways request"))
523 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile) 524 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile)
524 self.current_action_ids.add(id) 525 self.current_action_ids.add(id)
525 self.current_action_ids_cb[id] = self.onGatewaysFound 526 self.current_action_ids_cb[id] = self.onGatewaysFound
527
528 def onSearchDirectory(self, e):
529 debug(_("Search directory request"))
530
531 def requestSearchUi(button, edit):
532 self.removePopUp()
533 search_jid = edit.get_edit_text()
534 if search_jid:
535 def success(xml):
536 self.addWindow(XMLUI(self,xml_data=xml, misc={'callback': self._onSearchRequest, 'callback_args': [search_jid,]}))
537 def failure(error):
538 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp))
539 self.bridge.getSearchUI(search_jid, self.profile, callback=success, errback=failure)
540
541
542 # TODO: replace users.jabberfr.org by any XEP-0055 compatible service discovered on current server
543 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)
544 self.showPopUp(pop_up_widget)
526 545
527 def onAddContactRequest(self, menu): 546 def onAddContactRequest(self, menu):
528 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) 547 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)
529 self.showPopUp(pop_up_widget) 548 self.showPopUp(pop_up_widget)
530 549
546 target = data['__private__']['target'] 565 target = data['__private__']['target']
547 del data['__private__'] 566 del data['__private__']
548 gatewayManager = GatewaysManager(self, data, server=target) 567 gatewayManager = GatewaysManager(self, data, server=target)
549 self.addWindow(gatewayManager) 568 self.addWindow(gatewayManager)
550 569
570 def _onSearchRequest(self, data, search_jid):
571 def success(xml):
572 ui = XMLUI(self, title=_(u"Search result"), xml_data = xml)
573 ui.show('window')
574 def failure(error):
575 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp))
576 self.bridge.searchRequest(search_jid, dict(data), self.profile, callback=success, errback=failure)
577
551 sat = PrimitivusApp() 578 sat = PrimitivusApp()
552 sat.start() 579 sat.start()
553 580