Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 1634:95ea323e7d04
primitivus: removed all file menu + temporary workaround to send full jid on C.MENU_SINGLE menu action.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 20 Nov 2015 01:57:18 +0100 |
parents | 641cfd2faefe |
children | 7751b5a51586 |
comparison
equal
deleted
inserted
replaced
1633:2071d5cec5d6 | 1634:95ea323e7d04 |
---|---|
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core import log as logging | 21 from sat.core import log as logging |
22 log = logging.getLogger(__name__) | 22 log = logging.getLogger(__name__) |
23 import urwid | 23 import urwid |
24 from urwid_satext import sat_widgets | 24 from urwid_satext import sat_widgets |
25 # from urwid_satext.files_management import FileDialog # FIXME | |
26 from sat_frontends.quick_frontend import quick_widgets | 25 from sat_frontends.quick_frontend import quick_widgets |
27 from sat_frontends.quick_frontend.quick_chat import QuickChat | 26 from sat_frontends.quick_frontend.quick_chat import QuickChat |
28 from sat_frontends.quick_frontend import quick_games | 27 from sat_frontends.quick_frontend import quick_games |
29 from sat_frontends.primitivus import game_tarot | 28 from sat_frontends.primitivus import game_tarot |
30 from sat_frontends.primitivus.constants import Const as C | 29 from sat_frontends.primitivus.constants import Const as C |
144 if self.type == C.CHAT_GROUP: | 143 if self.type == C.CHAT_GROUP: |
145 self.host.addMenus(menu, C.MENU_ROOM, {'room_jid': self.target.bare}) | 144 self.host.addMenus(menu, C.MENU_ROOM, {'room_jid': self.target.bare}) |
146 game = _("Game") | 145 game = _("Game") |
147 menu.addMenu(game, "Tarot", self.onTarotRequest) | 146 menu.addMenu(game, "Tarot", self.onTarotRequest) |
148 elif self.type == C.CHAT_ONE2ONE: | 147 elif self.type == C.CHAT_ONE2ONE: |
149 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': self.target}) | 148 # FIXME: self.target is a bare jid, we need to check that |
150 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) | 149 contact_list = self.host.contact_lists[self.profile] |
150 full_jid = contact_list.getFullJid(self.target) | |
151 self.host.addMenus(menu, C.MENU_SINGLE, {'jid': full_jid}) | |
151 return menu | 152 return menu |
152 | 153 |
153 def presenceListener(self, entity, show, priority, statuses, profile): | 154 def presenceListener(self, entity, show, priority, statuses, profile): |
154 """Update entity's presence status | 155 """Update entity's presence status |
155 | 156 |
374 if len(self.occupants) != 4: | 375 if len(self.occupants) != 4: |
375 self.host.showPopUp(sat_widgets.Alert(_("Can't start game"), _("You need to be exactly 4 peoples in the room to start a Tarot game"), ok_cb=self.host.removePopUp)) | 376 self.host.showPopUp(sat_widgets.Alert(_("Can't start game"), _("You need to be exactly 4 peoples in the room to start a Tarot game"), ok_cb=self.host.removePopUp)) |
376 else: | 377 else: |
377 self.host.bridge.tarotGameCreate(self.target, list(self.occupants), self.profile) | 378 self.host.bridge.tarotGameCreate(self.target, list(self.occupants), self.profile) |
378 | 379 |
379 def onSendFileRequest(self, menu): | |
380 # TODO: move this to core with dynamic menus | |
381 pass | |
382 # dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp) # FIXME: to be removed | |
383 # self.host.showPopUp(dialog, 80, 80) | |
384 | |
385 # MISC EVENTS # | 380 # MISC EVENTS # |
386 # FIXME: to be removed | |
387 # def onFileSelected(self, filepath): | |
388 # self.host.removePopUp() | |
389 # try: | |
390 # filepath = filepath.decode('utf-8') # FIXME: correctly manage unicode | |
391 # except UnicodeError: | |
392 # log.error("FIXME: filepath with unicode error are not managed yet") | |
393 # self.host.showDialog(_(u"File has a unicode error in its name, it's not yet managed by SàT"), title=_("Can't send file"), type_="error") | |
394 # return | |
395 # # FIXME: check last_resource: what if self.target.resource exists ? | |
396 # last_resource = self.host.bridge.getMainResource(unicode(self.target.bare), self.profile) | |
397 # if last_resource: | |
398 # full_jid = jid.JID("%s/%s" % (self.target.bare, last_resource)) | |
399 # else: | |
400 # full_jid = self.target | |
401 # progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.profile) | |
402 # self.host.addProgress(progress_id, filepath) | |
403 # self.host.showDialog(_(u"You file request has been sent, we are waiting for your contact answer"), title=_("File request sent")) | |
404 | 381 |
405 def onDelete(self): | 382 def onDelete(self): |
406 QuickChat.onDelete(self) | 383 QuickChat.onDelete(self) |
407 if self.type == C.CHAT_GROUP: | 384 if self.type == C.CHAT_GROUP: |
408 self.host.removeListener('presence', self.presenceListener) | 385 self.host.removeListener('presence', self.presenceListener) |