Re: Patch (work in progress): remove TnyHeader get strings methods to provide dups



El mar, 25-03-2008 a las 15:18 +0100, Philip Van Hoof escribió:
> We are going for this API in Tinymail, because it's the right thing to
> do, so prepare your horses if you have been depending on TnyHeader's
> API.
> 
> Me and Jose are reviewing the work and will be migrating this patch into
> trunk today and tomorrow.

	Ok, and just another version of the patch, reducing a lot the changes
involving camel and adding some suggestions from Philip.

-- 
Jose Dapena Paz <jdapena igalia com>
Igalia
Index: libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-bs-msg-receive-strategy.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-bs-msg-receive-strategy.c	(copia de trabajo)
@@ -119,7 +119,7 @@
 	GError *parse_err = NULL;
 	CamelFolder *cfolder = _tny_camel_folder_get_camel_folder (TNY_CAMEL_FOLDER (folder));
 
-	uid = g_strdup (tny_header_get_uid (TNY_HEADER (header)));
+	uid = tny_header_dup_uid (TNY_HEADER (header));
 	structure_str = camel_folder_fetch_structure (cfolder, (const char *) uid, &ex);
 
 	if (camel_exception_is_set (&ex)) {
Index: libtinymail-camel/tny-camel-folder.c
===================================================================
--- libtinymail-camel/tny-camel-folder.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-folder.c	(copia de trabajo)
@@ -3785,10 +3785,10 @@
 	while (!tny_iterator_is_done (iter)) 
 	{
 		TnyHeader *header;
-		const gchar *uid;
+		gchar *uid;
 
 		header = TNY_HEADER (tny_iterator_get_current (iter));
-		uid = tny_header_get_uid (header);
+		uid = tny_header_dup_uid (header);
 
 		if (G_UNLIKELY (uid == NULL)) 
 		{
@@ -3811,7 +3811,7 @@
 			_tny_session_stop_operation (TNY_FOLDER_PRIV_GET_SESSION (priv));
 			return;
 		} else
-			g_ptr_array_add (uids, (gpointer) g_strdup (uid));
+			g_ptr_array_add (uids, (gpointer) uid);
 
 		g_object_unref (header);
 		tny_iterator_next (iter);
Index: libtinymail-camel/tny-camel-msg-remove-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-msg-remove-strategy.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-msg-remove-strategy.c	(copia de trabajo)
@@ -80,7 +80,7 @@
 	g_assert (TNY_IS_CAMEL_FOLDER (folder));
 	g_assert (TNY_IS_HEADER (header));
 
-	id = g_strdup (tny_header_get_uid (TNY_HEADER (header)));
+	id = tny_header_dup_uid (TNY_HEADER (header));
 	cfolder = _tny_camel_folder_get_folder (TNY_CAMEL_FOLDER (folder));
 	camel_folder_delete_message (cfolder, id);
 	camel_object_unref (CAMEL_OBJECT (cfolder));
Index: libtinymail-camel/tny-camel-mime-part.c
===================================================================
--- libtinymail-camel/tny-camel-mime-part.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-mime-part.c	(copia de trabajo)
@@ -352,22 +352,35 @@
 	if (TNY_IS_MSG (orig)) {
 		TnyHeader *hdr = NULL;
 		TnyHeader *dest_header;
+		gchar *str;
 
 		hdr = tny_msg_get_header (TNY_MSG (orig));
 		retval = TNY_MIME_PART (tny_camel_msg_new ());
  		dest_header = tny_msg_get_header (TNY_MSG (retval));
-		if (tny_header_get_bcc (hdr))
-			tny_header_set_bcc (dest_header, tny_header_get_bcc (hdr));
-		if (tny_header_get_cc (hdr))
-			tny_header_set_cc (dest_header, tny_header_get_cc (hdr));
-		if (tny_header_get_from (hdr))
-			tny_header_set_from (dest_header, tny_header_get_from (hdr));
-		if (tny_header_get_replyto (hdr))
-			tny_header_set_replyto (dest_header, tny_header_get_replyto (hdr));
-		if (tny_header_get_subject (hdr))
-			tny_header_set_subject (dest_header, tny_header_get_subject (hdr));
-		if (tny_header_get_to (hdr))
-			tny_header_set_to (dest_header, tny_header_get_to (hdr));
+		if (str = tny_header_dup_bcc (hdr)) {
+			tny_header_set_bcc (dest_header, str);
+			g_free (str);
+		}
+		if (str = tny_header_dup_cc (hdr)) {
+			tny_header_set_cc (dest_header, str);
+			g_free (str);
+		}
+		if (str = tny_header_dup_from (hdr)) {
+			tny_header_set_from (dest_header, str);
+			g_free (str);
+		}
+		if (str = tny_header_dup_replyto (hdr)) {
+			tny_header_set_replyto (dest_header, str);
+			g_free (str);
+		}
+		if (str = tny_header_dup_subject (hdr)) {
+			tny_header_set_subject (dest_header, str);
+			g_free (str);
+		}
+		if (str = tny_header_dup_to (hdr)) {
+			tny_header_set_to (dest_header, str);
+			g_free (str);
+		}
 		/* tny_header_set_priority (dest_header, tny_header_get_priority (hdr)); */
 		g_object_unref (hdr);
 		g_object_unref (dest_header);
Index: libtinymail-camel/camel-lite/camel/camel-folder-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-folder-summary.c	(revisión: 3521)
+++ libtinymail-camel/camel-lite/camel/camel-folder-summary.c	(copia de trabajo)
@@ -4034,7 +4034,18 @@
 	/*camel_content_info_dump(mi->content, 0);*/
 }
 
+void
+camel_folder_summary_lock ()
+{
+	g_static_rec_mutex_lock (&global_lock);	
+}
 
+void
+camel_folder_summary_unlock ()
+{
+	g_static_rec_mutex_unlock (&global_lock);	
+}
+
 static void
 camel_folder_summary_class_init (CamelFolderSummaryClass *klass)
 {
Index: libtinymail-camel/camel-lite/camel/camel-folder-summary.h
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-folder-summary.h	(revisión: 3521)
+++ libtinymail-camel/camel-lite/camel/camel-folder-summary.h	(copia de trabajo)
@@ -400,6 +400,9 @@
 void camel_folder_summary_move_up (CamelFolderSummary *s);
 #endif
 
+void camel_folder_summary_lock ();
+void camel_folder_summary_unlock ();
+
 G_END_DECLS
 
 #endif /* ! _CAMEL_FOLDER_SUMMARY_H */
Index: libtinymail-camel/tny-camel-pop-remote-msg-remove-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-pop-remote-msg-remove-strategy.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-pop-remote-msg-remove-strategy.c	(copia de trabajo)
@@ -78,13 +78,13 @@
 {
 	TnyCamelFolderPriv *fpriv = NULL;
 	TnyAccount *acc = NULL;
-	const gchar *uid;
+	gchar *uid;
 	CamelFolder *cfolder;
 
 	g_assert (TNY_IS_CAMEL_FOLDER (folder));
 	g_assert (TNY_IS_HEADER (header));
 
-	uid = tny_header_get_uid (header);
+	uid = tny_header_dup_uid (header);
 	fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (folder);
 	acc = fpriv->account;
 
@@ -92,24 +92,23 @@
 	{
 		const CamelService *service = _tny_camel_account_get_service (TNY_CAMEL_ACCOUNT (acc));
 		CamelPOP3Store *pop3_store = (CamelPOP3Store *) service;
-		gchar *expunged_path = NULL, *id = NULL;
+		gchar *expunged_path = NULL;
 		FILE *file = NULL;
 
-		id = g_strdup (uid);
 		/* camel-pop3-folder.c:455 + 490 is also interesting code! */
-		expunged_path = g_strdup_printf ("%s/%s.expunged", pop3_store->storage_path, id);
+		expunged_path = g_strdup_printf ("%s/%s.expunged", pop3_store->storage_path, uid);
 		cfolder = _tny_camel_folder_get_folder (TNY_CAMEL_FOLDER (folder));
-		camel_folder_delete_message (cfolder, id);
-		g_free (id);
+		camel_folder_delete_message (cfolder, uid);
 		camel_object_unref (CAMEL_OBJECT (cfolder));
 		file = fopen (expunged_path, "w");
 		g_free (expunged_path);
 		if (file != NULL)
 		{
-			fprintf (file, "%s", id);
+			fprintf (file, "%s", uid);
 			fclose (file);
 		}
 	}
+	g_free (uid);
 
 	return;
 }
Index: libtinymail-camel/tny-camel-full-msg-receive-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-full-msg-receive-strategy.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-full-msg-receive-strategy.c	(copia de trabajo)
@@ -75,7 +75,7 @@
 	if (!priv->strict_retrieval)
 		mtype = CAMEL_FOLDER_RECEIVE_ANY_OR_FULL;
 
-	id = g_strdup (tny_header_get_uid (TNY_HEADER (header)));
+	id = tny_header_dup_uid (TNY_HEADER (header));
 	message = NULL;
 	camel_message = camel_folder_get_message (priv->folder, (const char *) id, mtype, -1, &ex);
 	g_free (id);
@@ -97,7 +97,7 @@
 			_tny_camel_msg_set_received (TNY_CAMEL_MSG (message), 
 				tny_header_get_date_received (header));
 			_tny_camel_msg_set_folder (TNY_CAMEL_MSG (message), folder);
-			TNY_CAMEL_MSG_HEADER (nheader)->old_uid = g_strdup (tny_header_get_uid (header));
+			TNY_CAMEL_MSG_HEADER (nheader)->old_uid = tny_header_dup_uid (header);
 			_tny_camel_msg_set_header (TNY_CAMEL_MSG (message), nheader);
 			_tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message), 
 						CAMEL_MIME_PART (camel_message)); 
Index: libtinymail-camel/tny-camel-send-queue.c
===================================================================
--- libtinymail-camel/tny-camel-send-queue.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-send-queue.c	(copia de trabajo)
@@ -427,13 +427,17 @@
 			{
 				TnyHeader *curhdr = TNY_HEADER (tny_iterator_get_current (giter));
 				TnyHeaderFlags flags = tny_header_get_flags (curhdr);
+				gchar *uid;
 
+				uid = tny_header_dup_uid (curhdr);
+
 				if ((flags & TNY_HEADER_FLAG_SUSPENDED) ||
 				    (flags & TNY_HEADER_FLAG_ANSWERED) ||
 				    (g_hash_table_lookup_extended (failed_headers, 
-								   tny_header_get_uid (curhdr),
+								   uid,
 								   NULL, NULL)))
 					to_remove = g_list_prepend (to_remove, curhdr);
+				g_free (uid);
 
 				g_object_unref (curhdr);
 				tny_iterator_next (giter);
@@ -495,12 +499,12 @@
 				if (err != NULL) {
 					emit_error (self, header, msg, err, i, priv->total);
 					g_hash_table_insert (failed_headers, 
-							     g_strdup (tny_header_get_uid (header)), NULL);
+							     tny_header_dup_uid (header), NULL);
 				}
 			} else {
 				emit_error (self, header, msg, err, i, priv->total);
 				g_hash_table_insert (failed_headers, 
-						     g_strdup (tny_header_get_uid (header)), NULL);
+						     tny_header_dup_uid (header), NULL);
 			}
 
 			g_static_rec_mutex_lock (priv->todo_lock);
