Thread: [tuxdroid-svn] r4565 - in softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-04-20 14:09:43
|
Author: remi Date: 2009-04-20 16:09:29 +0200 (Mon, 20 Apr 2009) New Revision: 4565 Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/build.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/GadgetPackager.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/__init__.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/__init__.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/DirectoriesAndFilesTools.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/__init__.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/version.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/version.py Removed: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/GadgetHelper.py Modified: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/resources/gadget.xml Log: * adapted the gadget to perfectly run in the python framework. * bumped to 0.2 * fixed sound card selection on windows XP Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/build.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/build.py (rev 0) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/build.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +# Copyleft (C) 2009 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +from builder.GadgetPackager import GadgetPackager + +if __name__ == "__main__": + GadgetPackager().createTgf("tuxdroid-gadget-skype.tgf") Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/build.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/GadgetPackager.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/GadgetPackager.py (rev 0) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/GadgetPackager.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyleft (C) 2009 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +import os +from zipfile import * + +from util.misc.DirectoriesAndFilesTools import * + +# ------------------------------------------------------------------------------ +# Class to create a TGF file from the main directory of a python gadget project. +# ------------------------------------------------------------------------------ +class GadgetPackager(object): + """Class to create a TGF file from the main directory of a python gadget + project. + """ + + # -------------------------------------------------------------------------- + # Create a tgf file. + # -------------------------------------------------------------------------- + def createTgf(self, tgfFileName): + """Create a tgf file. + @param tgfFileName: Tux Gadget Format file name. + @return: The success of the file creation. + """ + self.__sourcePath = os.path.realpath("") + if not os.path.isdir(self.__sourcePath): + return False + if not os.path.isdir(os.path.join(self.__sourcePath, "executables")): + return False + if not os.path.isdir(os.path.join(self.__sourcePath, "resources")): + return False + # Get some paths + SRC_EXECUTABLES_PATH = os.path.join(self.__sourcePath, "executables") + SRC_RESOURCES_PATH = os.path.join(self.__sourcePath, "resources") + TMP_BUILD_PATH = os.path.join(self.__sourcePath, "tmp") + DEST_EXECUTABLES_PATH = os.path.join(TMP_BUILD_PATH, "executables") + DEST_RESOURCES_PATH = os.path.join(TMP_BUILD_PATH, "resources") + DEST_TGF_FILENAME = os.path.join(self.__sourcePath, tgfFileName) + # Create the temporary build path + MKDirsF(TMP_BUILD_PATH) + # Copy "executables" directory + CPDir(SRC_EXECUTABLES_PATH, DEST_EXECUTABLES_PATH) + # Copy "resources" directory + CPDir(SRC_RESOURCES_PATH, DEST_RESOURCES_PATH) + # Filtering the content of temporary path + RMWithFilters(TMP_BUILD_PATH, filters = ['.svn', '.pyc']) + # Create a zip file + directory = TMP_BUILD_PATH + last_cwd = os.getcwd() + os.chdir(TMP_BUILD_PATH) + zf = ZipFile(DEST_TGF_FILENAME, 'w', compression = ZIP_DEFLATED) + def walker(zip, directory, files, root = directory): + for file in files: + file = os.path.join(directory, file) + name = file[len(TMP_BUILD_PATH) + 1:] + if os.path.isfile(file): + zip.write(file, name, ZIP_DEFLATED) + elif os.path.isdir(file): + file = os.path.join(file, "") + name = os.path.join(name, "") + zip.writestr(name, name) + os.path.walk(TMP_BUILD_PATH, walker, zf) + zf.close() + os.chdir(os.path.abspath(last_cwd)) + # Remove the temporary directory + RMDirs(TMP_BUILD_PATH) + return True Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/GadgetPackager.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/__init__.py =================================================================== Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/__init__.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/__init__.py =================================================================== Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/__init__.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/DirectoriesAndFilesTools.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/DirectoriesAndFilesTools.py (rev 0) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/DirectoriesAndFilesTools.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyleft (C) 2008 Acness World +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +import os +import shutil + +if os.name == 'nt': + import win32con + import win32file + +# ============================================================================== +# Public functions +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Force to create a directories tree if not exists. +# ------------------------------------------------------------------------------ +def MKDirs(path): + """Force to create a directories tree if not exists. + @param path: Directory path. + """ + if not os.path.isdir(path): + try: + os.makedirs(path) + except: + pass + +# ------------------------------------------------------------------------------ +# Force to create a directories tree after having deleted the old one. +# ------------------------------------------------------------------------------ +def MKDirsF(path): + """Force to create a directories tree after having deleted the old one. + @param path: Directory path. + """ + if os.path.isdir(path): + RMDirs(path) + os.makedirs(path) + +# ------------------------------------------------------------------------------ +# Remove directories and files recursively. +# ------------------------------------------------------------------------------ +def RMDirs(path): + """Remove directories and files recursively. + @param path: Path of the base directory. + """ + if not os.path.isdir(path): + return + for root, dirs, files in os.walk(path, topdown = False): + for d in dirs: + try: + os.removedirs(os.path.join(root, d)) + except: + pass + for f in files: + try: + if os.name == 'nt': + win32file.SetFileAttributesW(os.path.join(root, f), + win32con.FILE_ATTRIBUTE_NORMAL) + os.remove(os.path.join(root, f)) + except: + pass + if os.path.isdir(path): + try: + os.removedirs(path) + except: + pass + +# ------------------------------------------------------------------------------ +# Remove directories and files recursively with filters. +# ------------------------------------------------------------------------------ +def RMWithFilters(path, filters = ['.pyc', '.pyo']): + """Remove directories and files recursively with filters. + @param path: Path of the base directory. + @param filters: Filters as list. + """ + def checkFilter(name): + for filter in filters: + if name.lower().find(filter.lower()) == (len(name) - len(filter)): + return True + return False + + if not os.path.isdir(path): + return + + for root, dirs, files in os.walk(path, topdown = False): + for d in dirs: + if checkFilter(os.path.join(root, d)): + try: + RMDirs(os.path.join(root, d)) + except: + pass + for f in files: + if checkFilter(os.path.join(root, f)): + try: + if os.name == 'nt': + win32file.SetFileAttributesW(os.path.join(root, f), + win32con.FILE_ATTRIBUTE_NORMAL) + os.remove(os.path.join(root, f)) + except: + pass + +# ------------------------------------------------------------------------------ +# Remove a file. +# ------------------------------------------------------------------------------ +def RMFile(path): + """Remove a file. + @param path: File path. + """ + if os.path.isfile(path): + try: + if os.name == 'nt': + win32file.SetFileAttributesW(path, + win32con.FILE_ATTRIBUTE_NORMAL) + os.remove(path) + except: + pass + +# ------------------------------------------------------------------------------ +# Copy a directories tree to another directory. +# ------------------------------------------------------------------------------ +def CPDir(src, dest): + """Copy a directories tree to another directory. + @param src: Source path. + @param dest: Destination path. + """ + if not os.path.isdir(src): + return + if os.path.isdir(dest): + RMDirs(dest) + shutil.copytree(src, dest) + +# ------------------------------------------------------------------------------ +# Retrieve the OS temporary directory. +# ------------------------------------------------------------------------------ +def GetOSTMPDir(): + """Retrieve the OS temporary directory. + @return: The OS temporary directory. + """ + result = None + # On Windows + if os.name == 'nt': + result = os.environ.get('tmp') + if result == None: + result = os.environ.get('temp') + if result == None: + result = "c:\\windows\\temp" + # On linux + else: + result = "/tmp" + return result Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/DirectoriesAndFilesTools.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/__init__.py =================================================================== Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/__init__.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/version.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/version.py (rev 0) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/version.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +"""Version data for tuxisalive.lib.Util""" + +__author__ = "Remi Jocaille (rem...@c2...)" + +# Copyleft (C) 2008 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +name = 'util.misc' +version = '0.0.1' +author = "Remi Jocaille (rem...@c2...)" + +description = "Utilities libraries." + +licence = "GPL" +date = "December 2008" Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/util/misc/version.py ___________________________________________________________________ Name: svn:keywords + Id Added: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/version.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/version.py (rev 0) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/version.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -0,0 +1,9 @@ +# Copyleft (C) 2009 C2ME Sa +# Remi Jocaille <rem...@c2...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +version = '0.0.1' +author = "Remi Jocaille (rem...@c2...)" +licence = "GPL" +date = "2009" Property changes on: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/builder/version.py ___________________________________________________________________ Name: svn:keywords + Id Deleted: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/GadgetHelper.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/GadgetHelper.py 2009-04-20 13:00:24 UTC (rev 4564) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/GadgetHelper.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -1,94 +0,0 @@ -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -import sys -import traceback -import platform - -# ------------------------------------------------------------------------------ -# This class is the minimal helper for builder python gadgets. -# It's an alternative to the SimpleGadget helper. -# ------------------------------------------------------------------------------ -class GadgetHelper(object): - """This class is the minimal helper for builder python gadgets. - It's an alternative to the SimpleGadget helper. - """ - - # -------------------------------------------------------------------------- - # Get if the platform is Windows or not. - # -------------------------------------------------------------------------- - def isWindows(): - """Get if the platform is Windows or not. - @return: A boolean. - """ - platformName = platform.system().lower() - return (platformName == "microsoft") or (platformName == "windows") - - # -------------------------------------------------------------------------- - # Throw a generic notification to the framework. - # -------------------------------------------------------------------------- - def throwNotification(messageId, *args): - """Throw a generic notification to the framework. - @param messageId: Message Id. - @param args: List of objects. - """ - stringBuffer = messageId - for arg in args: - stringBuffer += " '" - stringBuffer += str(arg).replace("'", "\\'") - stringBuffer += "'" - sys.stdout.write(stringBuffer + "\n") - sys.stdout.flush() - - # -------------------------------------------------------------------------- - # Throw a message to the framework. - # -------------------------------------------------------------------------- - def throwMessage(content, *args): - """Throw a message to the framework. - @param content: Content of the message. - @param args: Arguments for the message. - """ - tmp = [content,] - for arg in args: - tmp.append(arg) - GadgetHelper.throwNotification("message", *tmp) - - # -------------------------------------------------------------------------- - # Throw a trace message to the framework. - # -------------------------------------------------------------------------- - def throwTrace(message): - """Throw a trace message to the framework. - @param message: Throwed message. - """ - GadgetHelper.throwNotification("trace", message) - - # -------------------------------------------------------------------------- - # Throw an error message to the framework. - # -------------------------------------------------------------------------- - def throwError(message, sendTraceback = False): - """Throw an error message to the framework. - @param message: Thowed message if the gadget don't want to be traced. - @param sendTraceback: For to send the traceback. Default False. - """ - def formatException(): - fList = traceback.format_exception(sys.exc_info()[0], - sys.exc_info()[1], - sys.exc_info()[2]) - result = "" - for line in fList: - result += line - return result - messagesList = [message,] - if sendTraceback: - tmpList = formatException().split("\n") - for line in tmpList: - messagesList.append(line) - GadgetHelper.throwNotification("error", *messagesList) - - isWindows = staticmethod(isWindows) - throwNotification = staticmethod(throwNotification) - throwMessage = staticmethod(throwMessage) - throwTrace = staticmethod(throwTrace) - throwError = staticmethod(throwError) Modified: softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py =================================================================== --- softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py 2009-04-20 13:00:24 UTC (rev 4564) +++ softwares_suite_v3/community/gadget/tuxdroid-gadget-skype/trunk/tuxdroid-skype-gadget/executables/tuxdroid-gadget-skype.py 2009-04-20 14:09:29 UTC (rev 4565) @@ -1,268 +1,266 @@ -''' -This file is part of "tuxdroid-gadget-skype". - * Copyright 2008, kysoh - * Author : Conan Jerome - * eMail : jer...@ky... - * Site : http://www.kysoh.com/ - * - * "tuxdroid-gadget-skype " is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * "tuxdroid-gadget-skype" is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with "tuxdroid-gadget-skype"; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - ''' +# -*- coding: utf-8 -*- -import platform -import Skype4Py -import commands -import threading -import time +# Copyright (C) 2009 Kysoh Sa +# Conan Jerome <jer...@ky...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +__author__ = "Conan Jerome" +__appname__ = "Python gadget skype" +__version__ = "0.2" +__date__ = "2009/04/15" +__license__ = "GPL" + import os +import time +import sys +import threading import subprocess +import Skype4Py from tuxisalive.api.TuxAPI import * -from GadgetHelper import GadgetHelper +sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL']) -class Connection(object): - ''' - This class manage skype connection. - ''' +from util.SimpleGadget.SimpleGadgetConfiguration import SimpleGadgetConfiguration +from util.SimpleGadget.SimpleGadget import SimpleGadget - #Private global vars. - __currentCall = None - __tux = None - __currentContactIndex = -1 - __contactsDict = {} - __contactsList = [] - __allowedStatus = { - "Online" : Skype4Py.olsOnline, - "Away" : Skype4Py.olsAway, - "Do not disturb" : Skype4Py.olsDoNotDisturb, - "Invisible" : Skype4Py.olsInvisible, - "Busy" : Skype4Py.olsNotAvailable, - "Skype me": Skype4Py.olsSkypeMe - } - - __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 - __greenPhoneEvent = None - __redPhoneEvent = None +class Configuration(SimpleGadgetConfiguration): + """This class make an access to the gadget parameters. + Parameters are automatically filled by the SimpleGadget class at gadget + starting. + """ - #Users gadget parameters. - speaker = "Ryan" - pitch = 120 - ip = "127.0.0.1" - status = None - quitSkype = False - quitGadget = True - - - #Geting right gadget parameters. - if "tgp_ip" in os.environ: - ip = os.environ["tgp_ip"] - if "tgp_locutor" in os.environ: - speaker = os.environ["tgp_locutor"] - if "tgp_pitch" in os.environ: - pitch = int(os.environ["tgp_pitch"]) - if "tgp_quitSkype" in os.environ: - quitSkype = (os.environ["tgp_quitSkype"] == "true") - if "tgp_quitGadget" in os.environ: - quitGadget = (os.environ["tgp_quitGadget"] == "true") - if "tgp_startupStatus" in os.environ: - status = os.environ["tgp_startupStatus"] - + def __init__(self): + """Initialization of the class. + """ + # Call the super class + SimpleGadgetConfiguration.__init__(self) + # Initialize the parameters + self.__quitSkype = False + self.__quitGadget = False + self.__startupStatus = "" + def getQuitSkype(self): + return self.__quitSkype - def __init__(self): - ''' - Constructor - ''' - print("Debug: connecting") - - self.__tux = TuxAPI(self.ip, 270) - self.__tux.server.autoConnect(CLIENT_LEVEL_FREE, "SkypeGadget", "tuxdroid-gadget-skype") - self.__tux.server.waitConnected(3.0) - self.__tux.access.waitAcquire(3.0, ACCESS_PRIORITY_NORMAL) - - try: - #Start Skype client if not started. - self.__startSkype() - if not self.__activeMain: - self.__destroy() - #Connect to skype api. - self.__connectSkypeAPI() - except: - GadgetHelper.throwMessage("I cannot get connected to your Skeyepe. Please, check if you are connected. And verify if I can access skeyepe.") - self.__destroy() - - - - def __destroy(self): - ''' - Destroy current connection object. - ''' - try: - if self.__skype != None: - self.__resetTuxMotors() - self.__skype._API.Close() - self.__skype = None - self.__apiAttachState = -1 - - if self.__tux != None: - self.__tux.led.both.off() - self.__tux.led.both.on() - self.__resetTuxMotors() - self.__tux.access.release() - self.__tux.server.disconnect() - self.__tux.destroy() - - self.__activeMain = False - except: - pass - - - - def __initSkypeGadget(self): - ''' - Initialize the skype gadget when skype api is connected. - ''' - #Set tux as audio card. - self.__setTuxAudio() - - #Set the user status. - if self.__allowedStatus.has_key(self.status): - self.__skype._SetCurrentUserStatus(self.__allowedStatus[self.status]) - - #et the contacts list. - self.__getContacts() + def setQuitSkype(self, quitSkype): + self.__quitSkype = quitSkype + def getQuitGadget(self): + return self.__quitGadget + def setQuitGadget(self, quitGadget): + self.__quitGadget = quitGadget - def __initTuxCallbacks(self): - ''' - Init the Tux Droid callbacks - ''' - #Tux Droid switches. - self.__leftWingEvent = self.__tux.button.left.registerEventOnPressed(self.onLeftButtonPushed) - self.__rightWingEvent = self.__tux.button.right.registerEventOnPressed(self.onRightButonPushed) - self.__headEventID = self.__tux.button.head.registerEventOnReleased(self.onHeadButtonPushed) - #Remote control. - self.__tux.button.remote.registerEventOnPressed(self.onStandbyRemoteButtonPushed, K_STANDBY) - self.__leftArrowEvent = self.__tux.button.remote.registerEventOnPressed(self.onLeftButtonPushed, K_DOWN) - self.__rightArrowEvent = self.__tux.button.remote.registerEventOnPressed(self.onRightButonPushed, K_UP) - self.__okEventID = self.__tux.button.remote.registerEventOnPressed(self.onHeadButtonPushed, K_OK) - self.__greenPhoneEvent = self.__tux.button.remote.registerEventOnPressed(self.onHeadButtonPushed, K_RECEIVECALL) - self.__redPhoneEvent = self.__tux.button.remote.registerEventOnPressed(self.onFinishCall, K_HANGUP) + def getStartupStatus(self): + return self.__startupStatus + def setStartupStatus(self, startupStatus): + self.__startupStatus = startupStatus -######################################################### -######### private functions ######## +class SkypeGadget(SimpleGadget): + """Skype gadget class. + """ - def onLeftButtonPushed(self, value, delay): - ''' - On left switch / remote event. - ''' - thread = threading.Thread(target = self.nextContact, args = []) - thread.start() + def __init__(self): + """Initialization of the class. + """ + # Call the super class + SimpleGadget.__init__(self) + # Initialize some values ... + self.__currentCall = None + self.__tux = Non... [truncated message content] |