changeset 1171:0abce7f17782

core: a new "info" type is used in newMessage for system messages (not comming from outside)
author Goffi <goffi@goffi.org>
date Fri, 05 Sep 2014 19:29:30 +0200
parents 2df6427a5299
children e15d8a01cf6a
files src/bridge/bridge_constructor/bridge_template.ini src/core/constants.py src/plugins/plugin_misc_text_commands.py src/plugins/plugin_sec_otr.py
diffstat 4 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/bridge/bridge_constructor/bridge_template.ini	Fri Sep 05 11:16:38 2014 +0200
+++ b/src/bridge/bridge_constructor/bridge_template.ini	Fri Sep 05 19:29:30 2014 +0200
@@ -40,7 +40,7 @@
 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 3921 #2.1.1)
+doc_param_2=mess_type: Type of the message (cf RFC 6121 §5.2.2) + C.MESS_TYPE_INFO (system info)
 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
@@ -63,9 +63,9 @@
 sig_in=ssia{ss}s
 doc=Somebody changed his presence informations.
 doc_param_0=entity_jid: JID from which we have presence informations
-doc_param_1=show: availability status (see RFC 3921 #2.2.2.1)
-doc_param_2=priority: Priority level of the ressource (see RFC 3921 #2.2.2.3)
-doc_param_3=statuses: Natural language description of the availability status (see RFC 3921 #2.2.2.2)
+doc_param_1=show: availability status (see RFC 6121 §4.7.2.1)
+doc_param_2=priority: Priority level of the ressource (see RFC 6121 §4.7.2.3)
+doc_param_3=statuses: Natural language description of the availability status (see RFC 6121 §4.7.2.2)
 doc_param_4=%(doc_profile)s
 
 [subscribe]
@@ -73,7 +73,7 @@
 category=core
 sig_in=sss
 doc=Somebody wants to be added in roster
-doc_param_0=sub_type: Subscription states (see RFC 3921 #9)
+doc_param_0=sub_type: Subscription states (see RFC 6121 §3)
 doc_param_1=entity_jid: JID from which the subscription is coming
 doc_param_2=%(doc_profile)s
 
@@ -334,7 +334,7 @@
 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_3=mess_type: Type of the message (cf RFC 3921 #2.1.1) or "auto" for automatic type detection
+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
 
--- a/src/core/constants.py	Fri Sep 05 11:16:38 2014 +0200
+++ b/src/core/constants.py	Fri Sep 05 19:29:30 2014 +0200
@@ -57,8 +57,8 @@
     STATIC_BLOG_PARAM_KEYWORDS = "Keywords"
     STATIC_BLOG_PARAM_DESCRIPTION = "Description"
 
+
     ## Menus ##
-
     MENU_GLOBAL = "GLOBAL"
     MENU_ROOM = "ROOM"
     MENU_SINGLE = "SINGLE"
@@ -66,6 +66,7 @@
     MENU_ROSTER_JID_CONTEXT = "ROSTER_JID_CONTEXT"
     MENU_ROSTER_GROUP_CONTEXT = "MENU_ROSTER_GROUP_CONTEXT"
 
+
     ## Profile and entities ##
     PROF_KEY_NONE = '@NONE@'
     PROF_KEY_DEFAULT = '@DEFAULT@'
@@ -74,6 +75,9 @@
     ENTITY_CAP_HASH = 'CAP_HASH'
 
 
+    ## Messages ##
+    MESS_TYPE_INFO = 'info'
+
     ## Configuration ##
     if BaseDirectory:  # skipped when xdg module is not available (should not happen in backend)
 
@@ -188,6 +192,7 @@
 
     @classmethod
     def bool(cls, value):
+        """retour str text value for bool, or bool value for str"""
         if isinstance(value, bool):
             return cls.BOOL_TRUE if value else cls.BOOL_FALSE
         return value.lower() == cls.BOOL_TRUE
--- a/src/plugins/plugin_misc_text_commands.py	Fri Sep 05 11:16:38 2014 +0200
+++ b/src/plugins/plugin_misc_text_commands.py	Fri Sep 05 19:29:30 2014 +0200
@@ -168,7 +168,7 @@
         else:
             _from = self.host.getJidNStream(profile)[0]
 
-        self.host.bridge.newMessage(unicode(mess_data["to"]), message, mess_data['type'], unicode(_from), {}, profile=profile)
+        self.host.bridge.newMessage(unicode(mess_data["to"]), message, C.MESS_TYPE_INFO, unicode(_from), {}, profile=profile)
 
     def feedBackWrongContext(self, command, types, mess_data, profile):
         """Give a generic message to the user when a command has been used in a wrong context.
--- a/src/plugins/plugin_sec_otr.py	Fri Sep 05 11:16:38 2014 +0200
+++ b/src/plugins/plugin_sec_otr.py	Fri Sep 05 19:29:30 2014 +0200
@@ -106,10 +106,9 @@
             return
 
         client = self.user.client
-        # FIXME: newMessage should manage system message, so they don't appear as coming from the contact
         self.host.bridge.newMessage(client.jid.full(),
                                     feedback,
-                                    mess_type="headline",
+                                    mess_type=C.MESS_TYPE_INFO,
                                     to_jid=self.peer.full(),
                                     extra={},
                                     profile=client.profile)
@@ -413,7 +412,7 @@
                 client = self.host.getClient(profile)
                 self.host.bridge.newMessage(from_jid.full(),
                                             _(u"WARNING: received unencrypted data in a supposedly encrypted context"),
-                                            mess_type="headline", # FIXME: add message type for internal informations
+                                            mess_type=C.MESS_TYPE_INFO,
                                             to_jid=client.jid.full(),
                                             extra={},
                                             profile=client.profile)
@@ -454,7 +453,7 @@
                 client = self.host.getClient(profile)
                 self.host.bridge.newMessage(to_jid.full(),
                                             feedback,
-                                            mess_type="headline",
+                                            mess_type=C.MESS_TYPE_INFO,
                                             to_jid=client.jid.full(),
                                             extra={},
                                             profile=client.profile)