comparison frontends/src/primitivus/chat.py @ 801:02ee9ef95277

plugin XEP-0045, primitivus: added MUC configuration
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:06:12 +0100
parents bfabeedbf32e
children 1fe00f0c9a91
comparison
equal deleted inserted replaced
800:e0770d977d58 801:02ee9ef95277
22 from urwid_satext import sat_widgets 22 from urwid_satext import sat_widgets
23 from urwid_satext.files_management import FileDialog 23 from urwid_satext.files_management import FileDialog
24 from sat_frontends.quick_frontend.quick_chat import QuickChat 24 from sat_frontends.quick_frontend.quick_chat import QuickChat
25 from sat_frontends.primitivus.card_game import CardGame 25 from sat_frontends.primitivus.card_game import CardGame
26 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate 26 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate
27 from sat_frontends.primitivus.xmlui import XMLUI
27 import time 28 import time
28 from sat.tools.jid import JID 29 from sat.tools.jid import JID
29 30
30 31
31 class ChatText(urwid.FlowWidget): 32 class ChatText(urwid.FlowWidget):
129 def getMenu(self): 130 def getMenu(self):
130 """Return Menu bar""" 131 """Return Menu bar"""
131 menu = sat_widgets.Menu(self.host.loop) 132 menu = sat_widgets.Menu(self.host.loop)
132 if self.type == 'group': 133 if self.type == 'group':
133 game = _("Game") 134 game = _("Game")
135 muc = _("MUC")
134 menu.addMenu(game, "Tarot", self.onTarotRequest) 136 menu.addMenu(game, "Tarot", self.onTarotRequest)
137 menu.addMenu(muc, _("Configure room"), self.onConfigureRoom)
135 elif self.type == 'one2one': 138 elif self.type == 'one2one':
136 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) 139 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
137 return menu 140 return menu
138 141
139 def setType(self, type): 142 def setType(self, type):
333 if len(self.occupants) != 4: 336 if len(self.occupants) != 4:
334 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)) 337 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))
335 else: 338 else:
336 self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile) 339 self.host.bridge.tarotGameCreate(self.id, list(self.occupants), self.host.profile)
337 340
341 def onConfigureRoom(self, menu):
342 def gotUI(xmlui):
343 self.host.addWindow(XMLUI(self.host, xmlui))
344 def configureError(failure):
345 self.host.showPopUp(sat_widgets.Alert(_("Error"), unicode(failure), ok_cb=self.host.removePopUp))
346 self.host.bridge.configureRoom(self.id, self.host.profile, callback=gotUI, errback=configureError)
347
338 def onSendFileRequest(self, menu): 348 def onSendFileRequest(self, menu):
339 dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp) 349 dialog = FileDialog(ok_cb=self.onFileSelected, cancel_cb=self.host.removePopUp)
340 self.host.showPopUp(dialog, 80, 80) 350 self.host.showPopUp(dialog, 80, 80)
341 351
342 #MISC EVENTS# 352 #MISC EVENTS#