Author: jerome
Date: 2009-03-11 19:49:09 +0100 (Wed, 11 Mar 2009)
New Revision: 3965

Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py
Log:
* Fixed a bug with tux registered events.

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py
   2009-03-11 18:19:28 UTC (rev 3964)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py
   2009-03-11 18:49:09 UTC (rev 3965)
@@ -37,25 +37,29 @@
      '''
 
      #Private global vars.
-     __skype = None
      __currentCall = None
      __tux = None
      __currentContactIndex = -1
      __contactsDict = {}
      __contactsList = []
-     __okEventID = None
-     __headEventID = None
-     __okEventReleasedID = None
-     __headEventReleasedID = None
-     __pushTime = -1
+     
      __mutexNext = threading.Lock()
      __mutexPrev = threading.Lock()
      __mutexCall = threading.Lock()
+     
      #Skype api objects.
+     __skype = None
      __apiAttachState = -1
      __activeMain = True
+     
+     #registered events.
+     __okEventID = None
+     __headEventID = None
+     __leftWingEvent = None
+     __rightWingEvent = None
+     __leftArrowEvent = None
+     __rightArrowEvent = None
 
-
      #Users gadget parameters.
      speaker = "Ryan"
      pitch = 120
@@ -122,14 +126,14 @@
         Init the Tux Droid callbacks
         '''
         #Tux Droid switches.
-        self.__tux.button.left.registerEventOnPressed(self.onLeftButtonPushed)
-        self.__tux.button.right.registerEventOnPressed(self.onRightButonPushed)
-        self.__tux.button.head.registerEventOnPressed(self.onHeadButtonPushed)
+        self.__leftWingEvent = 
self.__tux.button.left.registerEventOnPressed(self.onLeftButtonPushed)
+        self.__rightWingEvent = 
self.__tux.button.right.registerEventOnPressed(self.onRightButonPushed)
+        self.__headEventID = 
self.__tux.button.head.registerEventOnPressed(self.onHeadButtonPushed)
         #Remote control.
         
self.__tux.button.remote.registerEventOnPressed(self.onStandbyRemoteButtonPushed,
 TuxAPIConst.K_STANDBY)
-        
self.__tux.button.remote.registerEventOnPressed(self.onLeftButtonPushed, 
TuxAPIConst.K_DOWN)
-        
self.__tux.button.remote.registerEventOnPressed(self.onRightButonPushed, 
TuxAPIConst.K_UP)
-        
self.__tux.button.remote.registerEventOnPressed(self.onHeadButtonPushed, 
TuxAPIConst.K_OK)
+        self.__leftArrowEvent = 
self.__tux.button.remote.registerEventOnPressed(self.onLeftButtonPushed, 
TuxAPIConst.K_DOWN)
+        self.__rightArrowEvent = 
self.__tux.button.remote.registerEventOnPressed(self.onRightButonPushed, 
TuxAPIConst.K_UP)
+        self.__okEventID = 
self.__tux.button.remote.registerEventOnPressed(self.onHeadButtonPushed, 
TuxAPIConst.K_OK)
 
 
 
@@ -288,22 +292,47 @@
 #########            callbacks            ###############
 
 
-     def __resetTuxMotors(self):
+     def __resetTuxMotors(self, removeEvents=True):
          '''
          Reset tux motors.
          '''
          self.__tux.flippers.down()
          self.__tux.mouth.close()
-         if (self.__okEventID != None) and (self.__headEventID != None):
+         
+         if removeEvents:
+             self.__removeTuxEvents()
+     
+     
+     def __removeTuxEvents(self):
+         '''
+         Remove tux switches and buttons registered events.
+         '''
+         #unregister ok push event
+         if self.__okEventID != None: 
              
self.__tux.button.remote.unregisterEventOnPressed(self.__okEventID)
+             
+         #unregister head button push    
+         if self.__headEventID != None:
              
self.__tux.button.head.unregisterEventOnPressed(self.__headEventID)
+             
+         #unregister left wing event
+         if self.__leftWingEvent != None:
+            
self.__tux.button.left.unregisterEventOnPressed(self.__leftWingEvent)
+            
+         #unregister right wing event
+         if self.__rightWingEvent != None:
+            
self.__tux.button.right.unregisterEventOnPressed(self.__rightWingEvent)
+            
+         #unregister left arrow event
+         if self.__leftArrowEvent != None:
+            
self.__tux.button.remote.unregisterEventOnPressed(self.__leftArrowEvent)
+            
+         #unregister right arrow event
+         if self.__rightArrowEvent != None:
+            
self.__tux.button.remote.unregisterEventOnPressed(self.__rightArrowEvent)
 
-         if (self.__okEventReleasedID != None) and (self.__headEventReleasedID 
!= None):
-             
self.__tux.button.remote.unregisterEventOnReleased(self.__okEventReleasedID)
-             
self.__tux.button.head.unregisterEventOnReleased(self.__headEventReleasedID)
 
 
-
      def __setTuxMotors(self):
          '''
          Set tux to get the call.
@@ -327,6 +356,7 @@
 
          elif Status in [Skype4Py.clsRinging, Skype4Py.clsEarlyMedia, 
Skype4Py.clsRouting, Skype4Py.clsInProgress]:
              self.__currentCall = Call
+             self.__removeTuxEvents()
              self.__setTuxMotors()
              self.__okEventID = 
self.__tux.button.remote.registerEventOnPressed(self.setCallFinished, K_OK)
              self.__headEventID = 
self.__tux.button.head.registerEventOnPressed(self.setCallFinished)
@@ -338,7 +368,6 @@
          '''
          Set calls callback.
          '''
-         print(Status)
          if not self.__getConnected():
              return
 
@@ -398,7 +427,6 @@
          '''
          Return the next user skype full name.
          '''
-         print("next")
          self.__mutexNext.acquire()
          if self.__currentContactIndex >= len(self.__contactsList) -1:
              self.__currentContactIndex = -1
@@ -417,7 +445,6 @@
          '''
          Return the previous user skype full name.
          '''
-         print("prev")
          self.__mutexPrev.acquire()
          if self.__currentContactIndex <= 0:
              self.__currentContactIndex =  len(self.__contactsList)


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to