EDataBook.BookSqlite¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37), EDataServer.Extensible (2) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | error_quark() | 
| class | new(path, source, cancellable) | 
| class | new_full(path, source, setup, vcard_callback, change_callback, user_data, cancellable) | 
| class | search_data_free(data) | 
| add_contact(contact, extra, replace, cancellable) | |
| add_contacts(contacts, extra, replace, cancellable) | |
| get_contact(uid, meta_contact) | |
| get_contact_extra(uid) | |
| get_key_value(key) | |
| get_key_value_int(key) | |
| get_locale() | |
| get_vcard(uid, meta_contact) | |
| has_contact(uid) | |
| lock(lock_type, cancellable) | |
| ref_collator() | |
| ref_source() | |
| remove_contact(uid, cancellable) | |
| remove_contacts(uids, cancellable) | |
| search(sexp, meta_contacts, cancellable) | |
| search_uids(sexp, cancellable) | |
| set_contact_extra(uid, extra) | |
| set_key_value(key, value) | |
| set_key_value_int(key, value) | |
| set_locale(lc_collate, cancellable) | |
| unlock(action) | 
Virtual Methods¶
| Inherited: | GObject.Object (7) | 
|---|
| do_before_insert_contact(db, contact, extra, replace, cancellable) | |
| do_before_remove_contact(db, contact_uid, cancellable) | 
Properties¶
None
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| before-insert-contact | |
| before-remove-contact | 
Class Details¶
- 
class EDataBook.BookSqlite(**kwargs)¶
- Bases: - GObject.Object,- EDataServer.Extensible- Abstract: - No - Structure: - EDataBook.BookSqliteClass- Contains only private data that should be read and manipulated using the functions below. - New in version 3.12. - 
classmethod new(path, source, cancellable)¶
- Parameters: - path (str) – location to load or create the new database
- source (EDataServer.Source) – an optionalEDataServer.Source, associated with theEDataBook.BookSqlite, orNone
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - A reference to a - EDataBook.BookSqlite- Return type: - Creates a new - EDataBook.BookSqlitewith the default summary configuration.- Aside from the manditory fields - EBookContacts.ContactField.UID,- EBookContacts.ContactField.REV, the default configuration stores the following fields for quick performance of searches:- EBookContacts.ContactField.FILE_AS,- EBookContacts.ContactField.NICKNAME,- EBookContacts.ContactField.FULL_NAME,- EBookContacts.ContactField.GIVEN_NAME,- EBookContacts.ContactField.FAMILY_NAME,- EBookContacts.ContactField.EMAIL,- EBookContacts.ContactField.TEL,- EBookContacts.ContactField.IS_LIST,- EBookContacts.ContactField.LIST_SHOW_ADDRESSES, and- EBookContacts.ContactField.WANTS_HTML.- The fields - EBookContacts.ContactField.FULL_NAMEand- EBookContacts.ContactField.EMAILare configured to respond extra quickly with the- EBookContacts.BookIndexType.PREFIXindex flag.- The fields - EBookContacts.ContactField.FILE_AS,- EBookContacts.ContactField.FAMILY_NAMEand- EBookContacts.ContactField.GIVEN_NAMEare configured to perform well with the- EDataBook.bSqlCursorinterface, using the- EBookContacts.BookIndexType.SORT_KEYindex flag.- New in version 3.12. 
- path (
 - 
classmethod new_full(path, source, setup, vcard_callback, change_callback, user_data, cancellable)¶
- Parameters: - path (str) – location to load or create the new database
- source (EDataServer.Source) – an optionalEDataServer.Source, associated with theEDataBook.BookSqlite, orNone
- setup (EBookContacts.SourceBackendSummarySetuporNone) – anEBookContacts.SourceBackendSummarySetupdescribing how the summary should be setup, orNoneto use the default
- vcard_callback (EDataBook.bSqlVCardCallbackorNone) – A function to resolve vcards
- change_callback (EDataBook.bSqlChangeCallbackorNone) – A function to catch notifications of vcard changes
- user_data (objectorNone) – callback user data
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - The newly created - EDataBook.BookSqlite, or- Noneif opening or creating the addressbook failed.- Return type: - Opens or creates a new addressbook at path. - Like - EDataBook.BookSqlite.new(), but allows configuration of which contact fields will be stored for quick reference in the summary. The configuration indicated by setup will only be taken into account when initially creating the underlying table, further configurations will be ignored.- The fields - EBookContacts.ContactField.UIDand- EBookContacts.ContactField.REVare not optional, they will be stored in the summary regardless of this function’s parameters. Only- EBookContacts.ContactFieldswith the type- GObject.TYPE_STRING,- GObject.TYPE_BOOLEANor #E_TYPE_CONTACT_ATTR_LIST are currently supported.- If vcard_callback is specified, then vcards will not be stored by functions such as e_book_sqlitedb_add_contact(). Instead vcard_callback will be invoked at any time the created - EDataBook.BookSqliterequires a vcard, either as a fallback for querying search expressions which cannot be satisfied with the summary fields, or when reporting results from searches.- If any error occurs and - Noneis returned, then the passed user_data will be automatically freed using the user_data_destroy function, if specified.- It is recommended to store all contact vcards in the - EDataBook.BookSqliteaddressbook if at all possible, however in some cases the vcards must be stored in some other storage.- New in version 3.12. 
- path (
 - 
classmethod search_data_free(data)¶
- Parameters: - data ( - EDataBook.bSqlSearchData) – An- EDataBook.bSqlSearchData- Frees an - EDataBook.bSqlSearchData- New in version 3.12. 
 - 
add_contact(contact, extra, replace, cancellable)¶
- Parameters: - contact (EBookContacts.Contact) –
- extra (str) –
- replace (bool) –
- cancellable (Gio.CancellableorNone) –
 - Raises: - Return type: 
- contact (
 - 
add_contacts(contacts, extra, replace, cancellable)¶
- Parameters: - contacts ([EBookContacts.Contact]) – A list of contacts to add to self
- extra ([str] orNone) – A list of extra data to store in association with this contact
- replace (bool) – Whether this contact should replace another contact with the same UID.
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Adds or replaces contacts in self. If replace_existing is specified then existing contacts with the same UID will be replaced, otherwise adding an existing contact will return an error. - If extra is specified, it must have an equal length as the contacts list. Each element from the extra list will be stored in association with it’s corresponding contact in the contacts list. - New in version 3.12. 
- contacts ([
 - 
get_contact(uid, meta_contact)¶
- Parameters: - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- ret_contact: - Return location to store the fetched contact - Return type: - ( - bool, ret_contact:- EBookContacts.Contact)- Fetch the - EBookContacts.Contactspecified by uid in self.- If meta_contact is specified, then a shallow - EBookContacts.Contactwill be created holding only the- EBookContacts.ContactField.UIDand- EBookContacts.ContactField.REVfields.- New in version 3.12. 
 - 
get_contact_extra(uid)¶
- Parameters: - uid ( - str) – The uid of the contact to fetch the extra data for- Raises: - GLib.Error- Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- ret_extra: - Return location to store the extra data - Return type: - ( - bool, ret_extra:- str)- Fetches the extra data previously set for uid, either with - EDataBook.BookSqlite.set_contact_extra() or when adding contacts.- New in version 3.12. 
 - 
get_key_value(key)¶
- Parameters: - key ( - str) – The key to fetch a value for- Raises: - GLib.Error- Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- value: - A return location to store the value for key - Return type: - ( - bool, value:- str)- Fetches the value for key and stores it in value - New in version 3.12. 
 - 
get_key_value_int(key)¶
- Parameters: - key ( - str) – The key to fetch a value for- Raises: - GLib.Error- Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- value: - A return location to store the value for key - Return type: - ( - bool, value:- int)- A convenience function to fetch the value of key as an integer. - New in version 3.12. 
 - 
get_locale()¶
- Raises: - GLib.Error- Returns: - Whether the locale was successfully fetched. - locale_out: - The location to return the current locale - Return type: - ( - bool, locale_out:- str)- Fetches the current locale setting for the address-book. - Upon success, lc_collate_out will hold the returned locale setting, otherwise - Falsewill be returned and error will be updated accordingly.- New in version 3.12. 
 - 
get_vcard(uid, meta_contact)¶
- Parameters: - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- ret_vcard: - Return location to store the fetched vcard string - Return type: - Fetch a vcard string for uid in self. - If meta_contact is specified, then a shallow vcard representation will be created holding only the - EBookContacts.ContactField.UIDand- EBookContacts.ContactField.REVfields.- New in version 3.12. 
 - 
has_contact(uid)¶
- Parameters: - uid ( - str) – The uid of the contact to check for- Raises: - GLib.Error- Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- exists: - Return location to store whether the contact exists. - Return type: - ( - bool, exists:- bool)- Checks if a contact bearing the UID indicated by uid is stored in self. - New in version 3.12. 
 - 
lock(lock_type, cancellable)¶
- Parameters: - lock_type (EDataBook.bSqlLockType) – TheEDataBook.bSqlLockTypeto acquire
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Obtains an exclusive lock on self and starts a transaction. - This should be called if you need to access self multiple times while ensuring an atomic transaction. End this transaction with - EDataBook.BookSqlite.unlock().- If cancellable is specified, then self will retain a reference to it until - EDataBook.BookSqlite.unlock() is called. Any accesses to self with the lock held are expected to have the same cancellable specified, or- None.- Aside from ensuring atomicity of transactions, this function will hold a mutex which will cause further calls to - EDataBook.BookSqlite.lock() to block. If you are accessing self from multiple threads, then any interactions with self should be nested in calls to- EDataBook.BookSqlite.lock() and- EDataBook.BookSqlite.unlock().- New in version 3.12. 
- lock_type (
 - 
ref_collator()¶
- Returns: - A reference to the active collator. - Return type: - EDataServer.Collator- References the currently active - EDataServer.Collatorfor self, use- EDataServer.Collator.unref() when finished using the returned collator.- Note that the active collator will change with the active locale setting. - New in version 3.12. 
 - 
ref_source()¶
- Returns: - A reference to the - EDataServer.Sourceto which self is paired, or- None.- Return type: - EDataServer.Source- References the - EDataServer.Sourceto which self is paired, use- GObject.Object.unref() when finished using the source. It can be- Nonein some cases, like when running tests.- New in version 3.16. 
 - 
remove_contact(uid, cancellable)¶
- Parameters: - uid (str) – the uid of the contact to remove
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Removes the contact indicated by uid from self. - New in version 3.12. 
- uid (
 - 
remove_contacts(uids, cancellable)¶
- Parameters: - uids ([str]) – aGLib.SListof uids indicating which contacts to remove
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Removes the contacts indicated by uids from self. - New in version 3.12. 
- uids ([
 - 
search(sexp, meta_contacts, cancellable)¶
- Parameters: - sexp (strorNone) – search expression; useNoneor an empty string to list all stored contacts.
- meta_contacts (bool) – Whether entire contacts are desired, or only the metadata
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- ret_list: - Return location to store a - GLib.SListof- EDataBook.bSqlSearchDatastructures- Return type: - ( - bool, ret_list: [- EDataBook.bSqlSearchData])- Searches self for contacts matching the search expression indicated by sexp. - When sexp refers only to - EBookContacts.ContactFieldsconfigured in the summary of self, the search should always be quick, when searching for other- EBookContacts.ContactFieldsa fallback will be used, possibly invoking any- EDataBook.bSqlVCardCallbackwhich may have been passed to- EDataBook.BookSqlite.new_full().- The returned ret_list list should be freed with g_slist_free() and all elements freed with - EDataBook.BookSqlite.search_data_free().- If meta_contact is specified, then shallow vcard representations will be created holding only the - EBookContacts.ContactField.UIDand- EBookContacts.ContactField.REVfields.- New in version 3.12. 
- sexp (
 - 
search_uids(sexp, cancellable)¶
- Parameters: - sexp (strorNone) – search expression; useNoneor an empty string to get all stored contacts.
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- ret_list: - Return location to store a - GLib.SListof contact uids- Return type: - Similar to e_book_sqlitedb_search(), but fetches only a list of contact UIDs. - The returned ret_list list should be freed with g_slist_free() and all elements freed with - GLib.free().- New in version 3.12. 
- sexp (
 - 
set_contact_extra(uid, extra)¶
- Parameters: - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Sets or replaces the extra data associated with uid. - New in version 3.12. 
 - 
set_key_value(key, value)¶
- Parameters: - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Sets the value for key to be value - New in version 3.12. 
 - 
set_key_value_int(key, value)¶
- Parameters: - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - A convenience function to set the value of key as an integer. - New in version 3.12. 
 - 
set_locale(lc_collate, cancellable)¶
- Parameters: - lc_collate (str) – The new locale for the addressbook
- cancellable (Gio.CancellableorNone) – AGio.Cancellable
 - Raises: - Returns: - Whether the new locale was successfully set. - Return type: - Relocalizes any locale specific data in the specified new lc_collate locale. - The lc_collate locale setting is stored and remembered on subsequent accesses of the addressbook, changing the locale will store the new locale and will modify sort keys and any locale specific data in the addressbook. - As a side effect, it’s possible that changing the locale will cause stored vcards to change. Notifications for these changes can be caught with the - EDataBook.bSqlVCardCallbackprovided to- EDataBook.BookSqlite.new_full().- New in version 3.12. 
- lc_collate (
 - 
unlock(action)¶
- Parameters: - action ( - EDataBook.bSqlUnlockAction) – Which- EDataBook.bSqlUnlockActionto take while unlocking- Raises: - GLib.Error- Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - bool- Releases an exclusive on self and finishes a transaction previously started with e_book_sqlite_lock_updates(). - If this fails, the lock on self is still released and error will be set to indicate why the transaction or rollback failed. - New in version 3.12. 
 - 
do_before_insert_contact(db, contact, extra, replace, cancellable) virtual¶
- Parameters: - db (objectorNone) –
- contact (EBookContacts.Contact) –
- extra (str) –
- replace (bool) –
- cancellable (Gio.CancellableorNone) –
 - Return type: 
- db (
 
- 
classmethod 
Signal Details¶
- 
EDataBook.BookSqlite.signals.before_insert_contact(book_sqlite, object, p0, p1, p2, p3, p4)¶
- Signal Name: - before-insert-contact- Flags: - Parameters: - book_sqlite (EDataBook.BookSqlite) – The object which received the signal
- object (objectorNone) –
- p0 (EBookContacts.Contact) –
- p1 (str) –
- p2 (bool) –
- p3 (GObject.Object) –
- p4 (objectorNone) –
 - Return type: 
- book_sqlite (
- 
EDataBook.BookSqlite.signals.before_remove_contact(book_sqlite, object, p0, p1, p2)¶
- Signal Name: - before-remove-contact- Flags: - Parameters: - book_sqlite (EDataBook.BookSqlite) – The object which received the signal
- object (objectorNone) –
- p0 (str) –
- p1 (Gio.CancellableorNone) –
- p2 (objectorNone) –
 - Return type: 
- book_sqlite (