From 49ca7e4cad1f98f521eeb4dd1bf2bf317b828dd6 Mon Sep 17 00:00:00 2001 From: Christophe Guiraud Date: Thu, 23 Aug 2012 13:59:31 +0200 Subject: [PATCH] Refactor source tree and add packaging --- .gitignore | 3 + AUTHORS | 2 + README | 16 ---- README.md | 25 ++++++ TODO | 6 -- cloudeebus/__init__.py | 19 +++++ cloudeebus/{server.py => cloudeebus.py} | 101 ++++++++++++----------- dbus-tools/autobahn.min.js | 75 ----------------- dbus-tools/dbus-register.html | 53 ------------ dbus-tools/dbus-register.js | 80 ------------------ dbus-tools/dbus-register.py | 127 ----------------------------- dbus-tools/dbus-send.html | 56 ------------- dbus-tools/dbus-send.js | 77 ------------------ dbus-tools/dbus-send.py | 139 -------------------------------- doc/dbus-tools/dbus-register.html | 129 +++++++++++++++++++++++++++++ doc/dbus-tools/dbus-send.html | 131 ++++++++++++++++++++++++++++++ doc/{ => sample}/cloudeebus.html | 1 - {doc => lib}/autobahn.min.js | 0 setup.py | 46 +++++++++++ 19 files changed, 405 insertions(+), 681 deletions(-) create mode 100644 .gitignore create mode 100644 AUTHORS delete mode 100644 README create mode 100644 README.md create mode 100644 cloudeebus/__init__.py rename cloudeebus/{server.py => cloudeebus.py} (75%) delete mode 100644 dbus-tools/autobahn.min.js delete mode 100644 dbus-tools/dbus-register.html delete mode 100644 dbus-tools/dbus-register.js delete mode 100644 dbus-tools/dbus-register.py delete mode 100644 dbus-tools/dbus-send.html delete mode 100644 dbus-tools/dbus-send.js delete mode 100644 dbus-tools/dbus-send.py create mode 100644 doc/dbus-tools/dbus-register.html create mode 100644 doc/dbus-tools/dbus-send.html rename doc/{ => sample}/cloudeebus.html (99%) rename {doc => lib}/autobahn.min.js (100%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4109c3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +build +dist diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..f48e975 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Luc Yriarte +Christophe Guiraud diff --git a/README b/README deleted file mode 100644 index 57e48e8..0000000 --- a/README +++ /dev/null @@ -1,16 +0,0 @@ -Abstract: ---------- - -Cloudeebus is a component which enables calling dbus methods and registering on dbus signals from Javascript. - - -Example: --------- - -The dbus-tools folder contains a dbus-send and a dbus-register server, with corresponding test pages. -Running a demo: - -python dbus-tools/dbus-send.py & -python dbus-tools/dbus-register.py & -firefox file://`pwd`/dbus-tools/dbus-send.html file://`pwd`/dbus-tools/dbus-register.html & - diff --git a/README.md b/README.md new file mode 100644 index 0000000..a352d39 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ + +Cloudeebus +========== + +Cloudeebus is a component which enables calling dbus methods and registering on dbus signals from Javascript. + + +Example: +-------- + +The /doc/dbus-tools folder contains a dbus-send and a dbus-register server, with corresponding test pages. + + * Running a demo: from the project root directory + + python cloudeebus/cloudeebus.py & + firefox file://`pwd`/doc/docdbus-tools/dbus-send.html file://`pwd`/doc/dbus-tools/dbus-register.html & + + +Acknowledgements +---------------- + +Cloudeebus uses code from the following open-source projects + + * [AutobahnJS](http://autobahn.ws/js) + * [AutobahnPython](http://autobahn.ws/python) diff --git a/TODO b/TODO index 2006ca5..4f8673e 100644 --- a/TODO +++ b/TODO @@ -24,9 +24,3 @@ Proxy object properties: - create properties at introspection if "org.freedesktop.DBus.Properties" interface available. - add "onPropertiesChanged(successCB)" method to automatically update properties. - -Source reorg: -------------- -- dbus-tools: html only (send / register) -- doc: sample page only, move autobahn to /lib -- server.py: rename cloudeebus.py diff --git a/cloudeebus/__init__.py b/cloudeebus/__init__.py new file mode 100644 index 0000000..6bafab5 --- /dev/null +++ b/cloudeebus/__init__.py @@ -0,0 +1,19 @@ +# Cloudeebus +# +# Copyright (C) 2012 Intel Corporation. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Luc Yriarte +# Christophe Guiraud +# diff --git a/cloudeebus/server.py b/cloudeebus/cloudeebus.py similarity index 75% rename from cloudeebus/server.py rename to cloudeebus/cloudeebus.py index 18a9f6b..201a19e 100644 --- a/cloudeebus/server.py +++ b/cloudeebus/cloudeebus.py @@ -1,12 +1,12 @@ ############################################################################### # Copyright 2012 Intel Corporation. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -97,89 +97,89 @@ class DbusCallHandler: class CloudeebusService: def __init__(self): # dbus connexions - self.dbusConnexions = {} + self.dbusConnexions = {} # proxy objects self.proxyObjects = {} # proxy methods self.proxyMethods = {} - # signal handlers - self.signalHandlers = {} + # signal handlers + self.signalHandlers = {} # pending dbus calls self.pendingCalls = [] def dbusConnexion(self, busName): - if not self.dbusConnexions.has_key(busName): - if busName == "session": - self.dbusConnexions[busName] = dbus.SessionBus() - elif busName == "system": - self.dbusConnexions[busName] = dbus.SystemBus() - else: - raise Exception("Error: invalid bus: %s" % busName) - return self.dbusConnexions[busName] + if not self.dbusConnexions.has_key(busName): + if busName == "session": + self.dbusConnexions[busName] = dbus.SessionBus() + elif busName == "system": + self.dbusConnexions[busName] = dbus.SystemBus() + else: + raise Exception("Error: invalid bus: %s" % busName) + return self.dbusConnexions[busName] def proxyObject(self, bus, serviceName, objectName): - id = hashId([serviceName, objectName]) - if not self.proxyObjects.has_key(id): - self.proxyObjects[id] = bus.get_object(serviceName, objectName) - return self.proxyObjects[id] + id = hashId([serviceName, objectName]) + if not self.proxyObjects.has_key(id): + self.proxyObjects[id] = bus.get_object(serviceName, objectName) + return self.proxyObjects[id] def proxyMethod(self, bus, serviceName, objectName, interfaceName, methodName): - id = hashId([serviceName, objectName, interfaceName, methodName]) - if not self.proxyMethods.has_key(id): - obj = self.proxyObject(bus, serviceName, objectName) - self.proxyMethods[id] = obj.get_dbus_method(methodName, interfaceName) - return self.proxyMethods[id] + id = hashId([serviceName, objectName, interfaceName, methodName]) + if not self.proxyMethods.has_key(id): + obj = self.proxyObject(bus, serviceName, objectName) + self.proxyMethods[id] = obj.get_dbus_method(methodName, interfaceName) + return self.proxyMethods[id] @exportRpc def dbusRegister(self, list): - # read arguments list by position + # read arguments list by position if len(list) < 5: - raise Exception("Error: expected arguments: bus, sender, object, interface, signal)") - - # check if a handler exists + raise Exception("Error: expected arguments: bus, sender, object, interface, signal)") + + # check if a handler exists sigId = hashId(list[1:5]) if self.signalHandlers.has_key(sigId): - return sigId - + return sigId + # get dbus connexion bus = self.dbusConnexion(list[0]) - + # get dbus proxy object = self.proxyObject(bus, list[1], list[2]) - + # create a handler that will publish the signal dbusSignalHandler = DbusSignalHandler(bus, object, *list[1:5]) self.signalHandlers[sigId] = dbusSignalHandler - + return dbusSignalHandler.id @exportRpc def dbusSend(self, list): - # clear pending calls - for call in self.pendingCalls: - if not call.pending: - self.pendingCalls.remove(call) - - # read arguments list by position + # clear pending calls + for call in self.pendingCalls: + if not call.pending: + self.pendingCalls.remove(call) + + # read arguments list by position if len(list) < 5: - raise Exception("Error: expected arguments: bus, destination, object, interface, message, [args])") - + raise Exception("Error: expected arguments: bus, destination, object, interface, message, [args])") + # get dbus connexion bus = self.dbusConnexion(list[0]) - + # parse JSON arg list args = [] if len(list) == 6: - args = json.loads(list[5]) - + args = json.loads(list[5]) + # get dbus proxy method = self.proxyMethod(bus, *list[1:5]) - + # use a deferred call handler to manage dbus results dbusCallHandler = DbusCallHandler(method, args) self.pendingCalls.append(dbusCallHandler) @@ -188,15 +188,15 @@ class CloudeebusService: @exportRpc def listNames(self, list): - # read arguments list by position - if len(list) < 1: - raise Exception("Error: expected arguments: bus)") - + # read arguments list by position + if len(list) < 1: + raise Exception("Error: expected arguments: bus)") + # get dbus connexion bus = self.dbusConnexion(list[0]) - + # return bus names as json array - return json.dumps(bus.list_names()) + return json.dumps(bus.list_names()) @@ -229,4 +229,3 @@ if __name__ == '__main__': DBusGMainLoop(set_as_default=True) reactor.run() - diff --git a/dbus-tools/autobahn.min.js b/dbus-tools/autobahn.min.js deleted file mode 100644 index 60350b1..0000000 --- a/dbus-tools/autobahn.min.js +++ /dev/null @@ -1,75 +0,0 @@ -/* - AutobahnJS - http://autobahn.ws - - Copyright 2011, 2012 Tavendo GmbH. - Licensed under the MIT License. - See license text at http://www.opensource.org/licenses/mit-license.php - - AutobahnJS includes code from: - - when - http://cujojs.com - - (c) copyright B Cavalier & J Hann - Licensed under the MIT License at: - http://www.opensource.org/licenses/mit-license.php - - Crypto-JS - http://code.google.com/p/crypto-js/ - - (c) 2009-2012 by Jeff Mott. All rights reserved. - Licensed under the New BSD License at: - http://code.google.com/p/crypto-js/wiki/License -*/ -/* - MIT License (c) copyright B Cavalier & J Hann */ -(function(a){a(function(){function a(){}function e(){}function d(a){var d=new e;d.then=function(d){f(arguments);var c;try{return d&&(c=d(a)),j(c===q?a:c)}catch(e){return b(e)}};return o(d)}function b(a){var d=new e;d.then=function(d,c){f(arguments);var e;try{return c?(e=c(a),j(e===q?a:e)):b(a)}catch(g){return b(g)}};return o(d)}function f(a){for(var b,d=a.length;d;)if(b=a[--d],null!=b&&"function"!=typeof b)throw Error("callback is not a function");}function h(){var a,c,g,m,i,j,k;g=[];m=[];i=function(a, -b,d){f(arguments);var c=h();g.push(function(d){d.then(a,b).then(c.resolve,c.reject,c.progress)});d&&m.push(d);return c.promise};j=function(a){for(var d,b=0;d=m[b++];)d(a)};k=function(a){var d,b=0;i=a.then;k=j=function(){throw Error("already completed");};for(m=q;d=g[b++];)d(a);g=[]};a={};c=new e;c.then=a.then=function(a,d,b){return i(a,d,b)};a.promise=o(c);a.resolver=o({resolve:a.resolve=function(a){k(d(a))},reject:a.reject=function(a){k(b(a))},progress:a.progress=function(a){j(a)}});return a}function g(a){return a&& -"function"===typeof a.then}function i(a,d,b,f){return j(a).then(d,b,f)}function j(a){var d;a instanceof e||(d=h(),g(a)?a.then(d.resolve,d.reject,d.progress):d.resolve(a),a=d.promise);return a}function k(d,b,f,e,g){function j(a){q(a)}function k(a){w(a)}function p(a){x(a)}var o,n,l,q,w,x,y;y=d.length>>>0;o=Math.max(0,Math.min(b,y));n=[];l=h();b=i(l,f,e,g);if(o){q=function(d){n.push(d);--o||(q=w=x=a,l.resolve(n))};w=function(d){q=w=x=a;l.reject(d)};x=l.progress;for(f=0;f>>0;b=arguments;if(1>=b.length)for(;;){if(e in d){f=d[e++];break}if(++e>=c)throw new TypeError;}else f=b[1];for(;e>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return c.rotl(a,8)&16711935|c.rotl(a,24)&4278255360;for(var b=0;b>>5]|=(a[f]&255)<< -24-c%32;return b},wordsToBytes:function(a){for(var b=[],f=0;f<32*a.length;f+=8)b.push(a[f>>>5]>>>24-f%32&255);return b},bytesToHex:function(a){for(var b=[],f=0;f>>4).toString(16)),b.push((a[f]&15).toString(16));return b.join("")},hexToBytes:function(a){for(var b=[],f=0;fg;g++)8*f+6*g<=8*a.length?b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-g)&63)):b.push("=");return b.join("")},base64ToBytes:function(a){if("function"==typeof atob)return e.stringToBytes(atob(a));for(var a=a.replace(/[^A-Z0-9+\/]/ig,""),b=[],f=0,c=0;f>> -6-2*c);return b}},a=a.charenc={};a.UTF8={stringToBytes:function(a){return e.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(e.bytesToString(a)))}};var e=a.Binary={stringToBytes:function(a){for(var b=[],f=0;f>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return c.rotl(a,8)&16711935|c.rotl(a,24)&4278255360;for(var b=0;b>>5]|=(a[f]&255)<< -24-c%32;return b},wordsToBytes:function(a){for(var b=[],f=0;f<32*a.length;f+=8)b.push(a[f>>>5]>>>24-f%32&255);return b},bytesToHex:function(a){for(var b=[],f=0;f>>4).toString(16)),b.push((a[f]&15).toString(16));return b.join("")},hexToBytes:function(a){for(var b=[],f=0;fg;g++)8*f+6*g<=8*a.length?b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c>>>6*(3-g)&63)):b.push("=");return b.join("")},base64ToBytes:function(a){if("function"==typeof atob)return e.stringToBytes(atob(a));for(var a=a.replace(/[^A-Z0-9+\/]/ig,""),b=[],c=0,h=0;c>> -6-2*h);return b}},a=a.charenc={};a.UTF8={stringToBytes:function(a){return e.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(e.bytesToString(a)))}};var e=a.Binary={stringToBytes:function(a){for(var b=[],c=0;c>5]|=128<<24-e%32;b[(e+64>>9<<4)+15]=e;for(u=0;um;m++){16>m?h[m]=b[m+u]:(s=h[m-15],r=h[m-2],h[m]=((s<<25|s>>>7)^(s<<14|s>>>18)^s>>>3)+(h[m-7]>>>0)+((r<<15|r>>>17)^(r<<13|r>>>19)^r>>>10)+(h[m-16]>>>0));r=e&l^e&n^l&n;var z=(e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22);s=(v>>>0)+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+ -(p&q^~p&t)+f[m]+(h[m]>>>0);r=z+r;v=t;t=q;q=p;p=o+s>>>0;o=n;n=l;l=e;e=s+r>>>0}a[0]+=e;a[1]+=l;a[2]+=n;a[3]+=o;a[4]+=p;a[5]+=q;a[6]+=t;a[7]+=v}return a};h._blocksize=16;h._digestsize=32})(); -(function(){var a=Crypto,c=a.util,e=a.charenc,d=e.UTF8,b=e.Binary;a.HMAC=function(a,e,g,i){e.constructor==String&&(e=d.stringToBytes(e));g.constructor==String&&(g=d.stringToBytes(g));g.length>4*a._blocksize&&(g=a(g,{asBytes:!0}));for(var j=g.slice(0),g=g.slice(0),k=0;k<4*a._blocksize;k++)j[k]^=92,g[k]^=54;a=a(j.concat(a(g.concat(e),{asBytes:!0})),{asBytes:!0});return i&&i.asBytes?a:i&&i.asString?b.bytesToString(a):c.bytesToHex(a)}})();/* - MIT License (c) 2011,2012 Copyright Tavendo GmbH. */ -var AUTOBAHNJS_VERSION="0.7.1",AUTOBAHNJS_DEBUG=!1,ab=window.ab={};ab._version=AUTOBAHNJS_VERSION; -(function(){Array.prototype.indexOf||(Array.prototype.indexOf=function(a){if(null===this)throw new TypeError;var c=Object(this),e=c.length>>>0;if(0===e)return-1;var d=0;0=e)return-1;for(d=0<=d?d:Math.max(e-Math.abs(d),0);d>>0;if({}.toString.call(a)!=="[object Function]")throw new TypeError(a+" is not a function");c&&(e=c);for(d=0;dc&&(c=b.length);e=b.slice(a,c).split(e);b=e[1].split(".");for(c=0;c - - - - - - - -

dbus-register

-
- - - - - - - - - - - - - - - - - - - -
bus: - -
sender: - -
object: - -
interface: - -
signal: - -
- - - -
-
- -
-

-    
-
diff --git a/dbus-tools/dbus-register.js b/dbus-tools/dbus-register.js
deleted file mode 100644
index 347b5f3..0000000
--- a/dbus-tools/dbus-register.js
+++ /dev/null
@@ -1,80 +0,0 @@
-// WAMP session object
-var mSession = null;
-
-// HTML DOM elements
-var mLog, mBus, mSender, mObject, mInterface, mSignal, mArgs, mUri;
-
-window.onload = function() {
-
-    function onSessionConnectedCB(session) { // WAMP session was established
-        mSession = session;
-        log_append("Session successfully connected.");
-    }
-
-    function onSessionErrorCB(code, reason) { // WAMP session is gone
-        mSession = null;
-        if (code == ab.CONNECTION_UNSUPPORTED) {
-             log_append("Browser is not supported");
-        } else {
-            log_append("Failed to open session, code = " + code + ", reason = " + reason);
-        }
-    }
-    
-    mLog = document.getElementById('log');
-    mBus = document.getElementById('bus');
-    mSender = document.getElementById('sender');
-    mObject = document.getElementById('object');
-    mInterface = document.getElementById('interface');
-    mSignal = document.getElementById('signal');
-    mArgs = document.getElementById('args');
-    mUri = document.getElementById('uri');
-    
-    // Connect to WAMP server
-    ab.connect(mUri.value, onSessionConnectedCB, onSessionErrorCB);
-};
-
-function sigHandler(id, data)
-{
-    log_append("got signal: " + id);
-    log_append("data: " + data + "\n");
-}
-
-function dbus_register()
-{
-    // RPC success callback
-    function myAsyncFuncSuccessCB(res) {
-        log_append("subscribing to: " + res + "\n");
-        mSession.subscribe(res, sigHandler);
-    }
-     // RPC error callback
-    function myAsyncFuncErrorCB(error, desc) {
-        log_append("error: " + desc + "\n");
-    }
-    log_append("dbusRegister: "
-    	+ mBus.options[mBus.selectedIndex].value + "\n\t"
-    	+ mSender.value + "\n\t"
-    	+ mObject.value + "\n\t"
-    	+ mInterface.value + "\n\t"
-    	+ mSignal.value + "\n"
-    		);
-    var arglist = [
-               	mBus.options[mBus.selectedIndex].value,
-               	mSender.value,
-               	mObject.value,
-               	mInterface.value,
-               	mSignal.value
-               	]
-
-    // call dbusRegister with bus type, sender, object, and signal
-    mSession.call("dbusRegister", arglist).then(myAsyncFuncSuccessCB, myAsyncFuncErrorCB);
-};
-
-function log_append(message) {
-    mLog.innerHTML += message + '\n';
-    mLog.scrollTop = mLog.scrollHeight;
-};
-
-function clear_log() {
-    mLog.innerHTML = "";
-    mLog.scrollTop = mLog.scrollHeight;
-};
\ No newline at end of file
diff --git a/dbus-tools/dbus-register.py b/dbus-tools/dbus-register.py
deleted file mode 100644
index 2880ce5..0000000
--- a/dbus-tools/dbus-register.py
+++ /dev/null
@@ -1,127 +0,0 @@
-###############################################################################
-# Copyright 2012 Intel Corporation.
-# 
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-# 
-# http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-###############################################################################
-
-
-import sys, dbus, json
-
-from twisted.internet import glib2reactor
-# Configure the twisted mainloop to be run inside the glib mainloop.
-# This must be done before importing the other twisted modules
-glib2reactor.install()
-from twisted.internet import reactor, defer
-
-from autobahn.websocket import listenWS
-from autobahn.wamp import exportRpc, WampServerFactory, WampServerProtocol
-
-from dbus.mainloop.glib import DBusGMainLoop
-
-import gobject
-gobject.threads_init()
-
-from dbus import glib
-glib.init_threads()
-
-# enable debug log
-from twisted.python import log
-log.startLogging(sys.stdout)
-
-
-
-###############################################################################
-def hashId(senderName, objectName, interfaceName, signalName):
-	return senderName + "#" + objectName + "#" + interfaceName + "#" + signalName
-
-
-
-###############################################################################
-class DbusSignalHandler:
-	def __init__(self, bus, senderName, objectName, interfaceName, signalName):
-		# publish hash id
-		self.id = hashId(senderName, objectName, interfaceName, signalName)
-        # connect dbus proxy object to signal
-		self.object = bus.get_object(senderName, objectName)
-		self.object.connect_to_signal(signalName, self.handleSignal, interfaceName)
-
-
-	def handleSignal(self, *args):
-		# publish dbus args under topic hash id
-		factory.dispatch(self.id, json.dumps(args))
-
-
-
-###############################################################################
-class DbusRegisterService:
-    def __init__(self):
-    	# signal handlers
-    	self.signalHandlers = {}
-
-
-    @exportRpc
-    def dbusRegister(self, list):
-    	# read arguments list by position
-        if len(list) < 5:
-        	raise Exception("Error: expected arguments: bus, sender, object, interface, signal)")
-        
-    	# check if a handler exists
-        sigId = hashId(list[1], list[2], list[3], list[4])
-        if self.signalHandlers.has_key(sigId):
-        	return sigId
-    	
-        if list[0] == "session":
-        	bus = dbus.SessionBus()
-        elif list[0] == "system":
-        	bus = dbus.SystemBus()
-        else:
-        	raise Exception("Error: invalid bus: %s" % list[0])
-        
-        # create a handler that will publish the signal
-        dbusSignalHandler = DbusSignalHandler(bus, list[1], list[2], list[3], list[4])
-        self.signalHandlers[sigId] = dbusSignalHandler
-        
-        return dbusSignalHandler.id
-
-
-
-###############################################################################
-class DbusRegisterServerProtocol(WampServerProtocol):
-	def onSessionOpen(self):
-		# create dbus-register service instance
-		self.DbusRegisterService = DbusRegisterService()
-		# register it for RPC
-		self.registerForRpc(self.DbusRegisterService)
-		# register for Publish / Subscribe
-		self.registerForPubSub("", True)
-
-
-
-###############################################################################
-if __name__ == '__main__':
-	port = "9001"
-	if len(sys.argv) == 2:
-		port = sys.argv[1]
-
-	uri = "ws://localhost:" + port
-
-	factory = WampServerFactory(uri, debugWamp = True)
-	factory.protocol = DbusRegisterServerProtocol
-	factory.setProtocolOptions(allowHixie76 = True)
-
-	listenWS(factory)
-
-	DBusGMainLoop(set_as_default=True)
-
-	reactor.run()
-
diff --git a/dbus-tools/dbus-send.html b/dbus-tools/dbus-send.html
deleted file mode 100644
index b3a2a37..0000000
--- a/dbus-tools/dbus-send.html
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-    
-        
-        
-        
-    
-   
-        

dbus-send

-
- - - - - - - - - - - - - - - - - - - - -
bus: - -
destination: - -
object: - -
interface: - -
message: - -
- -
- - - -
-
- -
-

-    
-
diff --git a/dbus-tools/dbus-send.js b/dbus-tools/dbus-send.js
deleted file mode 100644
index b1bcab8..0000000
--- a/dbus-tools/dbus-send.js
+++ /dev/null
@@ -1,77 +0,0 @@
-// WAMP session object
-var mSession = null;
-
-// HTML DOM elements
-var mLog, mBus, mDestination, mObject, mInterface, mMessage, mArgs, mUri;
-
-window.onload = function() {
-
-    function onSessionConnectedCB(session) { // WAMP session was established
-        mSession = session;
-        log_append("Session successfully connected.");
-    }
-
-    function onSessionErrorCB(code, reason) { // WAMP session is gone
-        mSession = null;
-        if (code == ab.CONNECTION_UNSUPPORTED) {
-             log_append("Browser is not supported");
-        } else {
-            log_append("Failed to open session, code = " + code + ", reason = " + reason);
-        }
-    }
-    
-    mLog = document.getElementById('log');
-    mBus = document.getElementById('bus');
-    mDestination = document.getElementById('destination');
-    mObject = document.getElementById('object');
-    mInterface = document.getElementById('interface');
-    mMessage = document.getElementById('message');
-    mArgs = document.getElementById('args');
-    mUri = document.getElementById('uri');
-    
-    // Connect to WAMP server
-    ab.connect(mUri.value, onSessionConnectedCB, onSessionErrorCB);
-};
-
-function dbus_send()
-{
-    // RPC success callback
-    function myAsyncFuncSuccessCB(res) {
-        log_append("got result: " + res + "\n");
-    }
-     // RPC error callback
-    function myAsyncFuncErrorCB(error, desc) {
-        log_append("error: " + desc + "\n");
-    }
-    log_append("dbusSend: "
-    	+ mBus.options[mBus.selectedIndex].value + "\n\t"
-    	+ mDestination.value + "\n\t"
-    	+ mObject.value + "\n\t"
-    	+ mInterface.value + "\n\t"
-    	+ mMessage.value + "\n\t"
-    	+ mArgs.value + "\n"
-    		);
-    var arglist = [
-               	mBus.options[mBus.selectedIndex].value,
-               	mDestination.value,
-               	mObject.value,
-               	mInterface.value,
-               	mMessage.value
-               	]
-    if (mArgs.value) {
-    	arglist.push(mArgs.value);
-    }
-
-    // call dbusSend with bus type, destination, object, message and arguments
-    mSession.call("dbusSend", arglist).then(myAsyncFuncSuccessCB, myAsyncFuncErrorCB);
-};
-
-function log_append(message) {
-    mLog.innerHTML += message + '\n';
-    mLog.scrollTop = mLog.scrollHeight;
-};
-
-function clear_log() {
-    mLog.innerHTML = "";
-    mLog.scrollTop = mLog.scrollHeight;
-};
\ No newline at end of file
diff --git a/dbus-tools/dbus-send.py b/dbus-tools/dbus-send.py
deleted file mode 100644
index 749cd7d..0000000
--- a/dbus-tools/dbus-send.py
+++ /dev/null
@@ -1,139 +0,0 @@
-###############################################################################
-# Copyright 2012 Intel Corporation.
-# 
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-# 
-# http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-###############################################################################
-
-
-import sys, dbus, json
-
-from twisted.internet import glib2reactor
-# Configure the twisted mainloop to be run inside the glib mainloop.
-# This must be done before importing the other twisted modules
-glib2reactor.install()
-from twisted.internet import reactor, defer
-
-from autobahn.websocket import listenWS
-from autobahn.wamp import exportRpc, WampServerFactory, WampServerProtocol
-
-from dbus.mainloop.glib import DBusGMainLoop
-
-import gobject
-gobject.threads_init()
-
-from dbus import glib
-glib.init_threads()
-
-# enable debug log
-from twisted.python import log
-log.startLogging(sys.stdout)
-
-
-
-###############################################################################
-class DbusCallHandler:
-	def __init__(self, method, args):
-        # deferred reply to return dbus results
-		self.pending = False
-		self.request = defer.Deferred()
-		self.method = method
-		self.args = args
-
-
-	def callMethod(self):
-		# dbus method async call
-		self.pending = True
-		self.method(*self.args, reply_handler=self.dbusSuccess, error_handler=self.dbusError)
-		return self.request
-
-
-	def dbusSuccess(self, *result):
-		# return JSON string result array
-		self.request.callback(json.dumps(result))
-		self.pending = False
-
-
-	def dbusError(self, error):
-		# return dbus error message
-		self.request.errback(error.get_dbus_message())
-		self.pending = False
-
-
-
-###############################################################################
-class DbusSendService:
-    def __init__(self):
-        # pending dbus calls
-        self.pendingCalls = []
-
-
-    @exportRpc
-    def dbusSend(self, list):
-    	# clear pending calls
-    	for call in self.pendingCalls:
-    		if not call.pending:
-    			self.pendingCalls.remove(call)
-    	
-    	# read arguments list by position
-        if len(list) < 5:
-        	raise Exception("Error: expected arguments: bus, destination, object, interface, message, [args])")
-        if list[0] == "session":
-        	bus = dbus.SessionBus()
-        elif list[0] == "system":
-        	bus = dbus.SystemBus()
-        else:
-        	raise Exception("Error: invalid bus: %s" % list[0])
-        
-        # parse JSON arg list
-        args = []
-        if len(list) == 6:
-         	args = json.loads(list[5])
-        
-        # get dbus proxy
-        object = bus.get_object(list[1], list[2])
-        method = object.get_dbus_method(list[4], list[3])
-        
-        # use a deferred call handler to manage dbus results
-        dbusCallHandler = DbusCallHandler(method, args)
-        self.pendingCalls.append(dbusCallHandler)
-        return dbusCallHandler.callMethod()
-
-
-
-###############################################################################
-class DbusSendServerProtocol(WampServerProtocol):
-	def onSessionOpen(self):
-		# create dbus-send service instance and register it for RPC.
-		self.dbusSendService = DbusSendService()
-		self.registerForRpc(self.dbusSendService)
-
-
-
-###############################################################################
-if __name__ == '__main__':
-	port = "9000"
-	if len(sys.argv) == 2:
-		port = sys.argv[1]
-
-	uri = "ws://localhost:" + port
-
-	factory = WampServerFactory(uri, debugWamp = True)
-	factory.protocol = DbusSendServerProtocol
-	factory.setProtocolOptions(allowHixie76 = True)
-
-	listenWS(factory)
-
-	DBusGMainLoop(set_as_default=True)
-
-	reactor.run()
-
diff --git a/doc/dbus-tools/dbus-register.html b/doc/dbus-tools/dbus-register.html
new file mode 100644
index 0000000..5378562
--- /dev/null
+++ b/doc/dbus-tools/dbus-register.html
@@ -0,0 +1,129 @@
+
+
+	
+		
+		
+		
+	
+	
+		

dbus-register

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bus: + +
sender:
object:
interface:
signal:
+
+ +
+

+	
+
diff --git a/doc/dbus-tools/dbus-send.html b/doc/dbus-tools/dbus-send.html
new file mode 100644
index 0000000..007dcea
--- /dev/null
+++ b/doc/dbus-tools/dbus-send.html
@@ -0,0 +1,131 @@
+
+
+	
+		
+		
+		
+	
+	
+		

dbus-send

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bus: + +
destination:
object:
interface:
message:
+
+ +
+

+	
+
diff --git a/doc/cloudeebus.html b/doc/sample/cloudeebus.html
similarity index 99%
rename from doc/cloudeebus.html
rename to doc/sample/cloudeebus.html
index 83f66f6..2928b95 100644
--- a/doc/cloudeebus.html
+++ b/doc/sample/cloudeebus.html
@@ -58,4 +58,3 @@ cloudeebus.connect("ws://localhost:9000", connectSuccess, errorCB);
 		

    
 
-
diff --git a/doc/autobahn.min.js b/lib/autobahn.min.js
similarity index 100%
rename from doc/autobahn.min.js
rename to lib/autobahn.min.js
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..017b8fa
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+# Cloudeebus
+#
+# Copyright (C) 2012 Intel Corporation. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Luc Yriarte 
+# Christophe Guiraud 
+#
+
+from setuptools import setup
+
+setup(name = "cloudeebus",
+	version = "0.0.1",
+	description = "Javascript-DBus bridge",
+	author = "Luc Yriarte, Christophe Guiraud",
+	author_email = "luc.yriarte@intel.com, christophe.guiraud@intel.com",
+	url = "https://01.org/cloudeebus/about",
+	license = "http://www.apache.org/licenses/LICENSE-2.0",
+	scripts = ["cloudeebus/cloudeebus.py"],
+	packages = ["cloudeebus"],
+	data_files = [("cloudeebus" ,["AUTHORS", "README.md", "LICENSE"])],
+	platforms = ("Any"),
+	install_requires = ["setuptools", "autobahn>=0.5.6"],
+	classifiers = ["License :: OSI Approved :: Apache Software License",
+		  "Development Status :: 3 - Alpha",
+		  "Environment :: Console",
+		  "Framework :: Autobahn",
+		  "Intended Audience :: Developers",
+		  "Operating System :: OS Independent",
+		  "Programming Language :: Python",
+		  "Topic :: Internet",
+		  "Topic :: Software Development :: Libraries"],
+	keywords = "cloudeebus autobahn websocket dbus javascript bridge")
-- 
2.7.4