# HG changeset patch
# Node ID a4c36db51270
# Parent  0822a5847e59
diff --git a/xeme/xemeconnection.c b/xeme/xemeconnection.c
--- a/xeme/xemeconnection.c
+++ b/xeme/xemeconnection.c
@@ -439,10 +439,7 @@ xeme_connection_set_resource(XemeConnect
 {
 	g_return_if_fail(XEME_IS_CONNECTION(connection));
 
-	if(!xeme_str_equal(connection->resource, resource)) {
-		g_free(connection->resource);
-		connection->resource = g_strdup(resource);
-
+	if(g_set_str(&connection->resource, resource)) {
 		g_object_notify_by_pspec(G_OBJECT(connection),
 		                         properties[PROP_RESOURCE]);
 	}
@@ -459,10 +456,7 @@ void
 xeme_connection_set_server(XemeConnection *connection, const char *server) {
 	g_return_if_fail(XEME_IS_CONNECTION(connection));
 
-	if(!xeme_str_equal(connection->server, server)) {
-		g_free(connection->server);
-		connection->server = g_strdup(server);
-
+	if(g_set_str(&connection->server, server)) {
 		g_object_notify_by_pspec(G_OBJECT(connection),
 		                         properties[PROP_SERVER]);
 	}
diff --git a/xeme/xemeextension.c b/xeme/xemeextension.c
--- a/xeme/xemeextension.c
+++ b/xeme/xemeextension.c
@@ -45,10 +45,7 @@ xeme_extension_set_element(XemeExtension
 
 	priv = xeme_extension_get_instance_private(extension);
 
-	if(!xeme_str_equal(priv->element, element)) {
-		g_free(priv->element);
-		priv->element = g_strdup(element);
-
+	if(g_set_str(&priv->element, element)) {
 		g_object_notify_by_pspec(G_OBJECT(extension),
 		                         properties[PROP_ELEMENT]);
 	}
@@ -62,10 +59,7 @@ xeme_extension_set_namespace(XemeExtensi
 
 	priv = xeme_extension_get_instance_private(extension);
 
-	if(!xeme_str_equal(priv->namespace, namespace)) {
-		g_free(priv->namespace);
-		priv->namespace = g_strdup(namespace);
-
+	if(g_set_str(&priv->namespace, namespace)) {
 		g_object_notify_by_pspec(G_OBJECT(extension),
 		                         properties[PROP_NAMESPACE]);
 	}
diff --git a/xeme/xememessage.c b/xeme/xememessage.c
--- a/xeme/xememessage.c
+++ b/xeme/xememessage.c
@@ -282,10 +282,7 @@ void
 xeme_message_set_thread(XemeMessage *message, const char *thread) {
 	g_return_if_fail(XEME_IS_MESSAGE(message));
 
-	if(g_strcmp0(message->thread, thread) != 0) {
-		g_free(message->thread);
-		message->thread = g_strdup(thread);
-
+	if(g_set_str(&message->thread, thread)) {
 		g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_THREAD]);
 	}
 }
@@ -303,10 +300,7 @@ xeme_message_set_thread_parent(XemeMessa
 {
 	g_return_if_fail(XEME_IS_MESSAGE(message));
 
-	if(g_strcmp0(message->thread_parent, thread_parent) != 0) {
-		g_free(message->thread_parent);
-		message->thread_parent = g_strdup(thread_parent);
-
+	if(g_set_str(&message->thread_parent, thread_parent)) {
 		g_object_notify_by_pspec(G_OBJECT(message),
 		                         properties[PROP_THREAD_PARENT]);
 	}
diff --git a/xeme/xemestanza.c b/xeme/xemestanza.c
--- a/xeme/xemestanza.c
+++ b/xeme/xemestanza.c
@@ -215,10 +215,7 @@ xeme_stanza_set_content_type(XemeStanza 
 
 	priv = xeme_stanza_get_instance_private(stanza);
 
-	if(g_strcmp0(priv->content_type, content_type) != 0) {
-		g_free(priv->content_type);
-		priv->content_type = g_strdup(content_type);
-
+	if(g_set_str(&priv->content_type, content_type)) {
 		g_object_notify_by_pspec(G_OBJECT(stanza),
 		                         properties[PROP_CONTENT_TYPE]);
 	}
@@ -244,10 +241,7 @@ xeme_stanza_set_from(XemeStanza *stanza,
 
 	priv = xeme_stanza_get_instance_private(stanza);
 
-	if(g_strcmp0(priv->from, from) != 0) {
-		g_free(priv->from);
-		priv->from = g_strdup(from);
-
+	if(g_set_str(&priv->from, from)) {
 		g_object_notify_by_pspec(G_OBJECT(stanza), properties[PROP_FROM]);
 	}
 }
@@ -272,10 +266,7 @@ xeme_stanza_set_id(XemeStanza *stanza, c
 
 	priv = xeme_stanza_get_instance_private(stanza);
 
-	if(g_strcmp0(priv->id, id) != 0) {
-		g_free(priv->id);
-		priv->id = g_strdup(id);
-
+	if(g_set_str(&priv->id, id)) {
 		g_object_notify_by_pspec(G_OBJECT(stanza), properties[PROP_ID]);
 	}
 }
@@ -300,10 +291,7 @@ xeme_stanza_set_to(XemeStanza *stanza, c
 
 	priv = xeme_stanza_get_instance_private(stanza);
 
-	if(g_strcmp0(priv->to, to) != 0) {
-		g_free(priv->to);
-		priv->to = g_strdup(to);
-
+	if(g_set_str(&priv->to, to)) {
 		g_object_notify_by_pspec(G_OBJECT(stanza),
 		                         properties[PROP_TO]);
 	}
@@ -328,10 +316,7 @@ xeme_stanza_set_xml_lang(XemeStanza *sta
 
 	priv = xeme_stanza_get_instance_private(stanza);
 
-	if(g_strcmp0(priv->xml_lang, xml_lang) != 0) {
-		g_free(priv->xml_lang);
-		priv->xml_lang = g_strdup(xml_lang);
-
+	if(g_set_str(&priv->xml_lang, xml_lang)) {
 		g_object_notify_by_pspec(G_OBJECT(stanza), properties[PROP_XML_LANG]);
 	}
 }
diff --git a/xeme/xemestream.c b/xeme/xemestream.c
--- a/xeme/xemestream.c
+++ b/xeme/xemestream.c
@@ -270,10 +270,7 @@ xeme_stream_set_id(XemeStream *stream, c
 
 	priv = xeme_stream_get_instance_private(stream);
 
-	if(g_strcmp0(priv->id, id) != 0) {
-		g_free(priv->id);
-		priv->id = g_strdup(id);
-
+	if(g_set_str(&priv->id, id)) {
 		g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_ID]);
 	}
 }
@@ -297,10 +294,7 @@ xeme_stream_set_to(XemeStream *stream, c
 
 	priv = xeme_stream_get_instance_private(stream);
 
-	if(g_strcmp0(priv->to, to) != 0) {
-		g_free(priv->to);
-		priv->to = g_strdup(to);
-
+	if(g_set_str(&priv->to, to)) {
 		g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_TO]);
 	}
 }
@@ -324,10 +318,7 @@ xeme_stream_set_from(XemeStream *stream,
 
 	priv = xeme_stream_get_instance_private(stream);
 
-	if(g_strcmp0(priv->from, from) != 0) {
-		g_free(priv->from);
-		priv->from = g_strdup(from);
-
+	if(g_set_str(&priv->from, from)) {
 		g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_FROM]);
 	}
 }
@@ -351,10 +342,7 @@ xeme_stream_set_language(XemeStream *str
 
 	priv = xeme_stream_get_instance_private(stream);
 
-	if(g_strcmp0(priv->language, language) != 0) {
-		g_free(priv->language);
-		priv->language = g_strdup(language);
-
+	if(g_set_str(&priv->language, language)) {
 		g_object_notify_by_pspec(G_OBJECT(stream),
 		                         properties[PROP_LANGUAGE]);
 	}
@@ -378,10 +366,7 @@ xeme_stream_set_version(XemeStream *stre
 	g_return_if_fail(XEME_IS_STREAM(stream));
 
 	priv = xeme_stream_get_instance_private(stream);
-	if(!xeme_str_equal(priv->version, version)) {
-		g_free(priv->version);
-		priv->version = g_strdup(version);
-
+	if(g_set_str(&priv->version, version)) {
 		g_object_notify_by_pspec(G_OBJECT(stream), properties[PROP_VERSION]);
 	}
 }
