Mercurial > libervia-backend
diff sat_bridge/DBus.py @ 66:8147b4f40809
SàT: multi-profile: DBus signals and frontend adaptation (first draft)
- Quick App: new single_profile parameter in __init__ (default: yes), used to tell if the application use only one profile at the time or not
- Quick App: new __check_profile method, tell if the profile is used by the current frontend
- Quick App: new methods plug_profile, unplug_profile and clear_profile, must be called by the frontend to tell which profiles to use
- DBus Bridge: new methods getProfileName, getProfilesList and createProfile
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 03 Feb 2010 23:35:57 +1100 |
parents | d35c5edab53f |
children | 0e50dd3a234a |
line wrap: on
line diff
--- a/sat_bridge/DBus.py Sun Jan 31 15:57:03 2010 +1100 +++ b/sat_bridge/DBus.py Wed Feb 03 23:35:57 2010 +1100 @@ -44,44 +44,44 @@ ### signals ### @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='') - def connected(self): + signature='s') + def connected(self, profile): debug("Connected signal") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='') - def disconnected(self): + signature='s') + def disconnected(self, profile): debug("Disconnected signal") @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='sa{ss}as') - def newContact(self, contact, attributes, groups): - debug("new contact signal (%s) sended", contact) + signature='sa{ss}ass') + def newContact(self, contact, attributes, groups, profile): + debug("new contact signal (%s) sended (profile: %s)", contact, profile) @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='ssss') - def newMessage(self, from_jid, msg, type='chat', to=''): + signature='sssss') + def newMessage(self, from_jid, msg, type='chat', to='', profile='@NONE@'): debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to) @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='ssia{ss}') - def presenceUpdate(self, entity, show, priority, statuses): - debug("presence update signal (from:%s show:%s priority:%d statuses:%s) sended" , entity, show, priority, statuses) + signature='ssia{ss}s') + def presenceUpdate(self, entity, show, priority, statuses, profile): + debug("presence update signal (from:%s show:%s priority:%d statuses:%s profile:%s) sended" , entity, show, priority, statuses, profile) + + @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, + signature='sss') + def subscribe(self, type, entity, profile): + debug("subscribe (type: [%s] from:[%s] profile:[%s])" , type, entity, profile) + + @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, + signature='ssss') + def paramUpdate(self, name, value, category, profile): + debug("param update signal: %s=%s in category %s (profile: %s)", name, value, category, profile) @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='ss') - def subscribe(self, type, entity): - debug("subscribe (type: [%s] from:[%s])" , type, entity) - - @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='sss') - def paramUpdate(self, name, value, category): - debug("param update signal: %s=%s in category %s", name, value, category) - - @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, - signature='s') - def contactDeleted(self, entity): - debug("contact deleted signal: %s", entity) + def contactDeleted(self, entity, profile): + debug("contact deleted signal: %s (profile: %s)", entity, profile) @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, signature='ssa{ss}') @@ -106,14 +106,19 @@ ### methods ### @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, + in_signature='s', out_signature='s') + def getProfileName(self, profile_key): + return self.cb["getProfileName"](profile_key) + + @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, in_signature='', out_signature='as') def getProfilesList(self): info ('Profile list asked') return self.cb["getProfilesList"]() @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, - in_signature='sb', out_signature='') - def createProfile(self, name, default=False): + in_signature='s', out_signature='') + def createProfile(self, name): info ('Profile creation asked') return self.cb["createProfile"](name, default) @@ -279,34 +284,34 @@ self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus) self.dbus_bridge = DbusObject(self.session_bus, '/org/goffi/SAT/bridge') - def connected(self): - self.dbus_bridge.connected() + def connected(self, profile): + self.dbus_bridge.connected(profile) - def disconnected(self): - self.dbus_bridge.disconnected() + def disconnected(self, profile): + self.dbus_bridge.disconnected(profile) - def newContact(self, contact, attributes, groups): - self.dbus_bridge.newContact(contact, attributes, groups) + def newContact(self, contact, attributes, groups, profile): + self.dbus_bridge.newContact(contact, attributes, groups, profile) - def newMessage(self,from_jid,msg,type='chat', to=''): + def newMessage(self,from_jid, msg, type, to, profile): debug("sending message...") - self.dbus_bridge.newMessage(from_jid, msg, type, to) + self.dbus_bridge.newMessage(from_jid, msg, type, to, profile) - def presenceUpdate(self, entity, show, priority, statuses): + def presenceUpdate(self, entity, show, priority, statuses, profile): debug("updating presence for %s",entity) - self.dbus_bridge.presenceUpdate(entity, show, priority, statuses) + self.dbus_bridge.presenceUpdate(entity, show, priority, statuses, profile) - def subscribe(self, type, entity): + def subscribe(self, type, entity, profile): debug("subscribe request for %s",entity) - self.dbus_bridge.subscribe(type, entity) + self.dbus_bridge.subscribe(type, entity, profile) - def paramUpdate(self, name, value, category): + def paramUpdate(self, name, value, category, profile): debug("updating param [%s] %s ", category, name) - self.dbus_bridge.paramUpdate(name, value, category) + self.dbus_bridge.paramUpdate(name, value, category, profile) - def contactDeleted(self, entity): + def contactDeleted(self, entity, profile): debug("sending contact deleted signal %s ", entity) - self.dbus_bridge.contactDeleted(entity) + self.dbus_bridge.contactDeleted(entity, profile) def askConfirmation(self, type, id, data): self.dbus_bridge.askConfirmation(type, id, data) @@ -321,7 +326,7 @@ self.dbus_bridge.updatedValue(name, value) def register(self, name, callback): - debug("registering DBus bridge method [%s]",name) + debug("registering DBus bridge method [%s]", name) self.dbus_bridge.register(name, callback) def addMethod(self, name, int_suffix, in_sign, out_sign, method):