EDataBook.BookCache¶
- Subclasses:
None
Methods¶
- Inherited:
EBackend.Cache (39), GObject.Object (37), EDataServer.Extensible (3)
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r |
The locale currently being used |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class EDataBook.BookCache(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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 cachesource (
EDataServer.SourceorNone) – an optionalEDataServer.Source, associated with theEDataBook.BookCache, orNonecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
A new
EDataBook.BookCacheorNoneon 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, andEBookContacts.ContactField.WANTS_HTML.The fields
EBookContacts.ContactField.FULL_NAMEandEBookContacts.ContactField.EMAILare configured to respond extra quickly with theEBookContacts.BookIndexType.PREFIXindex flag.The fields
EBookContacts.ContactField.FILE_AS,EBookContacts.ContactField.FAMILY_NAMEandEBookContacts.ContactField.GIVEN_NAMEare configured to perform well with theEDataBook.BookCacheCursor, using theEBookContacts.BookIndexType.SORT_KEYindex flag.New in version 3.26.
- classmethod new_full(filename, source, setup, cancellable)¶
- Parameters:
filename (
str) – file name to load or create the new cachesource (
EDataServer.SourceorNone) – an optionalEDataServer.Source, associated with theEDataBook.BookCache, orNonesetup (
EBookContacts.SourceBackendSummarySetuporNone) – anEBookContacts.SourceBackendSummarySetupdescribing how the summary should be setup, orNoneto use the defaultcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
A new
EDataBook.BookCacheorNoneon 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.UIDandEBookContacts.ContactField.REVare not optional, they will be stored in the summary regardless of this function’s parameters. OnlyEBookContacts.ContactFieldswith the typeGObject.TYPE_STRING,GObject.TYPE_BOOLEANor %E_TYPE_CONTACT_ATTR_LIST are currently supported.New in version 3.26.
- contains_email(email_address, cancellable)¶
- Parameters:
email_address (
str) – an email address to check forcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
- Return type:
Checks whether contains an email_address. When the email_address contains multiple addresses, then returns
Truewhen at least one address exists in the cache.If an error occurs, the function will set error and return
False.New in version 3.44.
- count_query(sexp, cancellable)¶
- Parameters:
sexp (
strorNone) – search expression; useNoneor an empty string to consider all stored contactscancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Whether succeeded.
- out_n_total:
return location to store the count of the contacts
- Return type:
Counts how many contacts satisfy the sexp.
New in version 3.50.
- cursor_calculate(cursor, cancellable)¶
- Parameters:
cursor (
EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorcancellable (
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_compare_contact(cursor, contact)¶
- Parameters:
cursor (
EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorcontact (
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_free(cursor)¶
- Parameters:
cursor (
EDataBook.BookCacheCursor) – TheEDataBook.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 modifysexp (
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() orEDataBook.BookCache.cursor_calculate().New in version 3.26.
- cursor_set_target_alphabetic_index(cursor, idx)¶
- Parameters:
cursor (
EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorto modifyidx (
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_step(cursor, flags, origin, count, cancellable)¶
- Parameters:
cursor (
EDataBook.BookCacheCursor) – TheEDataBook.BookCacheCursorto useflags (
EDataBook.BookCacheCursorStepFlags) – TheEDataBook.BookCacheCursorStepFlagsfor this steporigin (
EDataBook.BookCacheCursorOrigin) – TheEDataBook.BookCacheCursorOriginfrom whence to stepcount (
int) – A positive or negative amount of contacts to try and fetchcancellable (
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
NoneifEDataBook.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 aNoneGLib.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.
- dup_categories()¶
- Returns:
a comma-separated list of categories used by the contacts stored in the self, or
None, when no category is used by any contact.- Return type:
Returns a comma-separated list of categories used by the contacts stored in the self. Free the returned string with
GLib.free(), when no longer needed.New in version 3.48.
- dup_contact_revision(contact)¶
- Parameters:
contact (
EBookContacts.Contact) – anEBookContacts.Contact- Returns:
A newly allocated string containing revision of the contact.
- Return type:
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:
New in version 3.26.
- dup_query_contacts(sexp, sort_field, sort_type, n_offset, n_limit, out_contacts, cancellable)¶
- Parameters:
sexp (
strorNone) – search expression; useNoneor an empty string to consider all stored contactssort_field (
EBookContacts.ContactField) – a field to sort by, which should be in the summarysort_type (
EBookContacts.BookCursorSortType) – anEBookContacts.BookCursorSortTypen_offset (
int) – a 0-based offset in the sorted result to start reading from, or 0 to read from startn_limit (
int) – how many values to return only; use 0 orGObject.G_MAXUINTto read everything from the n_offsetout_contacts ([
EBookContacts.Contact]) – an array ofEBookContacts.Contact-s in the requested ordercancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Whether succeeded.
- Return type:
Queries the self for the contacts in the given range and order. The sort_field should be in the summary, otherwise an error is returned.
Free the out_contacts with g_ptr_aray_unref(), when no longer needed.
New in version 3.50.
- dup_query_field(summary_field, sexp, sort_field, sort_type, n_offset, n_limit, out_uids, out_values, cancellable)¶
- Parameters:
summary_field (
EBookContacts.ContactField) – a field to query, which should be in the summarysexp (
strorNone) – search expression; useNoneor an empty string to consider all stored contactssort_field (
EBookContacts.ContactField) – a field to sort by, which should be in the summarysort_type (
EBookContacts.BookCursorSortType) – anEBookContacts.BookCursorSortTypen_offset (
int) – a 0-based offset in the sorted result to start reading from, or 0 to read from startn_limit (
int) – how many values to return only; use 0 orGObject.G_MAXUINTto read everything from the n_offsetout_uids ([
str]) – contact UID-s in the requested orderout_values ([
str]) – summary_field values in the requested ordercancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Whether succeeded.
- Return type:
Queries the self for a summary_field value for contacts in the given range and order. To get complete contacts use
EDataBook.BookCache.dup_query_contacts(). Note the field value may not correspond precisely to the value stored in the vCard (it can be in lower case).Both summary_field and sort_field should be in the summary, otherwise an error is returned.
The out_uids and out_values will have the same number of elements, the indexes corresponding to each other. Free the arrays with g_ptr_aray_unref(), when no longer needed.
New in version 3.50.
- dup_summary_field(summary_field, uid, cancellable)¶
- Parameters:
summary_field (
EBookContacts.ContactField) – a field to query, which should be in the summaryuid (
str) – a contact UID to query the summary_field forcancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Whether succeeded.
- out_value:
summary_field value
- Return type:
Queries the self for a summary_field value for contact with UID uid. Note the field value may not correspond precisely to the value stored in the vCard (it can be in lower case).
Free the out_value with
GLib.free(), when no longer needed.New in version 3.50.
- get_contact(uid, meta_contact, cancellable)¶
- Parameters:
uid (
str) – The uid of the contact to fetchmeta_contact (
bool) – Whether an entire contact is desired, or only the metadatacancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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 theEBookContacts.ContactField.UIDandEBookContacts.ContactField.REVfields.New in version 3.26.
- get_contact_custom_flags(uid, cancellable)¶
- Parameters:
uid (
str) – The uid of the contact to set the extra data forcancellable (
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.
- get_contact_extra(uid, cancellable)¶
- Parameters:
uid (
str) – The uid of the contact to fetch the extra data forcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.
- get_uids_with_extra(extra, cancellable)¶
- Parameters:
extra (
str) – an extra column value to search forcancellable (
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.
- get_vcard(uid, meta_contact, cancellable)¶
- Parameters:
uid (
str) – The uid of the contact to fetchmeta_contact (
bool) – Whether an entire contact is desired, or only the metadatacancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.UIDandEBookContacts.ContactField.REVfields.New in version 3.26.
- put_contact(contact, extra, custom_flags, offline_flag, cancellable)¶
- Parameters:
contact (
EBookContacts.Contact) – anEBookContacts.Contactto be addedextra (
strorNone) – extra data to store in association with this contactcustom_flags (
int) – custom flags for the contact, not interpreted by the selfoffline_flag (
EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether putting this contact in offlinecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.
- put_contacts(contacts, extras, custom_flags, offline_flag, cancellable)¶
- Parameters:
contacts ([
EBookContacts.Contact]) – A list of contacts to add to selfextras ([
str] orNone) – A list of extra data to store in association with the contactscustom_flags ([
int] orNone) – optional custom flags to use for the contactsoffline_flag (
EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether putting these contacts in offlinecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.
- ref_collator()¶
- Returns:
A reference to the active collator.
- Return type:
References the currently active
EDataServer.Collatorfor self, useEDataServer.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, orNone.- Return type:
References the
EDataServer.Sourceto which self is paired, useGObject.Object.unref() when no longer needed. It can beNonein 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 removecustom_flags (
int) – custom flags for the contact with the given uid, not interpreted by the selfoffline_flag (
EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether removing this contact in offlinecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- Return type:
Removes the contact identified by uid from self.
New in version 3.26.
- remove_contacts(uids, custom_flags, offline_flag, cancellable)¶
- Parameters:
uids ([
str]) – aGLib.SListof uids indicating which contacts to removecustom_flags ([
int] orNone) – an optionalGLib.SListof custom flags for the idsoffline_flag (
EBackend.CacheOfflineFlag) – one ofEBackend.CacheOfflineFlag, whether removing these contacts in offlinecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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 isEBackend.CacheOfflineFlag.IS_OFFLINE. Otherwise it’s ignored. The length of the custom_flags should match the length of uids, when notNone.New in version 3.26.
- search(sexp, meta_contacts, cancellable)¶
- Parameters:
sexp (
strorNone) – search expression; useNoneor an empty string to list all stored contactsmeta_contacts (
bool) – Whether entire contacts are desired, or only the metadatacancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- out_list:
Return location to store a
GLib.SListofEDataBook.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 otherEBookContacts.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.UIDandEBookContacts.ContactField.REVfields.New in version 3.26.
- search_uids(sexp, cancellable)¶
- Parameters:
sexp (
strorNone) – search expression; useNoneor an empty string to get all stored contactscancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.
- search_with_callback(sexp, func, user_data, cancellable)¶
- Parameters:
sexp (
strorNone) – search expression; useNoneor an empty string to get all stored contactsfunc (
EDataBook.BookCacheSearchFunc) – anEDataBook.BookCacheSearchFunccallback to call for each found rowcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.
- set_contact_custom_flags(uid, custom_flags, cancellable)¶
- Parameters:
uid (
str) – The uid of the contact to set the extra data forcustom_flags (
int) – the custom flags to set for the contactcancellable (
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.
- set_contact_extra(uid, extra, cancellable)¶
- Parameters:
uid (
str) – The uid of the contact to set the extra data forcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- Return type:
Sets or replaces the extra data associated with uid.
New in version 3.26.
- set_locale(lc_collate, cancellable)¶
- Parameters:
lc_collate (
str) – The new locale for the cachecancellable (
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.
- do_dup_contact_revision(contact) virtual¶
- Parameters:
contact (
EBookContacts.Contact) – anEBookContacts.Contact- Returns:
A newly allocated string containing revision of the contact.
- Return type:
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) –
Signal Details¶
- EDataBook.BookCache.signals.categories_changed(book_cache, object)¶
- Signal Name:
categories-changed- Flags:
- Parameters:
book_cache (
EDataBook.BookCache) – The object which received the signalobject (
str) –
- 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 signalobject (
EBookContacts.Contact) –
- Return type:
- EDataBook.BookCache.signals.e164_changed(book_cache, object, p0)¶
- Signal Name:
e164-changed- Flags:
- Parameters:
book_cache (
EDataBook.BookCache) – The object which received the signalobject (
EBookContacts.Contact) –p0 (
bool) –