EDataBook.BookSqlite¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
Properties¶
None
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class EDataBook.BookSqlite(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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 databasesource (
EDataServer.SourceorNone) – an optionalEDataServer.Source, associated with theEDataBook.BookSqlite, orNonecancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
A reference to an
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, 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.bSqlCursorinterface, using theEBookContacts.BookIndexType.SORT_KEYindex flag.New in version 3.12.
- classmethod new_full(path, source, setup, vcard_callback, change_callback, user_data, cancellable)¶
- Parameters:
path (
str) – location to load or create the new databasesource (
EDataServer.SourceorNone) – an optionalEDataServer.Source, associated with theEDataBook.BookSqlite, orNonesetup (
EBookContacts.SourceBackendSummarySetuporNone) – anEBookContacts.SourceBackendSummarySetupdescribing how the summary should be setup, orNoneto use the defaultvcard_callback (
EDataBook.bSqlVCardCallbackorNone) – A function to resolve vcardschange_callback (
EDataBook.bSqlChangeCallbackorNone) – A function to catch notifications of vcard changescancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
The newly created
EDataBook.BookSqlite, orNoneif 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.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.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.
- classmethod search_data_free(data)¶
- Parameters:
data (
EDataBook.bSqlSearchData) – AnEDataBook.bSqlSearchData
Frees an
EDataBook.bSqlSearchDataNew in version 3.12.
- add_contact(contact, extra, replace, cancellable)¶
- Parameters:
contact (
EBookContacts.Contact) –extra (
str) –replace (
bool) –cancellable (
Gio.CancellableorNone) –
- Raises:
- Return type:
- add_contacts(contacts, extra, replace, cancellable)¶
- Parameters:
contacts ([
EBookContacts.Contact]) – A list of contacts to add to selfextra ([
str] orNone) – A list of extra data to store in association with this contactreplace (
bool) – Whether this contact should replace another contact with the same UID.cancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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.
- 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.
- 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.BookSqlite.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.
- exec_(sql_stmt, cancellable)¶
- Parameters:
sql_stmt (
str) – an SQLite statement to executecancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Executes an SQLite statement. Use
EDataBook.BookSqlite.select() for SELECT statements.New in version 3.48.
- get_contact(uid, meta_contact)¶
- Parameters:
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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 theEBookContacts.ContactField.UIDandEBookContacts.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:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- ret_extra:
Return location to store the extra data
- Return type:
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:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- value:
A return location to store the value for key
- Return type:
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:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- value:
A return location to store the value for key
- Return type:
A convenience function to fetch the value of key as an integer.
New in version 3.12.
- get_locale()¶
- Raises:
- Returns:
Whether the locale was successfully fetched.
- locale_out:
The location to return the current locale
- Return type:
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, otherwiseFalseis 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.UIDandEBookContacts.ContactField.REVfields.New in version 3.12.
- has_contact(uid)¶
- Parameters:
uid (
str) – The uid of the contact to check for- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- exists:
Return location to store whether the contact exists.
- Return type:
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 acquirecancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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, orNone.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 toEDataBook.BookSqlite.lock() andEDataBook.BookSqlite.unlock().New in version 3.12.
- 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.12.
- 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 finished using the source. It can beNonein some cases, like when running tests.New in version 3.16.
- remove_contact(uid, cancellable)¶
- Parameters:
uid (
str) – the uid of the contact to removecancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- Return type:
Removes the contact indicated by uid from self.
New in version 3.12.
- remove_contacts(uids, cancellable)¶
- Parameters:
uids ([
str]) – aGLib.SListof uids indicating which contacts to removecancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- Return type:
Removes the contacts indicated by uids from self.
New in version 3.12.
- 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 metadatacancellable (
Gio.CancellableorNone) – AGio.Cancellable
- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- ret_list:
Return location to store a
GLib.SListofEDataBook.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 otherEBookContacts.ContactFieldsa fallback will be used, possibly invoking anyEDataBook.bSqlVCardCallbackwhich may have been passed toEDataBook.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.UIDandEBookContacts.ContactField.REVfields.New in version 3.12.
- 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, otherwiseFalseis 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.
- select(sql_stmt, func, user_data, cancellable)¶
- Parameters:
sql_stmt (
str) – an SQLite SELECT statement to executefunc (
EDataBook.BookSqliteSelectFunc) – anEDataBook.BookSqliteSelectFuncfunction to call for each rowcancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject, orNone
- Raises:
- Returns:
Whether succeeded.
- Return type:
Executes a SELECT statement sql_stmt and calls func for each row of the result. Use
EDataBook.BookSqlite.exec_() for statements which do not return row sets.New in version 3.48.
- set_contact_extra(uid, extra)¶
- Parameters:
- 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.12.
- set_key_value(key, value)¶
- Parameters:
- Raises:
- Returns:
Trueon success, otherwiseFalseis 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, otherwiseFalseis 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 addressbookcancellable (
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 toEDataBook.BookSqlite.new_full().New in version 3.12.
- unlock(action)¶
- Parameters:
action (
EDataBook.bSqlUnlockAction) – WhichEDataBook.bSqlUnlockActionto take while unlocking- Raises:
- Returns:
Trueon success, otherwiseFalseis returned and error is set appropriately.- Return type:
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:
contact (
EBookContacts.Contact) –extra (
str) –replace (
bool) –cancellable (
Gio.CancellableorNone) –
- Return type:
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 signalp0 (
EBookContacts.Contact) –p1 (
str) –p2 (
bool) –p3 (
GObject.Object) –
- Return type:
- 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 signalp0 (
str) –p1 (
Gio.CancellableorNone) –
- Return type: