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



Author: fejj
Date: Fri Jul  4 21:59:30 2008
New Revision: 1368
URL: http://svn.gnome.org/viewvc/gmime?rev=1368&view=rev

Log:
2008-07-04  Jeffrey Stedfast  <fejj novell com>

	* mono/Message.custom: Updated.

	* gmime/gmime-message.[c,h]: Make GMIME_RECIPIENT_TYPE_* string
	macros into an enum. Translate the enum into strings as
	appropriate internally.



Modified:
   trunk/ChangeLog
   trunk/docs/reference/gmime-sections.txt
   trunk/docs/reference/gmime.hierarchy
   trunk/gmime/gmime-message.c
   trunk/gmime/gmime-message.h
   trunk/mono/Message.custom
   trunk/mono/gmime-api.raw

Modified: trunk/docs/reference/gmime-sections.txt
==============================================================================
--- trunk/docs/reference/gmime-sections.txt	(original)
+++ trunk/docs/reference/gmime-sections.txt	Fri Jul  4 21:59:30 2008
@@ -789,9 +789,7 @@
 
 <SECTION>
 <FILE>gmime-message</FILE>
-GMIME_RECIPIENT_TYPE_TO
-GMIME_RECIPIENT_TYPE_CC
-GMIME_RECIPIENT_TYPE_BCC
+GMimeRecipientType
 GMimeMessage
 g_mime_message_new
 g_mime_message_set_sender

Modified: trunk/docs/reference/gmime.hierarchy
==============================================================================
--- trunk/docs/reference/gmime.hierarchy	(original)
+++ trunk/docs/reference/gmime.hierarchy	Fri Jul  4 21:59:30 2008
@@ -36,3 +36,4 @@
     GMimeStreamMmap
     GMimeStreamNull
 GInterface
+  GTypePlugin

Modified: trunk/gmime/gmime-message.c
==============================================================================
--- trunk/gmime/gmime-message.c	(original)
+++ trunk/gmime/gmime-message.c	Fri Jul  4 21:59:30 2008
@@ -58,7 +58,7 @@
 static char *message_get_headers (GMimeObject *object);
 static ssize_t message_write_to_stream (GMimeObject *object, GMimeStream *stream);
 
-static void message_add_recipients_from_string (GMimeMessage *message, const char *type, const char *str);
+static void message_add_recipients_from_string (GMimeMessage *message, GMimeRecipientType type, const char *str);
 
 static ssize_t write_structured (GMimeStream *stream, const char *name, const char *value);
 static ssize_t write_addrspec (GMimeStream *stream, const char *name, const char *value);
@@ -69,6 +69,11 @@
 
 static GMimeObjectClass *parent_class = NULL;
 
