gmime r1423 - in trunk: . docs/reference gmime mono
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1423 - in trunk: . docs/reference gmime mono
- Date: Sun, 31 Aug 2008 20:19:13 +0000 (UTC)
Author: fejj
Date: Sun Aug 31 20:19:13 2008
New Revision: 1423
URL: http://svn.gnome.org/viewvc/gmime?rev=1423&view=rev
Log:
2008-08-31 Jeffrey Stedfast <fejj novell com>
* mono/Multipart.custom: GMime.Multipart now implements the IList
interface.
* gmime/gmime-message.c (g_mime_message_add_recipients_from_string):
Removed. This function was a kludge - use
g_mime_message_get_recipients() and then add recipients you have
manually instead.
* gmime/gmime-multipart.c (g_mime_multipart_clear): New method.
(g_mime_multipart_contains): Same.
(g_mime_multipart_index_of): Same.
Added:
trunk/mono/Multipart.custom
Modified:
trunk/ChangeLog
trunk/docs/reference/gmime-sections.txt
trunk/gmime/gmime-message.c
trunk/gmime/gmime-message.h
trunk/gmime/gmime-multipart.c
trunk/gmime/gmime-multipart.h
trunk/mono/GMime.metadata
trunk/mono/InternetAddressList.custom
trunk/mono/Makefile.am
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 Sun Aug 31 20:19:13 2008
@@ -751,10 +751,13 @@
g_mime_multipart_set_boundary
g_mime_multipart_get_boundary
g_mime_multipart_add
+g_mime_multipart_clear
g_mime_multipart_insert
g_mime_multipart_remove
g_mime_multipart_remove_at
g_mime_multipart_get_count
+g_mime_multipart_contains
+g_mime_multipart_index_of
g_mime_multipart_get_part
g_mime_multipart_foreach
g_mime_multipart_get_subpart_from_content_id
@@ -823,7 +826,6 @@
g_mime_message_set_reply_to
g_mime_message_get_reply_to
g_mime_message_add_recipient
-g_mime_message_add_recipients_from_string
g_mime_message_get_recipients
g_mime_message_get_all_recipients
g_mime_message_set_subject
Modified: trunk/gmime/gmime-message.c
==============================================================================
--- trunk/gmime/gmime-message.c (original)
+++ trunk/gmime/gmime-message.c Sun Aug 31 20:19:13 2008
@@ -1182,26 +1182,6 @@
/**
- * g_mime_message_add_recipients_from_string:
- * @message: MIME Message
- * @type: A #GMimeRecipientType
- * @str: A string of recipient names and addresses.
- *
- * 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, GMimeRecipientType type, const char *str)
-{
- g_return_if_fail (GMIME_IS_MESSAGE (message));
- g_return_if_fail (type < N_RECIPIENT_TYPES);
- g_return_if_fail (str != NULL);
-
- message_add_recipients_from_string (message, type, str);
-}
-
-
-/**
* g_mime_message_get_recipients:
* @message: MIME Message
* @type: A #GMimeRecipientType
Modified: trunk/gmime/gmime-message.h
==============================================================================
--- trunk/gmime/gmime-message.h (original)
+++ trunk/gmime/gmime-message.h Sun Aug 31 20:19:13 2008
@@ -103,7 +103,6 @@
const char *g_mime_message_get_reply_to (GMimeMessage *message);
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);
InternetAddressList *g_mime_message_get_recipients (GMimeMessage *message, GMimeRecipientType type);
InternetAddressList *g_mime_message_get_all_recipients (GMimeMessage *message);
Modified: trunk/gmime/gmime-multipart.c
==============================================================================
--- trunk/gmime/gmime-multipart.c (original)
+++ trunk/gmime/gmime-multipart.c Sun Aug 31 20:19:13 2008
@@ -63,11 +63,14 @@
static ssize_t multipart_write_to_stream (GMimeObject *object, GMimeStream *stream);
/* GMimeMultipart class methods */
+static void multipart_clear (GMimeMultipart *multipart);
static void multipart_add (GMimeMultipart *multipart, GMimeObject *part);
static void multipart_insert (GMimeMultipart *multipart, int index, GMimeObject *part);
static gboolean multipart_remove (GMimeMultipart *multipart, GMimeObject *part);
static GMimeObject *multipart_remove_at (GMimeMultipart *multipart, int index);
static GMimeObject *multipart_get_part (GMimeMultipart *multipart, int index);
+static gboolean multipart_contains (GMimeMultipart *multipart, GMimeObject *part);
+static int multipart_index_of (GMimeMultipart *multipart, GMimeObject *part);
static int multipart_get_count (GMimeMultipart *multipart);
static void multipart_set_boundary (GMimeMultipart *multipart, const char *boundary);
static const char *multipart_get_boundary (GMimeMultipart *multipart);
@@ -121,10 +124,13 @@
object_class->write_to_stream = multipart_write_to_stream;
klass->add = multipart_add;
+ klass->clear = multipart_clear;
klass->insert = multipart_insert;
klass->remove = multipart_remove;
klass->remove_at = multipart_remove_at;
klass->get_part = multipart_get_part;
+ klass->contains = multipart_contains;
+ klass->index_of = multipart_index_of;
klass->get_count = multipart_get_count;
klass->set_boundary = multipart_set_boundary;
klass->get_boundary = multipart_get_boundary;
@@ -420,6 +426,33 @@
static void
+multipart_clear (GMimeMultipart *multipart)
+{
+ int i;
+
+ for (i = 0; i < (int) multipart->children->len; i++)
+ g_object_unref (multipart->children->pdata[i]);
+
+ g_ptr_array_set_size (multipart->children, 0);
+}
+
+
+/**
+ * g_mime_multipart_clear:
+ * @multipart: a #GMimeMultipart object
+ *
+ * Removes all subparts from @multipart.
+ **/
+void
+g_mime_multipart_clear (GMimeMultipart *multipart)
+{
+ g_return_if_fail (GMIME_IS_MULTIPART (multipart));
+
+ GMIME_MULTIPART_GET_CLASS (multipart)->clear (multipart);
+}
+
+
+static void
multipart_add (GMimeMultipart *multipart, GMimeObject *part)
{
g_ptr_array_add (multipart->children, part);
@@ -592,6 +625,73 @@
}
+static gboolean
+multipart_contains (GMimeMultipart *multipart, GMimeObject *part)
+{
+ int i;
+
+ for (i = 0; i < (int) multipart->children->len; i++) {
+ if (part == (GMimeObject *) multipart->children->pdata[i])
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/**
+ * g_mime_multipart_contains:
+ * @multipart: a #GMimeMultipart object
+ * @part: mime part
+ *
+ * Checks if @part is contained within @multipart.
+ *
+ * Returns: %TRUE if @part is a subpart of @multipart or %FALSE
+ * otherwise.
+ **/
+gboolean
+g_mime_multipart_contains (GMimeMultipart *multipart, GMimeObject *part)
+{
+ g_return_val_if_fail (GMIME_IS_MULTIPART (multipart), FALSE);
+ g_return_val_if_fail (GMIME_IS_OBJECT (part), FALSE);
+
+ return GMIME_MULTIPART_GET_CLASS (multipart)->contains (multipart, part);
+}
+
+
+static int
+multipart_index_of (GMimeMultipart *multipart, GMimeObject *part)
+{
+ int i;
+
+ for (i = 0; i < (int) multipart->children->len; i++) {
+ if (part == (GMimeObject *) multipart->children->pdata[i])
+ return i;
+ }
+
+ return -1;
+}
+
+
+/**
+ * g_mime_multipart_index_of:
+ * @multipart: a #GMimeMultipart object
+ * @part: mime part
+ *
+ * Gets the index of @part within @multipart.
+ *
+ * Returns: the index of @part within @multipart or %-1 if not found.
+ **/
+int
+g_mime_multipart_index_of (GMimeMultipart *multipart, GMimeObject *part)
+{
+ g_return_val_if_fail (GMIME_IS_MULTIPART (multipart), -1);
+ g_return_val_if_fail (GMIME_IS_OBJECT (part), -1);
+
+ return GMIME_MULTIPART_GET_CLASS (multipart)->index_of (multipart, part);
+}
+
+
static int
multipart_get_count (GMimeMultipart *multipart)
{
Modified: trunk/gmime/gmime-multipart.h
==============================================================================
--- trunk/gmime/gmime-multipart.h (original)
+++ trunk/gmime/gmime-multipart.h Sun Aug 31 20:19:13 2008
@@ -60,12 +60,16 @@
struct _GMimeMultipartClass {
GMimeObjectClass parent_class;
+ void (* clear) (GMimeMultipart *multipart);
void (* add) (GMimeMultipart *multipart, GMimeObject *part);
void (* insert) (GMimeMultipart *multipart, int index, GMimeObject *part);
gboolean (* remove) (GMimeMultipart *multipart, GMimeObject *part);
GMimeObject * (* remove_at) (GMimeMultipart *multipart, int index);
GMimeObject * (* get_part) (GMimeMultipart *multipart, int index);
+ gboolean (* contains) (GMimeMultipart *multipart, GMimeObject *part);
+ int (* index_of) (GMimeMultipart *multipart, GMimeObject *part);
+
int (* get_count) (GMimeMultipart *multipart);
void (* set_boundary) (GMimeMultipart *multipart, const char *boundary);
@@ -85,12 +89,17 @@
void g_mime_multipart_set_postface (GMimeMultipart *multipart, const char *postface);
const char *g_mime_multipart_get_postface (GMimeMultipart *multipart);
+void g_mime_multipart_clear (GMimeMultipart *multipart);
+
void g_mime_multipart_add (GMimeMultipart *multipart, GMimeObject *part);
void g_mime_multipart_insert (GMimeMultipart *multipart, int index, GMimeObject *part);
gboolean g_mime_multipart_remove (GMimeMultipart *multipart, GMimeObject *part);
GMimeObject *g_mime_multipart_remove_at (GMimeMultipart *multipart, int index);
GMimeObject *g_mime_multipart_get_part (GMimeMultipart *multipart, int index);
+gboolean g_mime_multipart_contains (GMimeMultipart *multipart, GMimeObject *part);
+int g_mime_multipart_index_of (GMimeMultipart *multipart, GMimeObject *part);
+
int g_mime_multipart_get_count (GMimeMultipart *multipart);
void g_mime_multipart_set_boundary (GMimeMultipart *multipart, const char *boundary);
Modified: trunk/mono/GMime.metadata
==============================================================================
--- trunk/mono/GMime.metadata (original)
+++ trunk/mono/GMime.metadata Sun Aug 31 20:19:13 2008
@@ -43,7 +43,6 @@
<!-- DataWrapper -->
<attr path="/api/namespace/object[ cname='GMimeDataWrapper']/method[ name='GetStream']" name="name">GetGMimeStream</attr>
<attr path="/api/namespace/object[ cname='GMimeDataWrapper']/method[ name='SetStream']" name="name">SetGMimeStream</attr>
- <attr path="/api/namespace/object[ cname='GMimeDataWrapper']/method[ name='GetGMimeStream']/return-type" name="owned">true</attr>
<!-- Encoding -->
<attr path="/api/namespace/struct[ name='Encoding']/*/*/parameter[ name='inbuf']" name="type">const-guint8*</attr>
@@ -118,6 +117,7 @@
<remove-node path="/api/namespace/struct[ cname='GMimeHeader']"/>
<!-- HeaderList -->
+ <remove-node path="/api/namespace/struct[ cname='GMimeHeaderList']/method[ cname='g_mime_header_list_foreach']"/>
<attr path="/api/namespace/struct[ cname='GMimeHeaderList']/method[ name='HasRaw']" name="hidden">true</attr>
<attr path="/api/namespace/struct[ cname='GMimeHeaderList']/method[ name='SetRaw']" name="hidden">true</attr>
<attr path="/api/namespace/struct[ cname='GMimeHeaderList']/method[ name='Prepend']" name="name">PrependHeader</attr>
@@ -173,14 +173,14 @@
<remove-node path="/api/namespace/object[ cname='InternetAddressList']/method[ name='ToString']"/>
<!-- Message -->
- <attr path="/api/namespace/object[ cname='GMimeMessage']/method[ name='GetMimePart']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[ cname='GMimeMessage']/method[ name='GetAllRecipients']/return-type" name="owned">true</attr>
<!-- We implement these properties by hand, hide them. -->
<remove-node path="/api/namespace/object[ cname='GMimeMessage']/method[ cname='g_mime_message_get_recipients']"/>
<remove-node path="/api/namespace/object[ cname='GMimeMessage']/method[ cname='g_mime_message_get_date']"/>
<remove-node path="/api/namespace/object[ cname='GMimeMessage']/method[ cname='g_mime_message_set_date']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMessage']/method[ cname='g_mime_message_foreach_part']"/>
<!-- MessagePart -->
- <attr path="/api/namespace/object[ cname='GMimeMessagePart']/method[ name='GetMessage']/return-type" name="owned">true</attr>
<!-- MessagePartial -->
<add-node path="/api/namespace/object[ cname='GMimeMessagePartial']/method[ name='ReconstructMessage']/parameters"><parameter name="partials" type="GMimeMessagePartial**" array="true"/></add-node>
@@ -188,9 +188,23 @@
<attr path="/api/namespace/object[ cname='GMimeMessagePartial']/method[ name='ReconstructMessage']/*/parameter[ name='num']" name="name">n_partials</attr>
<!-- Multipart -->
- <attr path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='GetPart']/return-type" name="owned">true</attr>
- <attr path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='GetSubpartFromContentId']/return-type" name="owned">true</attr>
- <attr path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Foreach']" name="name">ForeachPart</attr>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Foreach']"/>
+ <!-- We're going to implement the IList interface -->
+ <add-node path="/api/namespace/object[ cname='GMimeMultipart']">
+ <implements>
+ <interface name="IList"/>
+ </implements>
+ </add-node>
+ <!-- Remove methods we're going to implement manually in GMimeMultipart.custom -->
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Add']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Clear']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='GetCount']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Contains']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='IndexOf']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Insert']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='Remove']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='RemoveAt']"/>
+ <remove-node path="/api/namespace/object[ cname='GMimeMultipart']/method[ name='GetPart']"/>
<!-- MultipartEncrypted -->
@@ -217,7 +231,6 @@
<remove-node path="/api/namespace/class[ name='Decode']"/>
<!-- Part -->
- <attr path="/api/namespace/object[ cname='GMimePart']/method[ name='GetContentObject']/return-type" name="owned">true</attr>
<!-- References -->
<attr path="/api/namespace/struct[ name='References']" name="opaque">true</attr>
Modified: trunk/mono/InternetAddressList.custom
==============================================================================
--- trunk/mono/InternetAddressList.custom (original)
+++ trunk/mono/InternetAddressList.custom Sun Aug 31 20:19:13 2008
@@ -12,7 +12,7 @@
//static extern void internet_address_list_concat (IntPtr list, IntPtr concat);
[DllImport("gmime")]
- static extern void internet_address_list_insert (IntPtr list, int index, IntPtr concat);
+ static extern void internet_address_list_insert (IntPtr list, int index, IntPtr ia);
[DllImport("gmime")]
static extern bool internet_address_list_remove (IntPtr list, IntPtr ia);
@@ -118,7 +118,7 @@
if (addr == null)
throw CannotAdd (value);
- return Add (value as InternetAddress);
+ return Add (addr);
}
public void Clear ()
Modified: trunk/mono/Makefile.am
==============================================================================
--- trunk/mono/Makefile.am (original)
+++ trunk/mono/Makefile.am Sun Aug 31 20:19:13 2008
@@ -31,6 +31,7 @@
InternetAddress.custom \
InternetAddressList.custom \
Message.custom \
+ Multipart.custom \
Object.custom \
Stream.custom
@@ -41,6 +42,7 @@
$(srcdir)/InternetAddress.custom \
$(srcdir)/InternetAddressList.custom \
$(srcdir)/Message.custom \
+ $(srcdir)/Multipart.custom \
$(srcdir)/Object.custom \
$(srcdir)/Stream.custom
Modified: trunk/mono/Message.custom
==============================================================================
--- trunk/mono/Message.custom (original)
+++ trunk/mono/Message.custom Sun Aug 31 20:19:13 2008
@@ -1,82 +1,82 @@
-[DllImport ("gmime")]
-static extern IntPtr g_mime_message_get_recipients (IntPtr message, int type);
-
-public InternetAddressList GetRecipients (GMime.RecipientType type)
-{
- IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
-
- return new InternetAddressList (list);
-}
-
-public InternetAddressList To {
- get { return GetRecipients (RecipientType.To); }
-}
-
-public InternetAddressList Cc {
- get { return GetRecipients (RecipientType.Cc); }
-}
-
-public InternetAddressList Bcc {
- get { return GetRecipients (RecipientType.Bcc); }
-}
-
-public System.Collections.IEnumerable References {
- get {
- string references = GetHeader ("References");
-
- if (references == null)
- yield break;
-
- GMime.References refs = GMime.References.Parse (references);
- GMime.References iter = refs;
-
- while (iter != null) {
- yield return iter;
- iter = iter.Next;
- }
-
- yield break;
- }
-}
-
-
-[DllImport("gmime")]
-static extern IntPtr internet_address_list_to_string (IntPtr list, bool encode);
-
-public string GetRecipientsAsString (GMime.RecipientType type, bool encode)
-{
- IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
- IntPtr str;
-
- if (list == IntPtr.Zero)
- return null;
-
- str = internet_address_list_to_string (list, encode);
-
- return GLib.Marshaller.PtrToStringGFree (str);
-}
-
-public string GetRecipientsAsString (GMime.RecipientType type)
-{
- return GetRecipientsAsString (type, false);
-}
-
-[DllImport("gmime")]
-static extern void g_mime_message_get_date (IntPtr message, out IntPtr date, out int gmt_offset);
-
-[DllImport("gmime")]
-static extern void g_mime_message_set_date (IntPtr message, IntPtr date, int gmt_offset);
-
-public DateTime Date {
- get {
- int tz_offset;
- IntPtr date;
-
- g_mime_message_get_date (Handle, out date, out tz_offset);
-
- return GLib.Marshaller.time_tToDateTime (date);
- }
- set {
- g_mime_message_set_date (Handle, GLib.Marshaller.DateTimeTotime_t (value), 0);
- }
-}
+ [DllImport ("gmime")]
+ static extern IntPtr g_mime_message_get_recipients (IntPtr message, int type);
+
+ public InternetAddressList GetRecipients (GMime.RecipientType type)
+ {
+ IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
+
+ return new InternetAddressList (list);
+ }
+
+ public InternetAddressList To {
+ get { return GetRecipients (RecipientType.To); }
+ }
+
+ public InternetAddressList Cc {
+ get { return GetRecipients (RecipientType.Cc); }
+ }
+
+ public InternetAddressList Bcc {
+ get { return GetRecipients (RecipientType.Bcc); }
+ }
+
+ public System.Collections.IEnumerable References {
+ get {
+ string references = GetHeader ("References");
+
+ if (references == null)
+ yield break;
+
+ GMime.References refs = GMime.References.Parse (references);
+ GMime.References iter = refs;
+
+ while (iter != null) {
+ yield return iter;
+ iter = iter.Next;
+ }
+
+ yield break;
+ }
+ }
+
+ [DllImport("gmime")]
+ static extern IntPtr internet_address_list_to_string (IntPtr list, bool encode);
+
+ public string GetRecipientsAsString (GMime.RecipientType type, bool encode)
+ {
+ IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
+ IntPtr str;
+
+ if (list == IntPtr.Zero)
+ return null;
+
+ str = internet_address_list_to_string (list, encode);
+
+ return GLib.Marshaller.PtrToStringGFree (str);
+ }
+
+ public string GetRecipientsAsString (GMime.RecipientType type)
+ {
+ return GetRecipientsAsString (type, false);
+ }
+
+ [DllImport("gmime")]
+ static extern void g_mime_message_get_date (IntPtr message, out IntPtr date, out int gmt_offset);
+
+ [DllImport("gmime")]
+ static extern void g_mime_message_set_date (IntPtr message, IntPtr date, int gmt_offset);
+
+ public DateTime Date {
+ get {
+ int tz_offset;
+ IntPtr date;
+
+ g_mime_message_get_date (Handle, out date, out tz_offset);
+
+ return GLib.Marshaller.time_tToDateTime (date);
+ }
+
+ set {
+ g_mime_message_set_date (Handle, GLib.Marshaller.DateTimeTotime_t (value), 0);
+ }
+ }
Added: trunk/mono/Multipart.custom
==============================================================================
--- (empty file)
+++ trunk/mono/Multipart.custom Sun Aug 31 20:19:13 2008
@@ -0,0 +1,269 @@
+#region Native Methods
+ [DllImport("gmime")]
+ static extern int g_mime_multipart_count (IntPtr multipart);
+
+ [DllImport("gmime")]
+ static extern void g_mime_multipart_clear (IntPtr multipart);
+
+ [DllImport("gmime")]
+ static extern int g_mime_multipart_add (IntPtr multipart, IntPtr part);
+
+ [DllImport("gmime")]
+ static extern void g_mime_multipart_insert (IntPtr multipart, int index, IntPtr part);
+
+ [DllImport("gmime")]
+ static extern bool g_mime_multipart_remove (IntPtr multipart, IntPtr part);
+
+ [DllImport("gmime")]
+ static extern bool g_mime_multipart_remove_at (IntPtr multipart, int index);
+
+ [DllImport("gmime")]
+ static extern bool g_mime_multipart_contains (IntPtr multipart, IntPtr part);
+
+ [DllImport("gmime")]
+ static extern int g_mime_multipart_index_of (IntPtr multipart, IntPtr part);
+
+ [DllImport("gmime")]
+ static extern IntPtr g_mime_multipart_get_part (IntPtr multipart, int index);
+#endregion
+
+ Exception CannotAdd (object value)
+ {
+ if (value == null)
+ return new ArgumentNullException ("value");
+
+ string message = String.Format ("Cannot add objects of type '{0}' to a GMime.Multipart.",
+ value.GetType ().ToString ());
+
+ return new InvalidOperationException (message);
+ }
+
+ Exception CannotInsert (object value)
+ {
+ if (value == null)
+ return new ArgumentNullException ("value");
+
+ string message = String.Format ("Cannot insert objects of type '{0}' into a GMime.Multipart.",
+ value.GetType ().ToString ());
+
+ return new InvalidOperationException (message);
+ }
+
+ Exception CannotRemove (object value)
+ {
+ if (value == null)
+ return new ArgumentNullException ("value");
+
+ string message = String.Format ("Cannot remove objects of type '{0}' from a GMime.Multipart.",
+ value.GetType ().ToString ());
+
+ return new InvalidOperationException (message);
+ }
+
+ Exception CannotSet (object value)
+ {
+ if (value == null)
+ return new ArgumentNullException ("value");
+
+ string message = String.Format ("Cannot set objects of type '{0}' on a GMime.Multipart.",
+ value.GetType ().ToString ());
+
+ return new InvalidOperationException (message);
+ }
+
+ public int Count {
+ get { return g_mime_multipart_count (Handle); }
+ }
+
+ public bool IsFixedSize {
+ get { return false; }
+ }
+
+ public bool IsReadOnly {
+ get { return false; }
+ }
+
+ public bool IsSynchronized {
+ get { return false; }
+ }
+
+ public object SyncRoot {
+ get { return this; }
+ }
+
+ public int Add (GMime.Object part)
+ {
+ if (part == null)
+ throw CannotAdd (part);
+
+ return g_mime_multipart_add (Handle, part.Handle);
+ }
+
+ int IList.Add (object value)
+ {
+ GMime.Object part = value as GMime.Object;
+
+ if (part == null)
+ throw CannotAdd (value);
+
+ return Add (part);
+ }
+
+ public void Clear ()
+ {
+ g_mime_multipart_clear (Handle);
+ }
+
+ public bool Contains (GMime.Object part)
+ {
+ if (part == null)
+ return false;
+
+ return g_mime_multipart_contains (Handle, part.Handle);
+ }
+
+ bool IList.Contains (object value)
+ {
+ return Contains (value as GMime.Object);
+ }
+
+ public void CopyTo (Array array, int index)
+ {
+ if (array == null)
+ throw new ArgumentNullException ("array");
+
+ if (index < 0)
+ throw new ArgumentOutOfRangeException ("index");
+
+ int n = Count;
+
+ for (int i = 0; i < n; i++)
+ array.SetValue (((IList) this)[i], index + i);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return new GMimeMultipartIterator (this);
+ }
+
+ public int IndexOf (GMime.Object part)
+ {
+ if (part == null)
+ return -1;
+
+ return g_mime_multipart_index_of (Handle, part.Handle);
+ }
+
+ int IList.IndexOf (object value)
+ {
+ return IndexOf (value as GMime.Object);
+ }
+
+ public void Insert (int index, GMime.Object part)
+ {
+ if (part == null)
+ throw CannotInsert (part);
+
+ if (index < 0)
+ throw new ArgumentOutOfRangeException ("index");
+
+ g_mime_multipart_insert (Handle, index, part.Handle);
+ }
+
+ void IList.Insert (int index, object value)
+ {
+ GMime.Object part = value as GMime.Object;
+
+ if (part == null)
+ throw CannotInsert (value);
+
+ Insert (index, part);
+ }
+
+ public void Remove (GMime.Object part)
+ {
+ if (part == null)
+ throw CannotRemove (part);
+
+ g_mime_multipart_remove (Handle, part.Handle);
+ }
+
+ void IList.Remove (object value)
+ {
+ GMime.Object part = value as GMime.Object;
+
+ if (part == null)
+ throw CannotRemove (value);
+
+ Remove (part);
+ }
+
+ public void RemoveAt (int index)
+ {
+ if (index < 0 || index >= Count)
+ throw new ArgumentOutOfRangeException ("index");
+
+ g_mime_multipart_remove_at (Handle, index);
+ }
+
+ public GMime.Object this[int index] {
+ get {
+ IntPtr raw = g_mime_multipart_get_part (Handle, index);
+
+ if (raw == IntPtr.Zero)
+ return null;
+
+ return GLib.Object.GetObject (raw) as GMime.Object;
+ }
+
+ set {
+ if (value == null)
+ throw CannotSet (value);
+
+ if (index > Count || index < Count)
+ throw new ArgumentOutOfRangeException ("index");
+
+ if (index < Count) {
+ RemoveAt (index);
+ Insert (index, value);
+ } else {
+ Add (value);
+ }
+ }
+ }
+
+ object IList.this[int index] {
+ get {
+ return this[index];
+ }
+
+ set {
+ this[index] = value as GMime.Object;
+ }
+ }
+
+ internal class GMimeMultipartIterator : IEnumerator {
+ GMime.Multipart multipart;
+ int index = -1;
+
+ public GMimeMultipartIterator (GMime.Multipart multipart)
+ {
+ this.multipart = multipart;
+ }
+
+ public object Current {
+ get { return multipart[index]; }
+ }
+
+ public void Reset ()
+ {
+ index = -1;
+ }
+
+ public bool MoveNext ()
+ {
+ index++;
+
+ return index < multipart.Count;
+ }
+ }
Modified: trunk/mono/gmime-api.raw
==============================================================================
--- trunk/mono/gmime-api.raw (original)
+++ trunk/mono/gmime-api.raw Sun Aug 31 20:19:13 2008
@@ -659,13 +659,6 @@
<parameter type="const-char*" name="address" />
</parameters>
</method>
- <method name="AddRecipientsFromString" cname="g_mime_message_add_recipients_from_string">
- <return-type type="void" />
- <parameters>
- <parameter type="GMimeRecipientType" name="type" />
- <parameter type="const-char*" name="str" />
- </parameters>
- </method>
<method name="ForeachPart" cname="g_mime_message_foreach_part">
<return-type type="void" />
<parameters>
@@ -828,29 +821,35 @@
<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">
+ <virtual_method name="Clear" cname="clear">
<return-type type="void" />
<parameters>
<parameter type="GMimeMultipart*" name="multipart" />
- <parameter type="GMimeObject*" name="part" />
</parameters>
</virtual_method>
- <virtual_method name="AddPartAt" cname="add_part_at">
+ <virtual_method name="Add" cname="add">
<return-type type="void" />
<parameters>
<parameter type="GMimeMultipart*" name="multipart" />
<parameter type="GMimeObject*" name="part" />
+ </parameters>
+ </virtual_method>
+ <virtual_method name="Insert" cname="insert">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="GMimeMultipart*" name="multipart" />
<parameter type="int" name="index" />
+ <parameter type="GMimeObject*" name="part" />
</parameters>
</virtual_method>
- <virtual_method name="RemovePart" cname="remove_part">
+ <virtual_method name="Remove" cname="remove">
<return-type type="gboolean" />
<parameters>
<parameter type="GMimeMultipart*" name="multipart" />
<parameter type="GMimeObject*" name="part" />
</parameters>
</virtual_method>
- <virtual_method name="RemovePartAt" cname="remove_part_at">
+ <virtual_method name="RemoveAt" cname="remove_at">
<return-type type="GMimeObject*" />
<parameters>
<parameter type="GMimeMultipart*" name="multipart" />
@@ -864,7 +863,21 @@
<parameter type="int" name="index" />
</parameters>
</virtual_method>
- <virtual_method name="GetNumber" cname="get_number">
+ <virtual_method name="Contains" cname="contains">
+ <return-type type="gboolean" />
+ <parameters>
+ <parameter type="GMimeMultipart*" name="multipart" />
+ <parameter type="GMimeObject*" name="part" />
+ </parameters>
+ </virtual_method>
+ <virtual_method name="IndexOf" cname="index_of">
+ <return-type type="int" />
+ <parameters>
+ <parameter type="GMimeMultipart*" name="multipart" />
+ <parameter type="GMimeObject*" name="part" />
+ </parameters>
+ </virtual_method>
+ <virtual_method name="GetCount" cname="get_count">
<return-type type="int" />
<parameters>
<parameter type="GMimeMultipart*" name="multipart" />
@@ -877,17 +890,19 @@
<parameter type="const-char*" name="boundary" />
</parameters>
</virtual_method>
- <method name="AddPart" cname="g_mime_multipart_add_part">
+ <method name="Add" cname="g_mime_multipart_add">
<return-type type="void" />
<parameters>
<parameter type="GMimeObject*" name="part" />
</parameters>
</method>
- <method name="AddPartAt" cname="g_mime_multipart_add_part_at">
+ <method name="Clear" cname="g_mime_multipart_clear">
<return-type type="void" />
+ </method>
+ <method name="Contains" cname="g_mime_multipart_contains">
+ <return-type type="gboolean" />
<parameters>
<parameter type="GMimeObject*" name="part" />
- <parameter type="int" name="index" />
</parameters>
</method>
<method name="Foreach" cname="g_mime_multipart_foreach">
@@ -900,7 +915,7 @@
<method name="GetBoundary" cname="g_mime_multipart_get_boundary">
<return-type type="const-char*" />
</method>
- <method name="GetNumber" cname="g_mime_multipart_get_number">
+ <method name="GetCount" cname="g_mime_multipart_get_count">
<return-type type="int" />
</method>
<method name="GetPart" cname="g_mime_multipart_get_part">
@@ -924,19 +939,32 @@
<method name="GetType" cname="g_mime_multipart_get_type" shared="true">
<return-type type="GType" />
</method>
+ <method name="IndexOf" cname="g_mime_multipart_index_of">
+ <return-type type="int" />
+ <parameters>
+ <parameter type="GMimeObject*" name="part" />
+ </parameters>
+ </method>
+ <method name="Insert" cname="g_mime_multipart_insert">
+ <return-type type="void" />
+ <parameters>
+ <parameter type="int" name="index" />
+ <parameter type="GMimeObject*" name="part" />
+ </parameters>
+ </method>
<constructor cname="g_mime_multipart_new" />
<constructor cname="g_mime_multipart_new_with_subtype">
<parameters>
<parameter type="const-char*" name="subtype" />
</parameters>
</constructor>
- <method name="RemovePart" cname="g_mime_multipart_remove_part">
+ <method name="Remove" cname="g_mime_multipart_remove">
<return-type type="gboolean" />
<parameters>
<parameter type="GMimeObject*" name="part" />
</parameters>
</method>
- <method name="RemovePartAt" cname="g_mime_multipart_remove_part_at">
+ <method name="RemoveAt" cname="g_mime_multipart_remove_at">
<return-type type="GMimeObject*" />
<parameters>
<parameter type="int" name="index" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]