# HG changeset patch # User Goffi # Date 1295903104 -3600 # Node ID 1d2e0dfe71141b2b9a8937b4bac1d36732c2d807 # Parent 0288f97334f29b77f862f3217dac80f0548bfdc5 bridge: core & frontend sides of bridge are now generated diff -r 0288f97334f2 -r 1d2e0dfe7114 frontends/src/bridge/DBus.py --- a/frontends/src/bridge/DBus.py Mon Jan 24 21:48:09 2011 +0100 +++ b/frontends/src/bridge/DBus.py Mon Jan 24 22:05:04 2011 +0100 @@ -21,6 +21,7 @@ from bridge_frontend import BridgeFrontend import dbus, dbus.glib +from logging import debug class BridgeExceptionNoService(Exception): pass @@ -48,7 +49,126 @@ elif iface == "request": self.db_req_iface.connect_to_signal(functionName, handler) -##METHODS_PART## + def addContact(self, entity, profile_key="@DEFAULT@"): + debug ("addContact") + return self.db_comm_iface.addContact(entity, profile_key) + + def callMenu(self, category, name, menu_type, profile_key): + debug ("callMenu") + return self.db_req_iface.callMenu(category, name, menu_type, profile_key) + + def confirmationAnswer(self, id, accepted, data): + debug ("confirmationAnswer") + return self.db_req_iface.confirmationAnswer(id, accepted, data) + + def connect(self, profile_key="@DEFAULT@"): + debug ("connect") + return self.db_comm_iface.connect(profile_key) + + def createProfile(self, profile): + debug ("createProfile") + return self.db_req_iface.createProfile(profile) + + def delContact(self, entity, profile_key="@DEFAULT@"): + debug ("delContact") + return self.db_comm_iface.delContact(entity, profile_key) + + def deleteProfile(self, profile): + debug ("deleteProfile") + return self.db_req_iface.deleteProfile(profile) + + def disconnect(self, profile_key="@DEFAULT@"): + debug ("disconnect") + return self.db_comm_iface.disconnect(profile_key) + + def getContacts(self, profile_key="@DEFAULT@"): + debug ("getContacts") + return self.db_comm_iface.getContacts(profile_key) + + def getHistory(self, from_jid, to_jid, size): + debug ("getHistory") + return self.db_comm_iface.getHistory(from_jid, to_jid, size) + + def getMenuHelp(self, category, name, menu_type): + debug ("getMenuHelp") + return self.db_req_iface.getMenuHelp(category, name, menu_type) + + def getMenus(self, ): + debug ("getMenus") + return self.db_req_iface.getMenus() + + def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): + debug ("getParamA") + return self.db_comm_iface.getParamA(name, category, attribute, profile_key) + + def getParams(self, profile_key="@DEFAULT@"): + debug ("getParams") + return self.db_comm_iface.getParams(profile_key) + + def getParamsCategories(self, ): + debug ("getParamsCategories") + return self.db_comm_iface.getParamsCategories() + + def getParamsForCategory(self, category, profile_key="@DEFAULT@"): + debug ("getParamsForCategory") + return self.db_comm_iface.getParamsForCategory(category, profile_key) + + def getParamsUI(self, profile_key="@DEFAULT@"): + debug ("getParamsUI") + return self.db_comm_iface.getParamsUI(profile_key) + + def getPresenceStatus(self, profile_key="@DEFAULT@"): + debug ("getPresenceStatus") + return self.db_comm_iface.getPresenceStatus(profile_key) + + def getProfileName(self, profile_key="@DEFAULT@"): + debug ("getProfileName") + return self.db_req_iface.getProfileName(profile_key) + + def getProfilesList(self, ): + debug ("getProfilesList") + return self.db_req_iface.getProfilesList() + + def getProgress(self, id): + debug ("getProgress") + return self.db_req_iface.getProgress(id) + + def getVersion(self, ): + debug ("getVersion") + return self.db_req_iface.getVersion() + + def getWaitingSub(self, profile_key="@DEFAULT@"): + debug ("getWaitingSub") + return self.db_comm_iface.getWaitingSub(profile_key) + + def isConnected(self, profile_key="@DEFAULT@"): + debug ("isConnected") + return self.db_comm_iface.isConnected(profile_key) + + def launchAction(self, action_type, data, profile_key="@DEFAULT@"): + debug ("launchAction") + return self.db_req_iface.launchAction(action_type, data, profile_key) + + def registerNewAccount(self, login, password, host, port=5222): + debug ("registerNewAccount") + return self.db_comm_iface.registerNewAccount(login, password, host, port) + + def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"): + debug ("sendMessage") + return self.db_comm_iface.sendMessage(to_jid, message, subject, mess_type, profile_key) + + def setParam(self, name, value, category, profile_key="@DEFAULT@"): + debug ("setParam") + return self.db_comm_iface.setParam(name, value, category, profile_key) + + def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"): + debug ("setPresence") + return self.db_comm_iface.setPresence(to_jid, show, priority, statuses, profile_key) + + def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): + debug ("subscription") + return self.db_comm_iface.subscription(sub_type, entity, profile_key) + #methods from plugins def getRoomJoined(self, profile_key='@DEFAULT@'): @@ -95,4 +215,3 @@ data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature return self.db_req_iface.gatewayRegister(action, target, data, profile_key) - diff -r 0288f97334f2 -r 1d2e0dfe7114 frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Mon Jan 24 21:48:09 2011 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Mon Jan 24 22:05:04 2011 +0100 @@ -119,9 +119,9 @@ self.profile = profile ###now we get the essential params### - self.profiles[profile]['whoami']=JID(self.bridge.getParamA("JabberID","Connection", profile)) - autoconnect = self.bridge.getParamA("autoconnect","Connection", profile) == "true" - self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile).split() #TODO: put this in a plugin + self.profiles[profile]['whoami']=JID(self.bridge.getParamA("JabberID","Connection", profile_key=profile)) + autoconnect = self.bridge.getParamA("autoconnect","Connection", profile_key=profile) == "true" + self.profiles[profile]['watched']=self.bridge.getParamA("Watched", "Misc", profile_key=profile).split() #TODO: put this in a plugin ## misc ## self.profiles[profile]['onlineContact'] = set() #FIXME: temporary @@ -440,7 +440,7 @@ """Must be called when the frontend is terminating""" #TODO: mange multi-profile here try: - autodisconnect = self.bridge.getParamA("autodisconnect","Connection", self.profile) == "true" + autodisconnect = self.bridge.getParamA("autodisconnect","Connection", profile_key=self.profile) == "true" if autodisconnect and self.bridge.isConnected(self.profile): #Does the user want autodisconnection ? self.bridge.disconnect(self.profile) diff -r 0288f97334f2 -r 1d2e0dfe7114 src/bridge/DBus.py --- a/src/bridge/DBus.py Mon Jan 24 21:48:09 2011 +0100 +++ b/src/bridge/DBus.py Mon Jan 24 22:05:04 2011 +0100 @@ -24,7 +24,7 @@ import dbus import dbus.service import dbus.mainloop.glib -from logging import debug, info, error +from logging import debug, info const_INT_PREFIX = "org.goffi.SAT" #Interface prefix const_COMM_SUFFIX = ".communication" @@ -45,72 +45,72 @@ @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, signature='ssa{ss}') def actionResult(self, answer_type, id, data): - pass + debug ("actionResult") @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, signature='ssa{sa{ss}}') def actionResultExt(self, answer_type, id, data): - pass + debug ("actionResultExt") @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, signature='ssa{ss}') def askConfirmation(self, conf_type, id, data): - pass + debug ("askConfirmation") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='s') def connected(self, profile): - pass + debug ("connected") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='ss') def connection_error(self, error_type, profile): - pass + debug ("connection_error") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='ss') def contactDeleted(self, entity, profile): - pass + debug ("contactDeleted") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='s') def disconnected(self, profile): - pass + debug ("disconnected") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='ssss') def newAlert(self, message, title, alert_type, profile): - pass + debug ("newAlert") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='sa{ss}ass') def newContact(self, contact, attributes, groups, profile): - pass + debug ("newContact") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='sssss') def newMessage(self, from_jid, message, mess_type, to_jid, profile): - pass + debug ("newMessage") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='ssss') def paramUpdate(self, name, value, category, profile): - pass + debug ("paramUpdate") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='ssia{ss}s') def presenceUpdate(self, entity, show, priority, statuses, profile): - pass + debug ("presenceUpdate") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='sss') def subscribe(self, sub_type, entity, profile): - pass + debug ("subscribe") @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, signature='sa{ss}') def updatedValue(self, name, value): - pass + debug ("updatedValue") ### methods ### @@ -118,151 +118,181 @@ @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ss', out_signature='') def addContact(self, entity, profile_key="@DEFAULT@"): + debug ("addContact") return self.cb["addContact"](unicode(entity), unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='ssss', out_signature='s') def callMenu(self, category, name, menu_type, profile_key): + debug ("callMenu") return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='sba{ss}', out_signature='') def confirmationAnswer(self, id, accepted, data): + debug ("confirmationAnswer") return self.cb["confirmationAnswer"](unicode(id), accepted, data) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='') def connect(self, profile_key="@DEFAULT@"): + debug ("connect") return self.cb["connect"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='s', out_signature='i') def createProfile(self, profile): + debug ("createProfile") return self.cb["createProfile"](unicode(profile)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ss', out_signature='') def delContact(self, entity, profile_key="@DEFAULT@"): + debug ("delContact") return self.cb["delContact"](unicode(entity), unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='s', out_signature='i') def deleteProfile(self, profile): + debug ("deleteProfile") return self.cb["deleteProfile"](unicode(profile)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='') def disconnect(self, profile_key="@DEFAULT@"): + debug ("disconnect") return self.cb["disconnect"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='a(sa{ss}as)') def getContacts(self, profile_key="@DEFAULT@"): + debug ("getContacts") return self.cb["getContacts"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ssi', out_signature='a{i(ss)}') def getHistory(self, from_jid, to_jid, size): + debug ("getHistory") return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='sss', out_signature='s') def getMenuHelp(self, category, name, menu_type): + debug ("getMenuHelp") return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='', out_signature='a(sss)') def getMenus(self, ): + debug ("getMenus") return self.cb["getMenus"]() @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, - in_signature='sss', out_signature='s') - def getParamA(self, name, category, profile_key="@DEFAULT@"): - return self.cb["getParamA"](unicode(name), unicode(category), unicode(profile_key)) + in_signature='ssss', out_signature='s') + def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"): + debug ("getParamA") + return self.cb["getParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='s') def getParams(self, profile_key="@DEFAULT@"): + debug ("getParams") return self.cb["getParams"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='', out_signature='as') def getParamsCategories(self, ): + debug ("getParamsCategories") return self.cb["getParamsCategories"]() @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ss', out_signature='s') def getParamsForCategory(self, category, profile_key="@DEFAULT@"): + debug ("getParamsForCategory") return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='s') def getParamsUI(self, profile_key="@DEFAULT@"): + debug ("getParamsUI") return self.cb["getParamsUI"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='a{sa{s(sia{ss})}}') def getPresenceStatus(self, profile_key="@DEFAULT@"): + debug ("getPresenceStatus") return self.cb["getPresenceStatus"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='s', out_signature='s') def getProfileName(self, profile_key="@DEFAULT@"): + debug ("getProfileName") return self.cb["getProfileName"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='', out_signature='as') def getProfilesList(self, ): + debug ("getProfilesList") return self.cb["getProfilesList"]() @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='s', out_signature='a{ss}') def getProgress(self, id): + debug ("getProgress") return self.cb["getProgress"](unicode(id)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='', out_signature='s') def getVersion(self, ): + debug ("getVersion") return self.cb["getVersion"]() @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='a{ss}') def getWaitingSub(self, profile_key="@DEFAULT@"): + debug ("getWaitingSub") return self.cb["getWaitingSub"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='b') def isConnected(self, profile_key="@DEFAULT@"): + debug ("isConnected") return self.cb["isConnected"](unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='sa{ss}s', out_signature='s') def launchAction(self, action_type, data, profile_key="@DEFAULT@"): + debug ("launchAction") return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='sssi', out_signature='s') def registerNewAccount(self, login, password, host, port=5222): + debug ("registerNewAccount") return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(host), port) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='sssss', out_signature='') - def sendMessage(self, to_jid, message, subject=, mess_type="chat", profile_key="@DEFAULT@"): + def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"): + debug ("sendMessage") 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, in_signature='ssss', out_signature='') def setParam(self, name, value, category, profile_key="@DEFAULT@"): + debug ("setParam") return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ssia{ss}s', out_signature='') def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"): + debug ("setPresence") return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key)) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='sss', out_signature='') def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): + debug ("subscription") return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key)) diff -r 0288f97334f2 -r 1d2e0dfe7114 src/bridge/bridge_constructor/bridge_template.ini --- a/src/bridge/bridge_constructor/bridge_template.ini Mon Jan 24 21:48:09 2011 +0100 +++ b/src/bridge/bridge_constructor/bridge_template.ini Mon Jan 24 22:05:04 2011 +0100 @@ -323,13 +323,15 @@ [getParamA] type=method category=communication -sig_in=sss +sig_in=ssss sig_out=s -param_2_default="@DEFAULT@" +param_2_default="value" +param_3_default="@DEFAULT@" doc=Helper method to get a parameter's attribute doc_param_0=name: as for [setParam] doc_param_1=category: as for [setParam] -doc_param_2=%(doc_profile_key)s +doc_param_2=attribute: Name of the attribute +doc_param_3=%(doc_profile_key)s [getParamsUI] type=method diff -r 0288f97334f2 -r 1d2e0dfe7114 src/bridge/bridge_constructor/dbus_core_template.py --- a/src/bridge/bridge_constructor/dbus_core_template.py Mon Jan 24 21:48:09 2011 +0100 +++ b/src/bridge/bridge_constructor/dbus_core_template.py Mon Jan 24 22:05:04 2011 +0100 @@ -24,7 +24,7 @@ import dbus import dbus.service import dbus.mainloop.glib -from logging import debug, info, error +from logging import debug, info const_INT_PREFIX = "org.goffi.SAT" #Interface prefix const_COMM_SUFFIX = ".communication" diff -r 0288f97334f2 -r 1d2e0dfe7114 src/bridge/bridge_constructor/dbus_frontend_template.py --- a/src/bridge/bridge_constructor/dbus_frontend_template.py Mon Jan 24 21:48:09 2011 +0100 +++ b/src/bridge/bridge_constructor/dbus_frontend_template.py Mon Jan 24 22:05:04 2011 +0100 @@ -21,6 +21,7 @@ from bridge_frontend import BridgeFrontend import dbus, dbus.glib +from logging import debug class BridgeExceptionNoService(Exception): pass