Initialize the gmime for upstream
[platform/upstream/gmime.git] / mono / Message.custom
1                 [DllImport ("gmime")]
2                 static extern IntPtr g_mime_message_get_recipients (IntPtr message, int type);
3                 
4                 public InternetAddressList GetRecipients (GMime.RecipientType type)
5                 {
6                         IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
7                         
8                         return new InternetAddressList (list);
9                 }
10                 
11                 public InternetAddressList To {
12                         get { return GetRecipients (RecipientType.To); }
13                 }
14                 
15                 public InternetAddressList Cc {
16                         get { return GetRecipients (RecipientType.Cc); }
17                 }
18                 
19                 public InternetAddressList Bcc {
20                         get { return GetRecipients (RecipientType.Bcc); }
21                 }
22                 
23                 public System.Collections.IEnumerable References {
24                         get {
25                                 GMime.HeaderList headers = HeaderList;
26                                 
27                                 if (headers == null)
28                                         yield break;
29                                 
30                                 string references = headers["References"];
31                                 
32                                 if (references == null)
33                                         yield break;
34                                 
35                                 GMime.References refs = GMime.References.Parse (references);
36                                 GMime.References iter = refs;
37                                 
38                                 while (iter != null) {
39                                         yield return iter;
40                                         iter = iter.Next;
41                                 }
42                                 
43                                 yield break;
44                         }
45                 }
46                 
47                 [DllImport("gmime")]
48                 static extern IntPtr internet_address_list_to_string (IntPtr list, bool encode);
49                 
50                 public string GetRecipientsAsString (GMime.RecipientType type, bool encode)
51                 {
52                         IntPtr list = g_mime_message_get_recipients (Handle, (int) type);
53                         IntPtr str;
54                         
55                         if (list == IntPtr.Zero)
56                                 return null;
57                         
58                         str = internet_address_list_to_string (list, encode);
59                         
60                         return GLib.Marshaller.PtrToStringGFree (str);
61                 }
62                 
63                 public string GetRecipientsAsString (GMime.RecipientType type)
64                 {
65                         return GetRecipientsAsString (type, false);
66                 }
67                 
68                 [DllImport("gmime")]
69                 static extern void g_mime_message_get_date (IntPtr message, out IntPtr date, out int gmt_offset);
70                 
71                 [DllImport("gmime")]
72                 static extern void g_mime_message_set_date (IntPtr message, IntPtr date, int gmt_offset);
73                 
74                 public DateTime Date {
75                         get {
76                                 int tz_offset;
77                                 IntPtr date;
78                                 
79                                 g_mime_message_get_date (Handle, out date, out tz_offset);
80                                 
81                                 return GLib.Marshaller.time_tToDateTime (date);
82                         }
83                         
84                         set {
85                                 g_mime_message_set_date (Handle, GLib.Marshaller.DateTimeTotime_t (value), 0);
86                         }
87                 }