gmime r1299 - in trunk: . docs/reference gmime mono



Author: fejj
Date: Thu May 29 03:33:02 2008
New Revision: 1299
URL: http://svn.gnome.org/viewvc/gmime?rev=1299&view=rev

Log:
2008-05-28  Jeffrey Stedfast  <fejj novell com>

	These changes are to make it so that changing the GMimeContentType
	and/or GMimeContentDisposition fields directly will still update
	the headers.

	* gmime/gmime-disposition.c (g_mime_content_disposition_set_disposition):
	Notify our parent object that we've changed.
	(g_mime_content_disposition_set_parameter): Same.

	* gmime/gmime-content-type.c (g_mime_content_type_set_parameter):
	Notify our parent object that we've changed.

	* gmime/gmime-object.c (_g_mime_object_content_type_changed):
	Renamed from sync_content_type() and also made callable from
	gmime-content-type.c
	(_g_mime_object_content_disposition_changed): Renamed from
	sync_content_disposition() and also made callable from
	gmime-disposition.c
	(g_mime_object_set_content_type): Set the parent object on the
	GMimeContentType and call _g_mime_object_content_type_changed().
	(g_mime_object_set_content_disposition): Set the parent object on
	the GMimeContentDisposition and call
	_g_mime_object_content_disposition_changed().



Modified:
   trunk/ChangeLog
   trunk/docs/reference/gmime-docs.sgml
   trunk/gmime/gmime-content-type.c
   trunk/gmime/gmime-disposition.c
   trunk/gmime/gmime-object.c
   trunk/mono/gmime-api.raw

Modified: trunk/docs/reference/gmime-docs.sgml
==============================================================================
--- trunk/docs/reference/gmime-docs.sgml	(original)
+++ trunk/docs/reference/gmime-docs.sgml	Thu May 29 03:33:02 2008
@@ -18,6 +18,7 @@
 <!ENTITY GMimeMessagePart SYSTEM "xml/gmime-message-part.xml">
 <!ENTITY GMimeMessagePartial SYSTEM "xml/gmime-message-partial.xml">
 <!ENTITY gmime-utils SYSTEM "xml/gmime-utils.xml">
+<!ENTITY gmime-encodings SYSTEM "xml/gmime-encodings.xml">
 <!ENTITY InternetAddress SYSTEM "xml/internet-address.xml">
 <!ENTITY GMimeParser SYSTEM "xml/gmime-parser.xml">
 <!ENTITY gmime-charset SYSTEM "xml/gmime-charset.xml">
@@ -158,6 +159,7 @@
     &gmime-charset;
     &gmime-iconv;
     &gmime-iconv-utils;
+    &gmime-encodings;
     &gmime-utils;
   </part>
 

Modified: trunk/gmime/gmime-content-type.c
==============================================================================
--- trunk/gmime/gmime-content-type.c	(original)
+++ trunk/gmime/gmime-content-type.c	Thu May 29 03:33:02 2008
@@ -53,10 +53,14 @@
  **/
 
 
+struct _GMimeObject;
+void _g_mime_object_content_type_changed (struct _GMimeObject *object);
+
+
 /**
  * g_mime_content_type_new:
- * @type: MIME type (or NULL for "text")
- * @subtype: MIME subtype (or NULL for "plain")
+ * @type: MIME type (or %NULL for "text")
+ * @subtype: MIME subtype (or %NULL for "plain")
  *
  * Creates a Content-Type object with type @type and subtype @subtype.
  *
@@ -325,7 +329,7 @@
 		if ((param = g_hash_table_lookup (mime_type->param_hash, attribute))) {
 			g_free (param->value);
 			param->value = g_strdup (value);
-			return;
+			goto changed;
 		}
 	} else if (!mime_type->param_hash) {
 		/* hash table not initialized */
@@ -335,6 +339,11 @@
 	param = g_mime_param_new (attribute, value);
 	mime_type->params = g_mime_param_append_param (mime_type->params, param);
 	g_hash_table_insert (mime_type->param_hash, param->name, param);
