diff src/bridge/DBus.py @ 371:3ea41a199b36

bridge refactoring: categories are now core and plugin instead of communication and request
author Goffi <goffi@goffi.org>
date Wed, 06 Jul 2011 01:04:24 +0200
parents efbfccfed623
children e66d300c5d42
line wrap: on
line diff
--- a/src/bridge/DBus.py	Fri Jun 24 17:45:22 2011 +0200
+++ b/src/bridge/DBus.py	Wed Jul 06 01:04:24 2011 +0200
@@ -28,8 +28,8 @@
 
 const_INT_PREFIX = "org.goffi.SAT"  #Interface prefix
 const_OBJ_PATH = '/org/goffi/SAT/bridge'
-const_COMM_SUFFIX = ".communication"
-const_REQ_SUFFIX = ".request"
+const_CORE_SUFFIX = ".core"
+const_PLUGIN_SUFFIX = ".plugin"
 
 class DbusObject(dbus.service.Object):
 
@@ -43,272 +43,280 @@
 
     ### signals ###    
 
-    @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX,
+                         signature='')
+    def dummySignal(self):
+        #FIXME: workaround for addSignal (doesn't work if one method doensn't
+        #       already exist for plugins), probably missing some initialisation, need
+        #       further investigations
+        pass
+
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ssa{ss}')
     def actionResult(self, answer_type, id, data):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ssa{sa{ss}}')
     def actionResultExt(self, answer_type, id, data):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ssa{ss}')
     def askConfirmation(self, conf_type, id, data):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='s')
     def connected(self, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ss')
     def connectionError(self, error_type, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ss')
     def contactDeleted(self, entity, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='s')
     def disconnected(self, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ssss')
     def newAlert(self, message, title, alert_type, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='sa{ss}ass')
     def newContact(self, contact, attributes, groups, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='sssss')
     def newMessage(self, from_jid, message, mess_type, to_jid, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ssss')
     def paramUpdate(self, name, value, category, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='ssia{ss}s')
     def presenceUpdate(self, entity, show, priority, statuses, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
                          signature='sss')
     def subscribe(self, sub_type, entity, profile):
         pass
 
-    @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
-                         signature='sa{ss}')
-    def updatedValue(self, name, value):
+    @dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
+                         signature='sa{ss}s')
+    def updatedValue(self, name, value, profile):
         pass
 
 
     ### methods ###    
     
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ss', out_signature='',
                          async_callbacks=None)
     def addContact(self, entity, profile_key="@DEFAULT@"):
         return self.cb["addContact"](unicode(entity), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='',
                          async_callbacks=('callback', 'errback'))
     def asyncConnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
         return self.cb["asyncConnect"](unicode(profile_key), callback, errback)
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssss', out_signature='s',
                          async_callbacks=None)
     def callMenu(self, category, name, menu_type, profile_key):
         return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='sba{ss}', out_signature='',
                          async_callbacks=None)
     def confirmationAnswer(self, id, accepted, data):
         return self.cb["confirmationAnswer"](unicode(id), accepted, data)
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='',
                          async_callbacks=None)
     def connect(self, profile_key="@DEFAULT@"):
         return self.cb["connect"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='i',
                          async_callbacks=None)
     def createProfile(self, profile):
         return self.cb["createProfile"](unicode(profile))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ss', out_signature='',
                          async_callbacks=None)
     def delContact(self, entity, profile_key="@DEFAULT@"):
         return self.cb["delContact"](unicode(entity), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='i',
                          async_callbacks=None)
     def deleteProfile(self, profile):
         return self.cb["deleteProfile"](unicode(profile))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='',
                          async_callbacks=None)
     def disconnect(self, profile_key="@DEFAULT@"):
         return self.cb["disconnect"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ss', out_signature='s',
                          async_callbacks=None)
     def getConfig(self, section, name):
         return self.cb["getConfig"](unicode(section), unicode(name))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='a(sa{ss}as)',
                          async_callbacks=None)
     def getContacts(self, profile_key="@DEFAULT@"):
         return self.cb["getContacts"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssi', out_signature='a{i(ss)}',
                          async_callbacks=None)
     def getHistory(self, from_jid, to_jid, size):
         return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size)
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='sss', out_signature='s',
                          async_callbacks=None)
     def getMenuHelp(self, category, name, menu_type):
         return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='', out_signature='a(sss)',
                          async_callbacks=None)
     def getMenus(self, ):
         return self.cb["getMenus"]()
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssss', out_signature='s',
                          async_callbacks=None)
     def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"):
         return self.cb["getParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='s',
                          async_callbacks=None)
     def getParams(self, profile_key="@DEFAULT@"):
         return self.cb["getParams"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='', out_signature='as',
                          async_callbacks=None)
     def getParamsCategories(self, ):
         return self.cb["getParamsCategories"]()
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ss', out_signature='s',
                          async_callbacks=None)
     def getParamsForCategory(self, category, profile_key="@DEFAULT@"):
         return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='s',
                          async_callbacks=None)
     def getParamsUI(self, profile_key="@DEFAULT@"):
         return self.cb["getParamsUI"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='a{sa{s(sia{ss})}}',
                          async_callbacks=None)
     def getPresenceStatus(self, profile_key="@DEFAULT@"):
         return self.cb["getPresenceStatus"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='s',
                          async_callbacks=None)
     def getProfileName(self, profile_key="@DEFAULT@"):
         return self.cb["getProfileName"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='', out_signature='as',
                          async_callbacks=None)
     def getProfilesList(self, ):
         return self.cb["getProfilesList"]()
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='a{ss}',
                          async_callbacks=None)
     def getProgress(self, id):
         return self.cb["getProgress"](unicode(id))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='', out_signature='s',
                          async_callbacks=None)
     def getVersion(self, ):
         return self.cb["getVersion"]()
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='a{ss}',
                          async_callbacks=None)
     def getWaitingSub(self, profile_key="@DEFAULT@"):
         return self.cb["getWaitingSub"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='s', out_signature='b',
                          async_callbacks=None)
     def isConnected(self, profile_key="@DEFAULT@"):
         return self.cb["isConnected"](unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='sa{ss}s', out_signature='s',
                          async_callbacks=None)
     def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
         return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssssi', out_signature='s',
                          async_callbacks=None)
     def registerNewAccount(self, login, password, email, host, port=5222):
         return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(email), unicode(host), port)
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='sssss', out_signature='',
                          async_callbacks=None)
     def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"):
         return self.cb["sendMessage"](unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssss', out_signature='',
                          async_callbacks=None)
     def setParam(self, name, value, category, profile_key="@DEFAULT@"):
         return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssia{ss}s', out_signature='',
                          async_callbacks=None)
     def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
         return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='sss', out_signature='',
                          async_callbacks=None)
     def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
         return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key))
 
-    @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
+    @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
                          in_signature='ssass', out_signature='',
                          async_callbacks=None)
     def updateContact(self, entity, name, groups, profile_key="@DEFAULT@"):
@@ -433,8 +441,8 @@
     def subscribe(self, sub_type, entity, profile):
         self.dbus_bridge.subscribe(sub_type, entity, profile)
 
-    def updatedValue(self, name, value):
-        self.dbus_bridge.updatedValue(name, value)
+    def updatedValue(self, name, value, profile):
+        self.dbus_bridge.updatedValue(name, value, profile)
 
 
     def register(self, name, callback):