[empathy: 10/19] empathy-message: remove useless public setters



commit 4cda099c0f5715355829e7ead5b272eb2465a3c0
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Apr 15 17:08:58 2011 +0200

    empathy-message: remove useless public setters
    
    Also fix the GParamFlags of properties.

 libempathy/empathy-message.c |  141 +++++++-----------------------------------
 libempathy/empathy-message.h |   13 ----
 2 files changed, 22 insertions(+), 132 deletions(-)
---
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 53422b6..1740e1d 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -93,28 +93,30 @@ empathy_message_class_init (EmpathyMessageClass *class)
 							    TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
 							    TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY,
 							    TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
-							    G_PARAM_READWRITE));
+							    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+							    G_PARAM_CONSTRUCT_ONLY));
 	g_object_class_install_property (object_class,
 					 PROP_SENDER,
 					 g_param_spec_object ("sender",
 							      "Message Sender",
 							      "The sender of the message",
 							      EMPATHY_TYPE_CONTACT,
-							      G_PARAM_READWRITE));
+							      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 	g_object_class_install_property (object_class,
 					 PROP_RECEIVER,
 					 g_param_spec_object ("receiver",
 							      "Message Receiver",
 							      "The receiver of the message",
 							      EMPATHY_TYPE_CONTACT,
-							      G_PARAM_READWRITE));
+							      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 	g_object_class_install_property (object_class,
 					 PROP_BODY,
 					 g_param_spec_string ("body",
 							      "Message Body",
 							      "The content of the message",
 							      NULL,
-							      G_PARAM_READWRITE));
+							      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+							      G_PARAM_CONSTRUCT_ONLY));
 	g_object_class_install_property (object_class,
 					 PROP_TIMESTAMP,
 					 g_param_spec_long ("timestamp",
@@ -123,14 +125,16 @@ empathy_message_class_init (EmpathyMessageClass *class)
 							    -1,
 							    G_MAXLONG,
 							    -1,
-							    G_PARAM_READWRITE));
+							    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+							    G_PARAM_CONSTRUCT_ONLY));
 	g_object_class_install_property (object_class,
 					 PROP_IS_BACKLOG,
 					 g_param_spec_boolean ("is-backlog",
 							       "History message",
 							       "If the message belongs to history",
 							       FALSE,
-							       G_PARAM_READWRITE));
+							       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+							       G_PARAM_CONSTRUCT_ONLY));
 
 
 	g_object_class_install_property (object_class,
@@ -139,7 +143,8 @@ empathy_message_class_init (EmpathyMessageClass *class)
 							       "Incoming",
 							       "If this is an incoming (as opposed to sent) message",
 							       FALSE,
-							       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+							       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+							       G_PARAM_CONSTRUCT_ONLY));
 
 	g_object_class_install_property (object_class,
 					 PROP_FLAGS,
@@ -147,7 +152,8 @@ empathy_message_class_init (EmpathyMessageClass *class)
 							       "Flags",
 							       "The TpChannelTextMessageFlags of this message",
 							       0, G_MAXUINT, 0,
-							       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+							       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+							       G_PARAM_CONSTRUCT_ONLY));
 
 	g_type_class_add_private (object_class, sizeof (EmpathyMessagePriv));
 
@@ -235,8 +241,7 @@ message_set_property (GObject      *object,
 
 	switch (param_id) {
 	case PROP_TYPE:
-		empathy_message_set_tptype (EMPATHY_MESSAGE (object),
-					    g_value_get_uint (value));
+		priv->type = g_value_get_uint (value);
 		break;
 	case PROP_SENDER:
 		empathy_message_set_sender (EMPATHY_MESSAGE (object),
@@ -247,11 +252,13 @@ message_set_property (GObject      *object,
 					     EMPATHY_CONTACT (g_value_get_object (value)));
 		break;
 	case PROP_BODY:
-		empathy_message_set_body (EMPATHY_MESSAGE (object),
-					 g_value_get_string (value));
+		g_assert (priv->body == NULL); /* construct only */
+		priv->body = g_value_dup_string (value);
 		break;
 	case PROP_TIMESTAMP:
 		priv->timestamp = g_value_get_long (value);
+		if (priv->timestamp <= 0)
+			priv->timestamp = empathy_time_get_current ();
 		break;
 	case PROP_IS_BACKLOG:
 		priv->is_backlog = g_value_get_boolean (value);
@@ -350,21 +357,6 @@ empathy_message_get_tptype (EmpathyMessage *message)
 	return priv->type;
 }
 
-void
-empathy_message_set_tptype (EmpathyMessage           *message,
-			    TpChannelTextMessageType  type)
-{
-	EmpathyMessagePriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-
-	priv = GET_PRIV (message);
-
-	priv->type = type;
-
-	g_object_notify (G_OBJECT (message), "type");
-}
-
 EmpathyContact *
 empathy_message_get_sender (EmpathyMessage *message)
 {
@@ -443,25 +435,6 @@ empathy_message_get_body (EmpathyMessage *message)
 	return priv->body;
 }
 
-void
-empathy_message_set_body (EmpathyMessage *message,
-			  const gchar    *body)
-{
-	EmpathyMessagePriv       *priv = GET_PRIV (message);
-
-	g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-
-	g_free (priv->body);
-
-	if (body) {
-		priv->body = g_strdup (body);
-	} else {
-		priv->body = NULL;
-	}
-
-	g_object_notify (G_OBJECT (message), "body");
-}
-
 time_t
 empathy_message_get_timestamp (EmpathyMessage *message)
 {
@@ -474,26 +447,6 @@ empathy_message_get_timestamp (EmpathyMessage *message)
 	return priv->timestamp;
 }
 
-void
-empathy_message_set_timestamp (EmpathyMessage *message,
-			       time_t          timestamp)
-{
-	EmpathyMessagePriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-	g_return_if_fail (timestamp >= -1);
-
-	priv = GET_PRIV (message);
-
-	if (timestamp <= 0) {
-		priv->timestamp = empathy_time_get_current ();
-	} else {
-		priv->timestamp = timestamp;
-	}
-
-	g_object_notify (G_OBJECT (message), "timestamp");
-}
-
 gboolean
 empathy_message_is_backlog (EmpathyMessage *message)
 {
@@ -506,21 +459,6 @@ empathy_message_is_backlog (EmpathyMessage *message)
 	return priv->is_backlog;
 }
 
-void
-empathy_message_set_is_backlog (EmpathyMessage *message,
-				gboolean is_backlog)
-{
-	EmpathyMessagePriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-
-	priv = GET_PRIV (message);
-
-	priv->is_backlog = is_backlog;
-
-	g_object_notify (G_OBJECT (message), "is-backlog");
-}
-
 #define IS_SEPARATOR(ch) (ch == ' ' || ch == ',' || ch == '.' || ch == ':')
 gboolean
 empathy_message_should_highlight (EmpathyMessage *message)
@@ -637,28 +575,6 @@ empathy_message_get_id (EmpathyMessage *message)
 	return priv->id;
 }
 
-void
-empathy_message_set_id (EmpathyMessage *message, guint id)
-{
-	EmpathyMessagePriv *priv = GET_PRIV (message);
-
-	priv->id = id;
-}
-
-void
-empathy_message_set_incoming (EmpathyMessage *message, gboolean incoming)
-{
-	EmpathyMessagePriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_MESSAGE (message));
-
-	priv = GET_PRIV (message);
-
-	priv->incoming = incoming;
-
-	g_object_notify (G_OBJECT (message), "incoming");
-}
-
 gboolean
 empathy_message_is_incoming (EmpathyMessage *message)
 {
@@ -699,26 +615,12 @@ empathy_message_get_flags (EmpathyMessage *self)
 	return priv->flags;
 }
 
