diff frontends/quick_frontend/quick_app.py @ 91:39c672544593

Tarot: bidding phase - quick_app: command line is now parsed, "profile" option allow to select it - xml_tools: list-single is now managed - plugin tarot: method and signal to manage contract (contrat): tarotChooseContrat & tarotGameContratChoosed - wix: Q&D Form hack to manage more generic form (not only registration), used to show contract selection form
author Goffi <goffi@goffi.org>
date Thu, 27 May 2010 19:26:19 +0930
parents 4020931569b8
children 2503de7fb4c7
line wrap: on
line diff
--- a/frontends/quick_frontend/quick_app.py	Sun May 23 16:39:05 2010 +0930
+++ b/frontends/quick_frontend/quick_app.py	Thu May 27 19:26:19 2010 +0930
@@ -22,6 +22,7 @@
 from logging import debug, info, error
 from tools.jid  import JID
 from sat_bridge_frontend.DBus import DBusBridgeFrontend
+from optparse import OptionParser
 import pdb
 
 import gettext
@@ -34,6 +35,7 @@
         self.rosterList = {}
         self.profiles = {}
         self.single_profile = single_profile
+        self.check_options()
         
         ## bridge ##
         self.bridge=DBusBridgeFrontend()
@@ -48,6 +50,7 @@
         self.bridge.register("roomNewSubject", self.roomNewSubject)
         self.bridge.register("tarotGameStarted", self.tarotGameStarted)
         self.bridge.register("tarotGameNew", self.tarotGameNew)
+        self.bridge.register("tarotChooseContrat", self.tarotChooseContrat)
         self.bridge.register("subscribe", self.subscribe)
         self.bridge.register("paramUpdate", self.paramUpdate)
         self.bridge.register("contactDeleted", self.contactDeleted)
@@ -63,6 +66,20 @@
         """Tell if the profile is currently followed by the application"""
         return profile in self.profiles.keys()
 
+    def check_options(self):
+        """Check command line options"""
+        usage=_("""
+        %prog [options]
+
+        %prog --help for options list
+        """)
+        parser = OptionParser(usage=usage)
+
+        parser.add_option("-p", "--profile", help=_("Select the profile to use"))
+
+        (self.options, args) = parser.parse_args()
+        return args
+
     def plug_profile(self, profile_key='@DEFAULT@'):
         """Tell application which profile must be used"""
         if self.single_profile and self.profiles:
@@ -134,6 +151,8 @@
             return
         debug(_("Connected"))
         self.setStatusOnline(True)
+        self.bridge.joinMUC('conference.necton2.int', 'test', self.profiles[self.profile]['whoami'].node, self.profile) #gof:
+        
 
     def disconnected(self, profile):
         """called when the connection is closed"""
@@ -262,9 +281,16 @@
         debug (_("New Tarot Game"))
         print "room: %s, hand: %s" % (room_jid,hand)
         if self.chat_wins.has_key(room_jid):
-            print "gof:",self.chat_wins[room_jid].getGame("Tarot")
             self.chat_wins[room_jid].getGame("Tarot").newGame(hand)
 
+    def tarotChooseContrat(self, room_jid, xml_data, profile):
+        """Called when the player has too select his contrat"""
+        if not self.__check_profile(profile):
+            return
+        debug (_("Tarot: need to select a contrat"))
+        if self.chat_wins.has_key(room_jid):
+            self.chat_wins[room_jid].getGame("Tarot").chooseContrat(xml_data)
+
 
 
     def subscribe(self, type, raw_jid, profile):