2003-07-29 Mikael Hallendal <micke@imendio.com>
authorhallski <hallski>
Tue, 29 Jul 2003 13:40:36 +0000
changeset 23 b8a56b77da30
parent 22 855fb414667f
child 24 0ba4011f5044
2003-07-29 Mikael Hallendal <micke@imendio.com> * loudmouth/lm-message.[ch]: - Added LM_MESSAGE_SUB_TYPE_NORMAL to be a sub type that can actually be set. - If type is not set in a <message/>-node it won't be reported to be LM_MESSAGE_SUB_TYPE_NORMAL but rather LM_MESSAGE_SUB_TYPE_NOT_SET.
ChangeLog
loudmouth/lm-message.c
loudmouth/lm-message.h
--- a/ChangeLog	Thu Jul 17 19:58:45 2003 +0000
+++ b/ChangeLog	Tue Jul 29 13:40:36 2003 +0000
@@ -1,3 +1,11 @@
+2003-07-29  Mikael Hallendal  <micke@imendio.com>
+
+	* loudmouth/lm-message.[ch]:
+	- Added LM_MESSAGE_SUB_TYPE_NORMAL to be a sub type that can actually 
+	  be set.
+	- If type is not set in a <message/>-node it won't be reported to be 
+	  LM_MESSAGE_SUB_TYPE_NORMAL but rather LM_MESSAGE_SUB_TYPE_NOT_SET.
+
 2003-07-17  Mikael Hallendal  <micke@imendio.com>
 
         * Release 0.12
--- a/loudmouth/lm-message.c	Thu Jul 17 19:58:45 2003 +0000
+++ b/loudmouth/lm-message.c	Tue Jul 29 13:40:36 2003 +0000
@@ -44,6 +44,7 @@
         LmMessageSubType  type;
         const gchar      *name;
 } sub_type_names[] = {
+	{ LM_MESSAGE_SUB_TYPE_NORMAL,          "normal"        },
         { LM_MESSAGE_SUB_TYPE_CHAT,            "chat"          },
 	{ LM_MESSAGE_SUB_TYPE_GROUPCHAT,       "groupchat"     },
 	{ LM_MESSAGE_SUB_TYPE_HEADLINE,        "headline"      },
@@ -106,7 +107,7 @@
                 return LM_MESSAGE_SUB_TYPE_NOT_SET;
         }
 
-        for (i = LM_MESSAGE_SUB_TYPE_CHAT;
+        for (i = LM_MESSAGE_SUB_TYPE_NORMAL;
 	     i <= LM_MESSAGE_SUB_TYPE_ERROR;
 	     ++i) {
                 if (g_ascii_strcasecmp (type_str, 
@@ -121,11 +122,13 @@
 const gchar *
 _lm_message_sub_type_to_string (LmMessageSubType type)
 {
-        if (type < LM_MESSAGE_SUB_TYPE_CHAT ||
+        if (type < LM_MESSAGE_SUB_TYPE_NORMAL ||
             type > LM_MESSAGE_SUB_TYPE_ERROR) {
 		return NULL;
         }
 
+	g_print("TYPE: %d -> %s\n", type, sub_type_names[type].name);
+
         return sub_type_names[type].name;
 }
 
@@ -135,7 +138,11 @@
 
 	switch (type) {
 	case LM_MESSAGE_TYPE_MESSAGE:
-		sub_type = LM_MESSAGE_SUB_TYPE_NORMAL;
+		/* A message without type should be handled like a message with
+		 * type=normal, but we won't set it to that since then the user
+		 * will not know if it's set or not.
+		 */
+		sub_type = LM_MESSAGE_SUB_TYPE_NOT_SET;
 		break;
 	case LM_MESSAGE_TYPE_PRESENCE:
 		sub_type = LM_MESSAGE_SUB_TYPE_AVAILABLE;
--- a/loudmouth/lm-message.h	Thu Jul 17 19:58:45 2003 +0000
+++ b/loudmouth/lm-message.h	Tue Jul 29 13:40:36 2003 +0000
@@ -1,5 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
+ * Copyright (C) 2003 Imendio HB
  * Copyright (C) 2003 Mikael Hallendal <micke@imendio.com>
  * Copyright (C) 2003 CodeFactory AB. 
  *
@@ -47,9 +48,9 @@
 
 typedef enum {
         LM_MESSAGE_SUB_TYPE_NOT_SET = -10,
-	LM_MESSAGE_SUB_TYPE_NORMAL = -2,
 	LM_MESSAGE_SUB_TYPE_AVAILABLE = -1,
-	LM_MESSAGE_SUB_TYPE_CHAT = 0,
+	LM_MESSAGE_SUB_TYPE_NORMAL = 0,
+	LM_MESSAGE_SUB_TYPE_CHAT,
         LM_MESSAGE_SUB_TYPE_GROUPCHAT,
         LM_MESSAGE_SUB_TYPE_HEADLINE,
         LM_MESSAGE_SUB_TYPE_UNAVAILABLE,