+	
+ changed:
+	
+	if (mime_type->parent_object)
+		_g_mime_object_content_type_changed (mime_type->parent_object);
 }
 
 

Modified: trunk/gmime/gmime-disposition.c
==============================================================================
--- trunk/gmime/gmime-disposition.c	(original)
+++ trunk/gmime/gmime-disposition.c	Thu May 29 03:33:02 2008
@@ -41,6 +41,10 @@
  **/
 
 
+struct _GMimeObject;
+void _g_mime_object_content_disposition_changed (struct _GMimeObject *object);
+
+
 /**
  * g_mime_content_disposition_new:
  *
@@ -55,9 +59,9 @@
 	
 	disposition = g_new (GMimeContentDisposition, 1);
 	disposition->disposition = g_strdup (GMIME_DISPOSITION_ATTACHMENT);
-	disposition->params = NULL;
-	disposition->param_hash = NULL;
 	disposition->parent_object = NULL;
+	disposition->param_hash = NULL;
+	disposition->params = NULL;
 	
 	return disposition;
 }
@@ -149,6 +153,9 @@
 	
 	g_free (disposition->disposition);
 	disposition->disposition = g_strdup (value);
+	
+	if (disposition->parent_object)
+		_g_mime_object_content_disposition_changed (disposition->parent_object);
 }
 
 
@@ -206,7 +213,7 @@
 		if ((param = g_hash_table_lookup (disposition->param_hash, attribute))) {
 			g_free (param->value);
 			param->value = g_strdup (value);
-			return;
+			goto changed;
 		}
 	} else if (!disposition->param_hash) {
 		/* hash table may not be initialized */
@@ -216,6 +223,11 @@
 	param = g_mime_param_new (attribute, value);
 	disposition->params = g_mime_param_append_param (disposition->params, param);
 	g_hash_table_insert (disposition->param_hash, param->name, param);
+	
+ changed:
+	
+	if (disposition->parent_object)
+		_g_mime_object_content_disposition_changed (disposition->parent_object);
 }
 
 

Modified: trunk/gmime/gmime-object.c
==============================================================================
--- trunk/gmime/gmime-object.c	(original)
+++ trunk/gmime/gmime-object.c	Thu May 29 03:33:02 2008
@@ -182,6 +182,33 @@
 	return nwritten;
 }
 
+void
+_g_mime_object_content_type_changed (GMimeObject *object)
+{
+	GMimeContentType *content_type;
+	GMimeParam *params;
+	GString *string;
+	char *type, *p;
+	
+	content_type = object->content_type;
+	
+	string = g_string_new ("Content-Type: ");
+	
+	type = g_mime_content_type_to_string (content_type);
+	g_string_append (string, type);
+	g_free (type);
+	
+	if ((params = content_type->params))
+		g_mime_param_write_to_string (params, FALSE, string);
+	
+	p = string->str;
+	g_string_free (string, FALSE);
+	
+	type = p + strlen ("Content-Type: ");
+	g_mime_header_set (object->headers, "Content-Type", type);
+	g_free (p);
+}
+
 static ssize_t
 write_disposition (GMimeStream *stream, const char *name, const char *value)
 {
@@ -204,6 +231,20 @@
 	return nwritten;
 }
 
