comparison src/bridge/DBus.py @ 267:bdcd535e179e

Bridge constructor: - moved constructor files in src/bridge/bridge_constructor - frontend side can now be generated
author Goffi <goffi@goffi.org>
date Mon, 24 Jan 2011 21:19:11 +0100
parents c4b84a2d2ad1
children 1d2e0dfe7114
comparison
equal deleted inserted replaced
266:c4b84a2d2ad1 267:bdcd535e179e
40 def register(self, name, cb): 40 def register(self, name, cb):
41 self.cb[name]=cb 41 self.cb[name]=cb
42 42
43 ### signals ### 43 ### signals ###
44 44
45 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
46 signature='ssa{ss}')
47 def actionResult(self, answer_type, id, data):
48 pass
49
50 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
51 signature='ssa{sa{ss}}')
52 def actionResultExt(self, answer_type, id, data):
53 pass
54
55 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
56 signature='ssa{ss}')
57 def askConfirmation(self, conf_type, id, data):
58 pass
59
45 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 60 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
46 signature='s') 61 signature='s')
47 def connected(self, profile): 62 def connected(self, profile):
48 debug("Connected signal") 63 pass
49 64
65 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66 signature='ss')
67 def connection_error(self, error_type, profile):
68 pass
69
70 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
71 signature='ss')
72 def contactDeleted(self, entity, profile):
73 pass
74
50 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 75 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
51 signature='s') 76 signature='s')
52 def disconnected(self, profile): 77 def disconnected(self, profile):
53 debug("Disconnected signal") 78 pass
54 79
55 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 80 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
56 signature='ss') 81 signature='ssss')
57 def connection_error(self, error_type, profile): 82 def newAlert(self, message, title, alert_type, profile):
58 debug("Connection_error signal") 83 pass
59 84
60 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 85 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
61 signature='sa{ss}ass') 86 signature='sa{ss}ass')
62 def newContact(self, contact, attributes, groups, profile): 87 def newContact(self, contact, attributes, groups, profile):
63 debug("new contact signal (%s) sended (profile: %s)", contact, profile) 88 pass
64 89
65 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 90 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
66 signature='sssss') 91 signature='sssss')
67 def newMessage(self, from_jid, msg, type, to, profile): 92 def newMessage(self, from_jid, message, mess_type, to_jid, profile):
68 debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to) 93 pass
69 94
70 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 95 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
71 signature='ssss') 96 signature='ssss')
72 def newAlert(self, msg, title, type, profile): 97 def paramUpdate(self, name, value, category, profile):
73 debug("new alert signal (title:%s type:%s msg:%s profile:%s) sended", type, title, msg, profile) 98 pass
74 99
75 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 100 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
76 signature='ssia{ss}s') 101 signature='ssia{ss}s')
77 def presenceUpdate(self, entity, show, priority, statuses, profile): 102 def presenceUpdate(self, entity, show, priority, statuses, profile):
78 debug("presence update signal (from:%s show:%s priority:%d statuses:%s profile:%s) sended" , entity, show, priority, statuses, profile) 103 pass
79 104
80 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, 105 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
81 signature='sss') 106 signature='sss')
82 def subscribe(self, type, entity, profile): 107 def subscribe(self, sub_type, entity, profile):
83 debug("subscribe (type: [%s] from:[%s] profile:[%s])" , type, entity, profile) 108 pass
84 109
85 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
86 signature='ssss')
87 def paramUpdate(self, name, value, category, profile):
88 debug("param update signal: %s=%s in category %s (profile: %s)", name, value, category, profile)
89
90 @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX,
91 signature='ss')
92 def contactDeleted(self, entity, profile):
93 debug("contact deleted signal: %s (profile: %s)", entity, profile)
94
95 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
96 signature='ssa{ss}')
97 def askConfirmation(self, type, id, data):
98 debug("asking for confirmation: id = [%s] type = %s data = %s", id, type, data)
99
100 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
101 signature='ssa{ss}')
102 def actionResult(self, type, id, data):
103 debug("result of action: id = [%s] type = %s data = %s", id, type, data)
104
105 @dbus.service.signal(const_INT_PREFIX+const_REQ_SUFFIX,
106 signature='ssa{sa{ss}}')
107 def actionResultExt(self, type, id, data):
108 debug("extended result of action: id = [%s] type = %s data = %s", id, type, data)
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 debug("updated value: %s = %s", name, value) 113 pass
114
114 115
115 ### methods ### 116 ### methods ###
116
117 117
118 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
119 in_signature='ss', out_signature='')
120 def addContact(self, entity, profile_key="@DEFAULT@"):
121 return self.cb["addContact"](unicode(entity), unicode(profile_key))
122
123 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
124 in_signature='ssss', out_signature='s')
125 def callMenu(self, category, name, menu_type, profile_key):
126 return self.cb["callMenu"](unicode(category), unicode(name), unicode(menu_type), unicode(profile_key))
127
128 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
129 in_signature='sba{ss}', out_signature='')
130 def confirmationAnswer(self, id, accepted, data):
131 return self.cb["confirmationAnswer"](unicode(id), accepted, data)
132
133 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
134 in_signature='s', out_signature='')
135 def connect(self, profile_key="@DEFAULT@"):
136 return self.cb["connect"](unicode(profile_key))
137
138 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
139 in_signature='s', out_signature='i')
140 def createProfile(self, profile):
141 return self.cb["createProfile"](unicode(profile))
142
143 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
144 in_signature='ss', out_signature='')
145 def delContact(self, entity, profile_key="@DEFAULT@"):
146 return self.cb["delContact"](unicode(entity), unicode(profile_key))
147
148 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
149 in_signature='s', out_signature='i')
150 def deleteProfile(self, profile):
151 return self.cb["deleteProfile"](unicode(profile))
152
153 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
154 in_signature='s', out_signature='')
155 def disconnect(self, profile_key="@DEFAULT@"):
156 return self.cb["disconnect"](unicode(profile_key))
157
158 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
159 in_signature='s', out_signature='a(sa{ss}as)')
160 def getContacts(self, profile_key="@DEFAULT@"):
161 return self.cb["getContacts"](unicode(profile_key))
162
163 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
164 in_signature='ssi', out_signature='a{i(ss)}')
165 def getHistory(self, from_jid, to_jid, size):
166 return self.cb["getHistory"](unicode(from_jid), unicode(to_jid), size)
167
168 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
169 in_signature='sss', out_signature='s')
170 def getMenuHelp(self, category, name, menu_type):
171 return self.cb["getMenuHelp"](unicode(category), unicode(name), unicode(menu_type))
172
173 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
174 in_signature='', out_signature='a(sss)')
175 def getMenus(self, ):
176 return self.cb["getMenus"]()
177
178 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
179 in_signature='sss', out_signature='s')
180 def getParamA(self, name, category, profile_key="@DEFAULT@"):
181 return self.cb["getParamA"](unicode(name), unicode(category), unicode(profile_key))
182
183 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
184 in_signature='s', out_signature='s')
185 def getParams(self, profile_key="@DEFAULT@"):
186 return self.cb["getParams"](unicode(profile_key))
187
188 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
189 in_signature='', out_signature='as')
190 def getParamsCategories(self, ):
191 return self.cb["getParamsCategories"]()
192
193 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
194 in_signature='ss', out_signature='s')
195 def getParamsForCategory(self, category, profile_key="@DEFAULT@"):
196 return self.cb["getParamsForCategory"](unicode(category), unicode(profile_key))
197
198 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
199 in_signature='s', out_signature='s')
200 def getParamsUI(self, profile_key="@DEFAULT@"):
201 return self.cb["getParamsUI"](unicode(profile_key))
202
203 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
204 in_signature='s', out_signature='a{sa{s(sia{ss})}}')
205 def getPresenceStatus(self, profile_key="@DEFAULT@"):
206 return self.cb["getPresenceStatus"](unicode(profile_key))
207
208 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
209 in_signature='s', out_signature='s')
210 def getProfileName(self, profile_key="@DEFAULT@"):
211 return self.cb["getProfileName"](unicode(profile_key))
212
213 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
214 in_signature='', out_signature='as')
215 def getProfilesList(self, ):
216 return self.cb["getProfilesList"]()
217
218 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
219 in_signature='s', out_signature='a{ss}')
220 def getProgress(self, id):
221 return self.cb["getProgress"](unicode(id))
222
118 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 223 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
119 in_signature='', out_signature='s') 224 in_signature='', out_signature='s')
120 def getVersion(self): 225 def getVersion(self, ):
121 return self.cb["getVersion"]() 226 return self.cb["getVersion"]()
122 227
123 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 228 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
124 in_signature='s', out_signature='s') 229 in_signature='s', out_signature='a{ss}')
125 def getProfileName(self, profile_key): 230 def getWaitingSub(self, profile_key="@DEFAULT@"):
126 return self.cb["getProfileName"](profile_key) 231 return self.cb["getWaitingSub"](unicode(profile_key))
127 232
128 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 233 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
129 in_signature='', out_signature='as') 234 in_signature='s', out_signature='b')
130 def getProfilesList(self): 235 def isConnected(self, profile_key="@DEFAULT@"):
131 info ('Profile list asked') 236 return self.cb["isConnected"](unicode(profile_key))
132 return self.cb["getProfilesList"]() 237
133 238 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
134 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX, 239 in_signature='sa{ss}s', out_signature='s')
135 in_signature='s', out_signature='i') 240 def launchAction(self, action_type, data, profile_key="@DEFAULT@"):
136 def createProfile(self, name): 241 return self.cb["launchAction"](unicode(action_type), data, unicode(profile_key))
137 info ('Profile creation asked')
138 return self.cb["createProfile"](unicode(name))
139
140 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
141 in_signature='s', out_signature='i')
142 def deleteProfile(self, name):
143 info ('Profile deletion asked')
144 return self.cb["deleteProfile"](unicode(name))
145 242
146 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 243 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
147 in_signature='sssi', out_signature='s') 244 in_signature='sssi', out_signature='s')
148 def registerNewAccount(self, login, password, host, port=5222): 245 def registerNewAccount(self, login, password, host, port=5222):
149 info ("New account registration asked") 246 return self.cb["registerNewAccount"](unicode(login), unicode(password), unicode(host), port)
150 return self.cb["registerNewAccount"](login, password, host, port)
151
152 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
153 in_signature='s', out_signature='')
154 def connect(self, profile_key='@DEFAULT@'):
155 info ("Connection asked")
156 return self.cb["connect"](profile_key)
157
158 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
159 in_signature='s', out_signature='')
160 def disconnect(self, profile_key='@DEFAULT@'):
161 info ("Disconnection asked")
162 return self.cb["disconnect"](profile_key)
163
164 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
165 in_signature='s', out_signature='b')
166 def isConnected(self, profile_key='@DEFAULT@'):
167 info ("Connection status asked")
168 return self.cb["isConnected"](profile_key)
169
170 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
171 in_signature='s', out_signature='a(sa{ss}as)')
172 def getContacts(self, profile_key='@DEFAULT@'):
173 debug("getContacts...")
174 return self.cb["getContacts"](profile_key)
175
176 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
177 in_signature='s', out_signature='a{sa{s(sia{ss})}}')
178 def getPresenceStatus(self, profile_key='@DEFAULT@'):
179 debug("getPresenceStatus...")
180 return self.cb["getPresenceStatus"](profile_key)
181
182 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
183 in_signature='s', out_signature='a{ss}')
184 def getWaitingSub(self, profile_key='@DEFAULT@'):
185 debug("getWaitingSub...")
186 return self.cb["getWaitingSub"](profile_key)
187 247
188 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 248 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
189 in_signature='sssss', out_signature='') 249 in_signature='sssss', out_signature='')
190 def sendMessage(self, to, message, subject="", type='chat', profile_key='@DEFAULT@'): 250 def sendMessage(self, to_jid, message, subject=, mess_type="chat", profile_key="@DEFAULT@"):
191 debug("sendMessage...") 251 return self.cb["sendMessage"](unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key))
192 print "sendtype=", type #gof 252
193 self.cb["sendMessage"](to, message, subject, type, profile_key) 253 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
254 in_signature='ssss', out_signature='')
255 def setParam(self, name, value, category, profile_key="@DEFAULT@"):
256 return self.cb["setParam"](unicode(name), unicode(value), unicode(category), unicode(profile_key))
194 257
195 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 258 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
196 in_signature='ssia{ss}s', out_signature='') 259 in_signature='ssia{ss}s', out_signature='')
197 def setPresence(self, to="", show="", priority=0, statuses={}, profile_key='@DEFAULT@'): 260 def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
198 self.cb["setPresence"](to, show, priority, statuses, profile_key) 261 return self.cb["setPresence"](unicode(to_jid), unicode(show), priority, statuses, unicode(profile_key))
199 262
200 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, 263 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
201 in_signature='sss', out_signature='') 264 in_signature='sss', out_signature='')
202 def subscription(self, type, entity, profile_key='@DEFAULT@'): 265 def subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
203 self.cb["subscription"](type, entity, profile_key) 266 return self.cb["subscription"](unicode(sub_type), unicode(entity), unicode(profile_key))
204 267
205 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
206 in_signature='ssss', out_signature='')
207 def setParam(self, name, value, category, profile_key='@DEFAULT@'):
208 self.cb["setParam"](unicode(name), unicode(value), unicode(category), profile_key)
209
210 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
211 in_signature='sss', out_signature='s')
212 def getParamA(self, name, category="default", profile_key='@DEFAULT@'):
213 return self.cb["getParamA"](name, category, profile_key = profile_key)
214
215
216 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
217 in_signature='s', out_signature='s')
218 def getParamsUI(self, profile_key='@DEFAULT@'):
219 return self.cb["getParamsUI"](profile_key)
220
221 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
222 in_signature='s', out_signature='s')
223 def getParams(self, profile_key='@DEFAULT@'):
224 return self.cb["getParams"](profile_key)
225
226 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
227 in_signature='ss', out_signature='s')
228 def getParamsForCategory(self, category, profile_key='@DEFAULT@'):
229 return self.cb["getParamsForCategory"](category, profile_key)
230
231 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
232 in_signature='', out_signature='as')
233 def getParamsCategories(self):
234 return self.cb["getParamsCategories"]()
235
236 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
237 in_signature='ssi', out_signature='a{i(ss)}')
238 def getHistory(self, from_jid, to_jid, size):
239 debug("History asked for %s", to_jid)
240 return self.cb["getHistory"](from_jid, to_jid, size)
241
242 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
243 in_signature='ss', out_signature='')
244 def addContact(self, entity, profile_key='@DEFAULT@'):
245 debug("Subscription asked for %s (profile %s)", entity, profile_key)
246 return self.cb["addContact"](entity, profile_key)
247
248 @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX,
249 in_signature='ss', out_signature='')
250 def delContact(self, entity, profile_key='@DEFAULT@'):
251 debug("Unsubscription asked for %s (profile %s)", entity, profile_key)
252 return self.cb["delContact"](entity, profile_key)
253
254 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
255 in_signature='sa{ss}s', out_signature='s')
256 def launchAction(self, type, data, profile_key='@DEFAULT@'):
257 return self.cb["launchAction"](type, data, profile_key)
258
259 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
260 in_signature='sba{ss}', out_signature='')
261 def confirmationAnswer(self, id, accepted, data):
262 debug("Answer for confirmation [%s]: %s", id, "Accepted" if accepted else "Refused")
263 return self.cb["confirmationAnswer"](id, accepted, data)
264
265
266 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
267 in_signature='s', out_signature='a{ss}')
268 def getProgress(self, id):
269 #debug("Progress asked for %s", id)
270 return self.cb["getProgress"](id)
271
272 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
273 in_signature='', out_signature='a(sss)')
274 def getMenus(self):
275 return self.cb["getMenus"]()
276
277 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
278 in_signature='sss', out_signature='s')
279 def getMenuHelp(self, category, name, type="NORMAL"):
280 return self.cb["getMenuHelp"](category, name, type)
281
282 @dbus.service.method(const_INT_PREFIX+const_REQ_SUFFIX,
283 in_signature='ssss', out_signature='s')
284 def callMenu(self, category, name, type, profile_key):
285 return self.cb["callMenu"](category, name, type, profile_key)
286 268
287 def __attribute_string(self, in_sign): 269 def __attribute_string(self, in_sign):
270 """Return arguments to user given a in_sign
271 @param in_sign: in_sign in the short form (using s,a,i,b etc)
272 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")"""
288 i=0 273 i=0
289 idx=0 274 idx=0
290 attr_string="" 275 attr_string=""
291 while i<len(in_sign): 276 while i<len(in_sign):
292 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']: 277 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']:
293 raise Exception #FIXME: create an exception here (unmanaged attribute type) 278 raise ParseError("Unmanaged attribute type [%c]" % in_sign[i])
294 279
295 attr_string += ("" if idx==0 else ",") + ("arg_%i" % idx) 280 attr_string += ("" if idx==0 else ", ") + ("arg_%i" % idx)
296 idx+=1 281 idx+=1
297 282
298 if in_sign[i] == 'a': 283 if in_sign[i] == 'a':
299 i+=1 284 i+=1
300 if in_sign[i]!='{' and in_sign[i]!='(': #FIXME: must manage tuples out of arrays 285 if in_sign[i]!='{' and in_sign[i]!='(': #FIXME: must manage tuples out of arrays
301 i+=1 286 i+=1
302 continue #we have a simple type for the array 287 continue #we have a simple type for the array
288 opening_car = in_sign[i]
289 assert(opening_car in ['{','('])
290 closing_car = '}' if opening_car == '{' else ')'
291 opening_count = 1
303 while (True): #we have a dict or a list of tuples 292 while (True): #we have a dict or a list of tuples
304 i+=1 293 i+=1
305 if i>=len(in_sign): 294 if i>=len(in_sign):
306 raise Exception #FIXME: create an exception here (the '}' is not presend) 295 raise ParseError("missing }")
307 if in_sign[i] == '}' or in_sign[i] == ')': 296 if in_sign[i] == opening_car:
308 break 297 opening_count+=1
298 if in_sign[i] == closing_car:
299 opening_count-=1
300 if opening_count == 0:
301 break
309 i+=1 302 i+=1
310 return attr_string 303 return attr_string
311
312
313 304
314 def addMethod(self, name, int_suffix, in_sign, out_sign): 305 def addMethod(self, name, int_suffix, in_sign, out_sign):
315 """Dynamically add a method to Dbus Bridge""" 306 """Dynamically add a method to Dbus Bridge"""
316 #FIXME: Better way ??? 307 #FIXME: Better way ???
317 attributes = self.__attribute_string(in_sign) 308 attributes = self.__attribute_string(in_sign)
340 info ("Init DBus...") 331 info ("Init DBus...")
341 self.session_bus = dbus.SessionBus() 332 self.session_bus = dbus.SessionBus()
342 self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus) 333 self.dbus_name = dbus.service.BusName(const_INT_PREFIX, self.session_bus)
343 self.dbus_bridge = DbusObject(self.session_bus, '/org/goffi/SAT/bridge') 334 self.dbus_bridge = DbusObject(self.session_bus, '/org/goffi/SAT/bridge')
344 335
336 def actionResult(self, answer_type, id, data):
337 self.dbus_bridge.actionResult(answer_type, id, data)
338
339 def actionResultExt(self, answer_type, id, data):
340 self.dbus_bridge.actionResultExt(answer_type, id, data)
341
342 def askConfirmation(self, conf_type, id, data):
343 self.dbus_bridge.askConfirmation(conf_type, id, data)
344
345 def connected(self, profile): 345 def connected(self, profile):
346 self.dbus_bridge.connected(profile) 346 self.dbus_bridge.connected(profile)
347 347
348 def connection_error(self, error_type, profile):
349 self.dbus_bridge.connection_error(error_type, profile)
350
351 def contactDeleted(self, entity, profile):
352 self.dbus_bridge.contactDeleted(entity, profile)
353
348 def disconnected(self, profile): 354 def disconnected(self, profile):
349 self.dbus_bridge.disconnected(profile) 355 self.dbus_bridge.disconnected(profile)
350 356
351 def connection_error(self, profile, error_type): 357 def newAlert(self, message, title, alert_type, profile):
352 self.dbus_bridge.connection_error(profile, error_type) 358 self.dbus_bridge.newAlert(message, title, alert_type, profile)
353 359
354 def newContact(self, contact, attributes, groups, profile): 360 def newContact(self, contact, attributes, groups, profile):
355 self.dbus_bridge.newContact(contact, attributes, groups, profile) 361 self.dbus_bridge.newContact(contact, attributes, groups, profile)
356 362
357 def newMessage(self, from_jid, msg, type='chat', to='', profile='@NONE@'): 363 def newMessage(self, from_jid, message, mess_type, to_jid, profile):
358 debug("sending message...") 364 self.dbus_bridge.newMessage(from_jid, message, mess_type, to_jid, profile)
359 self.dbus_bridge.newMessage(from_jid, msg, type, to, profile) 365
360 366 def paramUpdate(self, name, value, category, profile):
361 def newAlert(self, msg, title="", alert_type="INFO", profile='@NONE@'): 367 self.dbus_bridge.paramUpdate(name, value, category, profile)
362 self.dbus_bridge.newAlert(msg, title, alert_type, profile) 368
363
364 def presenceUpdate(self, entity, show, priority, statuses, profile): 369 def presenceUpdate(self, entity, show, priority, statuses, profile):
365 debug("updating presence for %s",entity)
366 self.dbus_bridge.presenceUpdate(entity, show, priority, statuses, profile) 370 self.dbus_bridge.presenceUpdate(entity, show, priority, statuses, profile)
367
368 def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
369 self.dbus_bridge.roomJoined(room_id, room_service, room_nicks, user_nick, profile)
370 371
371 def subscribe(self, sub_type, entity, profile): 372 def subscribe(self, sub_type, entity, profile):
372 debug("subscribe request for %s",entity)
373 self.dbus_bridge.subscribe(sub_type, entity, profile) 373 self.dbus_bridge.subscribe(sub_type, entity, profile)
374
375 def paramUpdate(self, name, value, category, profile):
376 debug("updating param [%s] %s ", category, name)
377 self.dbus_bridge.paramUpdate(name, value, category, profile)
378
379 def contactDeleted(self, entity, profile):
380 debug("sending contact deleted signal %s ", entity)
381 self.dbus_bridge.contactDeleted(entity, profile)
382
383 def askConfirmation(self, type, id, data):
384 self.dbus_bridge.askConfirmation(type, id, data)
385
386 def actionResult(self, type, id, data):
387 self.dbus_bridge.actionResult(type, id, data)
388
389 def actionResultExt(self, type, id, data):
390 self.dbus_bridge.actionResultExt(type, id, data)
391 374
392 def updatedValue(self, name, value): 375 def updatedValue(self, name, value):
393 self.dbus_bridge.updatedValue(name, value) 376 self.dbus_bridge.updatedValue(name, value)
377
394 378
395 def register(self, name, callback): 379 def register(self, name, callback):
396 debug("registering DBus bridge method [%s]", name) 380 debug("registering DBus bridge method [%s]", name)
397 self.dbus_bridge.register(name, callback) 381 self.dbus_bridge.register(name, callback)
398 382
403 self.register(name, method) 387 self.register(name, method)
404 388
405 def addSignal(self, name, int_suffix, signature): 389 def addSignal(self, name, int_suffix, signature):
406 self.dbus_bridge.addSignal(name, int_suffix, signature) 390 self.dbus_bridge.addSignal(name, int_suffix, signature)
407 setattr(DBusBridge, name, getattr(self.dbus_bridge, name)) 391 setattr(DBusBridge, name, getattr(self.dbus_bridge, name))
408