diff options
Diffstat (limited to 'mono/HeaderList.custom')
-rw-r--r-- | mono/HeaderList.custom | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/mono/HeaderList.custom b/mono/HeaderList.custom new file mode 100644 index 0000000..9cea737 --- /dev/null +++ b/mono/HeaderList.custom @@ -0,0 +1,56 @@ + [DllImport ("gmime")] + static extern IntPtr g_mime_header_list_set (IntPtr raw, IntPtr name, IntPtr value); + + [DllImport ("gmime")] + static extern IntPtr g_mime_header_list_get (IntPtr raw, IntPtr name); + + public string this[string name] { + get { + if (name == null) + throw new ArgumentNullException ("name"); + + IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name); + IntPtr raw_ret = g_mime_header_list_get (Handle, native_name); + string ret = GLib.Marshaller.Utf8PtrToString (raw_ret); + GLib.Marshaller.Free (native_name); + + return ret; + } + + set { + if (name == null) + throw new ArgumentNullException ("name"); + + IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name); + IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value); + g_mime_header_list_set (Handle, native_name, native_value); + GLib.Marshaller.Free (native_value); + GLib.Marshaller.Free (native_name); + } + } + + [DllImport ("gmime")] + static extern bool g_mime_header_list_get_iter (IntPtr raw, IntPtr iter); + + internal HeaderIter GetIter () + { + HeaderIter iter = new HeaderIter (); + + g_mime_header_list_get_iter (Handle, iter.Handle); + + return iter; + } + + public IEnumerator GetEnumerator () + { + return new HeaderEnumerator (this); + } + + public StreamWrapper Stream { + get { + GMime.StreamMem mem_stream = new GMime.StreamMem (); + this.WriteToStream (mem_stream); + mem_stream.Seek (0); + return new StreamWrapper (mem_stream); + } + } |