Index: libtinymail-camel/tny-camel-msg.c
===================================================================
--- libtinymail-camel/tny-camel-msg.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-msg.c	(copia de trabajo)
@@ -173,7 +173,7 @@
 	if (priv->folder)
 	{
 		TnyHeader *header = tny_msg_get_header (self);
-		const gchar *uid = tny_header_get_uid (header);
+		gchar *uid = tny_header_dup_uid (header);
 
 		/* This is incorrect, the UID will always be NULL */
 
@@ -195,6 +195,7 @@
 					g_free (urls);
 				}
 			}
+			g_free (uid);
 		}
 
 		g_object_unref (G_OBJECT (header));
@@ -210,10 +211,12 @@
 	CamelMimeMessage *msg;
 	
 	if (priv->folder && priv->header) {
+		gchar *uid;
 		msg = _tny_camel_msg_get_camel_mime_message (TNY_CAMEL_MSG (self));
+		uid = tny_header_dup_uid (priv->header);
 		_tny_camel_folder_rewrite_cache (TNY_CAMEL_FOLDER(priv->folder),
-						 tny_header_get_uid (priv->header),
-						 msg);
+						 uid, msg);
+		g_free (uid);
 	}
 	return;
 }
@@ -264,9 +267,11 @@
 
 	if (priv->folder && priv->header)
 	{
+		gchar *uid;
+		uid = tny_header_dup_uid (priv->header);
 		_tny_camel_folder_uncache_attachments (
-			TNY_CAMEL_FOLDER (priv->folder),
-			tny_header_get_uid (priv->header));
+			TNY_CAMEL_FOLDER (priv->folder), uid);
+		g_free (uid);
 		/* tny_header_set_flag (priv->header, TNY_HEADER_FLAG_PARTIAL); */
 	}
 }
Index: libtinymail-camel/tny-camel-partial-msg-receive-strategy.c
===================================================================
--- libtinymail-camel/tny-camel-partial-msg-receive-strategy.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-partial-msg-receive-strategy.c	(copia de trabajo)
@@ -75,7 +75,7 @@
 	if (!priv->strict_retrieval)
 		mtype = CAMEL_FOLDER_RECEIVE_ANY_OR_PARTIAL;
 
