[evolution-patches] =?utf-8?q?Bug_329692_=E2=80=93_attachment_siz?= =?utf-8?q?e_in_composer_not=09shown_when_reopening?=



Hello,

This bug implies both evolution and evolution-data-server. I added a function called
camel_mime_part_get_content_size () to evolution-data-server/camel/mime-part.c and
used it in evolution/widget/misc/attachment.c.

There's still a problem: the size displayed is bigger than the real file size because
camel_data_wrapper_decode_to_stream () (used with an null stream to get the size) returns
size of encoded data. How could i fix it?

This is my first patch, I hope i did everything right.(Please tell me what i did wrong.)

Sorry for my english.

Regards,

Jean-Christophe BEGUE
Index: widgets/misc/e-attachment.c
===================================================================
--- widgets/misc/e-attachment.c	(révision 34779)
+++ widgets/misc/e-attachment.c	(copie de travail)
@@ -600,7 +600,7 @@
 	new->body = part;
 	new->guessed_type = FALSE;
 	new->is_available_local = TRUE;
-	new->size = 0;
+	new->size = camel_mime_part_get_content_size (part);
 	new->file_name = g_strdup (camel_mime_part_get_filename(part));
 
 	return new;
Index: camel/camel-mime-part.c
===================================================================
--- camel/camel-mime-part.c	(révision 8343)
+++ camel/camel-mime-part.c	(copie de travail)
@@ -1060,3 +1060,25 @@
 		medium->content = NULL;
 	}
 }
+
+/**
+ * camel_mime_part_get_content_size
+ * @mime_part: a #CamelMimePart object
+ *
+ * Function used to get the size of the mime part provided data.
+ **/
+
+ssize_t
+camel_mime_part_get_content_size (CamelMimePart *mime_part)
+{
+	ssize_t written;	
+	CamelStreamNull *nstream;
+	CamelMedium *medium = CAMEL_MEDIUM (mime_part);
+	CamelDataWrapper *dw = camel_medium_get_content_object (medium);
+	
+	nstream =  camel_stream_null_new ();
+	written = camel_data_wrapper_write_to_stream (dw, nstream);
+	camel_object_unref (nstream);
+
+	return written;
+}
Index: camel/camel-mime-part.h
===================================================================
--- camel/camel-mime-part.h	(révision 8343)
+++ camel/camel-mime-part.h	(copie de travail)
@@ -103,6 +103,8 @@
 void      	camel_mime_part_set_content 	       (CamelMimePart *mime_part,
 							const char *content, int length, const char *type);
 
+ssize_t		camel_mime_part_get_content_size	(CamelMimePart *mime_part);
+
 G_END_DECLS
 
 #endif /* CAMEL_MIME_PART_H */


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