diff inkscape/firefox/helper_mb.py @ 262:c39b24036a75

Add proxy daemon and extention for the firefox integration. We need to implement javascript web client to repalce the unite test program testsoap.py
author wycc@wycc-desktop
date Fri, 23 Jan 2009 23:15:04 +0800
parents
children 96aae15527c8
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inkscape/firefox/helper_mb.py	Fri Jan 23 23:15:04 2009 +0800
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+from twisted.web import server, resource,soap
+from twisted.internet import reactor,defer
+import os,time
+
+
+
+
+class Server(soap.SOAPPublisher):
+    	"""
+	    SOAP server for inkscape extension.
+	"""
+        def soap_PUBLISH(self):
+		if self.client == None:
+			os.kill(self.pid,12)
+			time.sleep(1)
+			self.client = Client()
+		d = defer.Deferred()
+		self.client.PUBLISH().addCallback(self.quit,d)
+		return d
+			
+	def quit(self,result,d):
+		print [result]
+		d.callback(result)
+		self.client = None
+	def soap_SCENE(self,n):
+		if self.client == None:
+			os.kill(self.pid,12)
+			time.sleep(1)
+			self.client = Client()
+
+		d = defer.Deferred()
+		self.client.SCENE(n).addCallback(self.generic_return,d)
+		return d
+	def generic_return(self,result,d):
+		print [result]
+		d.callback(result)
+	def soap_START(self):
+		if self.client == None:
+			os.kill(self.pid,12)
+			time.sleep(1)
+			self.client = Client()
+		return "OK"
+		
+
+
+
+class Client(object):
+	def __init__(self):
+		self.proxy = soap.Proxy('http://localhost:8080')	
+	def PUBLISH(self):
+		return self.proxy.callRemote('PUBLISH')
+	def SCENE(self,n):
+		return self.proxy.callRemote('SCENE',n)
+pid = os.fork()	
+if pid==0:
+	os.execvp("inkscape-mb",["inkscape-mb","scene.svg"])
+s = Server()
+s.client = None
+s.pid = pid
+site = server.Site(s)
+reactor.listenTCP(19192,site)
+reactor.run()
+		
+