-	id = g_strdup (tny_header_get_uid (TNY_HEADER (header)));
+	id = tny_header_dup_uid (TNY_HEADER (header));
 
 	message = NULL;
 	camel_message = camel_folder_get_message (priv->folder, (const char *) id, mtype, -1, &ex);
@@ -97,7 +97,7 @@
 			_tny_camel_msg_set_received (TNY_CAMEL_MSG (message), 
 				tny_header_get_date_received (header));
 			_tny_camel_msg_set_folder (TNY_CAMEL_MSG (message), folder);
-			TNY_CAMEL_MSG_HEADER (nheader)->old_uid = g_strdup (tny_header_get_uid (header));
+			TNY_CAMEL_MSG_HEADER (nheader)->old_uid = tny_header_dup_uid (header);
 			_tny_camel_msg_set_header (TNY_CAMEL_MSG (message), nheader);
 			_tny_camel_mime_part_set_part (TNY_CAMEL_MIME_PART (message), 
 						CAMEL_MIME_PART (camel_message)); 
Index: libtinymail-camel/tny-camel-msg-header.c
===================================================================
--- libtinymail-camel/tny-camel-msg-header.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-msg-header.c	(copia de trabajo)
@@ -88,8 +88,8 @@
 	return camel_header_decode_string (str, charset);
 }
 
-static const gchar*
-tny_camel_msg_header_get_replyto (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_replyto (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 	const gchar *enc;
@@ -99,7 +99,7 @@
 		me->reply_to = decode_it (me->msg, enc, TRUE);
 	}
 
-	return (const gchar *) me->reply_to;
+	return g_strdup ((const gchar *) me->reply_to);
 }
 
 
@@ -204,8 +204,8 @@
 }
 
 
-static const gchar*
-tny_camel_msg_header_get_cc (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_cc (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 	const gchar *enc;
@@ -215,11 +215,11 @@
 		me->cc = decode_it (me->msg, enc, TRUE);
 	}
 
-	return (const gchar *) me->cc;
+	return g_strdup ((const gchar *) me->cc);
 }
 
-static const gchar*
-tny_camel_msg_header_get_bcc (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_bcc (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 	const gchar *enc;
@@ -229,7 +229,7 @@
 		me->bcc = decode_it (me->msg, enc, TRUE);
 	}
 
-	return (const gchar *) me->bcc;
+	return g_strdup ((const gchar *) me->bcc);
 }
 
 static TnyHeaderFlags
@@ -386,8 +386,8 @@
 		return retval;
 }
 
-static const gchar*
-tny_camel_msg_header_get_from (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_from (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 	const gchar *enc;
@@ -397,11 +397,11 @@
 		me->from = decode_it (me->msg, enc, TRUE);
 	}
 
-	return (const gchar *) me->from;
+	return g_strdup ((const gchar *) me->from);
 }
 
-static const gchar*
-tny_camel_msg_header_get_subject (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_subject (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 	const gchar *enc;
@@ -411,12 +411,12 @@
 		me->subject = decode_it (me->msg, enc, FALSE);
 	}
 
-	return (const gchar *) me->subject;
+	return g_strdup ((const gchar *) me->subject);
 }
 
 
-static const gchar*
-tny_camel_msg_header_get_to (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_to (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 	const gchar *enc;
@@ -426,17 +426,17 @@
 		me->to = decode_it (me->msg, enc, TRUE);
 	}
 
-	return (const gchar *) me->to;
+	return g_strdup ((const gchar *) me->to);
 
 }
 
-static const gchar*
-tny_camel_msg_header_get_message_id (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_message_id (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = camel_mime_message_get_message_id (me->msg);
+	retval = g_strdup (camel_mime_message_get_message_id (me->msg));
 
 	return retval;
 }
@@ -458,19 +458,19 @@
 	return retval;
 }
 
