rendered paste body static DateTime local_epoch = new DateTime (1970, 1, 1);
public static int DateTimeToUnixtime_t (DateTime time)
{
return ((int)time.Subtract (local_epoch).TotalSeconds);
}
[DllImport("glib-2.0")]
static extern unsafe IntPtr g_slist_nth_data (IntPtr slist, int pos);
[DllImport("glib-2.0")]
static extern int g_slist_length (IntPtr slist);
[DllImport("ecal")]
static extern unsafe IntPtr e_cal_get_items_from_source (IntPtr source, int type, string query, out IntPtr e\rror);
public static string[] GLibSListToStringArray (IntPtr slist)
{
string[] ret;
int i = 0;
int len = 0;
IntPtr tmp = IntPtr.Zero;
len = g_slist_length (slist);
ret = new String [len];
for (i = 0; i < len; i++) {
tmp = g_slist_nth_data (slist, i);
ret[i] = GLib.Marshaller.PtrToStringGFree (tmp);
}
return ret;
}
public static string[] GetItemsFromSource (Evolution.Source source, Evolution.CalSourceType type, string que\ry) {
IntPtr error = IntPtr.Zero;
IntPtr raw_ret = e_cal_get_items_from_source (source.Handle, (int) type, query, out error);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return GLibSListToStringArray (raw_ret);
}
[DllImport("ecal")]
static extern unsafe IntPtr e_cal_get_items_from_source_occur_in_range (IntPtr source,
int type,
int start_date_time,
int end_date_time,
out IntPtr error);
public static string[] GetItemsFromSourceOccurInRange (Evolution.Source source,
Evolution.CalSourceType type,
System.DateTime start_date_time,
System.DateTime end_date_time) {
IntPtr error = IntPtr.Zero;
IntPtr raw_ret = e_cal_get_items_from_source_occur_in_range (source.Handle, (int) type,
DateTimeToUnixtime_t (start_date_time),
DateTimeToUnixtime_t (end_date_time),
out error);
if (error != IntPtr.Zero) throw new GLib.GException (error);
return GLibSListToStringArray (raw_ret);
}