Mercurial > libervia-backend
comparison sat_bridge/DBus.py @ 49:9c79eb49d51f
DBus bridge improvment:
- new method to notice clients of updated values
- presence update refactored
- subscriptions management are now separated from presence
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 07 Jan 2010 00:00:25 +1100 |
parents | a61beb21d16d |
children | 6455fb62ff83 |
comparison
equal
deleted
inserted
replaced
48:4392f1fdb064 | 49:9c79eb49d51f |
---|---|
52 signature='ssss') | 52 signature='ssss') |
53 def newMessage(self, from_jid, msg, type='chat', to=''): | 53 def newMessage(self, from_jid, msg, type='chat', to=''): |
54 debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to) | 54 debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to) |
55 | 55 |
56 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, | 56 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, |
57 signature='ssssi') | 57 signature='ssia{ss}') |
58 def presenceUpdate(self, jid, type, show, status, priority): | 58 def presenceUpdate(self, entity, show, priority, statuses): |
59 debug("presence update signal (from:%s type: %s show:%s status:\"%s\" priority:%d) sended" , jid, type, show, status, priority) | 59 debug("presence update signal (from:%s show:%s priority:%d statuses:%s) sended" , entity, show, priority, statuses) |
60 | 60 |
61 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, | |
62 signature='ss') | |
63 def subscribe(self, type, entity): | |
64 debug("subscribe (type: [%s] from:[%s])" , type, entity) | |
65 | |
61 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, | 66 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, |
62 signature='sss') | 67 signature='sss') |
63 def paramUpdate(self, name, value, category): | 68 def paramUpdate(self, name, value, category): |
64 debug("param update signal: %s=%s in category %s", name, value, category) | 69 debug("param update signal: %s=%s in category %s", name, value, category) |
65 | 70 |
66 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, | 71 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, |
67 signature='s') | 72 signature='s') |
68 def contactDeleted(self, jid): | 73 def contactDeleted(self, entity): |
69 debug("contact deleted signal: %s", jid) | 74 debug("contact deleted signal: %s", entity) |
70 | 75 |
71 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, | 76 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, |
72 signature='ssa{ss}') | 77 signature='ssa{ss}') |
73 def askConfirmation(self, type, id, data): | 78 def askConfirmation(self, type, id, data): |
74 debug("asking for confirmation: id = [%s] type = %s data = %s", id, type, data) | 79 debug("asking for confirmation: id = [%s] type = %s data = %s", id, type, data) |
81 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, | 86 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, |
82 signature='ssa{sa{ss}}') | 87 signature='ssa{sa{ss}}') |
83 def actionResultExt(self, type, id, data): | 88 def actionResultExt(self, type, id, data): |
84 debug("extended result of action: id = [%s] type = %s data = %s", id, type, data) | 89 debug("extended result of action: id = [%s] type = %s data = %s", id, type, data) |
85 | 90 |
91 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, | |
92 signature='sa{ss}') | |
93 def updatedValue(self, name, value): | |
94 debug("updated value: %s = %s", name, value) | |
95 | |
86 ### methods ### | 96 ### methods ### |
87 | 97 |
88 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 98 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
89 in_signature='sssi', out_signature='s') | 99 in_signature='sssi', out_signature='s') |
90 def registerNewAccount(self, login, password, host, port=5222): | 100 def registerNewAccount(self, login, password, host, port=5222): |
108 def getContacts(self): | 118 def getContacts(self): |
109 debug("getContacts...") | 119 debug("getContacts...") |
110 return self.cb["getContacts"]() | 120 return self.cb["getContacts"]() |
111 | 121 |
112 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 122 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
113 in_signature='', out_signature='a(ssssi)') | 123 in_signature='', out_signature='a{sa{s(sia{ss})}}') |
114 def getPresenceStatus(self): | 124 def getPresenceStatus(self): |
115 debug("getPresenceStatus...") | 125 debug("getPresenceStatus...") |
116 return self.cb["getPresenceStatus"]() | 126 return self.cb["getPresenceStatus"]() |
127 | |
128 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | |
129 in_signature='', out_signature='a{ss}') | |
130 def getWaitingSub(self): | |
131 debug("getWaitingSub...") | |
132 return self.cb["getWaitingSub"]() | |
117 | 133 |
118 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 134 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
119 in_signature='ss', out_signature='') | 135 in_signature='ss', out_signature='') |
120 def sendMessage(self, to, message): | 136 def sendMessage(self, to, message): |
121 debug("sendMessage...") | 137 debug("sendMessage...") |
122 self.cb["sendMessage"](to, message) | 138 self.cb["sendMessage"](to, message) |
123 | 139 |
124 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 140 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
125 in_signature='ssssi', out_signature='') | 141 in_signature='ssia{ss}', out_signature='') |
126 def setPresence(self, to="", type="", show="", status="", priority=0): | 142 def setPresence(self, to="", show="", priority=0, statuses={}): |
127 self.cb["setPresence"](to, type, show, status, priority) | 143 self.cb["setPresence"](to, show, priority, statuses) |
144 | |
145 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | |
146 in_signature='ss', out_signature='') | |
147 def subscription(self, type, entity): | |
148 self.cb["subscription"](type, entity) | |
128 | 149 |
129 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 150 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
130 in_signature='sss', out_signature='') | 151 in_signature='sss', out_signature='') |
131 def setParam(self, name, value, category): | 152 def setParam(self, name, value, category): |
132 self.cb["setParam"](name, str(value), category) | 153 self.cb["setParam"](name, str(value), category) |
157 debug("History asked for %s", to_jid) | 178 debug("History asked for %s", to_jid) |
158 return self.cb["getHistory"](from_jid, to_jid, size) | 179 return self.cb["getHistory"](from_jid, to_jid, size) |
159 | 180 |
160 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 181 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
161 in_signature='s', out_signature='') | 182 in_signature='s', out_signature='') |
162 def addContact(self, jid): | 183 def addContact(self, entity): |
163 debug("Subscription asked for %s", jid) | 184 debug("Subscription asked for %s", entity) |
164 return self.cb["addContact"](jid) | 185 return self.cb["addContact"](entity) |
165 | 186 |
166 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 187 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
167 in_signature='s', out_signature='') | 188 in_signature='s', out_signature='') |
168 def delContact(self, jid): | 189 def delContact(self, entity): |
169 debug("Unsubscription asked for %s", jid) | 190 debug("Unsubscription asked for %s", entity) |
170 return self.cb["delContact"](jid) | 191 return self.cb["delContact"](entity) |
171 | 192 |
172 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, | 193 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, |
173 in_signature='', out_signature='b') | 194 in_signature='', out_signature='b') |
174 def isConnected(self): | 195 def isConnected(self): |
175 debug("Connection status requested") | 196 debug("Connection status requested") |
241 | 262 |
242 def newMessage(self,from_jid,msg,type='chat', to=''): | 263 def newMessage(self,from_jid,msg,type='chat', to=''): |
243 debug("sending message...") | 264 debug("sending message...") |
244 self.dbus_bridge.newMessage(from_jid, msg, type, to) | 265 self.dbus_bridge.newMessage(from_jid, msg, type, to) |
245 | 266 |
246 def presenceUpdate(self, jid, type, show, status, priority): | 267 def presenceUpdate(self, entity, show, priority, statuses): |
247 debug("updating presence for %s",jid) | 268 debug("updating presence for %s",entity) |
248 self.dbus_bridge.presenceUpdate(jid, type, show, status, priority) | 269 self.dbus_bridge.presenceUpdate(entity, show, priority, statuses) |
270 | |
271 def subscribe(self, type, entity): | |
272 debug("subscribe request for %s",entity) | |
273 self.dbus_bridge.subscribe(type, entity) | |
249 | 274 |
250 def paramUpdate(self, name, value, category): | 275 def paramUpdate(self, name, value, category): |
251 debug("updating param [%s] %s ", category, name) | 276 debug("updating param [%s] %s ", category, name) |
252 self.dbus_bridge.paramUpdate(name, value, category) | 277 self.dbus_bridge.paramUpdate(name, value, category) |
253 | 278 |
254 def contactDeleted(self, jid): | 279 def contactDeleted(self, entity): |
255 debug("sending contact deleted signal %s ", jid) | 280 debug("sending contact deleted signal %s ", entity) |
256 self.dbus_bridge.contactDeleted(jid) | 281 self.dbus_bridge.contactDeleted(entity) |
257 | 282 |
258 def askConfirmation(self, type, id, data): | 283 def askConfirmation(self, type, id, data): |
259 self.dbus_bridge.askConfirmation(type, id, data) | 284 self.dbus_bridge.askConfirmation(type, id, data) |
260 | 285 |
261 def actionResult(self, type, id, data): | 286 def actionResult(self, type, id, data): |
262 self.dbus_bridge.actionResult(type, id, data) | 287 self.dbus_bridge.actionResult(type, id, data) |
263 | 288 |
264 def actionResultExt(self, type, id, data): | 289 def actionResultExt(self, type, id, data): |
265 self.dbus_bridge.actionResultExt(type, id, data) | 290 self.dbus_bridge.actionResultExt(type, id, data) |
291 | |
292 def updatedValue(self, name, value): | |
293 self.dbus_bridge.updatedValue(name, value) | |
266 | 294 |
267 def register(self, name, callback): | 295 def register(self, name, callback): |
268 debug("registering DBus bridge method [%s]",name) | 296 debug("registering DBus bridge method [%s]",name) |
269 self.dbus_bridge.register(name, callback) | 297 self.dbus_bridge.register(name, callback) |
270 | 298 |