-static const gchar*
-tny_camel_msg_header_get_uid (TnyHeader *self)
+static gchar*
+tny_camel_msg_header_dup_uid (TnyHeader *self)
 {
 	TnyCamelMsgHeader *me = TNY_CAMEL_MSG_HEADER (self);
 
 	if (!me->old_uid)
 	{
-		g_warning ("tny_header_get_uid: This is a header instance for a new message. "
+		g_warning ("tny_header_dup_uid: This is a header instance for a new message. "
 			"The uid of it is therefore not available. This indicates a problem "
 			"in the software.");
 	}
 
-	return me->old_uid;
+	return g_strdup (me->old_uid);
 }
 
 static void 
@@ -586,17 +586,17 @@
 {
 	TnyHeaderIface *klass = (TnyHeaderIface *)g;
 
-	klass->get_from= tny_camel_msg_header_get_from;
-	klass->get_message_id= tny_camel_msg_header_get_message_id;
+	klass->dup_from= tny_camel_msg_header_dup_from;
+	klass->dup_message_id= tny_camel_msg_header_dup_message_id;
 	klass->get_message_size= tny_camel_msg_header_get_message_size;
-	klass->get_to= tny_camel_msg_header_get_to;
-	klass->get_subject= tny_camel_msg_header_get_subject;
+	klass->dup_to= tny_camel_msg_header_dup_to;
+	klass->dup_subject= tny_camel_msg_header_dup_subject;
 	klass->get_date_received= tny_camel_msg_header_get_date_received;
 	klass->get_date_sent= tny_camel_msg_header_get_date_sent;
-	klass->get_cc= tny_camel_msg_header_get_cc;
-	klass->get_bcc= tny_camel_msg_header_get_bcc;
-	klass->get_replyto= tny_camel_msg_header_get_replyto;
-	klass->get_uid= tny_camel_msg_header_get_uid;
+	klass->dup_cc= tny_camel_msg_header_dup_cc;
+	klass->dup_bcc= tny_camel_msg_header_dup_bcc;
+	klass->dup_replyto= tny_camel_msg_header_dup_replyto;
+	klass->dup_uid= tny_camel_msg_header_dup_uid;
 	klass->get_folder= tny_camel_msg_header_get_folder;
 	klass->set_bcc= tny_camel_msg_header_set_bcc;
 	klass->set_cc= tny_camel_msg_header_set_cc;
Index: libtinymail-camel/tny-camel-bs-msg-header.c
===================================================================
--- libtinymail-camel/tny-camel-bs-msg-header.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-bs-msg-header.c	(copia de trabajo)
@@ -36,11 +36,11 @@
 static GObjectClass *parent_class = NULL;
 
 
-static const gchar*
-tny_camel_bs_msg_header_get_replyto (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_replyto (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->reply_to;
+	return g_strdup (me->envelope->reply_to);
 }
 
 
@@ -88,18 +88,18 @@
 }
 
 
-static const gchar*
-tny_camel_bs_msg_header_get_cc (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_cc (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->cc;
+	return g_strdup (me->envelope->cc);
 }
 
-static const gchar*
-tny_camel_bs_msg_header_get_bcc (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_bcc (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->bcc;
+	return g_strdup (me->envelope->bcc);
 }
 
 static TnyHeaderFlags
@@ -136,33 +136,33 @@
 	return camel_header_decode_date (me->envelope->date, NULL);
 }
 
-static const gchar*
-tny_camel_bs_msg_header_get_from (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_from (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->from;
+	return g_strdup (me->envelope->from);
 }
 
-static const gchar*
-tny_camel_bs_msg_header_get_subject (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_subject (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->subject;
+	return g_strdup (me->envelope->subject);
 }
 
 
-static const gchar*
-tny_camel_bs_msg_header_get_to (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_to (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->to;
+	return g_strdup (me->envelope->to);
 }
 
-static const gchar*
-tny_camel_bs_msg_header_get_message_id (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_message_id (TnyHeader *self)
 {
 	TnyCamelBsMsgHeader *me = TNY_CAMEL_BS_MSG_HEADER (self);
-	return me->envelope->message_id;
+	return g_strdup (me->envelope->message_id);
 }
 
 
@@ -174,10 +174,10 @@
 	return me->msg_size;
 }
 
-static const gchar*
-tny_camel_bs_msg_header_get_uid (TnyHeader *self)
+static gchar*
+tny_camel_bs_msg_header_dup_uid (TnyHeader *self)
 {
-	g_warning ("tny_header_get_uid: This is a header instance for a RFC822 message. "
+	g_warning ("tny_header_dup_uid: This is a header instance for a RFC822 message. "
 		"The uid of it is therefore not available. This indicates a problem "
 		"in the software.");
 
@@ -214,17 +214,17 @@
 {
 	TnyHeaderIface *klass = (TnyHeaderIface *)g;
 
-	klass->get_from= tny_camel_bs_msg_header_get_from;
-	klass->get_message_id= tny_camel_bs_msg_header_get_message_id;
+	klass->dup_from= tny_camel_bs_msg_header_dup_from;
+	klass->dup_message_id= tny_camel_bs_msg_header_dup_message_id;
 	klass->get_message_size= tny_camel_bs_msg_header_get_message_size;
-	klass->get_to= tny_camel_bs_msg_header_get_to;
-	klass->get_subject= tny_camel_bs_msg_header_get_subject;
+	klass->dup_to= tny_camel_bs_msg_header_dup_to;
+	klass->dup_subject= tny_camel_bs_msg_header_dup_subject;
 	klass->get_date_received= tny_camel_bs_msg_header_get_date_received;
 	klass->get_date_sent= tny_camel_bs_msg_header_get_date_sent;
-	klass->get_cc= tny_camel_bs_msg_header_get_cc;
-	klass->get_bcc= tny_camel_bs_msg_header_get_bcc;
-	klass->get_replyto= tny_camel_bs_msg_header_get_replyto;
-	klass->get_uid= tny_camel_bs_msg_header_get_uid;
+	klass->dup_cc= tny_camel_bs_msg_header_dup_cc;
+	klass->dup_bcc= tny_camel_bs_msg_header_dup_bcc;
+	klass->dup_replyto= tny_camel_bs_msg_header_dup_replyto;
+	klass->dup_uid= tny_camel_bs_msg_header_dup_uid;
 	klass->get_folder= tny_camel_bs_msg_header_get_folder;
 	klass->set_bcc= tny_camel_bs_msg_header_set_bcc;
 	klass->set_cc= tny_camel_bs_msg_header_set_cc;
Index: libtinymail-camel/tny-camel-header.c
===================================================================
--- libtinymail-camel/tny-camel-header.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-header.c	(copia de trabajo)
@@ -71,8 +71,8 @@
 }
 
 
-static const gchar*
-tny_camel_header_get_replyto (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_replyto (TnyHeader *self)
 {
 	return NULL;
 }
@@ -122,19 +122,21 @@
 }
 
 
-static const gchar*
-tny_camel_header_get_cc (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_cc (TnyHeader *self)
 {
 	TnyCamelHeader *me = TNY_CAMEL_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = camel_message_info_cc (me->info);
+	camel_folder_summary_lock ();
+	retval = g_strdup (camel_message_info_cc (me->info));
+	camel_folder_summary_unlock ();
 
 	return retval;
 }
 
-static const gchar*
-tny_camel_header_get_bcc (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_bcc (TnyHeader *self)
 {
 	return NULL;
 }
@@ -222,47 +224,55 @@
 	return retval;
 }
 	
-static const gchar*
-tny_camel_header_get_from (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_from (TnyHeader *self)
 {
 	TnyCamelHeader *me = TNY_CAMEL_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = camel_message_info_from (me->info);
+	camel_folder_summary_lock ();
+	retval = g_strdup (camel_message_info_from (me->info));
+	camel_folder_summary_unlock ();
 
 	return retval;
 }
 
-static const gchar*
-tny_camel_header_get_subject (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_subject (TnyHeader *self)
 {
 	TnyCamelHeader *me = TNY_CAMEL_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = camel_message_info_subject (me->info);
+	camel_folder_summary_lock ();
+	retval = g_strdup (camel_message_info_subject (me->info));
+	camel_folder_summary_unlock ();
 
 	return retval;
 }
 
 
-static const gchar*
-tny_camel_header_get_to (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_to (TnyHeader *self)
 {
 	TnyCamelHeader *me = TNY_CAMEL_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = camel_message_info_to (me->info);
+	camel_folder_summary_lock ();
+	retval = g_strdup (camel_message_info_to (me->info));
+	camel_folder_summary_unlock ();
 
 	return retval;
 }
 
-static const gchar*
-tny_camel_header_get_message_id (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_message_id (TnyHeader *self)
 {
 	TnyCamelHeader *me = TNY_CAMEL_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = (const gchar*) camel_message_info_message_id (me->info);
+	camel_folder_summary_lock ();
+	retval = (gchar*) camel_message_info_message_id (me->info);
+	camel_folder_summary_unlock ();
 
 	return retval;
 }
@@ -282,13 +292,13 @@
 
 }
 
-static const gchar*
-tny_camel_header_get_uid (TnyHeader *self)
+static gchar*
+tny_camel_header_dup_uid (TnyHeader *self)
 {
 	TnyCamelHeader *me = TNY_CAMEL_HEADER (self);
-	const gchar *retval = NULL;
+	gchar *retval = NULL;
 
-	retval = camel_message_info_uid (me->info);
+	retval = g_strdup (camel_message_info_uid (me->info));
 
 	return retval;
 }
@@ -352,17 +362,17 @@
 {
 	TnyHeaderIface *klass = (TnyHeaderIface *)g;
 
-	klass->get_from= tny_camel_header_get_from;
-	klass->get_message_id= tny_camel_header_get_message_id;
+	klass->dup_from= tny_camel_header_dup_from;
+	klass->dup_message_id= tny_camel_header_dup_message_id;
 	klass->get_message_size= tny_camel_header_get_message_size;
-	klass->get_to= tny_camel_header_get_to;
-	klass->get_subject= tny_camel_header_get_subject;
+	klass->dup_to= tny_camel_header_dup_to;
+	klass->dup_subject= tny_camel_header_dup_subject;
 	klass->get_date_received= tny_camel_header_get_date_received;
 	klass->get_date_sent= tny_camel_header_get_date_sent;
-	klass->get_cc= tny_camel_header_get_cc;
-	klass->get_bcc= tny_camel_header_get_bcc;
-	klass->get_replyto= tny_camel_header_get_replyto;
-	klass->get_uid= tny_camel_header_get_uid;
+	klass->dup_cc= tny_camel_header_dup_cc;
+	klass->dup_bcc= tny_camel_header_dup_bcc;
+	klass->dup_replyto= tny_camel_header_dup_replyto;
+	klass->dup_uid= tny_camel_header_dup_uid;
 	klass->get_folder= tny_camel_header_get_folder;
 	klass->set_bcc= tny_camel_header_set_bcc;
 	klass->set_cc= tny_camel_header_set_cc;
Index: libtinymail-camel/tny-camel-bs-msg.c
===================================================================
--- libtinymail-camel/tny-camel-bs-msg.c	(revisión: 3521)
+++ libtinymail-camel/tny-camel-bs-msg.c	(copia de trabajo)
@@ -111,7 +111,7 @@
 
 	if (priv->folder) {
 		TnyHeader *header = tny_msg_get_header (self);
-		const gchar *uid = tny_header_get_uid (header);
+		gchar *uid = tny_header_dup_uid (header);
 
 		if (uid) {
 			TnyCamelFolderPriv *fpriv = TNY_CAMEL_FOLDER_GET_PRIVATE (priv->folder);
@@ -128,6 +128,7 @@
 					g_free (urls);
 				}
 			}
+			g_free (uid);
 		}
 
 		g_object_unref (header);
Index: libtinymail/tny-folder-monitor.c
===================================================================
--- libtinymail/tny-folder-monitor.c	(revisión: 3521)
+++ libtinymail/tny-folder-monitor.c	(copia de trabajo)
@@ -156,12 +156,15 @@
 static gboolean 
 uid_matcher (TnyList *list, GObject *item, gpointer match_data)
 {
-	const char *uid = tny_header_get_uid ((TnyHeader *) item);
+	gboolean result = FALSE;
+	char *uid = tny_header_dup_uid ((TnyHeader *) item);
 
 	if (uid && !strcmp (uid, (const char*) match_data))
- 		return TRUE;
+ 		result = TRUE;
 
-	return FALSE;
+	g_free (uid);
+
+	return result;
 }
 
 
@@ -173,10 +176,11 @@
 	while (!tny_iterator_is_done (iter))
 	{
 		TnyList *list = TNY_LIST (tny_iterator_get_current (iter));
-		const gchar *uid = tny_header_get_uid (header);
+		gchar *uid = tny_header_dup_uid (header);
 
 		if (check_duplicates && uid)
 			tny_list_remove_matches (list, uid_matcher, (gpointer) uid); 
+		g_free (uid);
 
 		tny_list_prepend (list, (GObject *) header);
 
@@ -266,11 +270,8 @@
 		{
 			const gchar *uid;
 			TnyHeader *header = TNY_HEADER (tny_iterator_get_current (iter));
-			uid = tny_header_get_uid (header);
-			if (uid) {
-				gchar *tuid = g_strdup (uid);
-				g_ptr_array_add (array, tuid);
-			}
+			uid = tny_header_dup_uid (header);
+			g_ptr_array_add (array, uid);
 			g_object_unref (header);
 			tny_iterator_next (iter);
 		}
Index: libtinymail/tny-header.c
===================================================================
--- libtinymail/tny-header.c	(revisión: 3521)
+++ libtinymail/tny-header.c	(copia de trabajo)
@@ -63,24 +63,24 @@
 }
 
 /**
- * tny_header_get_replyto:
+ * tny_header_dup_replyto:
  * @self: a #TnyHeader
  * 
  * Get the reply-to header
  * 
- * returns: (null-ok): reply-to header or NULL
+ * returns: (null-ok) (caller-owns): reply-to header or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar*
-tny_header_get_replyto (TnyHeader *self)
+gchar*
+tny_header_dup_replyto (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_replyto!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_replyto!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_replyto(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_replyto(self);
 }
 
 /**
@@ -221,45 +221,45 @@
 }
 
 /**
- * tny_header_get_cc:
+ * tny_header_dup_cc:
  * @self: a #TnyHeader
  * 
  * Get the CC header. The returned value should not be freed.
  * 
- * returns: (null-ok): CC header as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): CC header as a alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar*
-tny_header_get_cc (TnyHeader *self)
+gchar*
+tny_header_dup_cc (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_cc!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_cc!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_cc(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_cc(self);
 }
 
 /**
- * tny_header_get_bcc:
+ * tny_header_dup_bcc:
  * @self: a #TnyHeader
  * 
  * Get the BCC header. The returned value should not be freed.
  * 
- * returns: (null-ok): BCC header as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): BCC header as an alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar*
-tny_header_get_bcc (TnyHeader *self)
+gchar*
+tny_header_dup_bcc (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_bcc!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_bcc!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_bcc(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_bcc(self);
 }
 
 /**
@@ -306,49 +306,49 @@
 
 
 /**
- * tny_header_get_uid:
+ * tny_header_dup_uid:
  * @self: a #TnyHeader
  * 
- * Get an unique id of the message of which @self is a message header. The 
- * returned value should not be freed. The UID corresponds to the UID in
+ * Get an unique id of the message of which @self is a message header. The UID
+ * corresponds to the UID in
  * IMAP and the UIDL in POP if UIDL is supported or the UID if not.
  * 
- * returns: (null-ok): unique follow-up uid as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): unique follow-up uid as an alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar*
-tny_header_get_uid (TnyHeader *self)
+gchar*
+tny_header_dup_uid (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_uid!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_uid!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_uid(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_uid(self);
 }
 
 /**
- * tny_header_get_message_id:
+ * tny_header_dup_message_id:
  * @self: a #TnyHeader
  * 
  * Get an unique id of the message of which self is a message header. The 
- * returned value should not be freed. The message-id corresponds to the
+ * returned value should be freed. The message-id corresponds to the
  * message-id header in the MIME message.
  * 
- * returns: (null-ok): message-id header as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): message-id header as an alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar*
-tny_header_get_message_id (TnyHeader *self)
+gchar*
+tny_header_dup_message_id (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_message_id!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_message_id!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_message_id(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_message_id(self);
 }
 
 
@@ -377,67 +377,67 @@
 
 
 /**
- * tny_header_get_from:
+ * tny_header_dup_from:
  * @self: a #TnyHeader
  * 
- * Get the from header. The returned value should not be freed.
+ * Get the from header. The returned value should be freed.
  * 
- * returns: (null-ok): from header as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): from header as an alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar* 
-tny_header_get_from (TnyHeader *self)
+gchar* 
+tny_header_dup_from (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_from!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_from!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_from(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_from(self);
 }
 
 /**
- * tny_header_get_subject:
+ * tny_header_dup_subject:
  * @self: a #TnyHeader
  * 
- * Get the subject header. The returned value should not be freed.
+ * Get the subject header. The returned value should be freed.
  * 
- * returns: (null-ok): subject header as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): subject header as an alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar*
-tny_header_get_subject (TnyHeader *self)
+gchar*
+tny_header_dup_subject (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_subject!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_subject!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_subject(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_subject(self);
 }
 
 
 /**
- * tny_header_get_to:
+ * tny_header_dup_to:
  * @self: a #TnyHeader
  * 
- * Get the to header. The returned value should not be freed.
+ * Get the to header. The returned value should be freed.
  * 
- * returns: (null-ok): to header as a read-only string or NULL
+ * returns: (null-ok) (caller-owns): to header as an alloc'd string or NULL
  * since: 1.0
  * audience: application-developer
  **/
-const gchar* 
-tny_header_get_to (TnyHeader *self)
+gchar* 
+tny_header_dup_to (TnyHeader *self)
 {
 #ifdef DBC /* require */
 	g_assert (TNY_IS_HEADER (self));
-	g_assert (TNY_HEADER_GET_IFACE (self)->get_to!= NULL);
+	g_assert (TNY_HEADER_GET_IFACE (self)->dup_to!= NULL);
 #endif
 
-	return TNY_HEADER_GET_IFACE (self)->get_to(self);
+	return TNY_HEADER_GET_IFACE (self)->dup_to(self);
 }
 
 /**
Index: libtinymail/tny-header.h
===================================================================
--- libtinymail/tny-header.h	(revisión: 3521)
+++ libtinymail/tny-header.h	(copia de trabajo)
@@ -77,14 +77,14 @@
 {
 	GTypeInterface g;
 
-	const gchar* (*get_uid) (TnyHeader *self);
-	const gchar* (*get_bcc) (TnyHeader *self);
-	const gchar* (*get_cc) (TnyHeader *self);
-	const gchar* (*get_subject) (TnyHeader *self);
-	const gchar* (*get_to) (TnyHeader *self);
-	const gchar* (*get_from) (TnyHeader *self);
-	const gchar* (*get_replyto) (TnyHeader *self);
-	const gchar* (*get_message_id) (TnyHeader *self);
+	gchar* (*dup_uid) (TnyHeader *self);
+	gchar* (*dup_bcc) (TnyHeader *self);
+	gchar* (*dup_cc) (TnyHeader *self);
+	gchar* (*dup_subject) (TnyHeader *self);
+	gchar* (*dup_to) (TnyHeader *self);
+	gchar* (*dup_from) (TnyHeader *self);
+	gchar* (*dup_replyto) (TnyHeader *self);
+	gchar* (*dup_message_id) (TnyHeader *self);
 	guint (*get_message_size) (TnyHeader *self);
 	time_t (*get_date_received) (TnyHeader *self);
 	time_t (*get_date_sent) (TnyHeader *self);
@@ -103,17 +103,17 @@
 GType tny_header_get_type (void);
 GType tny_header_flags_get_type (void);
 
-const gchar* tny_header_get_uid (TnyHeader *self);
-const gchar* tny_header_get_bcc (TnyHeader *self);
-const gchar* tny_header_get_cc (TnyHeader *self);
+gchar* tny_header_dup_uid (TnyHeader *self);
+gchar* tny_header_dup_bcc (TnyHeader *self);
+gchar* tny_header_dup_cc (TnyHeader *self);
 time_t tny_header_get_date_received (TnyHeader *self);
 time_t tny_header_get_date_sent (TnyHeader *self);
-const gchar* tny_header_get_message_id (TnyHeader *self);
+gchar* tny_header_dup_message_id (TnyHeader *self);
 guint tny_header_get_message_size (TnyHeader *self);
-const gchar* tny_header_get_from (TnyHeader *self);
-const gchar* tny_header_get_to (TnyHeader *self);
-const gchar* tny_header_get_subject (TnyHeader *self);
-const gchar* tny_header_get_replyto (TnyHeader *self);
+gchar* tny_header_dup_from (TnyHeader *self);
+gchar* tny_header_dup_to (TnyHeader *self);
+gchar* tny_header_dup_subject (TnyHeader *self);
+gchar* tny_header_dup_replyto (TnyHeader *self);
 void tny_header_set_bcc (TnyHeader *self, const gchar *bcc);
 void tny_header_set_cc (TnyHeader *self, const gchar *cc);
 void tny_header_set_from (TnyHeader *self, const gchar *from);
Index: libtinymail/tny-expunged-header.c
===================================================================
--- libtinymail/tny-expunged-header.c	(revisión: 3521)
+++ libtinymail/tny-expunged-header.c	(copia de trabajo)
@@ -27,52 +27,52 @@
 
 static GObjectClass *parent_class = NULL;
 
-static const gchar*
-tny_expunged_header_get_uid (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_uid (TnyHeader *self)
 {
-	return "...";
+	return g_strdup ("...");
 }
 
-static const gchar*
-tny_expunged_header_get_bcc (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_bcc (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
-static const gchar*
-tny_expunged_header_get_cc (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_cc (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
-static const gchar*
-tny_expunged_header_get_subject (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_subject (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
-static const gchar*
-tny_expunged_header_get_to (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_to (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
-static const gchar*
-tny_expunged_header_get_from (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_from (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
-static const gchar*
-tny_expunged_header_get_replyto (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_replyto (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
-static const gchar*
-tny_expunged_header_get_message_id (TnyHeader *self)
+static gchar*
+tny_expunged_header_dup_message_id (TnyHeader *self)
 {
-	return "Expunged";
+	return g_strdup ("Expunged");
 }
 
 static guint
@@ -159,14 +159,14 @@
 static void
 tny_header_init (TnyHeaderIface *klass)
 {
-	klass->get_uid= tny_expunged_header_get_uid;
-	klass->get_bcc= tny_expunged_header_get_bcc;
-	klass->get_cc= tny_expunged_header_get_cc;
-	klass->get_subject= tny_expunged_header_get_subject;
-	klass->get_to= tny_expunged_header_get_to;
-	klass->get_from= tny_expunged_header_get_from;
-	klass->get_replyto= tny_expunged_header_get_replyto;
-	klass->get_message_id= tny_expunged_header_get_message_id;
+	klass->dup_uid= tny_expunged_header_dup_uid;
+	klass->dup_bcc= tny_expunged_header_dup_bcc;
+	klass->dup_cc= tny_expunged_header_dup_cc;
+	klass->dup_subject= tny_expunged_header_dup_subject;
+	klass->dup_to= tny_expunged_header_dup_to;
+	klass->dup_from= tny_expunged_header_dup_from;
+	klass->dup_replyto= tny_expunged_header_dup_replyto;
+	klass->dup_message_id= tny_expunged_header_dup_message_id;
 	klass->get_message_size= tny_expunged_header_get_message_size;
 	klass->get_date_received= tny_expunged_header_get_date_received;
 	klass->get_date_sent= tny_expunged_header_get_date_sent;
Index: tests/c-demo/tny-demoui-summary-view.c
===================================================================
--- tests/c-demo/tny-demoui-summary-view.c	(revisión: 3521)
+++ tests/c-demo/tny-demoui-summary-view.c	(copia de trabajo)
@@ -228,21 +228,26 @@
 {
 	if (header)
 	{
-		gchar *str = g_strdup_printf ("%s. Do you want to remove the message (%s)?",
-			err->message, tny_header_get_subject (header));
+		gchar *subject;
+		gchar *str;
+		
+		subject = tny_header_dup_subject (header);
+		str = g_strdup_printf ("%s. Do you want to remove the message (%s)?",
+			err->message, subject);
+		g_free (subject);
 		OnResponseInfo *info = g_slice_new (OnResponseInfo);
 
 		if (!rem_dialog)
 		{
 			rem_dialog = gtk_message_dialog_new (NULL, 0,
 				GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, str);
-			g_free (str);
 			info->self = g_object_ref (user_data);
 			info->header = g_object_ref (header);
 			g_signal_connect (G_OBJECT (rem_dialog), "response",
 				G_CALLBACK (on_response), info);
 			gtk_widget_show_all (rem_dialog);
 		}
+		g_free (str);
 	}
 	return;
 }
@@ -632,11 +637,16 @@
 
 			if (header)
 			{
-				GtkWidget *dialog = gtk_message_dialog_new (NULL, 
+				gchar *subject;
+				GtkWidget *dialog;
+
+				subject = tny_header_dup_subject (header);
+				dialog = gtk_message_dialog_new (NULL, 
 					GTK_DIALOG_MODAL,
 					GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, 
 					_("This will remove the message with subject \"%s\""),
-					tny_header_get_subject (header));
+					subject);
+				g_free (subject);
 
 				if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
 				{
@@ -680,12 +690,17 @@
 
 			if (header)
 			{
-				GtkWidget *dialog = gtk_message_dialog_new (NULL, 
-					GTK_DIALOG_MODAL,
-					GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, 
-					_("This will uncache the message with subject \"%s\""),
-					tny_header_get_subject (header));
+				gchar *subject;
+				GtkWidget *dialog;
 
+				subject = tny_header_dup_subject (header);
+				dialog = gtk_message_dialog_new (NULL, 
+								 GTK_DIALOG_MODAL,
+								 GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, 
+								 _("This will uncache the message with subject \"%s\""),
+								 subject);
+				g_free (subject);
+
 				if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES)
 				{
 					TnyFolder *folder;
@@ -1626,11 +1641,15 @@
 
 	if (folder) 
 	{
+		gchar *subject;
 		TnyList *headers = tny_simple_list_new ();
 
+		subject = tny_header_dup_subject (info->header);
+
 		g_print ("Transfering: %s to %s\n",
-			tny_header_get_subject (info->header), 
+			subject, 
 			tny_folder_get_name (info->to_folder));
+		g_free (subject);
 
 		tny_list_prepend (headers, (GObject *) info->header);
 		tny_folder_transfer_msgs_async (folder, headers, info->to_folder, 
Index: libtinymailui-gtk/tny-gtk-header-view.c
===================================================================
--- libtinymailui-gtk/tny-gtk-header-view.c	(revisión: 3521)
+++ libtinymailui-gtk/tny-gtk-header-view.c	(copia de trabajo)
@@ -86,28 +86,34 @@
 	if (header && G_IS_OBJECT (header))
 	{
 		gchar *str;
-		const gchar *to, *from, *subject;
+		gchar *to, *from, *subject;
 		g_object_ref (G_OBJECT (header)); 
 		priv->header = header;
 
-		to = tny_header_get_to (header);
-		from = tny_header_get_from (header);
-		subject = tny_header_get_subject (header);
+		to = tny_header_dup_to (header);
+		from = tny_header_dup_from (header);
+		subject = tny_header_dup_subject (header);
 
-		if (to)
+		if (to) {
 			gtk_label_set_text (GTK_LABEL (priv->to_label), to);
-		else
+			g_free (to);
+		} else {
 			gtk_label_set_text (GTK_LABEL (priv->to_label), "");
+		}
 
-		if (from)
+		if (from) {
 			gtk_label_set_text (GTK_LABEL (priv->from_label), from);
-		else
+			g_free (from);
+		} else {
 			gtk_label_set_text (GTK_LABEL (priv->from_label), "");
+		}
 
-		if (subject)
+		if (subject) {
 			gtk_label_set_text (GTK_LABEL (priv->subject_label), subject);
-		else
+			g_free (subject);
+		} else {
 			gtk_label_set_text (GTK_LABEL (priv->subject_label), "");
+		}
 
 		str = _get_readable_date (tny_header_get_date_sent (header));
 		gtk_label_set_text (GTK_LABEL (priv->date_label), (const gchar*)str);
Index: libtinymailui-gtk/tny-gtk-msg-window.c
===================================================================
--- libtinymailui-gtk/tny-gtk-msg-window.c	(revisión: 3521)
+++ libtinymailui-gtk/tny-gtk-msg-window.c	(copia de trabajo)
@@ -99,14 +99,15 @@
 
 	if (msg)
 	{
-		const gchar *subject;
+		gchar *subject;
 
 		g_assert (TNY_IS_MSG (msg));
 
 		header = TNY_HEADER (tny_msg_get_header (msg));
-		subject = tny_header_get_subject (header);
+		subject = tny_header_dup_subject (header);
 		if (subject)
 			gtk_window_set_title (GTK_WINDOW (self), subject);
+		g_free (subject);
 		g_object_unref (G_OBJECT (header));
 	}
 	tny_msg_view_set_msg (priv->msg_view, msg);
Index: libtinymailui-gtk/tny-gtk-header-list-model.c
===================================================================
--- libtinymailui-gtk/tny-gtk-header-list-model.c	(revisión: 3521)
+++ libtinymailui-gtk/tny-gtk-header-list-model.c	(copia de trabajo)
@@ -345,7 +345,7 @@
 {
 	TnyGtkHeaderListModelPriv *priv = TNY_GTK_HEADER_LIST_MODEL_GET_PRIVATE (self);
 
-	const gchar *str;
+	gchar *str;
 	gchar *rdate = NULL;
 	gint i;
 
@@ -392,9 +392,9 @@
 	{
 		case TNY_GTK_HEADER_LIST_MODEL_CC_COLUMN:
 			g_value_init (value, G_TYPE_STRING);
-			str = tny_header_get_cc ((TnyHeader*) priv->items->pdata[i]);
+			str = tny_header_dup_cc ((TnyHeader*) priv->items->pdata[i]);
 			if (str)
-				g_value_set_string (value, str);
+				g_value_take_string (value, str);
 			break;
 		case TNY_GTK_HEADER_LIST_MODEL_DATE_SENT_COLUMN:
 			g_value_init (value, G_TYPE_STRING);
@@ -433,21 +433,21 @@
 			break;
 		case TNY_GTK_HEADER_LIST_MODEL_TO_COLUMN:
 			g_value_init (value, G_TYPE_STRING);
-			str = tny_header_get_to ((TnyHeader*) priv->items->pdata[i]);
+			str = tny_header_dup_to ((TnyHeader*) priv->items->pdata[i]);
 			if (str)
-				g_value_set_string (value, str);
+				g_value_take_string (value, str);
 			break;
 		case TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN:
 			g_value_init (value, G_TYPE_STRING);
-			str = tny_header_get_subject ((TnyHeader*) priv->items->pdata[i]);
+			str = tny_header_dup_subject ((TnyHeader*) priv->items->pdata[i]);
 			if (str)
-				g_value_set_string (value, str);
+				g_value_take_string (value, str);
 			break;
 		case TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN:
 			g_value_init (value, G_TYPE_STRING);
-			str = tny_header_get_from ((TnyHeader*) priv->items->pdata[i]);
+			str = tny_header_dup_from ((TnyHeader*) priv->items->pdata[i]);
 			if (str)
-				g_value_set_string (value, str);
+				g_value_take_string (value, str);
 			break;
 		case TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN:
 			g_value_init (value, G_TYPE_INT);
@@ -702,12 +702,15 @@
 static gboolean 
 uid_matcher (TnyList *list, GObject *item, gpointer match_data)
 {
-	const char *uid = tny_header_get_uid ((TnyHeader *) item);
+	gboolean result = FALSE;
+	char *uid = tny_header_dup_uid ((TnyHeader *) item);
 
 	if (uid && !strcmp (uid, (const char*) match_data))
- 		return TRUE;
+ 		result = TRUE;
 
-	return FALSE;
+	g_free (uid);
+
+	return result;
 }
 
 
@@ -722,9 +725,9 @@
 	g_static_rec_mutex_lock (priv->iterator_lock);
 
 	if (priv->no_duplicates) {
-		const gchar *uid = tny_header_get_uid ((TnyHeader *) item);
-		if (uid)
-			tny_list_remove_matches (self, uid_matcher, (gpointer) uid); 
+		gchar *uid = tny_header_dup_uid ((TnyHeader *) item);
+		tny_list_remove_matches (self, uid_matcher, (gpointer) uid); 
+		g_free (uid);
 	}
 
 	/* Prepend something to the list itself. The get_length will auto update
@@ -1191,7 +1194,7 @@
  * @self: a #TnyGtkHeaderListModel
  *
  * Gets whether or not @self allows duplicates of #TnyHeader instances to be
- * added. The duplicates will be tested by tny_header_get_uid uniqueness.
+ * added. The duplicates will be tested by tny_header_dup_uid uniqueness.
  * 
  * returns: whether or not to allow duplicates
  * since: 1.0
@@ -1210,7 +1213,7 @@
  * @setting: whether or not to allow duplicates
  *
  * Sets whether or not @self allows duplicates of #TnyHeader instances to be
- * added. The duplicates will be tested by tny_header_get_uid uniqueness.
+ * added. The duplicates will be tested by tny_header_dup_uid uniqueness.
  * Setting this property to TRUE will negatively impact performance of @self.
  * It'll also influence behaviour of tny_list_prepend and tny_list_append.
  *
Index: bindings/vala/libtinymail-1.0/libtinymail-1.0.gi
===================================================================
--- bindings/vala/libtinymail-1.0/libtinymail-1.0.gi	(revisión: 3521)
+++ bindings/vala/libtinymail-1.0/libtinymail-1.0.gi	(copia de trabajo)
@@ -2153,13 +2153,13 @@
 			<requires>
 				<interface name="GObject"/>
 			</requires>
-			<method name="get_bcc" symbol="tny_header_get_bcc">
+			<method name="dup_bcc" symbol="tny_header_dup_bcc">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_cc" symbol="tny_header_get_cc">
+			<method name="dup_cc" symbol="tny_header_dup_cc">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
@@ -2189,13 +2189,13 @@
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_from" symbol="tny_header_get_from">
+			<method name="dup_from" symbol="tny_header_dup_from">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_message_id" symbol="tny_header_get_message_id">
+			<method name="dup_message_id" symbol="tny_header_dup_message_id">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
@@ -2213,25 +2213,25 @@
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_replyto" symbol="tny_header_get_replyto">
+			<method name="dup_replyto" symbol="tny_header_dup_replyto">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_subject" symbol="tny_header_get_subject">
+			<method name="dup_subject" symbol="tny_header_dup_subject">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_to" symbol="tny_header_get_to">
+			<method name="dup_to" symbol="tny_header_dup_to">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</method>
-			<method name="get_uid" symbol="tny_header_get_uid">
+			<method name="dup_uid" symbol="tny_header_dup_uid">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
@@ -2300,13 +2300,13 @@
 					<parameter name="mask" type="TnyHeaderFlags"/>
 				</parameters>
 			</method>
-			<vfunc name="get_bcc_func">
+			<vfunc name="dup_bcc_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_cc_func">
+			<vfunc name="dup_cc_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
@@ -2336,13 +2336,13 @@
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_from_func">
+			<vfunc name="dup_from_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_message_id_func">
+			<vfunc name="dup_message_id_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
@@ -2354,25 +2354,25 @@
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_replyto_func">
+			<vfunc name="dup_replyto_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_subject_func">
+			<vfunc name="dup_subject_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_to_func">
+			<vfunc name="dup_to_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>
 				</parameters>
 			</vfunc>
-			<vfunc name="get_uid_func">
+			<vfunc name="dup_uid_func">
 				<return-type type="gchar*"/>
 				<parameters>
 					<parameter name="self" type="TnyHeader*"/>


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