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.
This commit is contained in:
Goffi 2016-05-24 22:11:04 +02:00
commit f12803fa65
2 changed files with 784 additions and 453 deletions

View file

@ -165,6 +165,11 @@ class DbusObject(dbus.service.Object):
def entityDataUpdated(self, jid, name, value, profile):
pass
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
signature='sdssa{ss}a{ss}sa{ss}s')
def messageNew(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
pass
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
signature='ssss')
def newAlert(self, message, title, alert_type, profile):
@ -175,11 +180,6 @@ class DbusObject(dbus.service.Object):
def newContact(self, contact_jid, attributes, groups, profile):
pass
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
signature='ssssa{ss}s')
def newMessage(self, from_jid, message, mess_type, to_jid, extra, profile):
pass
@dbus.service.signal(const_INT_PREFIX+const_CORE_SUFFIX,
signature='ssss')
def paramUpdate(self, name, value, category, profile):
@ -320,12 +320,6 @@ class DbusObject(dbus.service.Object):
def getFeatures(self, profile_key, callback=None, errback=None):
return self._callback("getFeatures", unicode(profile_key), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ssibss', out_signature='a(dssssa{ss})',
async_callbacks=('callback', 'errback'))
def getHistory(self, from_jid, to_jid, limit, between=True, search='', profile="@NONE@", callback=None, errback=None):
return self._callback("getHistory", unicode(from_jid), unicode(to_jid), limit, between, unicode(search), unicode(profile), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ss', out_signature='s',
async_callbacks=None)
@ -404,6 +398,12 @@ class DbusObject(dbus.service.Object):
def getWaitingSub(self, profile_key="@DEFAULT@"):
return self._callback("getWaitingSub", unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ssibss', out_signature='a(sdssa{ss}a{ss}sa{ss})',
async_callbacks=('callback', 'errback'))
def historyGet(self, from_jid, to_jid, limit, between=True, search='', profile="@NONE@", callback=None, errback=None):
return self._callback("historyGet", unicode(from_jid), unicode(to_jid), limit, between, unicode(search), unicode(profile), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='s', out_signature='b',
async_callbacks=None)
@ -422,6 +422,12 @@ class DbusObject(dbus.service.Object):
def loadParamsTemplate(self, filename):
return self._callback("loadParamsTemplate", unicode(filename))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='sa{ss}a{ss}sa{ss}s', out_signature='',
async_callbacks=('callback', 'errback'))
def messageSend(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
return self._callback("messageSend", unicode(to_jid), message, subject, unicode(mess_type), extra, unicode(profile_key), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='sis', out_signature='',
async_callbacks=None)
@ -470,12 +476,6 @@ class DbusObject(dbus.service.Object):
def saveParamsTemplate(self, filename):
return self._callback("saveParamsTemplate", unicode(filename))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ssssa{ss}s', out_signature='',
async_callbacks=('callback', 'errback'))
def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), extra, unicode(profile_key), callback=callback, errback=errback)
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='sssis', out_signature='',
async_callbacks=None)
@ -626,15 +626,15 @@ class DBusBridge(Bridge):
def entityDataUpdated(self, jid, name, value, profile):
self.dbus_bridge.entityDataUpdated(jid, name, value, profile)
def messageNew(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
self.dbus_bridge.messageNew(uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile)
def newAlert(self, message, title, alert_type, profile):
self.dbus_bridge.newAlert(message, title, alert_type, profile)
def newContact(self, contact_jid, attributes, groups, profile):
self.dbus_bridge.newContact(contact_jid, attributes, groups, profile)
def newMessage(self, from_jid, message, mess_type, to_jid, extra, profile):
self.dbus_bridge.newMessage(from_jid, message, mess_type, to_jid, extra, profile)
def paramUpdate(self, name, value, category, profile):
self.dbus_bridge.paramUpdate(name, value, category, profile)

View file

@ -34,17 +34,24 @@ doc_param_1=attributes: Dictionary of attributes where keys are:
doc_param_2=groups: Roster's groups where the contact is
doc_param_3=%(doc_profile)s
[newMessage]
[messageNew]
type=signal
category=core
sig_in=ssssa{ss}s
sig_in=sdssa{ss}a{ss}sa{ss}s
doc=A message has been received
doc_param_0=from_jid: JID where the message is comming from
doc_param_1=message: Message itself
doc_param_2=mess_type: Type of the message (cf RFC 6121 §5.2.2) + C.MESS_TYPE_INFO (system info)
doc_param_0=uid: unique ID of the message (id specific to SàT, this it *NOT* an XMPP id)
doc_param_1=timestamp: when the message was sent (or declared sent for delayed messages)
doc_param_2=from_jid: JID where the message is comming from
doc_param_3=to_jid: JID where the message must be sent
doc_param_4=extra: extra message information
doc_param_5=%(doc_profile)s
doc_param_4=message: message itself, can be in several languages (key is language code or '' for default)
doc_param_5=subject: subject of the message, can be in several languages (key is language code or '' for default)
doc_param_6=mess_type: Type of the message (cf RFC 6121 §5.2.2) + C.MESS_TYPE_INFO (system info)
doc_param_7=extra: extra message information, can have data added by plugins and/or:
- thread: id of the thread
- thread_parent: id of the parent of the current thread
- received_timestamp: date of receiption for delayed messages
- delay_sender: entity which has originally sent or which has delayed the message
doc_param_8=%(doc_profile)s
[newAlert]
deprecated=
@ -434,11 +441,11 @@ doc_param_0=%(doc_profile_key)s
doc_return=List of confirmation request data, same as for [askConfirmation]
[sendMessage]
[messageSend]
async=
type=method
category=core
sig_in=ssssa{ss}s
sig_in=sa{ss}a{ss}sa{ss}s
sig_out=
param_2_default=''
param_3_default="auto"
@ -446,8 +453,10 @@ param_4_default={}
param_5_default="@NONE@"
doc=Send a message
doc_param_0=to_jid: JID of the recipient
doc_param_1=message: body of the message
doc_param_2=subject: Subject of the message ('' if no subject)
doc_param_1=message: body of the message:
key is the language of the body, use '' when unknown
doc_param_2=subject: Subject of the message
key is the language of the subkect, use '' when unknown
doc_param_3=mess_type: Type of the message (cf RFC 6121 §5.2.2) or "auto" for automatic type detection
doc_param_4=extra: optional data that can be used by a plugin to build more specific messages
doc_param_5=%(doc_profile_key)s
@ -577,12 +586,12 @@ doc_param_0=xml: XML definition of the parameters to be added
doc_param_1=%(doc_security_limit)s
doc_param_2=app: name of the frontend registering the parameters
[getHistory]
[historyGet]
async=
type=method
category=core
sig_in=ssibss
sig_out=a(dssssa{ss})
sig_out=a(sdssa{ss}a{ss}sa{ss})
param_3_default=True
param_4_default=''
param_5_default="@NONE@"
@ -593,7 +602,7 @@ doc_param_2=limit: max number of history elements to get (0 for the whole histor
doc_param_3=between: True if we want history between the two jids (in both direction), False if we only want messages from from_jid to to_jid
doc_param_4=search: pattern to filter the history results
doc_param_5=%(doc_profile)s
doc_return=Ordered list (by timestamp) of tuples (timestamp, full from_jid, full to_jid, message, type, extra)
doc_return=Ordered list (by timestamp) of data as in [messageNew] (without final profile)
[addContact]
type=method