1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
[DllImport("ebook")]
static extern unsafe bool e_book_get_contacts(IntPtr raw, IntPtr query, out IntPtr contacts, out IntPtr error);
public unsafe Contact[] GetContacts(Evolution.BookQuery query) {
if (query == null)
throw new ArgumentNullException ("query");
IntPtr contacts_handle;
IntPtr error = IntPtr.Zero;
bool raw_ret = e_book_get_contacts(Handle, query.Handle, out contacts_handle, out error);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (raw_ret == false)
return null;
GLib.List cl = new GLib.List(contacts_handle, typeof (Contact));
Contact[] result = new Contact [cl.Count];
for (int i = 0; i < cl.Count; i++)
result [i] = cl [i] as Contact;
return result;
}
[DllImport("ebook")]
static extern unsafe bool e_book_get_book_view(IntPtr raw, IntPtr query, IntPtr requested_fields, int max_results, out IntPtr book_view, out IntPtr error);
public unsafe BookView GetBookView (Evolution.BookQuery query,
IEnumerable requestedFields,
int max_results) {
IntPtr error = IntPtr.Zero;
IntPtr bookHandle;
GLib.List fieldsList = new GLib.List (typeof (string));
if (requestedFields != null) {
foreach (string field in requestedFields) {
fieldsList.Append (field);
}
}
bool raw_ret = e_book_get_book_view (Handle,
query.Handle,
fieldsList.Handle,
max_results,
out bookHandle,
out error);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (raw_ret == false || bookHandle == (IntPtr)0)
return null;
return new BookView (bookHandle);
}
[DllImport("evolutionglue")]
static extern bool e_book_glue_ebook_get_changes(IntPtr raw,
string changeid,
out IntPtr added,
out IntPtr modified,
out IntPtr deleted,
out IntPtr error);
public unsafe bool GetChanges(string changeid,
out Contact[] newcontacts,
out Contact[] updated,
out String[] removed )
{
IntPtr error = IntPtr.Zero;
IntPtr added = IntPtr.Zero;
IntPtr modified = IntPtr.Zero;
IntPtr deleted = IntPtr.Zero;
bool raw_ret = e_book_glue_ebook_get_changes (Handle,
changeid,
out added,
out modified,
out deleted,
out error);
if (error != IntPtr.Zero) throw new GLib.GException (error);
if (raw_ret == false) {
newcontacts = new Contact [0];
updated = new Contact [0];
removed = new string [0];
return raw_ret;
}
GLib.SList cl;
if (added != IntPtr.Zero) {
cl = new GLib.SList(added, typeof (Contact));
newcontacts = new Contact [cl.Count];
for (int i = 0; i < cl.Count; i++)
newcontacts [i] = cl [i] as Contact;
} else {
newcontacts = new Contact [0];
}
if (modified != IntPtr.Zero) {
cl = new GLib.SList(modified, typeof (Contact));
updated = new Contact [cl.Count];
for (int i = 0; i < cl.Count; i++)
updated [i] = cl [i] as Contact;
} else {
updated = new Contact [0];
}
if (deleted != IntPtr.Zero) {
GLib.SList sl = new GLib.SList(deleted, typeof (string));
removed = new string [sl.Count];
for (int i = 0; i < sl.Count; i++)
removed [i] = sl [i] as String;
} else {
removed = new string [0];
}
return raw_ret;
}
|