comparison src/bridge/DBus.py @ 272:1d2e0dfe7114

bridge: core & frontend sides of bridge are now generated
author Goffi <goffi@goffi.org>
date Mon, 24 Jan 2011 22:05:04 +0100
parents bdcd535e179e
children c1ad04586edf
comparison
equal deleted inserted replaced
271:0288f97334f2 272:1d2e0dfe7114
22 22
23 from bridge import Bridge 23 from bridge import Bridge
24 import dbus 24 import dbus
25 import dbus.service 25 import dbus.service
26 import dbus.mainloop.glib 26 import dbus.mainloop.glib
27 from logging import debug, info, error 27 from logging import debug, info
28 28
29 const_INT_PREFIX = "org.goffi.SAT" #Interface prefix 29 const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
30 const_COMM_SUFFIX = ".communication" 30 const_COMM_SUFFIX = ".communication"
31 const_REQ_SUFFIX = ".request" 31 const_REQ_SUFFIX = ".request"
32 32
43 ### signals ### 43 ### signals ###
44 44
45 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, 45 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
46 signature='ssa{ss}') 46 signature='ssa{ss}')
47 def actionResult(self, answer_type, id, data): 47 def actionResult(self, answer_type, id, data):
48 pass 48 debug ("actionResult")
49 49
50 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, 50 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
51 signature='ssa{sa{ss}}') 51 signature='ssa{sa{ss}}')
52 def actionResultExt(self, answer_type, id, data): 52 def actionResultExt(self, answer_type, id, data):
53 pass 53 debug ("actionResultExt")
54 54
55 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, 55 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
56 signature='ssa{ss}') 56 signature='ssa{ss}')
57 def askConfirmation(self, conf_type, id, data): 57 def askConfirmation(self, conf_type, id, data):
58 pass 58 debug ("askConfirmation")
59 59
60 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 60 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
61 signature='s') 61 signature='s')
62 def connected(self, profile): 62 def connected(self, profile):
63 pass 63 debug ("connected")
64 64
65 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 65 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66 signature='ss') 66 signature='ss')
67 def connection_error(self, error_type, profile): 67 def connection_error(self, error_type, profile):
68 pass 68 debug ("connection_error")
69 69
70 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 70 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
71 signature='ss') 71 signature='ss')
72 def contactDeleted(self, entity, profile): 72 def contactDeleted(self, entity, profile):
73 pass 73 debug ("contactDeleted")
74 74
75 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 75 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
76 signature='s') 76 signature='s')
77 def disconnected(self, profile): 77 def disconnected(self, profile):
78 pass 78 debug ("disconnected")
79 79
80 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 80 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
81 signature='ssss') 81 signature='ssss')
82 def newAlert(self, message, title, alert_type, profile): 82 def newAlert(self, message, title, alert_type, profile):
83 pass 83 debug ("newAlert")
84 84
85 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 85 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
86 signature='sa{ss}ass') 86 signature='sa{ss}ass')
87 def newContact(self, contact, attributes, groups, profile): 87 def newContact(self, contact, attributes, groups, profile):
88 pass 88 debug ("newContact")
89 89
90 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 90 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
91 signature='sssss') 91 signature='sssss')
92 def newMessage(self, from_jid, message, mess_type, to_jid, profile): 92 def newMessage(self, from_jid, message, mess_type, to_jid, profile):
93 pass 93 debug ("newMessage")
94 94
95 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 95 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
96 signature='ssss') 96 signature='ssss')
97 def paramUpdate(self, name, value, category, profile): 97 def paramUpdate(self, name, value, category, profile):
98 pass 98 debug ("paramUpdate")
99 99
100 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 100 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
101 signature='ssia{ss}s') 101 signature='ssia{ss}s')
102 def presenceUpdate(self, entity, show, priority, statuses, profile): 102 def presenceUpdate(self, entity, show, priority, statuses, profile):
103 pass 103 debug ("presenceUpdate")
104 104
105 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 105 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
106 signature='sss') 106 signature='sss')
107 def subscribe(self, sub_type, entity, profile): 107 def subscribe(self, sub_type, entity, profile):
108 pass 108 debug ("subscribe")
109 109
110 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX, 110 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
111 signature='sa{ss}') 111 signature='sa{ss}')
112 def updatedValue(self, name, value): 112 def updatedValue(self, name, value):
113 pass 113 debug ("updatedValue")
114 114
115 115
116 ### methods ### 116 ### methods ###
117 117
118 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 118 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
119 in_signature='ss', out_signature='') 119 in_signature='ss', out_signature='')
120 def addContact(self, entity, profile_key="@DEFAULT@"): 120 def addContact(self, entity, profile_key="@DEFAULT@"):
121 debug ("addContact")
121 return self.cb["addContact"](unicode(entity), unicode(profile_key)) 122 return self.cb["addContact"](unicode(entity), unicode(profile_key))
122 123
123 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 124 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
124 in_signature='ssss', out_signature='s') 125 in_signature='ssss', out_signature='s')
125 def callMenu(self, category, name, menu_type, profile_key): 126 def callMenu(self, category, name, menu_type, profile_key):
127 debug ("callMenu")
126 return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key)) 128 return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key))
127 129
128 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 130 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
129 in_signature='sba{ss}', out_signature='') 131 in_signature='sba{ss}', out_signature='')
130 def confirmationAnswer(self, id, accepted, data): 132 def confirmationAnswer(self, id, accepted, data):
133 debug ("confirmationAnswer")
131 return self.cb["confirmationAnswer"](unicode(id), accepted, data) 134 return self.cb["confirmationAnswer"](unicode(id), accepted, data)
132 135
133 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 136 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
134 in_signature='s', out_signature='') 137 in_signature='s', out_signature='')
135 def connect(self, profile_key="@DEFAULT@"): 138 def connect(self, profile_key="@DEFAULT@"):
139 debug ("connect")
136 return self.cb["connect"](unicode(profile_key)) 140 return self.cb["connect"](unicode(profile_key))
137 141
138 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 142 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
139 in_signature='s', out_signature='i') 143 in_signature='s', out_signature='i')
140 def createProfile(self, profile): 144 def createProfile(self, profile):
145 debug ("createProfile")
141 return self.cb["createProfile"](unicode(profile)) 146 return self.cb["createProfile"](unicode(profile))
142 147
143 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 148 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
144 in_signature='ss', out_signature='') 149 in_signature='ss', out_signature='')
145 def delContact(self, entity, profile_key="@DEFAULT@"): 150 def delContact(self, entity, profile_key="@DEFAULT@"):
151 debug ("delContact")
146 return self.cb["delContact"](unicode(entity), unicode(profile_key)) 152 return self.cb["delContact"](unicode(entity), unicode(profile_key))
147 153
148 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 154 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
149 in_signature='s', out_signature='i') 155 in_signature='s', out_signature='i')
150 def deleteProfile(self, profile): 156 def deleteProfile(self, profile):
157 debug ("deleteProfile")
151 return self.cb["deleteProfile"](unicode(profile)) 158 return self.cb["deleteProfile"](unicode(profile))
152 159
153 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 160 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
154 in_signature='s', out_signature='') 161 in_signature='s', out_signature='')
155 def disconnect(self, profile_key="@DEFAULT@"): 162 def disconnect(self, profile_key="@DEFAULT@"):
163 debug ("disconnect")
156 return self.cb["disconnect"](unicode(profile_key)) 164 return self.cb["disconnect"](unicode(profile_key))
157 165
158 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 166 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
159 in_signature='s', out_signature='a(sa{ss}as)') 167 in_signature='s', out_signature='a(sa{ss}as)')
160 def getContacts(self, profile_key="@DEFAULT@"): 168 def getContacts(self, profile_key="@DEFAULT@"):
169 debug ("getContacts")
161 return self.cb["getContacts"](unicode(profile_key)) 170 return self.cb["getContacts"](unicode(profile_key))
162 171
163 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 172 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
164 in_signature='ssi', out_signature='a{i(ss)}') 173 in_signature='ssi', out_signature='a{i(ss)}')
165 def getHistory(self, from_jid, to_jid, size): 174 def getHistory(self, from_jid, to_jid, size):
175 debug ("getHistory")
166 return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size) 176 return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size)
167 177
168 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 178 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
169 in_signature='sss', out_signature='s') 179 in_signature='sss', out_signature='s')
170 def getMenuHelp(self, category, name, menu_type): 180 def getMenuHelp(self, category, name, menu_type):
181 debug ("getMenuHelp")
171 return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type)) 182 return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type))
172 183
173 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 184 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
174 in_signature='', out_signature='a(sss)') 185 in_signature='', out_signature='a(sss)')
175 def getMenus(self, ): 186 def getMenus(self, ):
187 debug ("getMenus")
176 return self.cb["getMenus"]() 188 return self.cb["getMenus"]()
177 189
178 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 190 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
179 in_signature='sss', out_signature='s') 191 in_signature='ssss', out_signature='s')
180 def getParamA(self, name, category, profile_key="@DEFAULT@"): 192 def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"):
181 return self.cb["getParamA"](unicode(name), unicode(category), unicode(profile_key)) 193 debug ("getParamA")
194 return self.cb["getParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key))
182 195
183 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 196 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
184 in_signature='s', out_signature='s') 197 in_signature='s', out_signature='s')
185 def getParams(self, profile_key="@DEFAULT@"): 198 def getParams(self, profile_key="@DEFAULT@"):
199 debug ("getParams")
186 return self.cb["getParams"](unicode(profile_key)) 200 return self.cb["getParams"](unicode(profile_key))
187 201
188 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 202 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
189 in_signature='', out_signature='as') 203 in_signature='', out_signature='as')
190 def getParamsCategories(self, ): 204 def getParamsCategories(self, ):
205 debug ("getParamsCategories")
191 return self.cb["getParamsCategories"]() 206 return self.cb["getParamsCategories"]()
192 207
193 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 208 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
194 in_signature='ss', out_signature='s') 209 in_signature='ss', out_signature='s')
195 def getParamsForCategory(self, category, profile_key="@DEFAULT@"): 210 def getParamsForCategory(self, category, profile_key="@DEFAULT@"):
211 debug ("getParamsForCategory")
196 return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key)) 212 return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key))
197 213
198 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 214 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
199 in_signature='s', out_signature='s') 215 in_signature='s', out_signature='s')
200 def getParamsUI(self, profile_key="@DEFAULT@"): 216 def getParamsUI(self, profile_key="@DEFAULT@"):
217 debug ("getParamsUI")
201 return self.cb["getParamsUI"](unicode(profile_key)) 218 return self.cb["getParamsUI"](unicode(profile_key))
202 219
203 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 220 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
204 in_signature='s', out_signature='a{sa{s(sia{ss})}}') 221 in_signature='s', out_signature='a{sa{s(sia{ss})}}')
205 def getPresenceStatus(self, profile_key="@DEFAULT@"): 222 def getPresenceStatus(self, profile_key="@DEFAULT@"):
223 debug ("getPresenceStatus")
206 return self.cb["getPresenceStatus"](unicode(profile_key)) 224 return self.cb["getPresenceStatus"](unicode(profile_key))
207 225
208 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 226 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
209 in_signature='s', out_signature='s') 227 in_signature='s', out_signature='s')
210 def getProfileName(self, profile_key="@DEFAULT@"): 228 def getProfileName(self, profile_key="@DEFAULT@"):
229 debug ("getProfileName")
211 return self.cb["getProfileName"](unicode(profile_key)) 230 return self.cb["getProfileName"](unicode(profile_key))
212 231
213 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 232 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
214 in_signature='', out_signature='as') 233 in_signature='', out_signature='as')
215 def getProfilesList(self, ): 234 def getProfilesList(self, ):
235 debug ("getProfilesList")
216 return self.cb["getProfilesList"]() 236 return self.cb["getProfilesList"]()
217 237
218 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 238 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
219 in_signature='s', out_signature='a{ss}') 239 in_signature='s', out_signature='a{ss}')
220 def getProgress(self, id): 240 def getProgress(self, id):
241 debug ("getProgress")
221 return self.cb["getProgress"](unicode(id)) 242 return self.cb["getProgress"](unicode(id))
222 243
223 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 244 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
224 in_signature='', out_signature='s') 245 in_signature='', out_signature='s')
225 def getVersion(self, ): 246 def getVersion(self, ):
247 debug ("getVersion")
226 return self.cb["getVersion"]() 248 return self.cb["getVersion"]()
227 249
228 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 250 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
229 in_signature='s', out_signature='a{ss}') 251 in_signature='s', out_signature='a{ss}')
230 def getWaitingSub(self, profile_key="@DEFAULT@"): 252 def getWaitingSub(self, profile_key="@DEFAULT@"):
253 debug ("getWaitingSub")
231 return self.cb["getWaitingSub"](unicode(profile_key)) 254 return self.cb["getWaitingSub"](unicode(profile_key))
232 255
233 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 256 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
234 in_signature='s', out_signature='b') 257 in_signature='s', out_signature='b')
235 def isConnected(self, profile_key="@DEFAULT@"): 258 def isConnected(self, profile_key="@DEFAULT@"):
259 debug ("isConnected")
236 return self.cb["isConnected"](unicode(profile_key)) 260 return self.cb["isConnected"](unicode(profile_key))
237 261
238 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 262 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
239 in_signature='sa{ss}s', out_signature='s') 263 in_signature='sa{ss}s', out_signature='s')
240 def launchAction(self, action_type, data, profile_key="@DEFAULT@"): 264 def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
265 debug ("launchAction")
241 return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key)) 266 return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key))
242 267
243 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 268 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
244 in_signature='sssi', out_signature='s') 269 in_signature='sssi', out_signature='s')
245 def registerNewAccount(self, login, password, host, port=5222): 270 def registerNewAccount(self, login, password, host, port=5222):
271 debug ("registerNewAccount")
246 return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(host), port) 272 return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(host), port)
247 273
248 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 274 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
249 in_signature='sssss', out_signature='') 275 in_signature='sssss', out_signature='')
250 def sendMessage(self, to_jid, message, subject=, mess_type="chat", profile_key="@DEFAULT@"): 276 def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"):
277 debug ("sendMessage")
251 return self.cb["sendMessage"](unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key)) 278 return self.cb["sendMessage"](unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key))
252 279
253 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 280 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
254 in_signature='ssss', out_signature='') 281 in_signature='ssss', out_signature='')
255 def setParam(self, name, value, category, profile_key="@DEFAULT@"): 282 def setParam(self, name, value, category, profile_key="@DEFAULT@"):
283 debug ("setParam")
256 return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key)) 284 return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key))
257 285
258 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 286 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
259 in_signature='ssia{ss}s', out_signature='') 287 in_signature='ssia{ss}s', out_signature='')
260 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"): 288 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
289 debug ("setPresence")
261 return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key)) 290 return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key))
262 291
263 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 292 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
264 in_signature='sss', out_signature='') 293 in_signature='sss', out_signature='')
265 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"): 294 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
295 debug ("subscription")
266 return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key)) 296 return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key))
267 297
268 298
269 def __attribute_string(self, in_sign): 299 def __attribute_string(self, in_sign):
270 """Return arguments to user given a in_sign 300 """Return arguments to user given a in_sign