# HG changeset patch # User Goffi # Date 1262782825 -39600 # Node ID 9c79eb49d51fa28a0e0351f6506e4f75d88cfba4 # Parent 4392f1fdb0640233bdfb4700fec7aae40fc29532 DBus bridge improvment: - new method to notice clients of updated values - presence update refactored - subscriptions management are now separated from presence diff -r 4392f1fdb064 -r 9c79eb49d51f sat_bridge/DBus.py --- a/sat_bridge/DBus.py Wed Jan 06 23:56:44 2010 +1100 +++ b/sat_bridge/DBus.py Thu Jan 07 00:00:25 2010 +1100 @@ -54,19 +54,24 @@ 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='ssssi') - def presenceUpdate(self, jid, type, show, status, priority): - debug("presence update signal (from:%s type: %s show:%s status:\"%s\" priority:%d) sended" , jid, type, show, status, priority) + 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) @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, jid): - debug("contact deleted signal: %s", jid) + def contactDeleted(self, entity): + debug("contact deleted signal: %s", entity) @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, signature='ssa{ss}') @@ -83,6 +88,11 @@ def actionResultExt(self, type, id, data): debug("extended result of action: id = [%s] type = %s data = %s", id, type, data) + @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, + signature='sa{ss}') + def updatedValue(self, name, value): + debug("updated value: %s = %s", name, value) + ### methods ### @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, @@ -110,21 +120,32 @@ return self.cb["getContacts"]() @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, - in_signature='', out_signature='a(ssssi)') + in_signature='', out_signature='a{sa{s(sia{ss})}}') def getPresenceStatus(self): debug("getPresenceStatus...") return self.cb["getPresenceStatus"]() @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, + in_signature='', out_signature='a{ss}') + def getWaitingSub(self): + debug("getWaitingSub...") + return self.cb["getWaitingSub"]() + + @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ss', out_signature='') def sendMessage(self, to, message): debug("sendMessage...") self.cb["sendMessage"](to, message) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, - in_signature='ssssi', out_signature='') - def setPresence(self, to="", type="", show="", status="", priority=0): - self.cb["setPresence"](to, type, show, status, priority) + in_signature='ssia{ss}', out_signature='') + def setPresence(self, to="", show="", priority=0, statuses={}): + self.cb["setPresence"](to, show, priority, statuses) + + @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, + in_signature='ss', out_signature='') + def subscription(self, type, entity): + self.cb["subscription"](type, entity) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='sss', out_signature='') @@ -159,15 +180,15 @@ @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='') - def addContact(self, jid): - debug("Subscription asked for %s", jid) - return self.cb["addContact"](jid) + def addContact(self, entity): + debug("Subscription asked for %s", entity) + return self.cb["addContact"](entity) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='s', out_signature='') - def delContact(self, jid): - debug("Unsubscription asked for %s", jid) - return self.cb["delContact"](jid) + def delContact(self, entity): + debug("Unsubscription asked for %s", entity) + return self.cb["delContact"](entity) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='', out_signature='b') @@ -243,17 +264,21 @@ debug("sending message...") self.dbus_bridge.newMessage(from_jid, msg, type, to) - def presenceUpdate(self, jid, type, show, status, priority): - debug("updating presence for %s",jid) - self.dbus_bridge.presenceUpdate(jid, type, show, status, priority) + def presenceUpdate(self, entity, show, priority, statuses): + debug("updating presence for %s",entity) + self.dbus_bridge.presenceUpdate(entity, show, priority, statuses) + + def subscribe(self, type, entity): + debug("subscribe request for %s",entity) + self.dbus_bridge.subscribe(type, entity) def paramUpdate(self, name, value, category): debug("updating param [%s] %s ", category, name) self.dbus_bridge.paramUpdate(name, value, category) - def contactDeleted(self, jid): - debug("sending contact deleted signal %s ", jid) - self.dbus_bridge.contactDeleted(jid) + def contactDeleted(self, entity): + debug("sending contact deleted signal %s ", entity) + self.dbus_bridge.contactDeleted(entity) def askConfirmation(self, type, id, data): self.dbus_bridge.askConfirmation(type, id, data) @@ -264,6 +289,9 @@ def actionResultExt(self, type, id, data): self.dbus_bridge.actionResultExt(type, id, data) + def updatedValue(self, name, value): + self.dbus_bridge.updatedValue(name, value) + def register(self, name, callback): debug("registering DBus bridge method [%s]",name) self.dbus_bridge.register(name, callback)