tux-droid-svn Mailing List for Tux Droid CE (Page 6)
Status: Beta
Brought to you by:
ks156
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
(32) |
Mar
(108) |
Apr
(71) |
May
(38) |
Jun
(128) |
Jul
(1) |
Aug
(14) |
Sep
(77) |
Oct
(104) |
Nov
(90) |
Dec
(71) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(81) |
Feb
(18) |
Mar
(40) |
Apr
(102) |
May
(151) |
Jun
(74) |
Jul
(151) |
Aug
(257) |
Sep
(447) |
Oct
(379) |
Nov
(404) |
Dec
(430) |
| 2009 |
Jan
(173) |
Feb
(236) |
Mar
(519) |
Apr
(300) |
May
(112) |
Jun
(232) |
Jul
(314) |
Aug
(58) |
Sep
(203) |
Oct
(293) |
Nov
(26) |
Dec
(109) |
| 2010 |
Jan
(19) |
Feb
(25) |
Mar
(33) |
Apr
(1) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: jerome <c2m...@c2...> - 2009-12-15 14:01:51
|
Author: jerome
Date: 2009-12-15 14:44:04 +0100 (Tue, 15 Dec 2009)
New Revision: 5981
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* The plugin starts itself when user is making calls from Skype client interface.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 11:29:17 UTC (rev 5980)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 13:44:04 UTC (rev 5981)
@@ -153,10 +153,7 @@
self.client.start()
if self.configuration().getIsOutgoing():
- #Then getting online contact list.
- self.command = 'outgoing'
- self.client.notify('outgoing_call')
-
+ self.client.notify('get_outgoing_command')
def incomingPluginEvent(self, eventName, eventValues):
@@ -186,6 +183,7 @@
#Proceed call
if eventName == 'head':
self.client.notify('call_contact')
+
#Next contact
elif eventName == 'left':
self.client.notify('next_contact')
@@ -246,14 +244,25 @@
self.throwNotification("start")
self.throwMessage('%s' % Message[4:])
self.throwNotification("stop")
+
+ elif Message == 'command>interface_outgoing_call':
+ self.throwNotification("start")
+ self.throwActuation("upFlippers")
+ self.throwActuation("openMouth")
+ self.throwNotification("stop")
+ self.command = 'wait_end_call'
+
+ elif Message == 'command>user_outgoing_call':
+ self.command = 'outgoing'
+ self.client.notify('get_contacts')
def ClientOnConnected(self, id):
'''
'''
pass
+
-
##----------------------------------------------------------------
## * DAEMON command and functions.
##----------------------------------------------------------------
@@ -346,8 +355,7 @@
'''
Starting the plugin with 'incomingCall' command.
'''
- command = 'run'
- request = '/plugins_server/start_plugin?command='+ command + '&uuid='+ self.uuid +'¶meters='
+ request = '/plugins_server/start_plugin?command=run&uuid='+ self.uuid +'¶meters='
TuxDroidServerUtils.sendRequest("127.0.0.1", self.port, request)
self.command = 'incoming'
@@ -358,14 +366,21 @@
'''
#Send reset switches signal.
self.serv.notify('command>endcall')
+ self.command = ""
def OnOutgoingCall(self, contactHandle):
'''
- Outgoing call finished event.
+ Outgoing call in progress event.
'''
- self.serv.notify('command>outgoing')
+ #If call was done from skype client interface, then start the plugin
+ if not ( self.command == 'user_outgoing_call' ):
+ parameters = 'isOutgoing=true'
+ request = '/plugins_server/start_plugin?command=run&uuid='+ self.uuid +'¶meters=' + parameters
+ TuxDroidServerUtils.sendRequest("127.0.0.1", self.port, request)
+ self.command = 'interface_outgoing_call'
+
def OnOutgoingFinished(self, contactHandle):
@@ -373,6 +388,7 @@
'''
#Send reset switches signal.
self.serv.notify('command>endcall')
+ self.command = ""
def OnChatMessage(self, contactHandle):
@@ -531,12 +547,12 @@
self.synchronious.rejectCall()
#-------- Outgoing IPN messages --------#
- elif Message == 'outgoing_call':
+ elif Message == 'get_contacts':
#Outgoing call requested, so getting online list and sending outgoing command.
self.onlineList = self.synchronious.getOnlineList()
#And throwing the first online contact in list.
self.nextContact()
-
+
#Outgoing
elif Message == 'call_contact':
#Proceed call.
@@ -552,6 +568,16 @@
thread = threading.Thread(target=self.previousContact)
thread.start()
+ elif Message == 'get_outgoing_command':
+ if self.command == 'interface_outgoing_call':
+ #User call someone with Skype client interface.
+ self.serv.notify('command>interface_outgoing_call')
+ self.command = 'interface_outgoing_call'
+ else:
+ #User pick contact from tuxdroid
+ self.serv.notify('command>user_outgoing_call')
+ self.command = 'user_outgoing_call'
+
#-------- Common IPN messages --------#
elif Message == 'end_call':
self.synchronious.finishCall()
|
|
From: jerome <c2m...@c2...> - 2009-12-15 13:59:47
|
Author: jerome
Date: 2009-12-15 14:59:29 +0100 (Tue, 15 Dec 2009)
New Revision: 5982
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Added mutex for previous and next contact function.
* Added a 0.4 sec delay before throwing first contact.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 13:44:04 UTC (rev 5981)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 13:59:29 UTC (rev 5982)
@@ -112,6 +112,8 @@
asynchronious = None
connectorObj = None
+ mutex = threading.Lock()
+
#Used for run command only.
command = ""
canrun = True
@@ -437,21 +439,24 @@
Go next in the online contacts list.
'''
try:
+ self.mutex.acquire()
self.currentContact += 1
if self.currentContact >= len(self.onlineList):
self.currentContact = 0
self.serv.notify('tts>%s' % self.onlineList[self.currentContact])
- except:
- self.serv.notify('tts>%s' % self.onlineList[0])
-
+ finally:
+ time.sleep(0.4)
+ self.mutex.release()
+
def previousContact(self):
'''
Go previous in the online contacts list.
'''
try:
+ self.mutex.acquire()
self.currentContact -= 1
if self.currentContact <= -1:
@@ -459,10 +464,11 @@
self.currentContact = len(self.onlineList) - 1
self.serv.notify('tts>%s' % self.onlineList[self.currentContact])
- except:
- self.serv.notify('tts>%s' % self.onlineList[0])
+ finally:
+ time.sleep(0.4)
+ self.mutex.release()
+
-
def mainloop(self):
'''
Run main loop.
@@ -550,6 +556,7 @@
elif Message == 'get_contacts':
#Outgoing call requested, so getting online list and sending outgoing command.
self.onlineList = self.synchronious.getOnlineList()
+ time.sleep(0.4)
#And throwing the first online contact in list.
self.nextContact()
|
|
From: jerome <c2m...@c2...> - 2009-12-15 11:29:31
|
Author: jerome
Date: 2009-12-15 12:29:17 +0100 (Tue, 15 Dec 2009)
New Revision: 5980
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Throwing the first contact in the list.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 11:17:33 UTC (rev 5979)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 11:29:17 UTC (rev 5980)
@@ -156,6 +156,7 @@
#Then getting online contact list.
self.command = 'outgoing'
self.client.notify('outgoing_call')
+
def incomingPluginEvent(self, eventName, eventValues):
@@ -364,7 +365,7 @@
'''
Outgoing call finished event.
'''
- pass
+ self.serv.notify('command>outgoing')
def OnOutgoingFinished(self, contactHandle):
@@ -533,6 +534,8 @@
elif Message == 'outgoing_call':
#Outgoing call requested, so getting online list and sending outgoing command.
self.onlineList = self.synchronious.getOnlineList()
+ #And throwing the first online contact in list.
+ self.nextContact()
#Outgoing
elif Message == 'call_contact':
|
|
From: jerome <c2m...@c2...> - 2009-12-15 11:17:45
|
Author: jerome
Date: 2009-12-15 12:17:33 +0100 (Tue, 15 Dec 2009)
New Revision: 5979
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* First draft of outgoing functionality.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 10:33:37 UTC (rev 5978)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 11:17:33 UTC (rev 5979)
@@ -190,6 +190,12 @@
self.client.notify('next_contact')
elif eventName == 'right':
self.client.notify('previous_contact')
+
+ #endcall command, waiting for the call ends.
+ if self.command == 'wait_end_call':
+ if eventName == 'head':
+ #Then send finish call command to IPN server.
+ self.client.notify('end_call')
@@ -211,15 +217,31 @@
self.throwActuation("openMouth")
self.throwNotification("stop")
self.command = 'incoming'
+
elif Message == 'command>wait_end_call':
self.command = 'wait_end_call'
+
+ #Flippers up and mouth open if outgoing call.
+ if self.configuration().getIsOutgoing():
+ #Stop tts.
+ request = '/tts/stop?'
+ TuxDroidServerUtils.sendRequest("127.0.0.1", self.port, request)
+ self.throwNotification("start")
+ self.throwActuation("upFlippers")
+ self.throwActuation("openMouth")
+ self.throwNotification("stop")
+
elif Message == 'command>endcall':
self.throwNotification("start")
self.throwActuation("downFlippers")
self.throwActuation("closeMouth")
self.throwNotification("stop")
self.stop()
+
elif Message[:4].find('tts>') != -1:
+ #Stop current tts message.
+ request = '/tts/stop?'
+ TuxDroidServerUtils.sendRequest("127.0.0.1", self.port, request)
self.throwNotification("start")
self.throwMessage('%s' % Message[4:])
self.throwNotification("stop")
@@ -390,7 +412,7 @@
'''
Call the current selected contact.
'''
- pass
+ self.synchronious.call(self.onlineList[self.currentContact])
def nextContact(self):
@@ -399,7 +421,11 @@
'''
try:
self.currentContact += 1
- self.serv.notify('tts>%s' % self.onlineList[self.currentUser])
+
+ if self.currentContact >= len(self.onlineList):
+ self.currentContact = 0
+
+ self.serv.notify('tts>%s' % self.onlineList[self.currentContact])
except:
self.serv.notify('tts>%s' % self.onlineList[0])
@@ -408,7 +434,16 @@
'''
Go previous in the online contacts list.
'''
- pass
+ try:
+ self.currentContact -= 1
+
+ if self.currentContact <= -1:
+ #Then going to the last online list entry.
+ self.currentContact = len(self.onlineList) - 1
+
+ self.serv.notify('tts>%s' % self.onlineList[self.currentContact])
+ except:
+ self.serv.notify('tts>%s' % self.onlineList[0])
def mainloop(self):
@@ -489,6 +524,7 @@
self.serv.notify('command>wait_end_call')
thread = threading.Thread(target=self.synchronious.acceptCall, args =(self.asynchronious.call, ))
thread.start()
+
elif Message == 'reject_call' :
#Reject call.
self.synchronious.rejectCall()
@@ -497,14 +533,18 @@
elif Message == 'outgoing_call':
#Outgoing call requested, so getting online list and sending outgoing command.
self.onlineList = self.synchronious.getOnlineList()
- self.throwTrace(self.onlineList)
+
#Outgoing
elif Message == 'call_contact':
+ #Proceed call.
+ self.serv.notify('command>wait_end_call')
thread = threading.Thread(target=self.callCurrentContact)
thread.start()
+
elif Message == 'next_contact':
thread = threading.Thread(target=self.nextContact)
thread.start()
+
elif Message == 'previous_contact':
thread = threading.Thread(target=self.previousContact)
thread.start()
|
|
From: jerome <c2m...@c2...> - 2009-12-15 10:33:48
|
Author: jerome
Date: 2009-12-15 11:33:37 +0100 (Tue, 15 Dec 2009)
New Revision: 5978
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Fixed a dummy configuration bug...
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 09:53:54 UTC (rev 5977)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 10:33:37 UTC (rev 5978)
@@ -47,58 +47,56 @@
'''
Skype plugin configuration.
'''
- throwEmoticons = True
- throwTTS = True
- isOutgoing = False
def __init__(self):
'''
Configuration initialization.
'''
SimplePluginConfiguration.__init__(self)
- self.throwEmoticons = True
+ self.__throwEmoticons = True
+ self.__throwTTS = True
+ self.__isOutgoing = False
-
def getThrowEmoticons(self):
'''
Return true if emoticons will be thrown.
'''
- return self.throwEmoticons
+ return self.__throwEmoticons
- def setThrowEmoticons(self, aThrowEmoticons):
+ def setThrowEmoticons(self, throwEmoticons):
'''
Set the throwEmoticons parameter value.
'''
- self.throwEmoticons = aThrowEmoticons
+ self.__throwEmoticons = throwEmoticons
def getThrowTTS(self):
'''
Return the throwTTS parameter value.
'''
- return self.throwTTS
+ return self.__throwTTS
- def setThrowTTS(self, throw):
+ def setThrowTTS(self, throwTTS):
'''
Set the throwTTS parameter value.
'''
- self.throwTTS = throw
+ self.__throwTTS = throwTTS
def getIsOutgoing(self):
'''
Return the outgoing parameter value.
'''
- return self.isOutgoing
+ return self.__isOutgoing
- def setIsOutgoing(self, outgoing):
+ def setIsOutgoing(self, isOutgoing):
'''
Set the outgoing parameter value.
'''
- self.isOutgoing = outgoing
+ self.__isOutgoing = isOutgoing
class SkypePlugin(SimplePlugin):
@@ -122,6 +120,7 @@
onlineList = []
currentContact = -1
+
##----------------------------------------------------------------
## * Skype plugin main entry point.
##----------------------------------------------------------------
|
|
From: jerome <c2m...@c2...> - 2009-12-15 09:54:09
|
Author: jerome
Date: 2009-12-15 10:53:54 +0100 (Tue, 15 Dec 2009)
New Revision: 5977
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Removed debug messages.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 09:51:42 UTC (rev 5976)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 09:53:54 UTC (rev 5977)
@@ -163,7 +163,6 @@
'''
Tux Droid plugin event callback.
'''
- self.throwTrace(self.command)
if self.command == 'incoming':
#Accept call
if eventName == 'head':
@@ -174,9 +173,7 @@
#endcall command, waiting for the call ends.
if self.command == 'wait_end_call':
- self.throwTrace('here 0')
if eventName == 'head':
- self.throwTrace('here 1')
#Then send finish call command to IPN server.
self.client.notify('end_call')
@@ -185,7 +182,6 @@
'''
Tux Droid event callback for outgoing calls.
'''
- self.throwTrace("outgoing")
if self.command == 'outgoing':
#Proceed call
if eventName == 'head':
|
|
From: jerome <c2m...@c2...> - 2009-12-15 09:51:57
|
Author: jerome
Date: 2009-12-15 10:51:42 +0100 (Tue, 15 Dec 2009)
New Revision: 5976
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Fixed and implemented configuration.
* Finished incoming calls.
* Started to implement outgoing calls.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 09:08:36 UTC (rev 5975)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-15 09:51:42 UTC (rev 5976)
@@ -59,42 +59,42 @@
self.throwEmoticons = True
- def getThrowEmoticons():
+ def getThrowEmoticons(self):
'''
Return true if emoticons will be thrown.
'''
return self.throwEmoticons
- def setThrowEmoticons(aThrowEmoticons):
+ def setThrowEmoticons(self, aThrowEmoticons):
'''
Set the throwEmoticons parameter value.
'''
self.throwEmoticons = aThrowEmoticons
- def getThrowTTS()
+ def getThrowTTS(self):
'''
Return the throwTTS parameter value.
'''
return self.throwTTS
- def setThrowTTS(throw)
+ def setThrowTTS(self, throw):
'''
Set the throwTTS parameter value.
'''
self.throwTTS = throw
- def getIsOutgoing()
+ def getIsOutgoing(self):
'''
Return the outgoing parameter value.
'''
return self.isOutgoing
- def setIsOutgoing(outgoing)
+ def setIsOutgoing(self, outgoing):
'''
Set the outgoing parameter value.
'''
@@ -115,10 +115,13 @@
connectorObj = None
#Used for run command only.
- ready = False
command = ""
canrun = True
+ #Used for outgoing parameter only.
+ onlineList = []
+ currentContact = -1
+
##----------------------------------------------------------------
## * Skype plugin main entry point.
##----------------------------------------------------------------
@@ -131,7 +134,7 @@
self.port = TuxDroidServerUtils.getServerPort()
#Check for the command.
- if self.getCommand() == "runDaemon":
+ if self.getCommand() == "check":
self.runDaemon()
elif self.getCommand() == "run":
self.run()
@@ -139,7 +142,7 @@
self.runDaemon()
##----------------------------------------------------------------
- ## * PLUGIN COMMAND : Set Tux Droid for a call.
+ ## * PLUGIN COMMAND : Set Tux Droid for an incoming call call.
##----------------------------------------------------------------
def run(self):
'''
@@ -150,22 +153,48 @@
self.client.registerOnConnectedCallBack(self.ClientOnConnected)
self.client.start()
+ if self.configuration().getIsOutgoing():
+ #Then getting online contact list.
+ self.command = 'outgoing'
+ self.client.notify('outgoing_call')
def incomingPluginEvent(self, eventName, eventValues):
'''
Tux Droid plugin event callback.
'''
- if not self.ready:
- return
-
+ self.throwTrace(self.command)
if self.command == 'incoming':
- #Accept call
+ #Accept call
if eventName == 'head':
self.client.notify('accept_call')
#Reject Call
elif eventName in ['left', 'right']:
self.client.notify('reject_call')
+
+ #endcall command, waiting for the call ends.
+ if self.command == 'wait_end_call':
+ self.throwTrace('here 0')
+ if eventName == 'head':
+ self.throwTrace('here 1')
+ #Then send finish call command to IPN server.
+ self.client.notify('end_call')
+
+
+ def outgoingPluginEvent(self, eventName, eventValues):
+ '''
+ Tux Droid event callback for outgoing calls.
+ '''
+ self.throwTrace("outgoing")
+ if self.command == 'outgoing':
+ #Proceed call
+ if eventName == 'head':
+ self.client.notify('call_contact')
+ #Next contact
+ elif eventName == 'left':
+ self.client.notify('next_contact')
+ elif eventName == 'right':
+ self.client.notify('previous_contact')
@@ -173,27 +202,40 @@
'''
Recieved a message from server.
'''
+ thread = threading.Thread(target=self.OnNotification, args = (Message, ))
+ thread.start()
+
+
+ def OnNotification(self, Message):
+ '''
+ Threaded client notification.
+ '''
if Message == 'command>incoming':
self.throwNotification("start")
self.throwActuation("upFlippers")
self.throwActuation("openMouth")
self.throwNotification("stop")
- self.ready = True
self.command = 'incoming'
+ elif Message == 'command>wait_end_call':
+ self.command = 'wait_end_call'
elif Message == 'command>endcall':
self.throwNotification("start")
self.throwActuation("downFlippers")
self.throwActuation("closeMouth")
self.throwNotification("stop")
self.stop()
-
+ elif Message[:4].find('tts>') != -1:
+ self.throwNotification("start")
+ self.throwMessage('%s' % Message[4:])
+ self.throwNotification("stop")
+
def ClientOnConnected(self, id):
'''
'''
pass
-
+
##----------------------------------------------------------------
## * DAEMON command and functions.
##----------------------------------------------------------------
@@ -203,12 +245,14 @@
Run plugin command.
'''
#Creating and starting server.
+
self.serv = IPNServer('127.0.0.1', 48536)
self.serv.registerOnClientAddedCallBack(self.ServerOnClientAdded)
self.serv.registerOnClientRemovedCallBack(self.ServerOnClientRemoved)
self.serv.registerOnClientNotificationCallBack(self.ServerOnClientNotification)
self.serv.start()
+
#Initialize skype client and api objects.
self.connectorObj = connector.Connector()
self.connectorObj.OnAPIReady = self.initializeDaemon
@@ -303,14 +347,14 @@
'''
Outgoing call finished event.
'''
- #Send reset switches signal.
- self.serv.notify('command>endcall')
+ pass
def OnOutgoingFinished(self, contactHandle):
'''
'''
- pass
+ #Send reset switches signal.
+ self.serv.notify('command>endcall')
def OnChatMessage(self, contactHandle):
@@ -328,34 +372,57 @@
'''
Event that notify of incoming emoticon.
'''
+ if not self.configuration().getThrowEmoticons():
+ return
self.throwNotification("start")
self.throwActuation("playAttitune", attName)
self.throwNotification("stop")
+
+
-
def OnTTS(self, sentence):
'''
Event that notify a tts sentence to be said by Tux Droid.
'''
+ if not self.configuration().getThrowTTS():
+ return
self.throwNotification("start")
self.throwMessage(sentence)
self.throwNotification("stop")
- def ContactStatusChanged(self, UserHandle, Status):
+ def callCurrentContact(self):
'''
- Event that notify a contact status changed.
+ Call the current selected contact.
'''
- #Nothing for this plugin version, maybe later on.
pass
+ def nextContact(self):
+ '''
+ Go next in the online contacts list.
+ '''
+ try:
+ self.currentContact += 1
+ self.serv.notify('tts>%s' % self.onlineList[self.currentUser])
+ except:
+ self.serv.notify('tts>%s' % self.onlineList[0])
+
+
+ def previousContact(self):
+ '''
+ Go previous in the online contacts list.
+ '''
+ pass
+
+
def mainloop(self):
'''
Run main loop.
'''
while 1:
- time.sleep(2.0)
+ time.sleep(1.0)
+
#Setting Tux Droid as audio peripheral.
try:
#in try statement to take calls in care.
@@ -363,7 +430,7 @@
self.synchronious.setAudioCards()
except:
pass
-
+
##----------------------------------------------------------------
@@ -373,13 +440,16 @@
'''
OnPluginStop event.
'''
- if self.connectorObj != None:
- if self.getCommand() == 'outgoingCall':
- #TODO update this function.
- self.connectorObj.stop(KillClient=True)
- else:
- #In other cases, close connection but not skype client.
- self.connectorObj.stop()
+ if self.getCommand() == 'run':
+ self.client.stop()
+ else:
+ if self.connectorObj != None:
+ if self.getCommand() == 'outgoingCall':
+ #TODO update this function.
+ self.connectorObj.stop(KillClient=True)
+ else:
+ #In other cases, close connection but not skype client.
+ self.connectorObj.stop()
@@ -391,7 +461,10 @@
'''
#Start the adequate function for each plugin command.
if self.getCommand() == 'run':
- self.incomingPluginEvent(eventName, eventValues)
+ if not self.configuration().getIsOutgoing():
+ self.incomingPluginEvent(eventName, eventValues)
+ else:
+ self.outgoingPluginEvent(eventName, eventValues)
@@ -401,7 +474,8 @@
def ServerOnClientAdded(self, idClient):
'''
'''
- self.serv.notify( "command>" + self.command )
+ if not self.configuration().getIsOutgoing():
+ self.serv.notify( "command>" + self.command )
def ServerOnClientRemoved(self, idClient):
@@ -413,14 +487,37 @@
def ServerOnClientNotification(self, idClient, Message):
'''
'''
+ #-------- Incoming IPN messages --------#
if Message == 'accept_call':
if self.asynchronious.call != None:
#Take call
- self.synchronious.acceptCall(self.asynchronious.call)
+ self.serv.notify('command>wait_end_call')
+ thread = threading.Thread(target=self.synchronious.acceptCall, args =(self.asynchronious.call, ))
+ thread.start()
elif Message == 'reject_call' :
- #Reject call.
- self.synchronious.rejectCall()
+ #Reject call.
+ self.synchronious.rejectCall()
+ #-------- Outgoing IPN messages --------#
+ elif Message == 'outgoing_call':
+ #Outgoing call requested, so getting online list and sending outgoing command.
+ self.onlineList = self.synchronious.getOnlineList()
+ self.throwTrace(self.onlineList)
+ #Outgoing
+ elif Message == 'call_contact':
+ thread = threading.Thread(target=self.callCurrentContact)
+ thread.start()
+ elif Message == 'next_contact':
+ thread = threading.Thread(target=self.nextContact)
+ thread.start()
+ elif Message == 'previous_contact':
+ thread = threading.Thread(target=self.previousContact)
+ thread.start()
+
+ #-------- Common IPN messages --------#
+ elif Message == 'end_call':
+ self.synchronious.finishCall()
+
if __name__ == "__main__":
plugin = SkypePlugin()
|
|
From: jerome <c2m...@c2...> - 2009-12-15 09:08:48
|
Author: jerome
Date: 2009-12-15 10:08:36 +0100 (Tue, 15 Dec 2009)
New Revision: 5975
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/communicator.py
Log:
* Added mutex for emoticons and tts text research.
* Fixed an encoding problem ( need to be tested on Linux ).
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-14 12:48:31 UTC (rev 5974)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/communicator.py 2009-12-15 09:08:36 UTC (rev 5975)
@@ -60,8 +60,7 @@
contacts_ols = ['ONLINE', 'AWAY', 'NA', 'DND', 'SKYPEOUT', 'SKYPEME']
#List available offline statuses.
- contacts_ofs = [u'UNKNOWN', u'OFFLINE', u'INVISIBLE']
-
+ contacts_ofs = [u'UNKNOWN', u'OFFLINE', u'INVISIBLE']
###################################################
@@ -491,6 +490,9 @@
#@Params : TTS sentence.
OnAvailableTTSSentence = None
+
+
+ lock = threading.Lock()
###################################################
@@ -640,7 +642,12 @@
tts_available, message = self.__check_tts_sentence__(Message.Body)
if tts_available:
if self.OnAvailableTTSSentence != None:
- thread = threading.Thread(target = self.OnAvailableTTSSentence, args = [message, ])
+ try:
+ mess = message.encode("iso-8859-1")
+ except:
+ mess = message.encode("utf-8")
+
+ thread = threading.Thread(target = self.OnAvailableTTSSentence, args = [mess, ])
thread.start()
return
@@ -674,10 +681,13 @@
'''
Check message for matching emoticons.
'''
+ self.lock.acquire()
# Search for emoticon
for emoticon in EMOTICONS_TO_ATTITUNES.keys():
if message.lower().find(emoticon) != -1:
+ self.lock.release()
return ( True, emoticon )
+ self.lock.release()
return ( False, '' )
@@ -685,17 +695,23 @@
'''
Check if the message contains 'tux'.
'''
+ self.lock.acquire()
# speak the text if begin is "tuxdroid>"
if message.find('tuxdroid>') == 0:
+ self.lock.release()
return ( True, message[9:] )
# speak the text if begin is "tuxdroid"
if message.find('tuxdroid') == 0:
+ self.lock.release()
return ( True, message[8:] )
# speak the text if begin is "tux>"
if message.find('tux>') == 0:
+ self.lock.release()
return ( True, message[4:] )
# speak the text if begin is "tux"
if message.find('tux') == 0:
+ self.lock.release()
return ( True, message[3:] )
+ self.lock.release()
return ( False, '' )
|
|
From: jerome <c2m...@c2...> - 2009-12-14 12:48:58
|
Author: jerome
Date: 2009-12-14 13:48:31 +0100 (Mon, 14 Dec 2009)
New Revision: 5974
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
Log:
* Updated description, runDeamon was enable to notify.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-13 12:42:59 UTC (rev 5973)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-14 12:48:31 UTC (rev 5974)
@@ -17,12 +17,12 @@
<!-- Daemon ( incoming ) parameters -->
<parameter
name="throwEmoticons"
- description="Throw or not Emoticons"
+ description="Notify incoming Emoticons"
type="boolean"
defaultValue="true" />
<parameter
name="throwTTS"
- description="Throw or not TTS messages"
+ description="Notify incoming TTS messages"
type="boolean"
defaultValue="true" />
<!-- Outgoing parameter, select it to make outgoing calls -->
@@ -38,22 +38,25 @@
description="Start Skype incoming call"
daemon="true"
exclusive="true"
+ allUserButtons="true"
/>
<command
- name="runDaemon"
+ name="check"
description="Start Skype notifier"
daemon="true"
+ expiration="1"
+ notifier="true"
/>
</commands>
<tasks>
<task
name="Activation"
description="Activate the Skype notifier"
- command="runDaemon"
+ command="check"
type="once delayed"
activated="false"
- delay="00:00:15"
+ delay="00:00:10"
delayMask="false,false,false"
delayVisible="false"
/>
|
|
From: jerome <c2m...@c2...> - 2009-12-13 12:51:56
|
Author: jerome
Date: 2009-12-13 13:19:10 +0100 (Sun, 13 Dec 2009)
New Revision: 5970
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
Log:
* Updated command description.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-10 14:37:28 UTC (rev 5969)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-13 12:19:10 UTC (rev 5970)
@@ -17,32 +17,16 @@
</parameters>
<commands>
<command
- name="incomingCall"
- description="Start Skype incoming call"
+ name="run"
+ description="Start Skype incoming call"
daemon="true"
exclusive="true"
- critical="true"
- allUserButtons="true"/>
+ />
<command
name="runDaemon"
description="Start Skype notifier"
daemon="true"
- notifier="true"
- expiration="1" />
- <command
- name="outgoingCall"
- description="Start Skype outgoing call"
- daemon="true"
- exclusive="true"
- critical="true"
- allUserButtons="true"/>
- <command
- name="endCall"
- description="Start Skype end call"
- daemon="true"
- exclusive="true"
- critical="true"
- allUserButtons="true"/>
+ />
</commands>
<tasks>
<task
@@ -52,7 +36,7 @@
type="once delayed"
activated="false"
- delay="00:00:30"
+ delay="00:00:15"
delayMask="false,false,false"
delayVisible="false"
/>
|
|
From: jerome <c2m...@c2...> - 2009-12-13 12:51:56
|
Author: jerome
Date: 2009-12-13 13:22:25 +0100 (Sun, 13 Dec 2009)
New Revision: 5971
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Getting incoming calls.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-13 12:19:10 UTC (rev 5970)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-13 12:22:25 UTC (rev 5971)
@@ -79,12 +79,18 @@
'''
#plugin uuid
uuid = "8349ed52-572d-4c3f-a7b8-f6d4a5ae2c0"
+
port = 270
#Skype client - api objects.
synchronious = None
asynchronious = None
connectorObj = None
+ #Used for run command only.
+ ready = False
+ command = ""
+ canrun = True
+
##----------------------------------------------------------------
## * Skype plugin main entry point.
##----------------------------------------------------------------
@@ -99,78 +105,62 @@
#Check for the command.
if self.getCommand() == "runDaemon":
self.runDaemon()
- elif self.getCommand() == "incomingCall":
- self.incomingCall()
- elif self.getCommand() == "outgoingCall":
- self.outgoingCall()
- elif self.getCommand() == "endCall":
- self.endCall()
+ elif self.getCommand() == "run":
+ self.run()
else:
self.runDaemon()
##----------------------------------------------------------------
- ## * PLUGIN COMMAND : Set Tux Droid for an incoming call.
+ ## * PLUGIN COMMAND : Set Tux Droid for a call.
##----------------------------------------------------------------
- def incomingCall(self):
+ def run(self):
'''
Initialize Tux Droid switches for a call ( incoming or outgoing )
'''
- self.initializeCommandsClient()
+ self.client = IPNClient('127.0.0.1', 48536)
+ self.client.registerOnNotificationCallBack(self.ClientOnNotification)
+ self.client.registerOnConnectedCallBack(self.ClientOnConnected)
+ self.client.start()
- #Run main loop.
- thread = threading.Thread(target=self.mainloop)
- thread.start()
def incomingPluginEvent(self, eventName, eventValues):
'''
Tux Droid plugin event callback.
'''
- try:
- #Check for IPN client started.
- if not self.client.start():
- return
+ if not self.ready:
+ return
+
+ if self.command == 'incoming':
#Accept call
if eventName == 'head':
self.client.notify('accept_call')
#Reject Call
elif eventName in ['left', 'right']:
self.client.notify('reject_call')
- finally:
- #Quit plugin
-
-
-
- ##----------------------------------------------------------------
- ## * PLUGIN COMMAND : Set Tux Droid for an incoming call.
- ##----------------------------------------------------------------
- def outgoingCall(self):
+ #Quit run mode plugin.
+ self.stop()
+
+
+ def ClientOnNotification(self, Message):
'''
- Initialize Tux Droid for an outgoing call.
+ Recieved a message from server.
'''
- self.initializeCommandsClient()
+ if Message == 'command>incoming':
+ self.throwNotification("start")
+ self.throwActuation("upFlippers")
+ self.throwActuation("openMouth")
+ self.throwNotification("stop")
+ self.ready = True
+ self.command = 'incoming'
+
-
- ##----------------------------------------------------------------
- ## * PLUGIN COMMAND : Finish an incoming / outgoing call
- ##----------------------------------------------------------------
- def endCall(self):
+ def ClientOnConnected(self, id):
'''
- End an incoming or outgoing call.
'''
- self.client.notify('finish_call')
-
-
- def initializeCommandsClient(self):
- '''
- Initialize the commands sender ( client / server ).
- '''
- self.client = IPNClient('127.0.0.1', 48536)
- self.client.registerOnNotificationCallBack(self.ClientOnNotification)
- self.client.registerOnConnectedCallBack(self.ClientOnConnected)
- self.client.registerOnDisconnectedCallBack(self.ClientOnDisconnected)
- self.client.start()
+ pass
+
##----------------------------------------------------------------
## * DAEMON command and functions.
##----------------------------------------------------------------
@@ -252,20 +242,29 @@
Incoming call event.
'''
#Set up Tux Droid motors.
- self.throwActuation("upFlippers")
- self.throwActuation("openMouth")
-
- #Starting the plugin with 'incomingCall' command.
- command = 'incomingCall'
+ thread = threading.Thread(target=self.startRunMode)
+ thread.start()
+
+
+
+ def startRunMode(self):
+ '''
+ Starting the plugin with 'incomingCall' command.
+ '''
+ command = 'run'
request = '/plugins_server/start_plugin?command='+ command + '&uuid='+ self.uuid +'¶meters='
-
TuxDroidServerUtils.sendRequest("127.0.0.1", self.port, request)
+ self.command = 'incoming'
def OnIncomingFinished(self, contactHandle):
'''
'''
- pass
+ #Set up Tux Droid motors.
+ self.throwNotification("start")
+ self.throwActuation("downFlippers")
+ self.throwActuation("closeMouth")
+ self.throwNotification("stop")
@@ -318,7 +317,6 @@
pass
-
def mainloop(self):
'''
Run main loop.
@@ -327,8 +325,6 @@
time.sleep(2.0)
#Setting Tux Droid as audio peripheral.
try:
- #Starting server that will listen to requests.
- self.serv.start()
#in try statement to take calls in care.
if ( self.synchronious != None ) and ( not self.synchronious.isTuxDroidAudioCard() ):
self.synchronious.setAudioCards()
@@ -346,6 +342,7 @@
'''
if self.connectorObj != None:
if self.getCommand() == 'outgoingCall':
+ #TODO update this function.
self.connectorObj.stop(KillClient=True)
else:
#In other cases, close connection but not skype client.
@@ -360,19 +357,18 @@
@param eventValues: Event values.
'''
#Start the adequate function for each plugin command.
- if self.getCommand() == 'incomingCall':
+ if self.getCommand() == 'run':
self.incomingPluginEvent(eventName, eventValues)
- else:
- pass
+
+
-
##----------------------------------------------------------------
## * DAEMON Client / Server IPN Communication.
##----------------------------------------------------------------
def ServerOnClientAdded(self, idClient):
'''
'''
- pass
+ self.serv.notify( "command>" + self.command )
def ServerOnClientRemoved(self, idClient):
@@ -384,26 +380,14 @@
def ServerOnClientNotification(self, idClient, Message):
'''
'''
- pass
-
-
- def ClientOnNotification(self, Message):
- '''
- '''
- pass
+ if Message == 'accept_call':
+ if self.asynchronious.call != None:
+ #Take call
+ self.synchronious.acceptCall(self.asynchronious.call)
+ elif Message == 'reject_call' :
+ #Reject call.
+ self.synchronious.rejectCall()
-
- def ClientOnConnected(self, id):
- '''
- '''
- pass
-
-
- def ClientOnDisconnected(self):
- '''
- '''
- pass
-
if __name__ == "__main__":
plugin = SkypePlugin()
|
|
From: jerome <c2m...@c2...> - 2009-12-13 12:51:53
|
Author: jerome
Date: 2009-12-13 13:31:15 +0100 (Sun, 13 Dec 2009)
New Revision: 5972
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* And finish call.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-13 12:22:25 UTC (rev 5971)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-13 12:31:15 UTC (rev 5972)
@@ -138,9 +138,8 @@
#Reject Call
elif eventName in ['left', 'right']:
self.client.notify('reject_call')
- #Quit run mode plugin.
- self.stop()
+
def ClientOnNotification(self, Message):
'''
@@ -153,7 +152,13 @@
self.throwNotification("stop")
self.ready = True
self.command = 'incoming'
-
+ elif Message == 'command>endcall':
+ self.throwNotification("start")
+ self.throwActuation("downFlippers")
+ self.throwActuation("closeMouth")
+ self.throwNotification("stop")
+ self.stop()
+
def ClientOnConnected(self, id):
'''
@@ -259,19 +264,19 @@
def OnIncomingFinished(self, contactHandle):
'''
+ Incoming call finished event.
'''
- #Set up Tux Droid motors.
- self.throwNotification("start")
- self.throwActuation("downFlippers")
- self.throwActuation("closeMouth")
- self.throwNotification("stop")
+ #Send reset switches signal.
+ self.serv.notify('command>endcall')
def OnOutgoingCall(self, contactHandle):
'''
+ Outgoing call finished event.
'''
- pass
+ #Send reset switches signal.
+ self.serv.notify('command>endcall')
def OnOutgoingFinished(self, contactHandle):
|
|
From: jerome <c2m...@c2...> - 2009-12-13 12:43:15
|
Author: jerome
Date: 2009-12-13 13:42:59 +0100 (Sun, 13 Dec 2009)
New Revision: 5973
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
Log:
* Added outgoing parameter.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-13 12:31:15 UTC (rev 5972)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-13 12:42:59 UTC (rev 5973)
@@ -48,8 +48,9 @@
Skype plugin configuration.
'''
throwEmoticons = True
+ throwTTS = True
+ isOutgoing = False
-
def __init__(self):
'''
Configuration initialization.
@@ -70,9 +71,36 @@
Set the throwEmoticons parameter value.
'''
self.throwEmoticons = aThrowEmoticons
+
+
+ def getThrowTTS()
+ '''
+ Return the throwTTS parameter value.
+ '''
+ return self.throwTTS
+
+
+ def setThrowTTS(throw)
+ '''
+ Set the throwTTS parameter value.
+ '''
+ self.throwTTS = throw
+
+
+ def getIsOutgoing()
+ '''
+ Return the outgoing parameter value.
+ '''
+ return self.isOutgoing
+
+
+ def setIsOutgoing(outgoing)
+ '''
+ Set the outgoing parameter value.
+ '''
+ self.isOutgoing = outgoing
-
class SkypePlugin(SimplePlugin):
'''
Skype plugin base class.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-13 12:31:15 UTC (rev 5972)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-13 12:42:59 UTC (rev 5973)
@@ -14,6 +14,23 @@
<platform>all</platform>
</description>
<parameters>
+ <!-- Daemon ( incoming ) parameters -->
+ <parameter
+ name="throwEmoticons"
+ description="Throw or not Emoticons"
+ type="boolean"
+ defaultValue="true" />
+ <parameter
+ name="throwTTS"
+ description="Throw or not TTS messages"
+ type="boolean"
+ defaultValue="true" />
+ <!-- Outgoing parameter, select it to make outgoing calls -->
+ <parameter
+ name="isOutgoing"
+ description="Make outgoing calls"
+ type="boolean"
+ defaultValue="false" />
</parameters>
<commands>
<command
|
|
From: jerome <c2m...@c2...> - 2009-12-10 14:37:49
|
Author: jerome
Date: 2009-12-10 15:37:28 +0100 (Thu, 10 Dec 2009)
New Revision: 5969
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
Log:
* Updated command description.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-10 12:44:16 UTC (rev 5968)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-10 14:37:28 UTC (rev 5969)
@@ -18,7 +18,11 @@
<commands>
<command
name="incomingCall"
- description="Start Skype incoming call"/>
+ description="Start Skype incoming call"
+ daemon="true"
+ exclusive="true"
+ critical="true"
+ allUserButtons="true"/>
<command
name="runDaemon"
description="Start Skype notifier"
|
|
From: remi <c2m...@c2...> - 2009-12-10 12:44:35
|
Author: remi
Date: 2009-12-10 13:44:16 +0100 (Thu, 10 Dec 2009)
New Revision: 5968
Modified:
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml
Log:
*fixed gadget uuid in the xml file
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml 2009-12-10 12:18:28 UTC (rev 5967)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml 2009-12-10 12:44:16 UTC (rev 5968)
@@ -9,7 +9,7 @@
<onDemandIsAble>true</onDemandIsAble>
<platform>all</platform>
<ttsName>Twitter</ttsName>
- <uuid>6d380a3d-b03a-88db-e6da-7cc1d6c7af6f</uuid>
+ <uuid>33b14aea-907e-9d9d-7e64-c40c3bbf56fb</uuid>
<version>4.1</version>
</description>
<parameters>
|
|
From: remi <c2m...@c2...> - 2009-12-10 12:38:35
|
Author: remi
Date: 2009-12-10 13:18:28 +0100 (Thu, 10 Dec 2009)
New Revision: 5967
Modified:
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/de.wiki
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/en.wiki
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/fr.wiki
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.pot
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml
software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/nl.wiki
Log:
* Updated twitter gadget
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/de.wiki
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/de.wiki 2009-12-09 17:28:04 UTC (rev 5966)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/de.wiki 2009-12-10 12:18:28 UTC (rev 5967)
@@ -5,6 +5,7 @@
* '''Funktionsname :''' Damit können Sie die Gadget-Namen zu ändern.
* '''Benutzername :''' Login Ihres Twitter-Kontos.
* '''Passwort :''' Passwort Ihres Twitter-Kontos.
+* '''Tweets Lesen :''' Tux Droid liest den Inhalt Ihrer Tweets.
* '''Freund Updates prüfen :''' Tux Droid sucht nach den neuesten Tweets von den Leuten denen du folgst.
* '''Diese Gadget wird in die Favoritenliste aufgenommen :''' Diese Option aktivieren, um die Funktion in Ihrer Favoriten-
Liste hinzufügen.
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/en.wiki
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/en.wiki 2009-12-09 17:28:04 UTC (rev 5966)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/en.wiki 2009-12-10 12:18:28 UTC (rev 5967)
@@ -5,6 +5,7 @@
* '''Gadget name :''' Let's you modify the gadget name.
* '''Username :''' Enter your Twitter login.
* '''Password :''' Enter your Twitter password.
+* '''Read Tweet content :''' Will make Tux Droid read the Tweet content.
* '''Check for new Tweets :''' Will make Tux Droid check for any new Tweets from people you are following.
* '''Add this gadget to My Favorites list :''' To make the gadget accessible with the remote control and Tux Droid.
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/fr.wiki
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/fr.wiki 2009-12-09 17:28:04 UTC (rev 5966)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/fr.wiki 2009-12-10 12:18:28 UTC (rev 5967)
@@ -5,6 +5,7 @@
* '''Nom du gadget :''' Vous permet de modifier le nom du gadget.
* '''Utilisateur :''' Entrez votre nom d'utilisateur Twitter.
* '''Mot de passe :''' Entrez votre mot de passe Twitter.
+* '''Lire le contenu des Tweets :''' Tux Droid lira le contenu de vos Tweets.
* '''Vérifier les Tweets de mes amis :''' Tux Droid vérifiera la présence de nouveaux Tweets publiés par vos amis.
* '''Ajouter ce gadget dans ma liste de favoris :''' Rend le gadget accessible par la télécommande ainsi que par Tux Droid.
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.pot
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.pot 2009-12-09 17:28:04 UTC (rev 5966)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.pot 2009-12-10 12:18:28 UTC (rev 5967)
@@ -1,8 +1,8 @@
msgid "Twitter"
msgstr ""
-msgid "Twitter."
+msgid "Twitter"
msgstr ""
-msgid "The Twitter gadget will make Tux Droid read your tweets from your Twitter account."
+msgid "The Twitter plugin will make Tux Droid check your Twitter account."
msgstr ""
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml 2009-12-09 17:28:04 UTC (rev 5966)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/gadget.xml 2009-12-10 12:18:28 UTC (rev 5967)
@@ -1,6 +1,6 @@
-<gadget>
+<gadget>
<description>
- <author>Kysoh</author>
+ <author>Jérôme Conan</author>
<category>Misc</category>
<defaultLanguage>all</defaultLanguage>
<description>The Twitter gadget will make Tux Droid read your tweets from your Twitter account.</description>
@@ -8,9 +8,9 @@
<name>Twitter</name>
<onDemandIsAble>true</onDemandIsAble>
<platform>all</platform>
- <ttsName>Twitter.</ttsName>
- <uuid>33b14aea-907e-9d9d-7e64-c40c3bbf56fb</uuid>
- <version>2.1</version>
+ <ttsName>Twitter</ttsName>
+ <uuid>6d380a3d-b03a-88db-e6da-7cc1d6c7af6f</uuid>
+ <version>4.1</version>
</description>
<parameters>
<param_00>
@@ -39,15 +39,20 @@
<visible>false</visible>
</param_04>
<param_05>
+ <defaultValue>false</defaultValue>
+ <name>readTweets</name>
+ <visible>true</visible>
+ </param_05>
+ <param_06>
<defaultValue>_secret_</defaultValue>
<name>password</name>
<visible>true</visible>
- </param_05>
- <param_06>
+ </param_06>
+ <param_07>
<defaultValue>false</defaultValue>
<name>updateStatus</name>
<visible>false</visible>
- </param_06>
+ </param_07>
</parameters>
<parentPlugin>
<url>http://ftp.kysoh.com/</url>
Modified: software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/nl.wiki
===================================================================
--- software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/nl.wiki 2009-12-09 17:28:04 UTC (rev 5966)
+++ software_suite_v3/software/gadget/default/trunk/gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb/nl.wiki 2009-12-10 12:18:28 UTC (rev 5967)
@@ -5,7 +5,8 @@
* '''Gadget naam :''' Hier kan je de naam van de gadget wijzigen.
* '''Gebruikersnaam :''' Geef je login in van je Twitter account.
* '''Wachtwoord :''' Geef je wachtwoord in van je Twitter account.
-* '''Check nieuwe Tweets :''' Zal Tux Droid nieuwe Tweets laten lezen van je vrienden.
+* '''Lees Tweet inhoud :''' Tux Droid zal de inhoud van je Tweets lezen.
+* '''Check nieuwe Tweets :''' Tux Droid zal checken voor nieuwe Tweets van je vrienden.
* '''Plaats deze gadget in mijn Favorieten :''' Om de gadget met de afstandsbediening of via Tux Droid te starten.
= Alarmen =
|
|
From: jerome <c2m...@c2...> - 2009-12-09 17:28:17
|
Author: jerome
Date: 2009-12-09 18:28:04 +0100 (Wed, 09 Dec 2009)
New Revision: 5966
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
Log:
* Added on plugin event.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-09 14:37:28 UTC (rev 5965)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-09 17:28:04 UTC (rev 5966)
@@ -47,7 +47,6 @@
'''
Skype plugin configuration.
'''
-
throwEmoticons = True
@@ -118,11 +117,30 @@
'''
self.initializeCommandsClient()
- #Create Tux Droid api and repare events.
-
#Run main loop.
+ thread = threading.Thread(target=self.mainloop)
+ thread.start()
+ def incomingPluginEvent(self, eventName, eventValues):
+ '''
+ Tux Droid plugin event callback.
+ '''
+ try:
+ #Check for IPN client started.
+ if not self.client.start():
+ return
+ #Accept call
+ if eventName == 'head':
+ self.client.notify('accept_call')
+ #Reject Call
+ elif eventName in ['left', 'right']:
+ self.client.notify('reject_call')
+ finally:
+ #Quit plugin
+
+
+
##----------------------------------------------------------------
## * PLUGIN COMMAND : Set Tux Droid for an incoming call.
##----------------------------------------------------------------
@@ -319,6 +337,9 @@
+ ##----------------------------------------------------------------
+ ## * Tux Droid plugin events.
+ ##----------------------------------------------------------------
def onPluginStop(self):
'''
OnPluginStop event.
@@ -329,6 +350,20 @@
else:
#In other cases, close connection but not skype client.
self.connectorObj.stop()
+
+
+
+ def onPluginEvent(self, eventName, eventValues):
+ '''
+ Callback on plugin event.
+ @param eventName: Event name.
+ @param eventValues: Event values.
+ '''
+ #Start the adequate function for each plugin command.
+ if self.getCommand() == 'incomingCall':
+ self.incomingPluginEvent(eventName, eventValues)
+ else:
+ pass
##----------------------------------------------------------------
|
|
From: jerome <c2m...@c2...> - 2009-12-09 14:37:47
|
Author: jerome
Date: 2009-12-09 15:37:28 +0100 (Wed, 09 Dec 2009)
New Revision: 5965
Modified:
software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java
Log:
* Added a protection in case of empty messages / replies / updates list.
Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java
===================================================================
--- software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java 2009-12-09 13:00:01 UTC (rev 5964)
+++ software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java 2009-12-09 14:37:28 UTC (rev 5965)
@@ -343,7 +343,7 @@
throwMessage(pickSentence(newMultipleTweetSentences), String.valueOf(updateCount));
}
- else if(this.configuration().getReadTweets())
+ else if(this.configuration().getReadTweets() && updateCount > 0)
{
throwRes();
int i = 0;
@@ -394,16 +394,19 @@
else
{
//Readong tweet content.
- this.throwRes();
-
- int i = 0;
- while( i != this.privateMessages.size())
- {
- Hashtable<String, String> hash = this.privateMessages.get( i );
- throwMessage("Message from {0}, {1}", hash.get("name"), hash.get("value"));
- i++;
- }
- this.privateMessages.clear();
+ if (msCount > 0)
+ {
+ this.throwRes();
+
+ int i = 0;
+ while( i != this.privateMessages.size())
+ {
+ Hashtable<String, String> hash = this.privateMessages.get( i );
+ throwMessage("Message from {0}, {1}", hash.get("name"), hash.get("value"));
+ i++;
+ }
+ this.privateMessages.clear();
+ }
}
}
}
@@ -437,16 +440,19 @@
else
{
//Reading tweet content.
- this.throwRes();
-
- int i = 0;
- while( i != this.publicMessages.size())
- {
- Hashtable<String, String> hash = this.publicMessages.get( i );
- throwMessage("Reply from {0}, {1}", hash.get("name"), hash.get("value"));
- i++;
- }
- this.publicMessages.clear();
+ if (rpCount > 0)
+ {
+ this.throwRes();
+
+ int i = 0;
+ while( i != this.publicMessages.size())
+ {
+ Hashtable<String, String> hash = this.publicMessages.get( i );
+ throwMessage("Reply from {0}, {1}", hash.get("name"), hash.get("value"));
+ i++;
+ }
+ this.publicMessages.clear();
+ }
}
}
}
|
|
From: jerome <c2m...@c2...> - 2009-12-09 13:00:15
|
Author: jerome
Date: 2009-12-09 14:00:01 +0100 (Wed, 09 Dec 2009)
New Revision: 5964
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py
Log:
* Added some functionalities
* Removed 'self' keyword for two static methods
* Start to implement IPN service.
* Added different commands.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-09 11:56:53 UTC (rev 5963)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/plugin-skype.py 2009-12-09 13:00:01 UTC (rev 5964)
@@ -35,8 +35,11 @@
import connector
from communicator import SynchroniousCommands, AsynchroniousCommands
from errors import EquipmentException, UnavailableContactException, UserNotFindException
-from utils import StringUtils
+from utils import StringUtils, TuxDroidServerUtils
+from IPN.IPNServer import IPNServer
+from IPN.IPNClient import IPNClient
+
from util.SimplePlugin.SimplePluginConfiguration import SimplePluginConfiguration
from util.SimplePlugin.SimplePlugin import SimplePlugin
@@ -75,28 +78,96 @@
'''
Skype plugin base class.
'''
-
+ #plugin uuid
+ uuid = "8349ed52-572d-4c3f-a7b8-f6d4a5ae2c0"
+ port = 270
#Skype client - api objects.
synchronious = None
asynchronious = None
connectorObj = None
+ ##----------------------------------------------------------------
+ ## * Skype plugin main entry point.
+ ##----------------------------------------------------------------
def start(self):
'''
Plugin entry point.
This method should be used to dispatch commands.
'''
+ #Init port.
+ self.port = TuxDroidServerUtils.getServerPort()
+
+ #Check for the command.
if self.getCommand() == "runDaemon":
self.runDaemon()
+ elif self.getCommand() == "incomingCall":
+ self.incomingCall()
+ elif self.getCommand() == "outgoingCall":
+ self.outgoingCall()
+ elif self.getCommand() == "endCall":
+ self.endCall()
else:
self.runDaemon()
+ ##----------------------------------------------------------------
+ ## * PLUGIN COMMAND : Set Tux Droid for an incoming call.
+ ##----------------------------------------------------------------
+ def incomingCall(self):
+ '''
+ Initialize Tux Droid switches for a call ( incoming or outgoing )
+ '''
+ self.initializeCommandsClient()
+
+ #Create Tux Droid api and repare events.
+
+ #Run main loop.
+ ##----------------------------------------------------------------
+ ## * PLUGIN COMMAND : Set Tux Droid for an incoming call.
+ ##----------------------------------------------------------------
+ def outgoingCall(self):
+ '''
+ Initialize Tux Droid for an outgoing call.
+ '''
+ self.initializeCommandsClient()
+
+
+ ##----------------------------------------------------------------
+ ## * PLUGIN COMMAND : Finish an incoming / outgoing call
+ ##----------------------------------------------------------------
+ def endCall(self):
+ '''
+ End an incoming or outgoing call.
+ '''
+ self.client.notify('finish_call')
+
+
+ def initializeCommandsClient(self):
+ '''
+ Initialize the commands sender ( client / server ).
+ '''
+ self.client = IPNClient('127.0.0.1', 48536)
+ self.client.registerOnNotificationCallBack(self.ClientOnNotification)
+ self.client.registerOnConnectedCallBack(self.ClientOnConnected)
+ self.client.registerOnDisconnectedCallBack(self.ClientOnDisconnected)
+ self.client.start()
+
+ ##----------------------------------------------------------------
+ ## * DAEMON command and functions.
+ ##----------------------------------------------------------------
+
def runDaemon(self):
'''
Run plugin command.
'''
+ #Creating and starting server.
+ self.serv = IPNServer('127.0.0.1', 48536)
+ self.serv.registerOnClientAddedCallBack(self.ServerOnClientAdded)
+ self.serv.registerOnClientRemovedCallBack(self.ServerOnClientRemoved)
+ self.serv.registerOnClientNotificationCallBack(self.ServerOnClientNotification)
+ self.serv.start()
+
#Initialize skype client and api objects.
self.connectorObj = connector.Connector()
self.connectorObj.OnAPIReady = self.initializeDaemon
@@ -142,7 +213,7 @@
Incomming call refused because a call is already in progress
'''
#Sending a message to the call partner.
- message = "Sorry, I'm already in call, please try again later"
+ message = "I am currently in a conversation, please call me back later"
self.synchronious.sendTextMessage(contactHandle, message)
@@ -160,8 +231,17 @@
def OnIncomingCall(self, contactHandle):
'''
+ Incoming call event.
'''
- pass
+ #Set up Tux Droid motors.
+ self.throwActuation("upFlippers")
+ self.throwActuation("openMouth")
+
+ #Starting the plugin with 'incomingCall' command.
+ command = 'incomingCall'
+ request = '/plugins_server/start_plugin?command='+ command + '&uuid='+ self.uuid +'¶meters='
+
+ TuxDroidServerUtils.sendRequest("127.0.0.1", self.port, request)
def OnIncomingFinished(self, contactHandle):
@@ -229,6 +309,8 @@
time.sleep(2.0)
#Setting Tux Droid as audio peripheral.
try:
+ #Starting server that will listen to requests.
+ self.serv.start()
#in try statement to take calls in care.
if ( self.synchronious != None ) and ( not self.synchronious.isTuxDroidAudioCard() ):
self.synchronious.setAudioCards()
@@ -241,10 +323,53 @@
'''
OnPluginStop event.
'''
- self.connectorObj.stop()
+ if self.connectorObj != None:
+ if self.getCommand() == 'outgoingCall':
+ self.connectorObj.stop(KillClient=True)
+ else:
+ #In other cases, close connection but not skype client.
+ self.connectorObj.stop()
+
+ ##----------------------------------------------------------------
+ ## * DAEMON Client / Server IPN Communication.
+ ##----------------------------------------------------------------
+ def ServerOnClientAdded(self, idClient):
+ '''
+ '''
+ pass
+
+
+ def ServerOnClientRemoved(self, idClient):
+ '''
+ '''
+ pass
+
+
+ def ServerOnClientNotification(self, idClient, Message):
+ '''
+ '''
+ pass
+
+
+ def ClientOnNotification(self, Message):
+ '''
+ '''
+ pass
+
+
+ def ClientOnConnected(self, id):
+ '''
+ '''
+ pass
+
+
+ def ClientOnDisconnected(self):
+ '''
+ '''
+ pass
+
-
if __name__ == "__main__":
plugin = SkypePlugin()
plugin.boot(sys.argv[1:], SkypePluginConfiguration())
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py 2009-12-09 11:56:53 UTC (rev 5963)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py 2009-12-09 13:00:01 UTC (rev 5964)
@@ -347,7 +347,7 @@
Provide Tux Droid server utils functions.
'''
- def getServerPort(self):
+ def getServerPort():
'''
Return the current server port.
'''
@@ -360,7 +360,7 @@
return 54321
- def sendRequest(self, host, port, request):
+ def sendRequest(host, port, request):
'''
Send a request to tuxhttpserver.
'''
|
|
From: jerome <c2m...@c2...> - 2009-12-09 11:57:07
|
Author: jerome
Date: 2009-12-09 12:56:53 +0100 (Wed, 09 Dec 2009)
New Revision: 5963
Modified:
software_suite_v3/software/plugin/plugin-twitter/trunk/pom.xml
software_suite_v3/software/plugin/plugin-twitter/trunk/resources/plugin.xml
Log:
* Fixed a funny version number ...
Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/pom.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-twitter/trunk/pom.xml 2009-12-09 11:50:48 UTC (rev 5962)
+++ software_suite_v3/software/plugin/plugin-twitter/trunk/pom.xml 2009-12-09 11:56:53 UTC (rev 5963)
@@ -4,7 +4,7 @@
<groupId>com.kysoh</groupId>
<artifactId>plugin-twitter</artifactId>
<packaging>jar</packaging>
- <version>5.0</version>
+ <version>4.1</version>
<name>Twitter plugin for Tux Droid</name>
<url>http://www.tuxisalive.com</url>
Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-twitter/trunk/resources/plugin.xml 2009-12-09 11:50:48 UTC (rev 5962)
+++ software_suite_v3/software/plugin/plugin-twitter/trunk/resources/plugin.xml 2009-12-09 11:56:53 UTC (rev 5963)
@@ -9,7 +9,7 @@
<ttsName>Twitter</ttsName>
<description>The Twitter plugin will make Tux Droid check your Twitter account.</description>
<author>Jérôme Conan</author>
- <version>4.0</version>
+ <version>4.1</version>
<iconFile>resources/plugin.png</iconFile>
<executionMode>command</executionMode>
<uuid>623afa3f-7ae3-43f9-b89b-bc5a8185b0cf</uuid>
|
|
From: jerome <c2m...@c2...> - 2009-12-09 11:51:02
|
Author: jerome
Date: 2009-12-09 12:50:48 +0100 (Wed, 09 Dec 2009)
New Revision: 5962
Modified:
software_suite_v3/software/plugin/plugin-twitter/trunk/resources/de.po
software_suite_v3/software/plugin/plugin-twitter/trunk/resources/en.po
software_suite_v3/software/plugin/plugin-twitter/trunk/resources/nl.po
Log:
* Updated po files.
Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/resources/de.po
===================================================================
--- software_suite_v3/software/plugin/plugin-twitter/trunk/resources/de.po 2009-12-09 11:46:45 UTC (rev 5961)
+++ software_suite_v3/software/plugin/plugin-twitter/trunk/resources/de.po 2009-12-09 11:50:48 UTC (rev 5962)
@@ -140,25 +140,25 @@
msgstr "Keine Verbindung mit Ihrem Twitter möglich. Prüfen Sie die richtige Eingabe von Login und Kennwort."
msgid "Message from {0}, {1}"
-msgstr ""
+msgstr "Sie haben eine Nachricht von {0}, {1}"
msgid "Reply from {0}, {1}"
-msgstr ""
+msgstr "Sie haben eine Antwort von {0}, {1}"
msgid "Status update from {0}, {1}"
-msgstr ""
+msgstr "Sie haben eine Freund Aktualisierung von {0}, {1}"
msgid "Read Tweets content"
-msgstr ""
+msgstr "Tweets lesen"
msgid "You have a new message"
-msgstr ""
+msgstr "Sie haben eine neue Nachricht"
msgid "You have {0} messages"
-msgstr ""
+msgstr "Sie haben {0} Nachrichten"
msgid "You have a new reply"
-msgstr ""
+msgstr "Sie haben eine neue Antwort"
msgid "You have {0} new replies"
-msgstr ""
+msgstr "Sie haben {0} neue Antworten"
Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/resources/en.po
===================================================================
--- software_suite_v3/software/plugin/plugin-twitter/trunk/resources/en.po 2009-12-09 11:46:45 UTC (rev 5961)
+++ software_suite_v3/software/plugin/plugin-twitter/trunk/resources/en.po 2009-12-09 11:50:48 UTC (rev 5962)
@@ -149,7 +149,7 @@
msgstr "Status update from {0}, {1}"
msgid "Read Tweets content"
-msgstr "Read Tweets content"
+msgstr "Read Tweet content"
msgid "You have a new message"
msgstr "You have a new message"
Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/resources/nl.po
===================================================================
--- software_suite_v3/software/plugin/plugin-twitter/trunk/resources/nl.po 2009-12-09 11:46:45 UTC (rev 5961)
+++ software_suite_v3/software/plugin/plugin-twitter/trunk/resources/nl.po 2009-12-09 11:50:48 UTC (rev 5962)
@@ -140,25 +140,25 @@
msgstr "Ik kan geen verbinding maken met je Twitter. Controleer of je de correcte log-in en wacht woord hebt ingegeven."
msgid "Message from {0}, {1}"
-msgstr ""
+msgstr "Je hebt een bericht van {0}, {1}"
msgid "Reply from {0}, {1}"
-msgstr ""
+msgstr "Je hebt een antwoord van {0}, {1}"
msgid "Status update from {0}, {1}"
-msgstr ""
+msgstr "Je hebt een status update van {0}, {1}"
msgid "Read Tweets content"
-msgstr ""
+msgstr "Lees Tweet inhoud"
msgid "You have a new message"
-msgstr ""
+msgstr "Je hebt een nieuw bericht"
msgid "You have {0} messages"
-msgstr ""
+msgstr "Je hebt {0} berichten"
msgid "You have a new reply"
-msgstr ""
+msgstr "Je hebt een nieuw antwoord"
msgid "You have {0} new replies"
-msgstr ""
+msgstr "Je hebt {0} nieuwe antwoorden"
|
|
From: jerome <c2m...@c2...> - 2009-12-09 11:46:59
|
Author: jerome
Date: 2009-12-09 12:46:45 +0100 (Wed, 09 Dec 2009)
New Revision: 5961
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py
Log:
* Added server utils functions.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py 2009-12-09 11:45:45 UTC (rev 5960)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/utils.py 2009-12-09 11:46:45 UTC (rev 5961)
@@ -338,4 +338,54 @@
toPrettyString = staticmethod(toPrettyString)
- phoneNumberToTTS = staticmethod(phoneNumberToTTS)
+ phoneNumberToTTS = staticmethod(phoneNumberToTTS)
+
+
+
+class TuxDroidServerUtils(object):
+ '''
+ Provide Tux Droid server utils functions.
+ '''
+
+ def getServerPort(self):
+ '''
+ Return the current server port.
+ '''
+ if os.name == "nt":
+ return 270
+ else:
+ if os.geteuid() == 0:
+ return 270
+ else:
+ return 54321
+
+
+ def sendRequest(self, host, port, request):
+ '''
+ Send a request to tuxhttpserver.
+ '''
+ import socket
+ import httplib
+
+ old_timeout = socket.getdefaulttimeout()
+ socket.setdefaulttimeout(2.)
+ hp = "%s:%d" % (host, port)
+ h = httplib.HTTP(hp)
+ try:
+ h.connect()
+ except:
+ socket.setdefaulttimeout(old_timeout)
+ return 1
+ h.putrequest("GET", request)
+ h.endheaders()
+ errcode, errmsg, headers = h.getreply()
+ if errcode != 200:
+ socket.setdefaulttimeout(old_timeout)
+ return 1
+ else:
+ socket.setdefaulttimeout(old_timeout)
+ return 0
+
+
+ getServerPort = staticmethod(getServerPort)
+ sendRequest = staticmethod(sendRequest)
|
|
From: jerome <c2m...@c2...> - 2009-12-09 11:45:59
|
Author: jerome
Date: 2009-12-09 12:45:45 +0100 (Wed, 09 Dec 2009)
New Revision: 5960
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
Log:
* Updated commands.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-09 11:15:05 UTC (rev 5959)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-09 11:45:45 UTC (rev 5960)
@@ -16,21 +16,29 @@
<parameters>
</parameters>
<commands>
- <command
+ <command
+ name="incomingCall"
+ description="Start Skype incoming call"/>
+ <command
name="runDaemon"
description="Start Skype notifier"
daemon="true"
notifier="true"
expiration="1" />
<command
- name="incomingCall"
- description="Start Skype incoming call"/>
- <command
name="outgoingCall"
- description="Start Skype outgoing call"/>
+ description="Start Skype outgoing call"
+ daemon="true"
+ exclusive="true"
+ critical="true"
+ allUserButtons="true"/>
<command
name="endCall"
- description="Start Skype end call"/>
+ description="Start Skype end call"
+ daemon="true"
+ exclusive="true"
+ critical="true"
+ allUserButtons="true"/>
</commands>
<tasks>
<task
|
|
From: jerome <c2m...@c2...> - 2009-12-09 11:15:25
|
Author: jerome
Date: 2009-12-09 12:15:05 +0100 (Wed, 09 Dec 2009)
New Revision: 5959
Modified:
software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
Log:
* Updated available plugin commands.
Modified: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-08 15:05:44 UTC (rev 5958)
+++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/resources/plugin.xml 2009-12-09 11:15:05 UTC (rev 5959)
@@ -22,6 +22,15 @@
daemon="true"
notifier="true"
expiration="1" />
+ <command
+ name="incomingCall"
+ description="Start Skype incoming call"/>
+ <command
+ name="outgoingCall"
+ description="Start Skype outgoing call"/>
+ <command
+ name="endCall"
+ description="Start Skype end call"/>
</commands>
<tasks>
<task
|
|
From: jerome <c2m...@c2...> - 2009-12-08 15:05:56
|
Author: jerome Date: 2009-12-08 16:05:44 +0100 (Tue, 08 Dec 2009) New Revision: 5958 Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNClient.py software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNServer.py software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNSimpleTest.py software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNStressTest.py software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/__init__.py software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/version.py Log: * Added IPN package. Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNClient.py =================================================================== --- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNClient.py (rev 0) +++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNClient.py 2009-12-08 15:05:44 UTC (rev 5958) @@ -0,0 +1,354 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyright (C) 2009 Kysoh Sa +# Remi Jocaille <rem...@ky...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +import socket +import threading +import time + +# ============================================================================== +# Public class +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Interprocess Notifier Client Class. +# ------------------------------------------------------------------------------ +class IPNClient(object): + """Interprocess Notifier Client Class. + """ + + # -------------------------------------------------------------------------- + # Constructor. + # -------------------------------------------------------------------------- + def __init__(self, host = '127.0.0.1', port = 271): + """Constructor. + @param host: Host address of the server. + @param port: Host port of the server. + """ + self.__host = host + self.__port = port + self.__socket = None + self.__run = False + self.__runThread = None + self.__runMutex = threading.Lock() + self.__onNotification = None + self.__onConnected = None + self.__onDisconnected = None + self.__notifyThreadsList = [] + self.__ntlMutex = threading.Lock() + self.__id = "0" + self.__msgStack = IPNClientStack() + + # -------------------------------------------------------------------------- + # Get the indentifier of the client. + # -------------------------------------------------------------------------- + def getId(self): + """Get the indentifier of the client. + @return: The identifier if connected ortherwise '0' as string. + """ + return self.__id + + # -------------------------------------------------------------------------- + # Register a callback function to the "On notification" event. + # -------------------------------------------------------------------------- + def registerOnNotificationCallBack(self, funct): + """Register a callback function to the "On notification" event. + @param funct: Function pointer. The function must accept one parameter. + Example : + def onNotification(message): + print message + """ + self.__onNotification = funct + + # -------------------------------------------------------------------------- + # Register a callback function to the "On connected" event. + # -------------------------------------------------------------------------- + def registerOnConnectedCallBack(self, funct): + """Register a callback function to the "On connected" event. + @param funct: Function pointer. The function must accept one parameter. + Example : + def onConnected(identifier): + print "Client connected with identifier :", identifier + """ + self.__onConnected = funct + + # -------------------------------------------------------------------------- + # + # -------------------------------------------------------------------------- + def registerOnDisconnectedCallBack(self, funct): + """Register a callback function to the "On disconnected" event. + @param funct: Function pointer. + Example : + def onDisconnected(): + print "Client disconnected" + """ + self.__onDisconnected = funct + + # -------------------------------------------------------------------------- + # Start the client. + # -------------------------------------------------------------------------- + def start(self): + """Start the client. + @return: The success of the client start. + """ + # Exit the function if the client is already started + if self.__getRun(): + return True + # Create the client socket + self.__socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + # Set the socket to blocking mode before to connect it to the server + self.__socket.setblocking(1) + try: + # Connect the client to the server + self.__socket.connect((self.__host, self.__port)) + # Read my client identifier + self.__id = self.__socket.recv(128).split('\n')[0] + except socket.timeout: + self.__setRun(False) + self.__socket.setblocking(0) + # Failed to connect the client to the server + return False + except socket.error: + self.__setRun(False) + self.__socket.setblocking(0) + # Failed to connect the client to the server + return False + # Set the socket to unblocking mode + self.__socket.setblocking(0) + # Set the socket timeout to 100 msec + self.__socket.settimeout(0.1) + # Call the "On connected" event + if self.__onConnected != None: + self.__onConnected(self.__id) + # Start the message listening loop + self.__runThread = threading.Thread(target = self.__runLoop) + self.__runThread.start() + time.sleep(0.1) + # The client is successfuly connected to the server + return True + + # -------------------------------------------------------------------------- + # Stop the client. + # -------------------------------------------------------------------------- + def stop(self): + """Stop the client. + """ + # Exit the function is the client is not started + if not self.__getRun(): + return + # Stop the message listening loop + self.__setRun(False) + # Ensure that the thread of the message listening loop has been closed + if self.__runThread.isAlive(): + if not self.__runThread.join(5.0): + self.__runThread._Thread__stop() + # Ensure that the notifications thread has been closed. + self.__stopNotifyThreadList() + + # -------------------------------------------------------------------------- + # Notify a message to the server. + # -------------------------------------------------------------------------- + def notify(self, message): + """Notify a message to the server. + """ + # Exit the function is the client is not started + if not self.__getRun(): + return + # Regularize the message length (0 > correct size < 124) + if len(message) > 123: + message = message[:122] + self.__msgStack.push(message) + + # -------------------------------------------------------------------------- + # Add thread in the threaded messages list. + # -------------------------------------------------------------------------- + def __addNotifyThread(self, thread): + """Add thread in the threaded messages list. + @param thread: Thread to be added. + """ + self.__ntlMutex.acquire() + self.__notifyThreadsList.append(thread) + self.__ntlMutex.release() + + # -------------------------------------------------------------------------- + # Wait that the client has stopped. + # -------------------------------------------------------------------------- + def waitStop(self): + """Wait that the client has stopped. + """ + while self.__getRun(): + time.sleep(0.5) + time.sleep(0.5) + + # -------------------------------------------------------------------------- + # Clean the closed thread from the threaded messages list. + # -------------------------------------------------------------------------- + def __cleanNotifyThreadList(self): + """Clean the closed thread from the threaded messages list in order to + avoiding a memory leak issue. + """ + self.__ntlMutex.acquire() + newLst = [] + for t in self.__notifyThreadsList: + if t.isAlive(): + newLst.append(t) + self.__notifyThreadsList = newLst + self.__ntlMutex.release() + + # -------------------------------------------------------------------------- + # Stop all threads from the threaded messages list. + # -------------------------------------------------------------------------- + def __stopNotifyThreadList(self): + """Stop all threads from the threaded messages list. + """ + self.__ntlMutex.acquire() + for t in self.__notifyThreadsList: + if t.isAlive(): + # Wait for a hypothetical self closing of the thread + if not t.join(0.1): + # Otherwise, kill it + t._Thread__stop() + self.__ntlMutex.release() + + # -------------------------------------------------------------------------- + # Get the connection state of the client. + # -------------------------------------------------------------------------- + def __getRun(self): + """Get the connection state of the client. + @return: True or False. + """ + self.__runMutex.acquire() + result = self.__run + self.__runMutex.release() + return result + + # -------------------------------------------------------------------------- + # Set the connection state of the client. + # -------------------------------------------------------------------------- + def __setRun(self, value = True): + """Set the connection state of the client. + @param value: New value (True or False) + """ + self.__runMutex.acquire() + self.__run = value + self.__runMutex.release() + + # -------------------------------------------------------------------------- + # Loop listening message. + # -------------------------------------------------------------------------- + def __runLoop(self): + """Loop listening message. + """ + self.__setRun(True) + while self.__getRun(): + # Remove the closed threads from the threads list (garbage cleaning) + self.__cleanNotifyThreadList() + try: + # Wait a message from the server. (timeout at 100msec, defined + # in the function "start()") + data = self.__socket.recv(128) + # Extract the message from the frame + data = data.split('\n')[0] + # If the message is valid + if len(data) != 0: + # It's a PING + if data == "PING": + # Responding to the server + self.__socket.send("PONG") + time.sleep(0.01) + continue + # It's a notification request message + elif data == "GETNOTIFICATION": + # Responding to the server + message = self.__msgStack.pop() + if message == None: + self.__socket.send("PONG") + else: + self.__socket.send("RET:%s" % message) + time.sleep(0.01) + continue + # It's a notification message + else: + if self.__onNotification != None: + # Call the "On notification" event through a thread + # Store the thread in the threads list in order to + # stop all threads at the client closure + t = threading.Thread(target = self.__onNotification, + args = (data,)) + self.__addNotifyThread(t) + t.start() + time.sleep(0.01) + continue + except socket.timeout: + time.sleep(0.01) + # No message from the server ... + continue + except socket.error: + time.sleep(0.01) + # Server connection was broken, exit the loop ! + break + except: + time.sleep(0.01) + # Unexpected error, should never happen ... + continue + # The client must be disconnected + try: + self.__socket.close() + except: + pass + # Call the "On disconnected" event and reset the client identifier + if self.__id != "0": + if self.__onDisconnected != None: + self.__onDisconnected() + self.__id = "0" + +# ------------------------------------------------------------------------------ +# Interprocess Notifier Client Stack Class. +# ------------------------------------------------------------------------------ +class IPNClientStack(object): + """Interprocess Notifier Client Stack Class. + """ + + # -------------------------------------------------------------------------- + # Constructor. + # -------------------------------------------------------------------------- + def __init__(self): + """Constructor. + """ + self.__stack = [] + self.__mutex = threading.Lock() + + # -------------------------------------------------------------------------- + # Push a message to the stack. + # -------------------------------------------------------------------------- + def push(self, message): + """Push a message to the stack. + @param message: Message to push. + """ + self.__mutex.acquire() + self.__stack.insert(len(self.__stack), message) + self.__mutex.release() + + # -------------------------------------------------------------------------- + # Pop a message from the stack. + # -------------------------------------------------------------------------- + def pop(self): + """Pop a message from the stack. + @return: A message or None. + """ + result = None + self.__mutex.acquire() + if len(self.__stack) > 0: + result = self.__stack.pop(0) + self.__mutex.release() + return result Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNServer.py =================================================================== --- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNServer.py (rev 0) +++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNServer.py 2009-12-08 15:05:44 UTC (rev 5958) @@ -0,0 +1,475 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# Copyright (C) 2009 Kysoh Sa +# Remi Jocaille <rem...@ky...> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +import socket +import threading +import time + +try: + from hashlib import md5 +except: + from md5 import md5 + +#from tuxisalive.lib.logger import * + +# Formated PING command +_PING_CMD = "PING\n" + "".join(" " * 123) +# Formated GETNOTIFICATION command +_GETNOTIFICATION_CMD = "GETNOTIFICATION\n" + "".join(" " * 112) + +# ============================================================================== +# Public class +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Interprocess Notifier Server Class. +# ------------------------------------------------------------------------------ +class IPNServer(object): + """Interprocess Notifier Server Class. + """ + + # -------------------------------------------------------------------------- + # Constructor. + # -------------------------------------------------------------------------- + def __init__(self, host = '127.0.0.1', port = 271): + """Constructor. + @param host: Host IP to listen. + Example : '127.0.0.1' for local loop only. + Example : '192.168.0.1' for local network only. + Example : '' for internet access. + @param port: TCP port to listen. + """ + self.__cliLst = [] + self.__cliMutex = threading.Lock() + self.__socket = None + self.__host = host + self.__port = port + self.__runLst = False + self.__runLstThread = None + self.__runLstMutex = threading.Lock() + self.__runPing = False + self.__runPingThread = None + self.__runPingMutex = threading.Lock() + self.__notifyThreadsList = [] + self.__ntlMutex = threading.Lock() + self.__onClientAdded = None + self.__onClientRemoved = None + self.__onClientNotification = None + + # -------------------------------------------------------------------------- + # Register a callback function to the "On client added" event. + # -------------------------------------------------------------------------- + def registerOnClientAddedCallBack(self, funct): + """Register a callback function to the "On client added" event. + @param funct: Function pointer. The function must accept one parameter. + Example : + def onClientAdded(idClient): + print idClient + """ + self.__onClientAdded = funct + + # -------------------------------------------------------------------------- + # Register a callback function to the "On client removed" event. + # -------------------------------------------------------------------------- + def registerOnClientRemovedCallBack(self, funct): + """Register a callback function to the "On client removed" event. + @param funct: Function pointer. The function must accept one parameter. + Example : + def onClientRemoved(idClient): + print idClient + """ + self.__onClientRemoved = funct + + # -------------------------------------------------------------------------- + # Register a callback function to the "On client notification" event. + # -------------------------------------------------------------------------- + def registerOnClientNotificationCallBack(self, funct): + """Register a callback function to the "On client notification" event. + @param funct: Function pointer. The function must accept one parameter. + Example : + def onClientNotification(idClient, message): + print idClient + """ + self.__onClientNotification = funct + + # -------------------------------------------------------------------------- + # Check if a client exists. + # -------------------------------------------------------------------------- + def clientExists(self, id): + """Check if a client exists. + @param id: Id client. + @return: True or False. + """ + self.__cliMutex.acquire() + result = False + for cli in self.__cliLst: + if cli['id'] == id: + result = True + break + self.__cliMutex.release() + return result + + # -------------------------------------------------------------------------- + # Start the server. + # -------------------------------------------------------------------------- + def start(self): + """Start the server. + @return: The success of the server start. True or False. + """ + # Exit the function if the server is already started + if self.__getRunLst(): + return True + # Create the server socket + self.__socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + try: + # Bind the socket + self.__socket.bind((self.__host, self.__port)) + # Set the socket to listen mode + self.__socket.listen(50) + #Run the listen loop and the ping loop + self.__runLstThread = threading.Thread(target = self.__listenLoop) + self.__runLstThread.start() + self.__runPingThread = threading.Thread(target = self.__pingLoop) + self.__runPingThread.start() + time.sleep(0.1) + # Server successfuly started + return True + except socket.timeout: + self.__setRunLst(False) + # Failed to start the server + return False + except socket.error: + self.__setRunLst(False) + # Failed to start the server + return False + except: + self.__setRunLst(False) + # Failed to start the server + return False + + # -------------------------------------------------------------------------- + # Stop the server. + # -------------------------------------------------------------------------- + def stop(self): + """Stop the server. + """ + # If the server don't runs then exit the function + if not self.__getRunLst(): + return + # Stop the listen loop + self.__setRunLst(False) + # Stop the ping loop + self.__setRunPing(False) + # Close the server socket + self.__socket.close() + time.sleep(0.1) + # Ensure that the threads have been stopped + if self.__runLstThread.isAlive(): + self.__runLstThread._Thread__stop() + if self.__runPingThread.isAlive(): + self.__runPingThread.join() + self.__stopNotifyThreadList() + # Clear the clients list + self.__clearClients() + + # -------------------------------------------------------------------------- + # Wait that the server has stopped. + # -------------------------------------------------------------------------- + def waitStop(self): + """Wait that the server has stopped. + """ + while self.__getRunLst(): + time.sleep(0.5) + time.sleep(0.5) + + # -------------------------------------------------------------------------- + # Add thread in the threaded messages list. + # -------------------------------------------------------------------------- + def __addNotifyThread(self, thread): + """Add thread in the threaded messages list. + @param thread: Thread to be added. + """ + self.__ntlMutex.acquire() + self.__notifyThreadsList.append(thread) + self.__ntlMutex.release() + + # -------------------------------------------------------------------------- + # Clean the closed thread from the threaded messages list. + # -------------------------------------------------------------------------- + def __cleanNotifyThreadList(self): + """Clean the closed thread from the threaded messages list in order to + avoiding a memory leak issue. + """ + self.__ntlMutex.acquire() + newLst = [] + for t in self.__notifyThreadsList: + if t.isAlive(): + newLst.append(t) + self.__notifyThreadsList = newLst + self.__ntlMutex.release() + + # -------------------------------------------------------------------------- + # Stop all threads from the threaded messages list. + # -------------------------------------------------------------------------- + def __stopNotifyThreadList(self): + """Stop all threads from the threaded messages list. + """ + self.__ntlMutex.acquire() + for t in self.__notifyThreadsList: + if t.isAlive(): + # Wait for a hypothetical self closing of the thread + if not t.join(0.1): + # Otherwise, kill it + t._Thread__stop() + self.__ntlMutex.release() + + # -------------------------------------------------------------------------- + # Get the state of the listening loop. + # -------------------------------------------------------------------------- + def __getRunLst(self): + """Get the state of the listening loop. + @return: True or False. + """ + self.__runLstMutex.acquire() + result = self.__runLst + self.__runLstMutex.release() + return result + + # -------------------------------------------------------------------------- + # Set the state of the listening loop. + # -------------------------------------------------------------------------- + def __setRunLst(self, value = True): + """Set the state of the listening loop. + @param value: New value (True or False) + """ + self.__runLstMutex.acquire() + self.__runLst = value + self.__runLstMutex.release() + + # -------------------------------------------------------------------------- + # Get the state of the ping loop. + # -------------------------------------------------------------------------- + def __getRunPing(self): + """Get the state of the ping loop. + @return: True or False. + """ + self.__runPingMutex.acquire() + result = self.__runPing + self.__runPingMutex.release() + return result + + # -------------------------------------------------------------------------- + # Set the state of the ping loop. + # -------------------------------------------------------------------------- + def __setRunPing(self, value = True): + """Set the state of the ping loop. + @param value: New value (True or False) + """ + self.__runPingMutex.acquire() + self.__runPing = value + self.__runPingMutex.release() + + # -------------------------------------------------------------------------- + # Add a new client in the clients list. + # -------------------------------------------------------------------------- + def __addClient(self, connection, address): + """Add a new client in the clients list. + @param connection: Client socket. + @param address: Client address. + """ + self.__cliMutex.acquire() + # Create a md5 hash of the socket address in order to make an unique + # identifier for the client. + md5H = md5() + md5H.update(str(address[0]) + str(address[1])) + id = md5H.hexdigest() + # Create a dictionary for the client configuration + cliConf = { + 'connection' : connection, + 'address' : address, + 'id' : id, + } + # Add the client to the list + self.__cliLst.append(cliConf) + # Create a 128 bytes length string with the id client. + idToSend = id + "\n" + "".join(" " * (127 - len(id))) + try: + # Send the identifer to the client + connection.send(idToSend) + except: + pass + self.__cliMutex.release() + # Call the "On client added" event + if self.__onClientAdded != None: + self.__onClientAdded(id) + + # -------------------------------------------------------------------------- + # Remove a client from the clients list. + # -------------------------------------------------------------------------- + def __removeClient(self, address): + """Remove a client from the clients list. + @param address: Client address. + """ + self.__cliMutex.acquire() + removedId = None + # Search the client address in the registered clients + for cli in self.__cliLst: + if cli['address'] == address: + cli['connection'].close() + self.__cliLst.remove(cli) + removedId = cli['id'] + break + self.__cliMutex.release() + # If the client has been removed then call the "On client removed" event + if removedId != None: + if self.__onClientRemoved != None: + self.__onClientRemoved(removedId) + + # -------------------------------------------------------------------------- + # Clear the clients list. + # -------------------------------------------------------------------------- + def __clearClients(self): + """Clear the clients list. + """ + self.__cliMutex.acquire() + self.__cliLst = [] + self.__cliMutex.release() + + # -------------------------------------------------------------------------- + # Socket listening loop. + # -------------------------------------------------------------------------- + def __listenLoop(self): + """Socket listening loop. + """ + self.__setRunLst(True) + while self.__getRunLst(): + try: + # Wait for a new client connection. This function is blocking + # the loop. The parent loop must be killed. + connection, address = self.__socket.accept() + # If the client socket is valid then add it to the clients list + if (connection != None) and (address != None): + self.__addClient(connection, address) + except: + pass + + # -------------------------------------------------------------------------- + # Ping loop. + # -------------------------------------------------------------------------- + def __pingLoop(self): + """Ping loop. + """ + self.__setRunPing(True) + while self.__getRunPing(): + aClientHasRemoved = False + self.__cliMutex.acquire() + # Ping all clients + for cli in self.__cliLst: + try: + # Send the PING command + cli['connection'].send(_PING_CMD) + # Read the client response + data = cli['connection'].recv(128) + except: + self.__cliMutex.release() + # If an error occuring during the client ping then remove it + # from the clients list + self.__removeClient(cli['address']) + aClientHasRemoved = True + self.__cliMutex.acquire() + break + if data != "PONG": + self.__cliMutex.release() + # If the client response is invalid then remove it from the + # clients list + self.__removeClient(cli['address']) + aClientHasRemoved = True + self.__cliMutex.acquire() + break + self.__cliMutex.release() + if aClientHasRemoved: + continue + # Read clients notifications (20x). + for i in range(20): + if not self.__getRunPing(): + break + # Remove the closed threads from the threads list + # (garbage cleaning) + self.__cleanNotifyThreadList() + self.__cliMutex.acquire() + for cli in self.__cliLst: + try: + # Send the GETNOTIFICATION command + cli['connection'].send(_GETNOTIFICATION_CMD) + # Read the client response + data = cli['connection'].recv(128) + except: + self.__cliMutex.release() + # If an error occuring during the client ping then remove it + # from the clients list + self.__removeClient(cli['address']) + self.__cliMutex.acquire() + break + if data == "PONG": + pass + elif data.find("RET:") == 0: + if self.__onClientNotification != None: + self.__cliMutex.release() + t = threading.Thread(target = self.__onClientNotification, + args = (cli['id'], data[4:])) + self.__addNotifyThread(t) + t.start() + self.__cliMutex.acquire() + else: + self.__cliMutex.release() + # If the client response is invalid then remove it from the + # clients list + self.__removeClient(cli['address']) + self.__cliMutex.acquire() + break + + self.__cliMutex.release() + time.sleep(0.1) + + # -------------------------------------------------------------------------- + # Send a message to the connected clients. + # -------------------------------------------------------------------------- + def notify(self, message, idClient = None): + """Send a message to the connected clients. + @param message: Message to notify. The maximal size of a message is 127 + characters. + @param idClient: Id of the client to notify or None for all clients. + """ + # Regularize the message length (0 > correct size < 128) + if len(message) > 127: + message = message[:126] + if len(message) == 0: + message = "NOTIFY" + message = message + "\n" + "".join(" " * (127 - len(message))) + self.__cliMutex.acquire() + # Send the message to the clients + for cli in self.__cliLst: + try: + if idClient == None: + cli['connection'].send(message) + else: + if cli['id'] == idClient: + cli['connection'].send(message) + except: + # No special action if the client connection is broken, it will + # be removed by the "ping" loop + pass + # Can't sent another message while 100 msec + time.sleep(0.1) + self.__cliMutex.release() Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNSimpleTest.py =================================================================== --- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNSimpleTest.py (rev 0) +++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNSimpleTest.py 2009-12-08 15:05:44 UTC (rev 5958) @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# 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 + +import threading +import time + +from IPNServer import IPNServer +from IPNClient import IPNClient + +# ============================================================================== +# Server functions +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Callback function on "client added" event. +# ------------------------------------------------------------------------------ +def serverOnClientAdded(idClient): + print "[Server] New client :", idClient + +# ------------------------------------------------------------------------------ +# Callback function on "client removed" event. +# ------------------------------------------------------------------------------ +def serverOnClientRemoved(idClient): + print "[Server] Removed client :", idClient + +# ------------------------------------------------------------------------------ +# Callback function on "client notification" event. +# ------------------------------------------------------------------------------ +def serverOnClientNotification(idClient, message): + print "[Server] Client [%s] Notification (%s)" % (idClient, message) + +# ============================================================================== +# Client functions +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Callback function on "connected" event. +# ------------------------------------------------------------------------------ +def clientOnConnected(id): + print "[Client] Connected with id : ", id + +# ------------------------------------------------------------------------------ +# Callback function on "disconnected" event. +# ------------------------------------------------------------------------------ +def clientOnDisconnected(): + print "[Client] Disconnected" + +# ------------------------------------------------------------------------------ +# Callback function on "notification" event. +# ------------------------------------------------------------------------------ +def clientOnNotification(message): + print "[Client] Message from server :", message + +# ------------------------------------------------------------------------------ +# Test the IPN module. +# ------------------------------------------------------------------------------ +def test(): + """Test the IPN module. + """ + # Create an IPN server + serv = IPNServer('127.0.0.1', 48536) + serv.registerOnClientAddedCallBack(serverOnClientAdded) + serv.registerOnClientRemovedCallBack(serverOnClientRemoved) + serv.registerOnClientNotificationCallBack(serverOnClientNotification) + + # Create an IPN client + cli = IPNClient('127.0.0.1', 48536) + cli.registerOnNotificationCallBack(clientOnNotification) + cli.registerOnConnectedCallBack(clientOnConnected) + cli.registerOnDisconnectedCallBack(clientOnDisconnected) + + # Start the server in thread + if not serv.start(): + print "Error whil starting the server." + return + + # Start the client + if not cli.start(): + print "Error whil starting the client." + serv.stop() + return + + # Server send notification to client(s) + serv.notify("Hello world from Server") + cli.notify("How are you from client") + + # Finish + cli.stop() + serv.stop() + +# ------------------------------------------------------------------------------ +# Main +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + test() Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNStressTest.py =================================================================== --- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNStressTest.py (rev 0) +++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/IPNStressTest.py 2009-12-08 15:05:44 UTC (rev 5958) @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- + +import version +__author__ = version.author +__date__ = version.date +__version__ = version.version +__licence__ = version.licence +del version + +# 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 + +import threading +import time + +from IPNServer import IPNServer +from IPNClient import IPNClient + +# ============================================================================== +# Server functions +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Callback function on "client added" event. +# ------------------------------------------------------------------------------ +def serverOnClientAdded(idClient): + print "[Server] New client :", idClient + +# ------------------------------------------------------------------------------ +# Callback function on "client removed" event. +# ------------------------------------------------------------------------------ +def serverOnClientRemoved(idClient): + print "[Server] Removed client :", idClient + +# ------------------------------------------------------------------------------ +# Callback function on "client notification" event. +# ------------------------------------------------------------------------------ +def serverOnClientNotification(idClient, message): + print "[Server] Client [%s] Notification (%s)" % (idClient, message) + +# ------------------------------------------------------------------------------ +# Function to create a IPN server. +# ------------------------------------------------------------------------------ +def serverProcess(timeout = 100.0): + serv = IPNServer() + serv.registerOnClientAddedCallBack(serverOnClientAdded) + serv.registerOnClientRemovedCallBack(serverOnClientRemoved) + serv.registerOnClientNotificationCallBack(serverOnClientNotification) + if serv.start(): + for i in range(int(timeout / 0.1)): + serv.notify("Hello") + time.sleep(0.001) + serv.stop() + +# ============================================================================== +# Client functions +# ============================================================================== + +# ------------------------------------------------------------------------------ +# Callback function on "connected" event. +# ------------------------------------------------------------------------------ +def clientOnConnected(id): + print "[Client] Connected with id : ", id + +# ------------------------------------------------------------------------------ +# Callback function on "disconnected" event. +# ------------------------------------------------------------------------------ +def clientOnDisconnected(): + print "[Client] Disconnected" + +# ------------------------------------------------------------------------------ +# Callback function on "notification" event. +# ------------------------------------------------------------------------------ +def clientOnNotification(message): + print "[Client] Message :", message + +# ------------------------------------------------------------------------------ +# Create a IPN client. +# ------------------------------------------------------------------------------ +def clientProcess(timeout = 10.0): + cli = IPNClient() + #cli.registerOnNotificationCallBack(clientOnNotification) + cli.registerOnConnectedCallBack(clientOnConnected) + cli.registerOnDisconnectedCallBack(clientOnDisconnected) + if cli.start(): + cli.notify("Hello world") + time.sleep(timeout) + cli.stop() + else: + print "Client can't be connected" + +# ------------------------------------------------------------------------------ +# Test the IPN module. +# ------------------------------------------------------------------------------ +def test(): + """Test the IPN module. + """ + # Create a IPN server + t = threading.Thread(target = serverProcess, args = (15.0,)) + t.start() + # Create 50 IPN clients + for i in range(50): + t = threading.Thread(target = clientProcess, args = (5.0,)) + t.start() + time.sleep(0.02) + time.sleep(14.0) + +# ------------------------------------------------------------------------------ +# Main +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + test() Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/__init__.py =================================================================== Added: software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/version.py =================================================================== --- software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/version.py (rev 0) +++ software_suite_v3/software/plugin/plugin-skype/branches/in_out_plugin/executables/IPN/version.py 2009-12-08 15:05:44 UTC (rev 5958) @@ -0,0 +1,4 @@ +version = '1.0.0' +author = "Remi Jocaille (rem...@ky...)" +licence = "GPL" +date = "December 2009" |