Mercurial > libervia-web
comparison src/server/server.py @ 913:58f611481e6d
server, browser: removed deprecated methods which have been removed from backend, and associated code
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 28 Aug 2016 19:25:52 +0200 |
parents | e8b133b77aa4 |
children | 0c0551967bdf |
comparison
equal
deleted
inserted
replaced
912:1ced5b522ae2 | 913:58f611481e6d |
---|---|
316 f.processors = self.processors | 316 f.processors = self.processors |
317 f.indexNames = self.indexNames[:] | 317 f.indexNames = self.indexNames[:] |
318 f.childNotFound = self.childNotFound | 318 f.childNotFound = self.childNotFound |
319 return f | 319 return f |
320 | 320 |
321 class SATActionIDHandler(object): | |
322 """Manage SàT action action_id lifecycle""" | |
323 ID_LIFETIME = 30 # after this time (in seconds), action_id will be suppressed and action result will be ignored | |
324 | |
325 def __init__(self): | |
326 self.waiting_ids = {} | |
327 | |
328 def waitForId(self, callback, action_id, profile, *args, **kwargs): | |
329 """Wait for an action result | |
330 | |
331 @param callback: method to call when action gave a result back | |
332 @param action_id: action_id to wait for | |
333 @param profile: %(doc_profile)s | |
334 @param *args: additional argument to pass to callback | |
335 @param **kwargs: idem | |
336 """ | |
337 action_tuple = (action_id, profile) | |
338 self.waiting_ids[action_tuple] = (callback, args, kwargs) | |
339 reactor.callLater(self.ID_LIFETIME, self.purgeID, action_tuple) | |
340 | |
341 def purgeID(self, action_tuple): | |
342 """Called when an action_id has not be handled in time""" | |
343 if action_tuple in self.waiting_ids: | |
344 log.warning(u"action of action_id %s [%s] has not been managed, action_id is now ignored" % action_tuple) | |
345 del self.waiting_ids[action_tuple] | |
346 | |
347 def actionResultCb(self, answer_type, action_id, data, profile): | |
348 """Manage the actionResult signal""" | |
349 action_tuple = (action_id, profile) | |
350 if action_tuple in self.waiting_ids: | |
351 callback, args, kwargs = self.waiting_ids[action_tuple] | |
352 del self.waiting_ids[action_tuple] | |
353 callback(answer_type, action_id, data, *args, **kwargs) | |
354 | |
355 | 321 |
356 class JSONRPCMethodManager(jsonrpc.JSONRPC): | 322 class JSONRPCMethodManager(jsonrpc.JSONRPC): |
357 | 323 |
358 def __init__(self, sat_host): | 324 def __init__(self, sat_host): |
359 jsonrpc.JSONRPC.__init__(self) | 325 jsonrpc.JSONRPC.__init__(self) |
447 | 413 |
448 def jsonrpc_getWaitingSub(self): | 414 def jsonrpc_getWaitingSub(self): |
449 """Return list of room already joined by user""" | 415 """Return list of room already joined by user""" |
450 profile = ISATSession(self.session).profile | 416 profile = ISATSession(self.session).profile |
451 return self.sat_host.bridge.getWaitingSub(profile) | 417 return self.sat_host.bridge.getWaitingSub(profile) |
452 | |
453 def jsonrpc_getWaitingConf(self): | |
454 """Return list of waiting confirmations""" | |
455 profile = ISATSession(self.session).profile | |
456 return self.sat_host.bridge.getWaitingConf(profile) | |
457 | 418 |
458 def jsonrpc_setStatus(self, presence, status): | 419 def jsonrpc_setStatus(self, presence, status): |
459 """Change the presence and/or status | 420 """Change the presence and/or status |
460 @param presence: value from ("", "chat", "away", "dnd", "xa") | 421 @param presence: value from ("", "chat", "away", "dnd", "xa") |
461 @param status: any string to describe your status | 422 @param status: any string to describe your status |
866 | 827 |
867 def jsonrpc_getNewAccountDomain(self): | 828 def jsonrpc_getNewAccountDomain(self): |
868 """@return: the domain for new account creation""" | 829 """@return: the domain for new account creation""" |
869 d = self.asyncBridgeCall("getNewAccountDomain") | 830 d = self.asyncBridgeCall("getNewAccountDomain") |
870 return d | 831 return d |
871 | |
872 def jsonrpc_confirmationAnswer(self, confirmation_id, result, answer_data): | |
873 """Send the user's answer to any previous 'askConfirmation' signal""" | |
874 profile = ISATSession(self.session).profile | |
875 self.sat_host.bridge.confirmationAnswer(confirmation_id, result, answer_data, profile) | |
876 | 832 |
877 def jsonrpc_syntaxConvert(self, text, syntax_from=C.SYNTAX_XHTML, syntax_to=C.SYNTAX_CURRENT): | 833 def jsonrpc_syntaxConvert(self, text, syntax_from=C.SYNTAX_XHTML, syntax_to=C.SYNTAX_CURRENT): |
878 """ Convert a text between two syntaxes | 834 """ Convert a text between two syntaxes |
879 @param text: text to convert | 835 @param text: text to convert |
880 @param syntax_from: source syntax (e.g. "markdown") | 836 @param syntax_from: source syntax (e.g. "markdown") |
1488 _upload_radiocol = UploadManagerRadioCol(self) | 1444 _upload_radiocol = UploadManagerRadioCol(self) |
1489 _upload_avatar = UploadManagerAvatar(self) | 1445 _upload_avatar = UploadManagerAvatar(self) |
1490 self.signal_handler.plugRegister(_register) | 1446 self.signal_handler.plugRegister(_register) |
1491 self.sessions = {} # key = session value = user | 1447 self.sessions = {} # key = session value = user |
1492 self.prof_connected = set() # Profiles connected | 1448 self.prof_connected = set() # Profiles connected |
1493 self.action_handler = SATActionIDHandler() | |
1494 | 1449 |
1495 ## bridge ## | 1450 ## bridge ## |
1496 try: | 1451 try: |
1497 self.bridge = DBusBridgeFrontend() | 1452 self.bridge = DBusBridgeFrontend() |
1498 except BridgeExceptionNoService: | 1453 except BridgeExceptionNoService: |
1500 sys.exit(1) | 1455 sys.exit(1) |
1501 | 1456 |
1502 def backendReady(dummy): | 1457 def backendReady(dummy): |
1503 self.bridge.register("connected", self.signal_handler.connected) | 1458 self.bridge.register("connected", self.signal_handler.connected) |
1504 self.bridge.register("disconnected", self.signal_handler.disconnected) | 1459 self.bridge.register("disconnected", self.signal_handler.disconnected) |
1505 self.bridge.register("actionResult", self.action_handler.actionResultCb) | |
1506 #core | 1460 #core |
1507 for signal_name in ['presenceUpdate', 'messageNew', 'subscribe', 'contactDeleted', | 1461 for signal_name in ['presenceUpdate', 'messageNew', 'subscribe', 'contactDeleted', |
1508 'newContact', 'entityDataUpdated', 'askConfirmation', 'newAlert', 'paramUpdate']: | 1462 'newContact', 'entityDataUpdated', 'paramUpdate']: |
1509 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) | 1463 self.bridge.register(signal_name, self.signal_handler.getGenericCb(signal_name)) |
1510 # XXX: actionNew is handled separately because the handler must manage security_limit | 1464 # XXX: actionNew is handled separately because the handler must manage security_limit |
1511 self.bridge.register('actionNew', self.signal_handler.actionNewHandler) | 1465 self.bridge.register('actionNew', self.signal_handler.actionNewHandler) |
1512 #plugins | 1466 #plugins |
1513 for signal_name in ['psEvent', 'mucRoomJoined', 'tarotGameStarted', 'tarotGameNew', 'tarotGameChooseContrat', | 1467 for signal_name in ['psEvent', 'mucRoomJoined', 'tarotGameStarted', 'tarotGameNew', 'tarotGameChooseContrat', |