[tuxdroid-svn] r5520 - software_suite_v3/software/plugin/plugin-skype/trunk/executables
Status: Beta
Brought to you by:
ks156
|
From: jerome <c2m...@c2...> - 2009-09-29 11:22:26
|
Author: jerome
Date: 2009-09-29 13:22:08 +0200 (Tue, 29 Sep 2009)
New Revision: 5520
Modified:
software_suite_v3/software/plugin/plugin-skype/trunk/executables/plugin-skype.py
Log:
* Fixed a bug quitting the Skype application.
* Improved contact list retrieve.
Modified: software_suite_v3/software/plugin/plugin-skype/trunk/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/trunk/executables/plugin-skype.py 2009-09-28 14:07:21 UTC (rev 5519)
+++ software_suite_v3/software/plugin/plugin-skype/trunk/executables/plugin-skype.py 2009-09-29 11:22:08 UTC (rev 5520)
@@ -25,7 +25,7 @@
from util.SimplePlugin.SimplePlugin import SimplePlugin
from util.system.TaskBar import refreshTaskBar
from util.system.Device import *
-from Skype4Py.errors import ISkypeError as SkypeError, ISkypeAPIError as SkypeAPIError
+from Skype4Py.errors import ISkypeError as SkypeError, ISkypeAPIError as SkypeAPIError
class Configuration(SimplePluginConfiguration):
@@ -88,6 +88,8 @@
# Skype process
self.__skypeProcess = None
self.attemptTimeout = 0
+ self.normalStart = False
+ self.count = 1
def start(self):
"""Plugin entry point.
@@ -192,7 +194,30 @@
# ==========================================================================
# Skype API
# ==========================================================================
-
+
+ def __poolSkypeApplication(self):
+ '''
+ Pool Skype application to quit gadget in case of client not running.
+ '''
+
+ while True:
+ time.sleep(0.2)
+ if ( not self.__getSkypeAppConnected() ):
+ self.stop()
+
+
+
+ def __onOnlineStatus(self, User, Status):
+ '''
+ Skype api online status received ( contact online status changed ).
+ '''
+ #Refreshing contacts list.
+ if self.count <= 1:
+ self.__getContacts()
+ else:
+ self.__getContacts(say=False)
+ self.count = self.count + 1
+
def __onSkypeAPIStatusReceived(self, value):
"""Received api connection status.
"""
@@ -202,15 +227,20 @@
self.__selectTuxAsAudioCard()
time.sleep(0.2)
- # Get the contacts list.
- self.__getContacts()
-
+ # Get the contacts list.
+ if self.normalStart:
+ self.__getContacts()
+
# Set the user status.
status = self.configuration().getStartupStatus()
if self.__allowedStatus.has_key(status):
self.__skype.ChangeUserStatus(self.__allowedStatus[status])
-
+
+ #Start Pooling skype.
+ thread = threading.Thread(target = self.__poolSkypeApplication)
+ thread.start()
+
elif self.attemptTimeout == 6:
self.stop()
return
@@ -252,6 +282,7 @@
"""
# Create and attach skype api
self.__skype = Skype4Py.Skype()
+ self.__skype.OnOnlineStatus = self.__onOnlineStatus
self.__skype.OnAttachmentStatus = self.__onSkypeAPIStatusReceived
self.__skype.OnCallStatus = self.__onSkypeCall
@@ -372,6 +403,7 @@
"""
# Return if skype is already started.
if self.__getSkypeAppConnected():
+ self.normalStart = True
return
self.throwMessage("Please wait while I launch the skeyepe application")
if os.name == "nt":
@@ -396,13 +428,7 @@
cmd,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE)
- while True:
- try:
- buffer = self.__skypeProcess.stdout.read(100)
- except:
- buffer = ""
- if len(buffer) == 0:
- break
+
else:
self.throwMessage("Sorry, it looks like skeyepe is not installed. Please go to the skeyepe website to download the software.")
self.__activeMain = False
@@ -436,12 +462,11 @@
self.__skypeProcess = subprocess.Popen("skype", stdin = subprocess.PIPE,
stdout = subprocess.PIPE)
- while not self.__getSkypeAppConnected():
- time.sleep(1)
self.__activeMain = True
else:
self.throwMessage("Sorry, it looks like skeyepe is not installed. Please go to the skeyepe website to download the software.")
self.__activeMain = False
+ self.stop()
# ==========================================================================
# Tux Droid body
@@ -474,18 +499,27 @@
# Contacs list
# ==========================================================================
- def __getContacts(self):
+ def __getContacts(self, say=True):
"""Retrieve the contact list from skype.
"""
self.__mutexContacts.acquire()
+
+ self.throwTrace( self.__skype.AttachmentStatus)
+ while (not ( self.__skype.AttachmentStatus in [Skype4Py.apiAttachSuccess, ])):
+ time.sleep(0.2)
+
self.__contactsList = []
self.__contactsDict = {}
+
for user in self.__skype.Friends:
+
if user.OnlineStatus not in [Skype4Py.olsUnknown,
Skype4Py.olsOffline, Skype4Py.olsInvisible]:
userFNEnc = user.FullName.encode("UTF-8").replace(" ", "_")
userDNEnc = user.DisplayName.encode("UTF-8").replace(" ", "_")
+
userHEnc = user.Handle.encode("UTF-8").replace(" ", "_")
+
if len(userFNEnc) > 0:
self.__contactsDict[userFNEnc] = userHEnc
self.__contactsList.append(userFNEnc)
@@ -495,15 +529,15 @@
else:
self.__contactsDict[userHEnc] = userHEnc
self.__contactsList.append(userHEnc)
-
+
self.__contactsDict["Quit gadget"] = "Quit gadget"
self.__contactsList.insert(0, "Quit gadget")
self.__currentContactIndex = 0
self.__mutexContacts.release()
self.__tuxBodyResetLeds()
- self.nextContact()
+ self.nextContact(tts=say)
- def __selectContact(self, incIdx):
+ def __selectContact(self, incIdx, say=True):
"""
"""
self.__mutexContacts.acquire()
@@ -522,12 +556,13 @@
self.__mutexContacts.release()
self.throwActuation("playSound", 11, 100.0)
self.throwActuation("abortTts")
- self.throwMessage(user)
+ if say:
+ self.throwMessage(user)
- def nextContact(self):
+ def nextContact(self, tts=True):
"""Select the next user skype full name.
"""
- self.__selectContact(1)
+ self.__selectContact(1, say=tts)
def previousContact(self):
"""Select the previous user skype full name.
|