+static const char *recipient_types[] = {
+	"To", "Cc", "Bcc"
+};
+
+#define N_RECIPIENT_TYPES G_N_ELEMENTS (recipient_types)
 
 static char *rfc822_headers[] = {
 	"Return-Path",
@@ -759,6 +764,7 @@
 {
 	GMimeMessage *message = (GMimeMessage *) object;
 	InternetAddressList *addrlist;
+	const char *type;
 	int i;
 	
 	if (!g_ascii_strcasecmp ("MIME-Version", header))
@@ -788,18 +794,21 @@
 		message->reply_to = NULL;
 		break;
 	case HEADER_TO:
-		addrlist = g_hash_table_lookup (message->recipients, GMIME_RECIPIENT_TYPE_TO);
-		g_hash_table_remove (message->recipients, GMIME_RECIPIENT_TYPE_TO);
+		type = recipient_types[GMIME_RECIPIENT_TYPE_TO];
+		addrlist = g_hash_table_lookup (message->recipients, type);
+		g_hash_table_remove (message->recipients, type);
 		internet_address_list_destroy (addrlist);
 		break;
 	case HEADER_CC:
-		addrlist = g_hash_table_lookup (message->recipients, GMIME_RECIPIENT_TYPE_CC);
-		g_hash_table_remove (message->recipients, GMIME_RECIPIENT_TYPE_CC);
+		type = recipient_types[GMIME_RECIPIENT_TYPE_CC];
+		addrlist = g_hash_table_lookup (message->recipients, type);
+		g_hash_table_remove (message->recipients, type);
 		internet_address_list_destroy (addrlist);
 		break;
 	case HEADER_BCC:
-		addrlist = g_hash_table_lookup (message->recipients, GMIME_RECIPIENT_TYPE_BCC);
-		g_hash_table_remove (message->recipients, GMIME_RECIPIENT_TYPE_BCC);
+		type = recipient_types[GMIME_RECIPIENT_TYPE_BCC];
+		addrlist = g_hash_table_lookup (message->recipients, type);
+		g_hash_table_remove (message->recipients, type);
 		internet_address_list_destroy (addrlist);
 		break;
 	case HEADER_SUBJECT:
@@ -1010,90 +1019,86 @@
 
 
 static void
-sync_recipient_header (GMimeMessage *message, const char *type)
+sync_recipient_header (GMimeMessage *message, GMimeRecipientType type)
 {
+	const char *name = recipient_types[type];
 	const InternetAddressList *recipients;
 	char *string;
 	
 	/* sync the specified recipient header */
 	if ((recipients = g_mime_message_get_recipients (message, type))) {
 		string = internet_address_list_to_string (recipients, TRUE);
-		g_mime_header_list_set (GMIME_OBJECT (message)->headers, type, string);
+		g_mime_header_list_set (GMIME_OBJECT (message)->headers, name, string);
 		g_free (string);
 	} else
-		g_mime_header_list_set (GMIME_OBJECT (message)->headers, type, NULL);
+		g_mime_header_list_set (GMIME_OBJECT (message)->headers, name, NULL);
 }
 
 
 /**
  * g_mime_message_add_recipient:
  * @message: MIME Message to change
- * @type: Recipient type
+ * @type: A #GMimeRecipientType
  * @name: The recipient's name
  * @address: The recipient's address
  *
- * Add a recipient of a chosen type to the MIME Message. Available
- * recipient types include: #GMIME_RECIPIENT_TYPE_TO,
- * #GMIME_RECIPIENT_TYPE_CC and #GMIME_RECIPIENT_TYPE_BCC.
+ * Add a recipient of a chosen type to the MIME Message.
  **/
 void
-g_mime_message_add_recipient (GMimeMessage *message, const char *type, const char *name, const char *address)
+g_mime_message_add_recipient (GMimeMessage *message, GMimeRecipientType type, const char *name, const char *address)
 {
 	InternetAddressList *recipients;
 	InternetAddress *ia;
 	
 	g_return_if_fail (GMIME_IS_MESSAGE (message));
-	g_return_if_fail (type != NULL);
+	g_return_if_fail (type < N_RECIPIENT_TYPES);
 	g_return_if_fail (name != NULL);
 	g_return_if_fail (address != NULL);
 	
 	ia = internet_address_new_name (name, address);
 	
-	recipients = g_hash_table_lookup (message->recipients, type);
-	g_hash_table_remove (message->recipients, type);
+	recipients = g_hash_table_lookup (message->recipients, recipient_types[type]);
+	g_hash_table_remove (message->recipients, recipient_types[type]);
 	
 	recipients = internet_address_list_append (recipients, ia);
 	internet_address_unref (ia);
 	
-	g_hash_table_insert (message->recipients, (char *) type, recipients);
+	g_hash_table_insert (message->recipients, (char *) recipient_types[type], recipients);
 	sync_recipient_header (message, type);
 }
 
 
 static void
-message_add_recipients_from_string (GMimeMessage *message, const char *type, const char *str)
+message_add_recipients_from_string (GMimeMessage *message, GMimeRecipientType type, const char *str)
 {
 	InternetAddressList *recipients, *addrlist;
 	
-	recipients = g_hash_table_lookup (message->recipients, type);
-	g_hash_table_remove (message->recipients, type);
+	recipients = g_hash_table_lookup (message->recipients, recipient_types[type]);
+	g_hash_table_remove (message->recipients, recipient_types[type]);
 	
 	if ((addrlist = internet_address_parse_string (str))) {
 		recipients = internet_address_list_concat (recipients, addrlist);
 		internet_address_list_destroy (addrlist);
 	}
 	
-	g_hash_table_insert (message->recipients, (char *) type, recipients);
+	g_hash_table_insert (message->recipients, (char *) recipient_types[type], recipients);
 }
 
 
 /**
  * g_mime_message_add_recipients_from_string:
  * @message: MIME Message
- * @type: Recipient type
+ * @type: A #GMimeRecipientType
  * @str: A string of recipient names and addresses.
  *
- * Add a list of recipients of a chosen type to the MIME
- * Message. Available recipient types include:
- * #GMIME_RECIPIENT_TYPE_TO, #GMIME_RECIPIENT_TYPE_CC and
- * #GMIME_RECIPIENT_TYPE_BCC. The string must be in the format
- * specified in rfc822.
+ * Add a list of recipients of a chosen type to the MIME Message. The
+ * string @str must be in the format specified in rfc822.
  **/
 void
-g_mime_message_add_recipients_from_string (GMimeMessage *message, const char *type, const char *str)
+g_mime_message_add_recipients_from_string (GMimeMessage *message, GMimeRecipientType type, const char *str)
 {
 	g_return_if_fail (GMIME_IS_MESSAGE (message));
-	g_return_if_fail (type != NULL);
+	g_return_if_fail (type < N_RECIPIENT_TYPES);
 	g_return_if_fail (str != NULL);
 	
 	message_add_recipients_from_string (message, type, str);
@@ -1105,31 +1110,23 @@
 /**
  * g_mime_message_get_recipients:
  * @message: MIME Message
- * @type: Recipient type
+ * @type: A #GMimeRecipientType
  *
- * Gets a list of recipients of type @type from @message. Available
- * recipient types include: #GMIME_RECIPIENT_TYPE_TO,
- * #GMIME_RECIPIENT_TYPE_CC and #GMIME_RECIPIENT_TYPE_BCC.
+ * Gets a list of recipients of type @type from @message.
  *
  * Returns: a list of recipients of a chosen type from the MIME
  * Message.
  **/
 const InternetAddressList *
-g_mime_message_get_recipients (GMimeMessage *message, const char *type)
+g_mime_message_get_recipients (GMimeMessage *message, GMimeRecipientType type)
 {
 	g_return_val_if_fail (GMIME_IS_MESSAGE (message), NULL);
-	g_return_val_if_fail (type != NULL, NULL);
+	g_return_val_if_fail (type < N_RECIPIENT_TYPES, NULL);
 	
-	return g_hash_table_lookup (message->recipients, type);
+	return g_hash_table_lookup (message->recipients, recipient_types[type]);
 }
 
 
-static const char *recipient_types[] = {
-	GMIME_RECIPIENT_TYPE_TO,
-	GMIME_RECIPIENT_TYPE_CC,
-	GMIME_RECIPIENT_TYPE_BCC
-};
-
 /**
  * g_mime_message_get_all_recipients:
  * @message: MIME Message

Modified: trunk/gmime/gmime-message.h
==============================================================================
--- trunk/gmime/gmime-message.h	(original)
+++ trunk/gmime/gmime-message.h	Fri Jul  4 21:59:30 2008
@@ -44,6 +44,21 @@
 
 
 /**
+ * GMimeRecipientType:
+ * @GMIME_RECIPIENT_TYPE_TO: Represents the recipients in the To: header.
+ * @GMIME_RECIPIENT_TYPE_CC: Represents the recipients in the Cc: header.
+ * @GMIME_RECIPIENT_TYPE_BCC: Represents the recipients in the Bcc: header.
+ *
+ * A message recipient type.
+ **/
+typedef enum _GMimeRecipientType {
+	GMIME_RECIPIENT_TYPE_TO,
+	GMIME_RECIPIENT_TYPE_CC,
+	GMIME_RECIPIENT_TYPE_BCC,
+} GMimeRecipientType;
+
+
+/**
  * GMimeMessage:
  * @parent_object: parent #GMimeObject
  * @mime_part: toplevel MIME part
@@ -77,31 +92,6 @@
 };
 
 
-/**
- * GMIME_RECIPIENT_TYPE_TO:
- *
- * Recipients in the To: header.
- **/
-#define	GMIME_RECIPIENT_TYPE_TO  "To"
-
-
-/**
- * GMIME_RECIPIENT_TYPE_CC:
- *
- * Recipients in the Cc: header.
- **/
-#define	GMIME_RECIPIENT_TYPE_CC  "Cc"
-
-
-/**
- * GMIME_RECIPIENT_TYPE_BCC:
- *
- * Recipients in the Bcc: header.
- **/
-#define	GMIME_RECIPIENT_TYPE_BCC "Bcc"
-
-
-
 GType g_mime_message_get_type (void);
 
 GMimeMessage *g_mime_message_new (gboolean pretty_headers);
@@ -112,9 +102,9 @@
 void g_mime_message_set_reply_to (GMimeMessage *message, const char *reply_to);
 const char *g_mime_message_get_reply_to (GMimeMessage *message);
 
-void g_mime_message_add_recipient (GMimeMessage *message, const char *type, const char *name, const char *address);
-void g_mime_message_add_recipients_from_string (GMimeMessage *message, const char *type, const char *str);
-const InternetAddressList *g_mime_message_get_recipients (GMimeMessage *message, const char *type);
+void g_mime_message_add_recipient (GMimeMessage *message, GMimeRecipientType type, const char *name, const char *address);
+void g_mime_message_add_recipients_from_string (GMimeMessage *message, GMimeRecipientType type, const char *str);
+const InternetAddressList *g_mime_message_get_recipients (GMimeMessage *message, GMimeRecipientType type);
 InternetAddressList *g_mime_message_get_all_recipients (GMimeMessage *message);
 
 void g_mime_message_set_subject (GMimeMessage *message, const char *subject);

Modified: trunk/mono/Message.custom
==============================================================================
--- trunk/mono/Message.custom	(original)
+++ trunk/mono/Message.custom	Fri Jul  4 21:59:30 2008
@@ -1,15 +1,9 @@
-public enum RecipientType {
-	To,
-	Cc,
-	Bcc
-};
-
 [DllImport ("gmime")]
-static extern IntPtr g_mime_message_get_recipients (IntPtr message, string type);
+static extern IntPtr g_mime_message_get_recipients (IntPtr message, int type);
 
-public InternetAddressList GetRecipients (RecipientType type)
+public InternetAddressList GetRecipients (GMime.RecipientType type)
 {
-	IntPtr list = g_mime_message_get_recipients (Handle, type.ToString ());
+	IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
 
 	return new InternetAddressList (list);
 }
@@ -38,9 +32,9 @@
 [DllImport("gmime")]
 static extern IntPtr internet_address_list_to_string (IntPtr list, bool encode);
 
-public string GetRecipientsAsString (RecipientType type, bool encode)
+public string GetRecipientsAsString (GMime.RecipientType type, bool encode)
 {
-	IntPtr list = g_mime_message_get_recipients (Handle, type.ToString ());
+	IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
 	IntPtr str;
 	
 	if (list == IntPtr.Zero)
@@ -51,7 +45,7 @@
 	return GLib.Marshaller.PtrToStringGFree (str);
 }
 
-public string GetRecipientsAsString (RecipientType type)
+public string GetRecipientsAsString (GMime.RecipientType type)
 {
 	return GetRecipientsAsString (type, false);
 }

Modified: trunk/mono/gmime-api.raw
==============================================================================
--- trunk/mono/gmime-api.raw	(original)
+++ trunk/mono/gmime-api.raw	Fri Jul  4 21:59:30 2008
@@ -47,6 +47,11 @@
       <member cname="GMIME_FILTER_GZIP_MODE_ZIP" name="Zip" />
       <member cname="GMIME_FILTER_GZIP_MODE_UNZIP" name="Unzip" />
     </enum>
+    <enum name="RecipientType" cname="GMimeRecipientType" type="enum">
+      <member cname="GMIME_RECIPIENT_TYPE_TO" name="To" />
+      <member cname="GMIME_RECIPIENT_TYPE_CC" name="Cc" />
+      <member cname="GMIME_RECIPIENT_TYPE_BCC" name="Bcc" />
+    </enum>
     <enum name="SeekWhence" cname="GMimeSeekWhence" type="enum">
       <member cname="GMIME_STREAM_SEEK_SET" name="Set" value="SEEK_SET" />
       <member cname="GMIME_STREAM_SEEK_CUR" name="Cur" value="SEEK_CUR" />
@@ -613,8 +618,8 @@
       </method>
     </object>
     <object name="GpgContext" cname="GMimeGpgContext" parent="GMimeCipherContext">
-      <field name="Path" cname="path" type="char*" />
       <field name="AlwaysTrust" cname="always_trust" type="gboolean" />
+      <field name="Path" cname="path" type="char*" />
       <method name="GetAlwaysTrust" cname="g_mime_gpg_context_get_always_trust">
         <return-type type="gboolean" />
       </method>
@@ -635,14 +640,14 @@
       </method>
     </object>
     <object name="Message" cname="GMimeMessage" parent="GMimeObject">
-      <field name="From" cname="from" type="char*" />
-      <field name="ReplyTo" cname="reply_to" type="char*" />
+      <field name="MimePart" cname="mime_part" type="GMimeObject*" />
       <field name="Recipients" cname="recipients" type="GHashTable*" />
+      <field name="MessageId" cname="message_id" type="char*" />
+      <field name="ReplyTo" cname="reply_to" type="char*" />
       <field name="Subject" cname="subject" type="char*" />
+      <field name="From" cname="from" type="char*" />
       <field name="Date" cname="date" type="time_t" />
       <field name="TzOffset" cname="tz_offset" type="int" />
-      <field name="MessageId" cname="message_id" type="char*" />
-      <field name="MimePart" cname="mime_part" type="GMimeObject*" />
       <method name="AddHeader" cname="g_mime_message_add_header">
         <return-type type="void" />
         <parameters>
@@ -653,7 +658,7 @@
       <method name="AddRecipient" cname="g_mime_message_add_recipient">
         <return-type type="void" />
         <parameters>
-          <parameter type="char*" name="type" />
+          <parameter type="GMimeRecipientType" name="type" />
           <parameter type="const-char*" name="name" />
           <parameter type="const-char*" name="address" />
         </parameters>
@@ -661,7 +666,7 @@
       <method name="AddRecipientsFromString" cname="g_mime_message_add_recipients_from_string">
         <return-type type="void" />
         <parameters>
-          <parameter type="char*" name="type" />
+          <parameter type="GMimeRecipientType" name="type" />
           <parameter type="const-char*" name="str" />
         </parameters>
       </method>
@@ -700,7 +705,7 @@
       <method name="GetRecipients" cname="g_mime_message_get_recipients">
         <return-type type="const-InternetAddressList*" />
         <parameters>
-          <parameter type="const-char*" name="type" />
+          <parameter type="GMimeRecipientType" name="type" />
         </parameters>
       </method>
       <method name="GetReplyTo" cname="g_mime_message_get_reply_to">
@@ -798,9 +803,9 @@
       </method>
     </object>
     <object name="MessagePartial" cname="GMimeMessagePartial" parent="GMimePart">
-      <field name="Id" cname="id" type="char*" />
       <field name="Number" cname="number" type="int" />
       <field name="Total" cname="total" type="int" />
+      <field name="Id" cname="id" type="char*" />
       <method name="GetId" cname="g_mime_message_partial_get_id">
         <return-type type="const-char*" />
       </method>
@@ -836,7 +841,10 @@
       </method>
     </object>
     <object name="Multipart" cname="GMimeMultipart" parent="GMimeObject">
-      <field name="Priv" cname="priv" type="struct-_GMimeMultipartPrivate*" />
+      <field name="Children" cname="children" type="GPtrArray*" />
+      <field name="Boundary" cname="boundary" type="char*" />
+      <field name="Preface" cname="preface" type="char*" />
+      <field name="Postface" cname="postface" type="char*" />
       <virtual_method name="AddPart" cname="add_part">
         <return-type type="void" />
         <parameters>
@@ -1614,12 +1622,12 @@
       </method>
     </object>
     <object name="StreamBuffer" cname="GMimeStreamBuffer" parent="GMimeStream">
+      <field name="Mode" cname="mode" type="GMimeStreamBufferMode" />
       <field name="Source" cname="source" type="GMimeStream*" />
       <field name="Buffer" cname="buffer" type="char*" />
       <field name="Bufptr" cname="bufptr" type="char*" />
       <field name="Bufend" cname="bufend" type="char*" />
       <field name="Buflen" cname="buflen" type="size_t" />
-      <field name="Mode" cname="mode" type="GMimeStreamBufferMode" />
       <method name="GetType" cname="g_mime_stream_buffer_get_type" shared="true">
         <return-type type="GType" />
       </method>
@@ -1741,8 +1749,8 @@
       </method>
     </object>
     <object name="StreamMem" cname="GMimeStreamMem" parent="GMimeStream">
-      <field name="Owner" cname="owner" type="gboolean" />
       <field name="Buffer" cname="buffer" type="GByteArray*" />
+      <field name="Owner" cname="owner" type="gboolean" />
       <method name="GetByteArray" cname="g_mime_stream_mem_get_byte_array">
         <return-type type="GByteArray*" />
       </method>
@@ -1883,8 +1891,8 @@
     <struct name="ContentDisposition" cname="GMimeContentDisposition" opaque="true">
       <field name="ParentObject" cname="parent_object" type="gpointer" access="public" writeable="true" />
       <field name="ParamHash" cname="param_hash" type="GHashTable*" access="public" writeable="true" />
-      <field name="Disposition" cname="disposition" type="char*" access="public" writeable="true" />
       <field name="Params" cname="params" type="GMimeParam*" access="public" writeable="true" />
+      <field name="Disposition" cname="disposition" type="char*" access="public" writeable="true" />
       <method name="Destroy" cname="g_mime_content_disposition_destroy">
         <return-type type="void" />
       </method>
@@ -1929,9 +1937,9 @@
     <struct name="ContentType" cname="GMimeContentType" opaque="true">
       <field name="ParentObject" cname="parent_object" type="gpointer" access="public" writeable="true" />
       <field name="ParamHash" cname="param_hash" type="GHashTable*" access="public" writeable="true" />
+      <field name="Params" cname="params" type="GMimeParam*" access="public" writeable="true" />
       <field name="Type" cname="type" type="char*" access="public" writeable="true" />
       <field name="Subtype" cname="subtype" type="char*" access="public" writeable="true" />
-      <field name="Params" cname="params" type="GMimeParam*" access="public" writeable="true" />
       <method name="Destroy" cname="g_mime_content_type_destroy">
         <return-type type="void" />
       </method>
@@ -2621,7 +2629,7 @@
         </parameters>
       </method>
       <method name="Word" cname="g_mime_decode_word" shared="true">
-        <return-type type="char*" />
+        <return-type type="const-char*" />
         <parameters>
           <parameter type="const-char**" name="in" />
         </parameters>



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