Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_app.py @ 1955:633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
/!\ database schema has been modified, do a backup before updating
message have been refactored, here are the main changes:
- languages are now handled
- all messages have an uid (internal to SàT)
- message updating is anticipated
- subject is now first class
- new naming scheme is used newMessage => messageNew, getHistory => historyGet, sendMessage => messageSend
- minimal compatibility refactoring in quick_frontend/Primitivus, better refactoring should follow
- threads handling
- delayed messages are saved into history
- info messages may also be saved in history (e.g. to keep track of people joining/leaving a room)
- duplicate messages should be avoided
- historyGet return messages in right order, no need to sort again
- plugins have been updated to follow new features, some of them need to be reworked (e.g. OTR)
- XEP-0203 (Delayed Delivery) is now fully handled in core, the plugin just handle disco and creation of a delay element
- /!\ jp and Libervia are currently broken, as some features of Primitivus
It has been put in one huge commit to avoid breaking messaging between changes.
This is the main part of message refactoring, other commits will follow to take profit of the new features/behaviour.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 May 2016 22:11:04 +0200 |
parents | e68483c5a999 |
children | a2bc5089c2eb |
comparison
equal
deleted
inserted
replaced
1943:ccfe45302a5c | 1955:633b5c21aefd |
---|---|
246 ProfileManager.bridge = self.bridge | 246 ProfileManager.bridge = self.bridge |
247 self.registerSignal("connected") | 247 self.registerSignal("connected") |
248 self.registerSignal("disconnected") | 248 self.registerSignal("disconnected") |
249 self.registerSignal("actionNew") | 249 self.registerSignal("actionNew") |
250 self.registerSignal("newContact") | 250 self.registerSignal("newContact") |
251 self.registerSignal("newMessage") | 251 self.registerSignal("messageNew") |
252 self.registerSignal("newAlert") | 252 self.registerSignal("newAlert") |
253 self.registerSignal("presenceUpdate") | 253 self.registerSignal("presenceUpdate") |
254 self.registerSignal("subscribe") | 254 self.registerSignal("subscribe") |
255 self.registerSignal("paramUpdate") | 255 self.registerSignal("paramUpdate") |
256 self.registerSignal("contactDeleted") | 256 self.registerSignal("contactDeleted") |
480 def newContactHandler(self, jid_s, attributes, groups, profile): | 480 def newContactHandler(self, jid_s, attributes, groups, profile): |
481 entity = jid.JID(jid_s) | 481 entity = jid.JID(jid_s) |
482 groups = list(groups) | 482 groups = list(groups) |
483 self.contact_lists[profile].setContact(entity, groups, attributes, in_roster=True) | 483 self.contact_lists[profile].setContact(entity, groups, attributes, in_roster=True) |
484 | 484 |
485 def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile): | 485 def messageNewHandler(self, uid, timestamp, from_jid_s, to_jid_s, msg, subject, type_, extra, profile): |
486 from_jid = jid.JID(from_jid_s) | 486 from_jid = jid.JID(from_jid_s) |
487 to_jid = jid.JID(to_jid_s) | 487 to_jid = jid.JID(to_jid_s) |
488 if not self.trigger.point("newMessageTrigger", from_jid, msg, type_, to_jid, extra, profile=profile): | 488 if not self.trigger.point("messageNewTrigger", uid, timestamp, from_jid, to_jid, msg, subject, type_, extra, profile=profile): |
489 return | 489 return |
490 | 490 |
491 from_me = from_jid.bare == self.profiles[profile].whoami.bare | 491 from_me = from_jid.bare == self.profiles[profile].whoami.bare |
492 target = to_jid if from_me else from_jid | 492 target = to_jid if from_me else from_jid |
493 | 493 |
503 #XXX: needed to show entities which haven't sent any | 503 #XXX: needed to show entities which haven't sent any |
504 # presence information and which are not in roster | 504 # presence information and which are not in roster |
505 contact_list.setContact(from_jid) | 505 contact_list.setContact(from_jid) |
506 | 506 |
507 # we display the message in the widget | 507 # we display the message in the widget |
508 chat_widget.newMessage(from_jid, target, msg, type_, extra, profile) | 508 |
509 chat_widget.messageNew(uid, timestamp, from_jid, target, msg, subject, type_, extra, profile) | |
509 | 510 |
510 # ContactList alert | 511 # ContactList alert |
511 if not from_me: | 512 if not from_me: |
512 visible = False | 513 visible = False |
513 for widget in self.visible_widgets: | 514 for widget in self.visible_widgets: |
518 if self.isHidden(): # the window is hidden | 519 if self.isHidden(): # the window is hidden |
519 self.updateAlertsCounter(extra_inc=1) | 520 self.updateAlertsCounter(extra_inc=1) |
520 else: | 521 else: |
521 contact_list.addAlert(from_jid.bare if type_ == C.MESS_TYPE_GROUPCHAT else from_jid) | 522 contact_list.addAlert(from_jid.bare if type_ == C.MESS_TYPE_GROUPCHAT else from_jid) |
522 | 523 |
523 def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key=C.PROF_KEY_NONE): | 524 def messageSend(self, to_jid, message, subject=None, mess_type="auto", extra=None, callback=None, errback=None, profile_key=C.PROF_KEY_NONE): |
525 if subject is None: | |
526 subject = {} | |
527 if extra is None: | |
528 extra = {} | |
524 if callback is None: | 529 if callback is None: |
525 callback = lambda dummy=None: None # FIXME: optional argument is here because pyjamas doesn't support callback without arg with json proxy | 530 callback = lambda dummy=None: None # FIXME: optional argument is here because pyjamas doesn't support callback without arg with json proxy |
526 if errback is None: | 531 if errback is None: |
527 errback = lambda failure: self.showDialog(failure.fullname, failure.message, "error") | 532 errback = lambda failure: self.showDialog(failure.fullname, failure.message, "error") |
528 | 533 |
529 if not self.trigger.point("sendMessageTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key): | 534 if not self.trigger.point("messageSendTrigger", to_jid, message, subject, mess_type, extra, callback, errback, profile_key=profile_key): |
530 return | 535 return |
531 | 536 |
532 self.bridge.sendMessage(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback) | 537 self.bridge.messageSend(unicode(to_jid), message, subject, mess_type, extra, profile_key, callback=callback, errback=errback) |
533 | 538 |
534 def newAlertHandler(self, msg, title, alert_type, profile): | 539 def newAlertHandler(self, msg, title, alert_type, profile): |
535 assert alert_type in ['INFO', 'ERROR'] | 540 assert alert_type in ['INFO', 'ERROR'] |
536 self.showDialog(unicode(msg), unicode(title), alert_type.lower()) | 541 self.showDialog(unicode(msg), unicode(title), alert_type.lower()) |
537 | 542 |