-void
-empathy_message_set_flags        (EmpathyMessage           *self,
-				TpChannelTextMessageFlags flags)
-{
-	EmpathyMessagePriv *priv;
-
-	g_return_if_fail (EMPATHY_IS_MESSAGE (self));
-
-	priv = GET_PRIV (self);
-
-	priv->flags = flags;
-
-	g_object_notify (G_OBJECT (self), "flags");
-}
-
 EmpathyMessage *
 empathy_message_new_from_tp_message (TpMessage *tp_msg,
 				     gboolean incoming)
 {
 	EmpathyMessage *message;
+	EmpathyMessagePriv *priv;
 	gchar *body;
 	TpChannelTextMessageFlags flags;
 	guint id;
@@ -741,7 +643,8 @@ empathy_message_new_from_tp_message (TpMessage *tp_msg,
 	id = tp_asv_get_uint32 (tp_message_peek (tp_msg, 0),
 		"pending-message-id", NULL);
 
-	empathy_message_set_id (message, id);
+	priv = GET_PRIV (message);
+	priv->id = id;
 
 	g_free (body);
 	return message;
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
index fd608b1..bba65ae 100644
--- a/libempathy/empathy-message.h
+++ b/libempathy/empathy-message.h
@@ -60,8 +60,6 @@ EmpathyMessage *         empathy_message_new_from_tp_message (TpMessage *tp_msg,
 							      gboolean incoming);
 
 TpChannelTextMessageType empathy_message_get_tptype        (EmpathyMessage           *message);
-void                     empathy_message_set_tptype        (EmpathyMessage           *message,
-							    TpChannelTextMessageType  type);
 EmpathyContact *         empathy_message_get_sender        (EmpathyMessage           *message);
 void                     empathy_message_set_sender        (EmpathyMessage           *message,
 							    EmpathyContact           *contact);
@@ -69,30 +67,19 @@ EmpathyContact *         empathy_message_get_receiver      (EmpathyMessage
 void                     empathy_message_set_receiver      (EmpathyMessage           *message,
 							    EmpathyContact           *contact);
 const gchar *            empathy_message_get_body          (EmpathyMessage           *message);
-void                     empathy_message_set_body          (EmpathyMessage           *message,
-							    const gchar              *body);
 time_t                   empathy_message_get_timestamp     (EmpathyMessage           *message);
-void                     empathy_message_set_timestamp     (EmpathyMessage           *message,
-							    time_t                    timestamp);
 gboolean                 empathy_message_is_backlog        (EmpathyMessage           *message);
-void                     empathy_message_set_is_backlog    (EmpathyMessage           *message,
-							    gboolean                 is_backlog);
 gboolean                 empathy_message_is_incoming       (EmpathyMessage           *message);
-void                     empathy_message_set_incoming      (EmpathyMessage           *message,
-							    gboolean                 incoming);
 
 gboolean                 empathy_message_should_highlight  (EmpathyMessage           *message);
 TpChannelTextMessageType empathy_message_type_from_str     (const gchar              *type_str);
 const gchar *            empathy_message_type_to_str       (TpChannelTextMessageType  type);
 
 guint                    empathy_message_get_id (EmpathyMessage *message);
-void                     empathy_message_set_id (EmpathyMessage *message, guint id);
 
 gboolean                 empathy_message_equal (EmpathyMessage *message1, EmpathyMessage *message2);
 
 TpChannelTextMessageFlags empathy_message_get_flags        (EmpathyMessage           *message);
-void                      empathy_message_set_flags        (EmpathyMessage           *message,
-							    TpChannelTextMessageFlags flags);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]