EDataBook.BookCache¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | EBackend.Cache (39), GObject.Object (37), EDataServer.Extensible (2) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | new(filename, source, cancellable) | 
| class | new_full(filename, source, setup, cancellable) | 
| cursor_calculate(cursor, cancellable) | |
| cursor_compare_contact(cursor, contact) | |
| cursor_free(cursor) | |
| cursor_set_sexp(cursor, sexp) | |
| cursor_set_target_alphabetic_index(cursor, idx) | |
| cursor_step(cursor, flags, origin, count, cancellable) | |
| dup_contact_revision(contact) | |
| dup_locale() | |
| get_contact(uid, meta_contact, cancellable) | |
| get_contact_custom_flags(uid, cancellable) | |
| get_contact_extra(uid, cancellable) | |
| get_uids_with_extra(extra, cancellable) | |
| get_vcard(uid, meta_contact, cancellable) | |
| put_contact(contact, extra, custom_flags, offline_flag, cancellable) | |
| put_contacts(contacts, extras, custom_flags, offline_flag, cancellable) | |
| ref_collator() | |
| ref_source() | |
| remove_contact(uid, custom_flags, offline_flag, cancellable) | |
| remove_contacts(uids, custom_flags, offline_flag, cancellable) | |
| search(sexp, meta_contacts, cancellable) | |
| search_uids(sexp, cancellable) | |
| search_with_callback(sexp, func, user_data, cancellable) | |
| set_contact_custom_flags(uid, custom_flags, cancellable) | |
| set_contact_extra(uid, extra, cancellable) | |
| set_locale(lc_collate, cancellable) | 
Virtual Methods¶
| Inherited: | EBackend.Cache (7), GObject.Object (7) | 
|---|
| do_dup_contact_revision(contact) | |
| do_e164_changed(contact, is_replace) | 
Signals¶
| Inherited: | EBackend.Cache (3), GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| dup-contact-revision | |
| e164-changed | 
Fields¶
| Inherited: | EBackend.Cache (3), GObject.Object (1) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| parent | EBackend.Cache | r | 
Class Details¶
- 
class EDataBook.BookCache(**kwargs)¶
- Bases: - EBackend.Cache,- EDataServer.Extensible- Abstract: - No - Structure: - EDataBook.BookCacheClass- Contains only private data that should be read and manipulated using the functions below. - New in version 3.26. - 
classmethod new(filename, source, cancellable)¶
- Parameters: - filename (str) – file name to load or create the new cache
- source (EDataServer.SourceorNone) – an optionalEDataServer.Source, associated with theEDataBook.BookCache, orNone
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - A new - EDataBook.BookCacheor- Noneon error- Return type: - Creates a new - EDataBook.BookCachewith the default summary configuration.- Aside from the mandatory 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.BookCacheCursor, using the- EBookContacts.BookIndexType.SORT_KEYindex flag.- New in version 3.26. 
- filename (
 - 
classmethod new_full(filename, source, setup, cancellable)¶
- Parameters: - filename (str) – file name to load or create the new cache
- source (EDataServer.SourceorNone) – an optionalEDataServer.Source, associated with theEDataBook.BookCache, orNone
- setup (EBookContacts.SourceBackendSummarySetuporNone) – anEBookContacts.SourceBackendSummarySetupdescribing how the summary should be setup, orNoneto use the default
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - A new - EDataBook.BookCacheor- Noneon error- Return type: - Creates a new - EDataBook.BookCachewith the given or the default summary configuration.- 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.- New in version 3.26. 
- filename (
 - 
cursor_calculate(cursor, cancellable)¶
- Parameters: - cursor (EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursor
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Whether out_total and out_position were successfully calculated. - out_total: - A return location to store the total result set for this cursor - out_position: - A return location to store the cursor position - Return type: - Calculates the out_total amount of results for the cursor’s query expression, as well as the current out_position of cursor in the results. The out_position is represented as the amount of results which lead up to the current value of cursor, if cursor currently points to an exact contact, the position also includes the cursor contact. - New in version 3.26. 
- cursor (
 - 
cursor_compare_contact(cursor, contact)¶
- Parameters: - cursor (EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursor
- contact (EBookContacts.Contact) – TheEBookContacts.Contactto compare
 - Returns: - A value that is less than, equal to, or greater than zero if contact is found, respectively, to be less than, to match, or be greater than the current value of cursor. - out_matches_sexp: - Whether the contact matches the cursor’s search expression - Return type: - Compares contact with cursor and returns whether contact is less than, equal to, or greater than cursor. - New in version 3.26. 
- cursor (
 - 
cursor_free(cursor)¶
- Parameters: - cursor ( - EDataBook.BookCacheCursor) – The- EDataBook.BookCacheCursorto free- Frees the cursor, previously allocated with - EDataBook.BookCacheCursor.new().- New in version 3.26. 
 - 
cursor_set_sexp(cursor, sexp)¶
- Parameters: - cursor (EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorto modify
- sexp (str) – The new query expression for cursor
 - Raises: - Returns: - Trueif the expression was valid and accepted by cursor- Return type: - Modifies the current query expression for cursor. This will not modify cursor’s state, but will change the outcome of any further calls to - EDataBook.BookCache.cursor_step() or- EDataBook.BookCache.cursor_calculate().- New in version 3.26. 
- cursor (
 - 
cursor_set_target_alphabetic_index(cursor, idx)¶
- Parameters: - cursor (EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorto modify
- idx (int) – The alphabetic index
 - Sets the cursor position to an - ‘Alphabetic Index [cursor-alphabet]’ into the alphabet active in self’s locale. - After setting the target to an alphabetic index, for example the index for letter ‘E’, then further calls to - EDataBook.BookCache.cursor_step() will return results starting with the letter ‘E’ (or results starting with the last result in ‘D’, if moving in a negative direction).- The passed index must be a valid index in the active locale, knowledge on the currently active alphabet index must be obtained using - EDataServer.CollatorAPIs.- Use - EDataBook.BookCache.ref_collator() to obtain the active collator for self.- New in version 3.26. 
- cursor (
 - 
cursor_step(cursor, flags, origin, count, cancellable)¶
- Parameters: - cursor (EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorto use
- flags (EDataBook.BookCacheCursorStepFlags) – TheEDataBook.BookCacheCursorStepFlagsfor this step
- origin (EDataBook.BookCacheCursorOrigin) – TheEDataBook.BookCacheCursorOriginfrom whence to step
- count (int) – A positive or negative amount of contacts to try and fetch
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - The number of contacts traversed if successful, otherwise -1 is returned and the error is set. - out_results: - A return location to store the results, or - Noneif- EDataBook.BookCacheCursorStepFlags.FETCHis not specified in flags.- Return type: - ( - int, out_results: [- EDataBook.BookCacheSearchData])- Steps cursor through its sorted query by a maximum of count contacts starting from origin. - If count is negative, then the cursor will move through the list in reverse. - If cursor reaches the beginning or end of the query results, then the returned list might not contain the amount of desired contacts, or might return no results if the cursor currently points to the last contact. Reaching the end of the list is not considered an error condition. Attempts to step beyond the end of the list after having reached the end of the list will however trigger an - EBackend.CacheError.END_OF_LISTerror.- If - EDataBook.BookCacheCursorStepFlags.FETCHis specified in flags, a pointer to a- None- GLib.SListpointer should be provided for the out_results parameter.- The result list will be stored to out_results and should be freed with g_slist_free_full (results, - EDataBook.BookCacheSearchData.free); when no longer needed.- New in version 3.26. 
- cursor (
 - 
dup_contact_revision(contact)¶
- Parameters: - contact ( - EBookContacts.Contact) – an- EBookContacts.Contact- Returns: - A newly allocated string containing revision of the contact. - Return type: - str- Returns the contact revision, used to detect changes. The returned string should be freed with - GLib.free(), when no longer needed.- New in version 3.26. 
 - 
dup_locale()¶
- Returns: - A new string containing the current local being used by the self. Free it with - GLib.free(), when no longer needed.- Return type: - str- New in version 3.26. 
 - 
get_contact(uid, meta_contact, cancellable)¶
- Parameters: - uid (str) – The uid of the contact to fetch
- meta_contact (bool) – Whether an entire contact is desired, or only the metadata
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- out_contact: - Return location to store the fetched contact - Return type: - ( - bool, out_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.26. 
- uid (
 - 
get_contact_custom_flags(uid, cancellable)¶
- Parameters: - uid (str) – The uid of the contact to set the extra data for
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Whether succeeded. - out_custom_flags: - return location to store the custom flags - Return type: - Gets the custom flags previously set for the uid, either with - EDataBook.BookCache.set_contact_custom_flags(), when adding contacts or when removing contacts in offline.- New in version 3.34. 
- uid (
 - 
get_contact_extra(uid, cancellable)¶
- Parameters: - uid (str) – The uid of the contact to fetch the extra data for
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- out_extra: - Return location to store the extra data - Return type: - Fetches the extra data previously set for uid, either with - EDataBook.BookCache.set_contact_extra() or when adding contacts.- New in version 3.26. 
- uid (
 - 
get_uids_with_extra(extra, cancellable)¶
- Parameters: - extra (str) – an extra column value to search for
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Whether succeeded. - out_uids: - return location to store the UIDs to - Return type: - Gets all the UID-s the extra data is set for. - The out_uids should be freed with g_slist_free_full (uids, - GLib.free); when no longer needed.- New in version 3.26. 
- extra (
 - 
get_vcard(uid, meta_contact, cancellable)¶
- Parameters: - uid (str) – The uid of the contact to fetch
- meta_contact (bool) – Whether an entire contact is desired, or only the metadata
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- out_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.26. 
- uid (
 - 
put_contact(contact, extra, custom_flags, offline_flag, cancellable)¶
- Parameters: - contact (EBookContacts.Contact) – anEBookContacts.Contactto be added
- extra (strorNone) – extra data to store in association with this contact
- custom_flags (int) – custom flags for the contact, not interpreted by the self
- offline_flag (EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether putting this contact in offline
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - This is a convenience wrapper for - EDataBook.BookCache.put_contacts(), which is the preferred way to add or modify multiple contacts when possible.- New in version 3.26. 
- contact (
 - 
put_contacts(contacts, extras, custom_flags, offline_flag, cancellable)¶
- Parameters: - contacts ([EBookContacts.Contact]) – A list of contacts to add to self
- extras ([str] orNone) – A list of extra data to store in association with the contacts
- custom_flags ([int] orNone) – optional custom flags to use for the contacts
- offline_flag (EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether putting these contacts in offline
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Adds or replaces contacts in self. - If extras is specified, it must have an equal length as the contacts list. Similarly the non- - Nonecustom_flags length should be the same as the length of the contacts. Each element from the extras list and custom_flags list will be stored in association with its corresponding contact in the contacts list.- New in version 3.26. 
- contacts ([
 - 
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.26. 
 - 
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 no longer needed. It can be- Nonein some cases, like when running tests.- New in version 3.26. 
 - 
remove_contact(uid, custom_flags, offline_flag, cancellable)¶
- Parameters: - uid (str) – the uid of the contact to remove
- custom_flags (int) – custom flags for the contact with the given uid, not interpreted by the self
- offline_flag (EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether removing this contact in offline
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Removes the contact identified by uid from self. - New in version 3.26. 
- uid (
 - 
remove_contacts(uids, custom_flags, offline_flag, cancellable)¶
- Parameters: - uids ([str]) – aGLib.SListof uids indicating which contacts to remove
- custom_flags ([int] orNone) – an optionalGLib.SListof custom flags for the ids
- offline_flag (EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether removing these contacts in offline
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Removes the contacts indicated by uids from self. The custom_flags is used, if not - None, only if the offline_flag is- EBackend.CacheOfflineFlag.IS_OFFLINE. Otherwise it’s ignored. The length of the custom_flags should match the length of uids, when not- None.- New in version 3.26. 
- 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) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- out_list: - Return location to store a - GLib.SListof- EDataBook.BookCacheSearchDatastructures- Return type: - ( - bool, out_list: [- EDataBook.BookCacheSearchData])- Searches self for contacts matching the search expression 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.- The returned out_list list should be freed with g_slist_free_full (list, - EDataBook.BookCacheSearchData.free) when no longer needed.- 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.26. 
- sexp (
 - 
search_uids(sexp, cancellable)¶
- Parameters: - sexp (strorNone) – search expression; useNoneor an empty string to get all stored contacts
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- out_list: - Return location to store a - GLib.SListof contact uids- Return type: - Similar to - EDataBook.BookCache.search(), but fetches only a list of contact UIDs.- The returned out_list list should be freed with g_slist_free_full(list, - GLib.free) when no longer needed.- New in version 3.26. 
- sexp (
 - 
search_with_callback(sexp, func, user_data, cancellable)¶
- Parameters: - sexp (strorNone) – search expression; useNoneor an empty string to get all stored contacts
- func (EDataBook.BookCacheSearchFuncorNone) – anEDataBook.BookCacheSearchFunccallback to call for each found row
- user_data (objectorNone) – user data for func
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Trueon success, otherwise- Falseis returned and error is set appropriately.- Return type: - Similar to - EDataBook.BookCache.search(), but calls the func for each found contact.- New in version 3.26. 
- sexp (
 - 
set_contact_custom_flags(uid, custom_flags, cancellable)¶
- Parameters: - uid (str) – The uid of the contact to set the extra data for
- custom_flags (int) – the custom flags to set for the contact
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - Raises: - Returns: - Whether succeeded. - Return type: - Sets or replaces the custom flags associated with a contact identified by the uid. - New in version 3.34. 
- uid (
 - 
set_contact_extra(uid, extra, cancellable)¶
- Parameters: - uid (str) – The uid of the contact to set the extra data for
- extra (strorNone) – The extra data to set
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - 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.26. 
- uid (
 - 
set_locale(lc_collate, cancellable)¶
- Parameters: - lc_collate (str) – The new locale for the cache
- cancellable (Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
 - 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 cache, changing the locale will store the new locale and will modify sort keys and any locale specific data in the cache. - As a side effect, it’s possible that changing the locale will cause stored vCard-s to change. - New in version 3.26. 
- lc_collate (
 - 
do_dup_contact_revision(contact) virtual¶
- Parameters: - contact ( - EBookContacts.Contact) – an- EBookContacts.Contact- Returns: - A newly allocated string containing revision of the contact. - Return type: - str- Returns the contact revision, used to detect changes. The returned string should be freed with - GLib.free(), when no longer needed.- New in version 3.26. 
 - 
do_e164_changed(contact, is_replace) virtual¶
- Parameters: - contact (EBookContacts.Contact) –
- is_replace (bool) –
 
- contact (
 
- 
classmethod 
Signal Details¶
- 
EDataBook.BookCache.signals.dup_contact_revision(book_cache, object)¶
- Signal Name: - dup-contact-revision- Flags: - Parameters: - book_cache (EDataBook.BookCache) – The object which received the signal
- object (EBookContacts.Contact) –
 - Return type: 
- book_cache (
- 
EDataBook.BookCache.signals.e164_changed(book_cache, object, p0)¶
- Signal Name: - e164-changed- Flags: - Parameters: - book_cache (EDataBook.BookCache) – The object which received the signal
- object (EBookContacts.Contact) –
- p0 (bool) –
 
- book_cache (