Author: jerome
Date: 2009-03-13 10:08:27 +0100 (Fri, 13 Mar 2009)
New Revision: 4042

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/resources/gadget.pot
Log:
* Removed the loop waiting for skype appl and api connection, tts a message 
instead ( less intrusive and users know what to do if the gadget cannot get 
connected ).
* Starting Skype in a thread.
* Updated pot file.

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-13 08:11:37 UTC (rev 4041)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py
   2009-03-13 09:08:27 UTC (rev 4042)
@@ -85,44 +85,21 @@
         self.__tux.server.autoConnect(TuxAPIConst.CLIENT_LEVEL_FREE, 
"SkypeGadget", "tuxdroid-gadget-skype")
         self.__tux.server.waitConnected(3.0)
         self.__tux.access.waitAcquire(3.0, ACCESS_PRIORITY_NORMAL)
-        t = threading.Thread(target = self.__start, args = [])
-        t.start()
         
+        try:
+            #Start Skype client if not started. 
+            self.__startSkype()
+            #Connect to skype api.
+            self.__connectSkypeAPI()
+        except:
+            print("message: \"" + "I cannot get connected to your Skype. 
Please, verify you are connected and verify I can access to skype." + "\"")
+            self.__destroy()
 
 
 #########################################################
 #########            private functions           ########
 
-     def __start(self):
-         '''
-         Connect to the skype api and get contacts list.
-         '''
-         try:
-            #Get skype aplication state
-            if not self.__getSkypeConnected():    
-                self.__startSkype()
-                t = threading.Thread(target = self.__start, args = [])
-                t.start()
-                return
 
-            if self.__getConnected():
-               return
-            #Connect to skype api.
-            self.__skype = Skype4Py.Skype()
-            self.__skype.OnAttachmentStatus = 
self.skypeApplicationAPIStatusReceived
-            self.__setSkypeCallBacks()
-            self.__skype.Attach()
-            self.__initSkypeGadget()
-            self.__initTuxCallbacks()
-            print("Debug: connected")
-         except:
-            time.sleep(1)
-            t = threading.Thread(target = self.__start, args = [])
-            t.start()
-
-
-
-
      def __initSkypeGadget(self):
         '''
         Initialize the skype gadget when skype api is connected.
@@ -200,13 +177,17 @@
          Destroy current connection object.
          """
          try:
-             self.__resetTuxMotors()
-             self.__skype._API.Close()
-             self.__skype = None
-             self.__tux.access.release()
-             self.__tux.server.disconnect()
-             self.__tux.destroy()
-             self.__apiAttachState = -1
+             if self.__skype != None:
+                 self.__resetTuxMotors()
+                 self.__skype._API.Close()
+                 self.__skype = None
+                 self.__apiAttachState = -1
+             
+             if self.__tux != None:
+                 self.__tux.access.release()
+                 self.__tux.server.disconnect()
+                 self.__tux.destroy()
+             
              self.__activeMain = False
          except:
              pass
@@ -262,6 +243,19 @@
          return (platform == 'Windows' ) or (platform == 'windows') or 
(platform == "Microsoft")
     
 
+     def __connectSkypeAPI(self):
+         '''
+         Get connected to the Skype client.
+         '''
+         self.__skype = Skype4Py.Skype()
+         self.__skype.Timeout = 10000
+         self.__skype.OnAttachmentStatus = 
self.skypeApplicationAPIStatusReceived
+         self.__setSkypeCallBacks()
+         self.__skype.Attach()
+         self.__initSkypeGadget()
+         self.__initTuxCallbacks()
+         print("Debug: connected")
+         
 
      def __getSkypeConnected(self):
          """
@@ -287,31 +281,41 @@
             return
         
         if self.isWindows():
-            if "ProgramFiles" in os.environ:
-                process = subprocess.Popen(os.environ["ProgramFiles"] + 
"\\Skype\\Phone\\Skype.exe", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
-                result = process.stdout.read()
-                if ("not" in result) and ("recognized" in result) and 
("command" in result):
-                    print("message: \"" + "Cannot find Skype client" + "\"")
-                    self.__destroy()
+            thread = threading.Thread(target=self.__startSkypeWindows, args=[])
+            thread.start()
         else:
-            #Searching for skype binary.
-            cmd = ["skype", "--version"]
-            process = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE)
+            thread = threading.Thread(target=self.__startSkypeLinux, args=[])
+            thread.start()
+     
+     
+     
+     def __startSkypeWindows(self):
+         '''
+         Start skype on windows.
+         '''
+         if "ProgramFiles" in os.environ:
+            process = subprocess.Popen(os.environ["ProgramFiles"] + 
"\\Skype\\Phone\\Skype.exe", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
             result = process.stdout.read()
-            result = result.split()
-            if("Skype" in result) and ("Copyright" in result):
-                #Then skype is in PATH
-                thread = threading.Thread(target=self.__startSkypeLinux, 
args=[])
-                thread.start()
+            if ("not" in result) and ("recognized" in result) and ("command" 
in result):
+                print("message: \"" + "Cannot find Skype client" + "\"")
+                self.__destroy()
+                    
      
      
-     
      def __startSkypeLinux(self):
          '''
          Start skype on linux ( thread needed to do not block the script ).
          '''
-         #checking for auto-connect user parameter
-         subprocess.Popen("skype", stdin=subprocess.PIPE, 
stdout=subprocess.PIPE)
+         #Searching for skype binary.
+         cmd = ["skype", "--version"]
+         process = subprocess.Popen(cmd, stdin=subprocess.PIPE, 
stdout=subprocess.PIPE)
+         result = process.stdout.read()
+         result = result.split()
+         if("Skype" in result) and ("Copyright" in result):
+             #Then skype is in PATH
+             subprocess.Popen("skype", stdin=subprocess.PIPE, 
stdout=subprocess.PIPE)
+         else:
+             print("message: \"" + "Cannot find Skype client" + "\"")
             
         
         

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/resources/gadget.pot
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/resources/gadget.pot
   2009-03-13 08:11:37 UTC (rev 4041)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/resources/gadget.pot
   2009-03-13 09:08:27 UTC (rev 4042)
@@ -9,3 +9,9 @@
 
 msgid "connected"
 msgstr ""
+
+msgid "Cannot find Skype client"
+msgstr ""
+
+msgid "I cannot get connected to your Skype. Please, verify you are connected 
and verify I can access to skype."
+msgstr ""


------------------------------------------------------------------------------
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