1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is Mozilla Mobile Browser.
16
* The Initial Developer of the Original Code is Mozilla.
17
* Portions created by the Initial Developer are Copyright (C) 2010
18
* the Initial Developer. All Rights Reserved.
21
* Mark Finkle <mfinkle@mozilla.com>
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
37
let EXPORTED_SYMBOLS = ["GLib", "EBook"];
39
const Cu = Components.utils;
41
Cu.import("resource://gre/modules/ctypes.jsm");
46
init: function glib_init() {
50
this.lib = true; // TODO hook up the real glib
52
this.GError = new ctypes.StructType("GError", [
53
{"domain": ctypes.int32_t},
54
{"code": ctypes.int32_t},
55
{"message": ctypes.char.ptr}
58
this.GList = new ctypes.StructType("GList", [
59
{"data": ctypes.voidptr_t},
60
{"next": ctypes.voidptr_t},
61
{"prev": ctypes.voidptr_t}
69
E_CONTACT_FULL_NAME: 4,
72
E_CONTACT_EMAIL_3: 10,
73
E_CONTACT_EMAIL_4: 11,
74
E_CONTACT_PHONE_BUSINESS: 17,
75
E_CONTACT_PHONE_BUSINESS_2: 18,
76
E_CONTACT_PHONE_HOME: 23,
77
E_CONTACT_PHONE_HOME_2: 24,
78
E_CONTACT_PHONE_MOBILE: 27,
80
E_CONTACT_EMAIL_FIRST: 8,
81
E_CONTACT_EMAIL_LAST: 11,
82
E_CONTACT_PHONE_FIRST: 16,
83
E_CONTACT_PHONE_LAST: 34,
85
init: function ebook_init() {
93
this.lib = ctypes.open("libebook-1.2.so.5");
97
this.lib = ctypes.open("libebook-1.2.so.9");
99
Cu.reportError("EBook: couldn't load libebook:\n" + e)
105
this.EBook = new ctypes.StructType("EBook");
106
this.EQuery = new ctypes.StructType("EQuery");
108
this.openSystem = this.lib.declare("e_book_new_system_addressbook", ctypes.default_abi, EBook.EBook.ptr, GLib.GError.ptr.ptr);
109
this.openBook = this.lib.declare("e_book_open", ctypes.default_abi, ctypes.bool, EBook.EBook.ptr, ctypes.bool, GLib.GError.ptr.ptr);
111
this.queryAnyFieldContains = this.lib.declare("e_book_query_any_field_contains", ctypes.default_abi, EBook.EQuery.ptr, ctypes.char.ptr);
113
this.getContacts = this.lib.declare("e_book_get_contacts", ctypes.default_abi, ctypes.bool, EBook.EBook.ptr, EBook.EQuery.ptr, GLib.GList.ptr.ptr, GLib.GError.ptr.ptr);
114
this.getContactField = this.lib.declare("e_contact_get_const", ctypes.default_abi, ctypes.char.ptr, ctypes.voidptr_t, ctypes.uint32_t);