[tuxdroid-svn] r5924 - software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/execut
Status: Beta
Brought to you by:
ks156
From: jerome <c2m...@c2...> - 2009-12-03 12:28:39
|
Author: jerome Date: 2009-12-03 13:27:24 +0100 (Thu, 03 Dec 2009) New Revision: 5924 Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/communicator.py Log: * Changed the way to check emoticons and tts sentences. * Changed events order. Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/communicator.py =================================================================== --- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/communicator.py 2009-12-03 12:25:41 UTC (rev 5923) +++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/communicator.py 2009-12-03 12:27:24 UTC (rev 5924) @@ -97,9 +97,9 @@ sleep(1) #Checking if Tux Droid was successfully set as audio card. - if not self.isTuxDroidAudioCard(): - return False - return True + if self.isTuxDroidAudioCard(): + return True + return False except: #Return False, maybe Tux Droid is not connected. return False @@ -145,14 +145,14 @@ name = '' #Getting tts name to use. - if tounicode(uDatas['display_name']) != u'': + if uDatas['display_name'] != u'': name = StringUtils.toPrettyString(uDatas['display_name']) - elif tounicode(uDatas['full_name']) != u'': + elif uDatas['full_name'] != u'': name = StringUtils.toPrettyString(uDatas['full_name']) - else: + else: name = StringUtils.toPrettyString(uDatas['handle']) - uDatas['name'] = tounicode(name).lower() + uDatas['name'] = name.lower() self.contacts.append(uDatas) finally: self.connectionObj.releaseSkypeLock() @@ -464,14 +464,15 @@ OnIncomingCall = None OnIncomingFinished = None - - #@Params : ttsName, skype name otherwise. - OnIncomingMessage = None - + #incoming call was refused because a call is in progress. # Sending event with user handle that tries to call. OnIncomingCallRefused = None + + #@Params : ttsName, skype name otherwise. + OnIncomingMessage = None + #### Outgoing triggered events #### #@Params : ttsName, cut number otherwise. OnOutgoingCall = None @@ -615,11 +616,28 @@ def __on_message_status__(self, Message, Status): ''' ''' + #Checking first for available emoticon, if one found, then do not + #trigger message event BUT emoticon event. + emoticon_available, type = self.__check_emoticons__(Message.Body) + if emoticon_available: + if self.OnAvailableEmoticon != None: + arg = [EMOTICONS_TO_ATTITUNES[type], ] + thread = threading.Thread(target = self.OnAvailableEmoticon, args = arg) + thread.start() + return + #Same as emoticons but with tts sentences. + tts_available, message = self.__check_tts_sentence__(Message.Body) + if tts_available: + if self.OnAvailableTTSSentence != None: + thread = threading.Thread(target = self.OnAvailableTTSSentence, args = [message, ]) + thread.start() + return + exclude_list = ['<partlist', '<part identity', '</name>', '<name>'] exclude_message = False if Status == 'RECEIVED': - - #Checking if message body is not empty. + #Checking if message body is not empty. + #Handle empty lists api case. try: Message.Body.splitlines()[0] except: @@ -643,20 +661,11 @@ #Checking chat state and throwing only if this message #is in the 'missed chats' list. if chat.Name == Message.ChatName: - #throwing event. if self.OnIncomingMessage != None: thread = threading.Thread(target=self.OnIncomingMessage, args=[handle, ]) thread.start() - - #Checking for matching emoticons / attitunes. - emoticons = threading.Thread(target = self.__check_emoticons__(Message.Body)) - emoticons.start() - - #Checking for matching tts requests. - tts = threading.Thread(target = self.__check_tts_sentence__, args=[Message.Body]) - tts.start() - + @@ -667,11 +676,8 @@ # Search for emoticon for emoticon in EMOTICONS_TO_ATTITUNES.keys(): if message.lower().find(emoticon) != -1: - if self.OnAvailableEmoticon != None: - arg = [EMOTICONS_TO_ATTITUNES[emoticon], ] - thread = threading.Thread(target = self.OnAvailableEmoticon, args = arg) - thread.start() - return + return ( True, emoticon ) + return ( False, '' ) def __check_tts_sentence__(self, message): @@ -680,28 +686,15 @@ ''' # speak the text if begin is "tuxdroid>" if message.find('tuxdroid>') == 0: - self.__trigger_tts__(message[9:]) - return + return ( True, message[9:] ) # speak the text if begin is "tuxdroid" if message.find('tuxdroid') == 0: - self.__trigger_tts__(message[8:]) - return + return ( True, message[8:] ) # speak the text if begin is "tux>" if message.find('tux>') == 0: - self.__trigger_tts__(message[4:]) - return + return ( True, message[4:] ) # speak the text if begin is "tux" if message.find('tux') == 0: - self.__trigger_tts__(message[3:]) - return - - - def __trigger_tts__(self, message): - ''' - Trigger the 'tts sentence available' event. - ''' - if self.OnAvailableTTSSentence != None: - thread = threading.Thread(target = self.OnAvailableTTSSentence, args = [message, ]) - thread.start() - - \ No newline at end of file + return ( True, message[3:] ) + return ( False, '' ) + |