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.Source
orNone
) – an optionalEDataServer.Source
, associated with theEDataBook.BookSqlite
, orNone
cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
A reference to an
EDataBook.BookSqlite
- Return type:
Creates a new
EDataBook.BookSqlite
with 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_NAME
andEBookContacts.ContactField.EMAIL
are configured to respond extra quickly with theEBookContacts.BookIndexType.PREFIX
index flag.The fields
EBookContacts.ContactField.FILE_AS
,EBookContacts.ContactField.FAMILY_NAME
andEBookContacts.ContactField.GIVEN_NAME
are configured to perform well with theEDataBook.bSqlCursor
interface, using theEBookContacts.BookIndexType.SORT_KEY
index 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.Source
orNone
) – an optionalEDataServer.Source
, associated with theEDataBook.BookSqlite
, orNone
setup (
EBookContacts.SourceBackendSummarySetup
orNone
) – anEBookContacts.SourceBackendSummarySetup
describing how the summary should be setup, orNone
to use the defaultvcard_callback (
EDataBook.bSqlVCardCallback
orNone
) – A function to resolve vcardschange_callback (
EDataBook.bSqlChangeCallback
orNone
) – A function to catch notifications of vcard changescancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
The newly created
EDataBook.BookSqlite
, orNone
if 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.UID
andEBookContacts.ContactField.REV
are not optional, they will be stored in the summary regardless of this function’s parameters. OnlyEBookContacts.ContactFields
with the typeGObject.TYPE_STRING
,GObject.TYPE_BOOLEAN
or #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.BookSqlite
requires 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
None
is 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.BookSqlite
addressbook 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.bSqlSearchData
New in version 3.12.
- add_contact(contact, extra, replace, cancellable)¶
- Parameters:
contact (
EBookContacts.Contact
) –extra (
str
) –replace (
bool
) –cancellable (
Gio.Cancellable
orNone
) –
- 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.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
True
on success, otherwiseFalse
is 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 (
str
orNone
) – search expression; useNone
or an empty string to consider all stored contactscancellable (
Gio.Cancellable
orNone
) – 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 (
str
orNone
) – search expression; useNone
or 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.BookCursorSortType
n_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_MAXUINT
to read everything from the n_offsetout_contacts ([
EBookContacts.Contact
]) – an array ofEBookContacts.Contact
-s in the requested ordercancellable (
Gio.Cancellable
orNone
) – 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 (
str
orNone
) – search expression; useNone
or 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.BookCursorSortType
n_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_MAXUINT
to 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.Cancellable
orNone
) – 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.Cancellable
orNone
) – 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.Cancellable
orNone
) – optionalGio.Cancellable
object, 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:
True
on success, otherwiseFalse
is 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.Contact
specified by uid in self.If meta_contact is specified, then a shallow
EBookContacts.Contact
will be created holding only theEBookContacts.ContactField.UID
andEBookContacts.ContactField.REV
fields.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:
True
on success, otherwiseFalse
is 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:
True
on success, otherwiseFalse
is 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:
True
on success, otherwiseFalse
is 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
False
will be returned and error will be updated accordingly.New in version 3.12.
- get_vcard(uid, meta_contact)¶
- Parameters:
- Raises:
- Returns:
True
on success, otherwiseFalse
is 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.UID
andEBookContacts.ContactField.REV
fields.New in version 3.12.
- has_contact(uid)¶
- Parameters:
uid (
str
) – The uid of the contact to check for- Raises:
- Returns:
True
on success, otherwiseFalse
is 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.bSqlLockType
to acquirecancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
True
on success, otherwiseFalse
is 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.Collator
for 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.Source
to which self is paired, orNone
.- Return type:
References the
EDataServer.Source
to which self is paired, useGObject.Object.unref
() when finished using the source. It can beNone
in 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.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
True
on success, otherwiseFalse
is 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.SList
of uids indicating which contacts to removecancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
True
on success, otherwiseFalse
is 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 (
str
orNone
) – search expression; useNone
or an empty string to list all stored contacts.meta_contacts (
bool
) – Whether entire contacts are desired, or only the metadatacancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
True
on success, otherwiseFalse
is returned and error is set appropriately.- ret_list:
Return location to store a
GLib.SList
ofEDataBook.bSqlSearchData
structures
- Return type:
(
bool
, ret_list: [EDataBook.bSqlSearchData
])
Searches self for contacts matching the search expression indicated by sexp.
When sexp refers only to
EBookContacts.ContactFields
configured in the summary of self, the search should always be quick, when searching for otherEBookContacts.ContactFields
a fallback will be used, possibly invoking anyEDataBook.bSqlVCardCallback
which 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.UID
andEBookContacts.ContactField.REV
fields.New in version 3.12.
- search_uids(sexp, cancellable)¶
- Parameters:
sexp (
str
orNone
) – search expression; useNone
or an empty string to get all stored contacts.cancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
- Raises:
- Returns:
True
on success, otherwiseFalse
is returned and error is set appropriately.- ret_list:
Return location to store a
GLib.SList
of 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.BookSqliteSelectFunc
function to call for each rowcancellable (
Gio.Cancellable
orNone
) – optionalGio.Cancellable
object, 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:
True
on success, otherwiseFalse
is 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:
True
on success, otherwiseFalse
is 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:
True
on success, otherwiseFalse
is 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.Cancellable
orNone
) – 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.bSqlVCardCallback
provided toEDataBook.BookSqlite.new_full
().New in version 3.12.
- unlock(action)¶
- Parameters:
action (
EDataBook.bSqlUnlockAction
) – WhichEDataBook.bSqlUnlockAction
to take while unlocking- Raises:
- Returns:
True
on success, otherwiseFalse
is 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.Cancellable
orNone
) –
- 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.Cancellable
orNone
) –
- Return type: