Author: gwadavel
Date: 2008-12-23 14:52:17 +0100 (Tue, 23 Dec 2008)
New Revision: 3293

Modified:
   software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py
Log:
same version as tuxdroid-gadget-pidgin


Modified: software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py
===================================================================
--- software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py       
2008-12-23 13:19:46 UTC (rev 3292)
+++ software_suite_v2/software/scripts/pidgin/trunk/tux_pidgin.py       
2008-12-23 13:52:17 UTC (rev 3293)
@@ -65,21 +65,8 @@
 from tuxisalive.api import *
 #------------------------------------------------
 #------------------------------------------------
-         
-# Uncomment or Comment for french language
-# Décommentez ou commentez pour le français
 
-tgp_language = "fr"
 
-# Uncomment or Comment for English language
-# Décommentez ou commentez pour l'anglais
-
-# tgp_language = "en"
-
-# Debug
-
-DEBUG = False
-
 # True : for use chat, False : for don't use
 # True  : pour utiliser les salons de discutions, False : ne pas utiliser 
 
@@ -98,6 +85,13 @@
 # tgp_away = True
 tgp_away = False
 
+
+# Address and port of Tux HTTP server
+
+tgp_ip = "127.0.0.1"
+tgp_port = 270
+
+
 LANGUAGE = ""
 
 FR = {"say": "dit", "online": "est en ligne", "pidginoff": "pidgin n'est pas 
lancé", "pidginon": "Tux pidgin est démarré"}
@@ -106,6 +100,7 @@
 class MessageParser(sgmllib.SGMLParser):
     """I found this snippets in this website :
     http://quickies.seriot.ch/index.php""";
+    
     def __init__(self):
         sgmllib.SGMLParser.__init__(self)
         
@@ -118,20 +113,30 @@
     def handle_data(self, data):
         self.theString += data
     
-def langue():
-    """ Select Language """
-    
+def lang():
+    """ Search LANGUAGE in os.environ """
+
     global LANGUAGE
-    if tgp_language == "fr":
-               LANGUAGE = FR
-               tux.tts.setLocutor("Julie")
-    else:
-        LANGUAGE = EN
-        tux.tts.setLocutor("Heather")   
-    tux.tts.setPitch(100)
+        
+    if "fr_" in os.environ['LANG']: 
+        locutor = "Bruno" 
+        pitch = 100
+        LANGUAGE = FR
+    elif ("en_" in os.environ['LANG']) or ("us_" in os.environ['LANG']):
+        locutor = "Ryan" 
+        pitch = 100
+        LANGUAGE = EN 
+    else: # for other language
+        locutor = "Ryan" 
+        pitch = 100
+        LANGUAGE = EN    
+    tux.tts.setLocutor(locutor)
+    tux.tts.setPitch(pitch)
+
        
 def tuxConnect():
        """ Wait connected """
+       
        tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxPidgin', 'NONE')
        tux.server.waitConnected(10.0)
        tux.dongle.waitConnected(10.0)
@@ -139,13 +144,15 @@
        
 def away():
     """ Test status away ou available """
+    
     # i found this here http://arstechnica.com/reviews/apps/pidgin-2-0.ars/4
     # Iterate through every active account
+    
     for acctID in purple.PurpleAccountsGetAllActive():
+    
     # Retrieve the current status
         status = purple.PurpleSavedstatusGetCurrent()
         type = purple.PurpleSavedstatusGetType(status)
-        if DEBUG: print ("type", type)
     if type == 5: # 5 = away 2 = available
         return True
     else:
@@ -153,6 +160,7 @@
 
 def received_im_msg(account, name, message, conversation, flags):
     """ This method is execute when a message is receive """
+    
     buddy = purple.PurpleFindBuddy(account, name)
     if buddy != 0:
         alias = purple.PurpleBuddyGetAlias(buddy)
@@ -167,8 +175,10 @@
   
 def buddy_signed_on(buddyid):
     """ This method is excute when a buddy is sign on """
+    
     alias = purple.PurpleBuddyGetAlias(buddyid)
     text = "%s %s" % (alias, LANGUAGE["online"])
+    text = text.encode('utf-8')
     tux_speak(text)
 
 
@@ -178,20 +188,19 @@
     if tgp_away and (not away()):
        return        
     if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
-        if DEBUG:
-               print("tux connect")
-               print(text)
         tux.mouth.open()
         tux.tts.speak(text)
         tux.mouth.close()
         tux.access.release()
 
 # Main
-tux = TuxAPI('127.1.1.1', 270)
+
+tux = TuxAPI(tgp_ip, tgp_port)
 tuxConnect()
 tux.tts.setEncoding("utf-8")
-langue()
-if DEBUG: print lang
+
+
+lang()
 bus = dbus.SessionBus()
 
 try:


------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to