+void
+_g_mime_object_content_disposition_changed (GMimeObject *object)
+{
+	char *str;
+	
+	if (object->disposition) {
+		str = g_mime_content_disposition_to_string (object->disposition, FALSE);
+		g_mime_header_set (object->headers, "Content-Disposition", str);
+		g_free (str);
+	} else {
+		g_mime_header_remove (object->headers, "Content-Disposition");
+	}
+}
+
 
 /**
  * g_mime_object_register_type:
@@ -306,43 +347,16 @@
 	return object;
 }
 
-
-static void
-sync_content_type (GMimeObject *object)
-{
-	GMimeContentType *content_type;
-	GMimeParam *params;
-	GString *string;
-	char *type, *p;
-	
-	content_type = object->content_type;
-	
-	string = g_string_new ("Content-Type: ");
-	
-	type = g_mime_content_type_to_string (content_type);
-	g_string_append (string, type);
-	g_free (type);
-	
-	if ((params = content_type->params))
-		g_mime_param_write_to_string (params, FALSE, string);
-	
-	p = string->str;
-	g_string_free (string, FALSE);
-	
-	type = p + strlen ("Content-Type: ");
-	g_mime_header_set (object->headers, "Content-Type", type);
-	g_free (p);
-}
-
 static void
 set_content_type (GMimeObject *object, GMimeContentType *content_type)
 {
 	if (object->content_type)
 		g_mime_content_type_destroy (object->content_type);
 	
-	object->content_type = content_type;
+	if ((object->content_type = content_type))
+		content_type->parent_object = object;
 	
-	sync_content_type (object);
+	_g_mime_object_content_type_changed (object);
 }
 
 
@@ -396,8 +410,6 @@
 	g_return_if_fail (name != NULL);
 	
 	g_mime_content_type_set_parameter (object->content_type, name, value);
-	
-	sync_content_type (object);
 }
 
 
@@ -439,21 +451,6 @@
 }
 
 
-static void
-sync_content_disposition (GMimeObject *object)
-{
-	char *str;
-	
-	if (object->disposition) {
-		str = g_mime_content_disposition_to_string (object->disposition, FALSE);
-		g_mime_header_set (object->headers, "Content-Disposition", str);
-		g_free (str);
-	} else {
-		g_mime_header_remove (object->headers, "Content-Disposition");
-	}
-}
-
-
 /**
  * g_mime_object_set_content_disposition:
  * @object: Mime object
@@ -469,9 +466,10 @@
 	if (object->disposition)
 		g_mime_content_disposition_destroy (object->disposition);
 	
-	object->disposition = disposition;
+	if ((object->disposition = disposition))
+		disposition->parent_object = object;
 	
-	sync_content_disposition (object);
+	_g_mime_object_content_disposition_changed (object);
 }
 
 
@@ -492,10 +490,10 @@
 	
 	if (object->disposition) {
 		g_mime_content_disposition_set_disposition (object->disposition, disposition);
-		sync_content_disposition (object);
 	} else if (disposition) {
-		object->disposition = g_mime_content_disposition_new_from_string (disposition);
-		sync_content_disposition (object);
+		if ((object->disposition = g_mime_content_disposition_new_from_string (disposition)))
+			object->disposition->parent_object = object;
+		_g_mime_object_content_disposition_changed (object);
 	}
 }
 
@@ -535,12 +533,12 @@
 	g_return_if_fail (GMIME_IS_OBJECT (object));
 	g_return_if_fail (attribute != NULL);
 	
-	if (!object->disposition)
+	if (!object->disposition) {
 		object->disposition = g_mime_content_disposition_new ();
+		object->disposition->parent_object = object;
+	}
 	
 	g_mime_content_disposition_set_parameter (object->disposition, attribute, value);
-	
-	sync_content_disposition (object);
 }
 
 

Modified: trunk/mono/gmime-api.raw
==============================================================================
--- trunk/mono/gmime-api.raw	(original)
+++ trunk/mono/gmime-api.raw	Thu May 29 03:33:02 2008
@@ -29,7 +29,6 @@
       <member cname="GMIME_CONTENT_ENCODING_BASE64" name="Base64" />
       <member cname="GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE" name="Quotedprintable" />
       <member cname="GMIME_CONTENT_ENCODING_UUENCODE" name="Uuencode" />
-      <member cname="GMIME_CONTENT_ENCODING_COUNT" name="Count" />
     </enum>
     <enum name="FilterCRLFDirection" cname="GMimeFilterCRLFDirection" type="enum">
       <member cname="GMIME_FILTER_CRLF_ENCODE" name="Encode" />



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