EBookBackendSqliteDB

EBookBackendSqliteDB

Functions

#define E_BOOK_SDB_ERROR
EBookBackendSqliteDB * e_book_backend_sqlitedb_new ()
EBookBackendSqliteDB * e_book_backend_sqlitedb_new_full ()
gboolean e_book_backend_sqlitedb_lock_updates ()
gboolean e_book_backend_sqlitedb_unlock_updates ()
gboolean e_book_backend_sqlitedb_new_contact ()
gboolean e_book_backend_sqlitedb_new_contacts ()
gboolean e_book_backend_sqlitedb_remove_contact ()
gboolean e_book_backend_sqlitedb_remove_contacts ()
gboolean e_book_backend_sqlitedb_has_contact ()
EContact * e_book_backend_sqlitedb_get_contact ()
gchar * e_book_backend_sqlitedb_get_vcard_string ()
GSList * e_book_backend_sqlitedb_search ()
GSList * e_book_backend_sqlitedb_search_uids ()
GHashTable * e_book_backend_sqlitedb_get_uids_and_rev ()
gboolean e_book_backend_sqlitedb_get_is_populated ()
gboolean e_book_backend_sqlitedb_set_is_populated ()
gboolean e_book_backend_sqlitedb_get_revision ()
gboolean e_book_backend_sqlitedb_set_revision ()
gchar * e_book_backend_sqlitedb_get_sync_data ()
gboolean e_book_backend_sqlitedb_set_sync_data ()
gchar * e_book_backend_sqlitedb_get_key_value ()
gboolean e_book_backend_sqlitedb_set_key_value ()
gchar * e_book_backend_sqlitedb_get_contact_bdata ()
gboolean e_book_backend_sqlitedb_set_contact_bdata ()
gboolean e_book_backend_sqlitedb_get_has_partial_content ()
gboolean e_book_backend_sqlitedb_set_has_partial_content ()
GSList * e_book_backend_sqlitedb_get_partially_cached_ids ()
gboolean e_book_backend_sqlitedb_delete_addressbook ()
gboolean e_book_backend_sqlitedb_remove ()
void e_book_backend_sqlitedb_search_data_free ()
gboolean e_book_backend_sqlitedb_check_summary_query ()
gboolean e_book_backend_sqlitedb_check_summary_fields ()
gboolean e_book_backend_sqlitedb_is_summary_query ()
gboolean e_book_backend_sqlitedb_is_summary_fields ()
gboolean e_book_backend_sqlitedb_add_contact ()
gboolean e_book_backend_sqlitedb_add_contacts ()

Types and Values

Object Hierarchy


Description

Functions

E_BOOK_SDB_ERROR

#define E_BOOK_SDB_ERROR (e_book_backend_sqlitedb_error_quark ())

Error domain for EBookBackendSqliteDB operations.

Since 3.8


e_book_backend_sqlitedb_new ()

EBookBackendSqliteDB *
e_book_backend_sqlitedb_new (const gchar *path,
                             const gchar *emailid,
                             const gchar *folderid,
                             const gchar *folder_name,
                             gboolean store_vcard,
                             GError **error);

If the path for multiple addressbooks are same, the contacts from all addressbooks would be stored in same db in different tables.

Parameters

path

location where the db would be created

 

emailid

email id of the user

 

folderid

folder id of the address-book

 

folder_name

name of the address-book

 

store_vcard

True if the vcard should be stored inside db, if FALSE only the summary fields would be stored inside db.

 

Returns

Since 3.2


e_book_backend_sqlitedb_new_full ()

EBookBackendSqliteDB *
e_book_backend_sqlitedb_new_full (const gchar *path,
                                  const gchar *emailid,
                                  const gchar *folderid,
                                  const gchar *folder_name,
                                  gboolean store_vcard,
                                  ESourceBackendSummarySetup *setup,
                                  GError **error);

Like e_book_backend_sqlitedb_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 E_CONTACT_UID and E_CONTACT_REV are not optional, they will be stored in the summary regardless of this function's parameters

Only EContactFields with the type G_TYPE_STRING, G_TYPE_BOOLEAN or E_TYPE_CONTACT_ATTR_LIST are currently supported.

Parameters

path

location where the db would be created

 

emailid

email id of the user

 

folderid

folder id of the address-book

 

folder_name

name of the address-book

 

store_vcard

True if the vcard should be stored inside db, if FALSE only the summary fields would be stored inside db.

 

setup

an ESourceBackendSummarySetup describing how the summary should be setup

 

error

A location to store any error that may have occurred

 

Returns

The newly created EBookBackendSqliteDB.

[transfer full]

Since 3.8


e_book_backend_sqlitedb_lock_updates ()

gboolean
e_book_backend_sqlitedb_lock_updates (EBookBackendSqliteDB *ebsdb,
                                      GError **error);

e_book_backend_sqlitedb_unlock_updates ()

gboolean
e_book_backend_sqlitedb_unlock_updates
                               (EBookBackendSqliteDB *ebsdb,
                                gboolean do_commit,
                                GError **error);

e_book_backend_sqlitedb_new_contact ()

gboolean
e_book_backend_sqlitedb_new_contact (EBookBackendSqliteDB *ebsdb,
                                     const gchar *folderid,
                                     EContact *contact,
                                     gboolean replace_existing,
                                     GError **error);

This is a convenience wrapper for e_book_backend_sqlitedb_new_contacts, which is the preferred means to add or modify multiple contacts when possible.

Parameters

ebsdb

An EBookBackendSqliteDB

 

folderid

folder id

 

contact

EContact to be added

 

replace_existing

Whether this contact should replace another contact with the same UID.

 

error

A location to store any error that may have occurred.

 

Returns

TRUE on success.

Since 3.8


e_book_backend_sqlitedb_new_contacts ()

gboolean
e_book_backend_sqlitedb_new_contacts (EBookBackendSqliteDB *ebsdb,
                                      const gchar *folderid,
                                      GSList *contacts,
                                      gboolean replace_existing,
                                      GError **error);

Adds or replaces contacts in ebsdb . If replace_existing is specified then existing contacts with the same UID will be replaced, otherwise adding an existing contact will return an error.

Parameters

ebsdb

An EBookBackendSqliteDB

 

folderid

folder id

 

contacts

list of EContacts

 

replace_existing

Whether this contact should replace another contact with the same UID.

 

error

A location to store any error that may have occurred.

 

Returns

TRUE on success.

Since 3.8


e_book_backend_sqlitedb_remove_contact ()

gboolean
e_book_backend_sqlitedb_remove_contact
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                const gchar *uid,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_remove_contacts ()

gboolean
e_book_backend_sqlitedb_remove_contacts
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                GSList *uids,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_has_contact ()

gboolean
e_book_backend_sqlitedb_has_contact (EBookBackendSqliteDB *ebsdb,
                                     const gchar *folderid,
                                     const gchar *uid,
                                     gboolean *partial_content,
                                     GError **error);

FIXME: Document me.

Note: The partial_content is unused here.

Since 3.2


e_book_backend_sqlitedb_get_contact ()

EContact *
e_book_backend_sqlitedb_get_contact (EBookBackendSqliteDB *ebsdb,
                                     const gchar *folderid,
                                     const gchar *uid,
                                     GHashTable *fields_of_interest,
                                     gboolean *with_all_required_fields,
                                     GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_vcard_string ()

gchar *
e_book_backend_sqlitedb_get_vcard_string
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                const gchar *uid,
                                GHashTable *fields_of_interest,
                                gboolean *with_all_required_fields,
                                GError **error);

Searches ebsdb in the context of folderid for uid .

If ebsdb is configured to store the whole vcards, the whole vcard will be returned. Otherwise the summary cache will be searched and the virtual vcard will be built from the summary cache.

In either case, with_all_required_fields if specified, will be updated to reflect whether the returned vcard string satisfies the passed 'fields_of_interest' parameter.

Parameters

ebsdb

An EBookBackendSqliteDB

 

folderid

The folder id

 

uid

The uid to fetch a vcard for

 

fields_of_interest

The required fields for this vcard, or NULL to require all fields.

 

with_all_required_fields

Whether all the required fields are present in the returned vcard.

[allow none][out]

error

A location to store any error that may have occurred.

 

Returns

The vcard string for uid or NULL if uid was not found.

[transfer full]

Since 3.2


e_book_backend_sqlitedb_search ()

GSList *
e_book_backend_sqlitedb_search (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                const gchar *sexp,
                                GHashTable *fields_of_interest,
                                gboolean *searched,
                                gboolean *with_all_required_fields,
                                GError **error);

Searching with summary fields is always supported. Search expressions containing any other field is supported only if backend chooses to store the vcard inside the db.

Summary fields - uid, rev, nickname, given_name, family_name, file_as email_1, email_2, email_3, email_4, is_list, list_show_addresses, wants_html

If ebsdb was incapable of returning vcards with results that satisfy fields_of_interest , then with_all_required_fields will be updated to FALSE and only uid fields will be present in the returned vcards. This can be useful when a summary query succeeds and the returned list can be used to iterate and fetch for full required data from another persistance.

Parameters

sexp

search expression; use NULL or an empty string to get all stored contacts.

 

fields_of_interest

a GHashTable containing the names of fields to return, or NULL for all. At the moment if this is non-null, the vcard will be populated with summary fields, else it would return the whole vcard if its stored in the db. [not implemented fully]

 

searched

Whether ebsdb was capable of searching for the provided query sexp .

[allow none][out]

with_all_required_fields

Whether all the required fields are present in the returned vcards.

[allow none][out]

Returns

List of EbSdbSearchData.

Since 3.2


e_book_backend_sqlitedb_search_uids ()

GSList *
e_book_backend_sqlitedb_search_uids (EBookBackendSqliteDB *ebsdb,
                                     const gchar *folderid,
                                     const gchar *sexp,
                                     gboolean *searched,
                                     GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_uids_and_rev ()

GHashTable *
e_book_backend_sqlitedb_get_uids_and_rev
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                GError **error);

Gets hash table of all uids (key) and rev (value) pairs stored for each contact in the cache. The hash table should be freed with g_hash_table_destroy(), if not needed anymore. Each key and value is a newly allocated string.

Since 3.4


e_book_backend_sqlitedb_get_is_populated ()

gboolean
e_book_backend_sqlitedb_get_is_populated
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_set_is_populated ()

gboolean
e_book_backend_sqlitedb_set_is_populated
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                gboolean populated,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_revision ()

gboolean
e_book_backend_sqlitedb_get_revision (EBookBackendSqliteDB *ebsdb,
                                      const gchar *folderid,
                                      gchar **revision_out,
                                      GError **error);

Fetches the current revision for the address-book indicated by folderid .

Upon success, revision_out will hold the returned revision, otherwise FALSE will be returned and error will be updated accordingly.

Parameters

ebsdb

An EBookBackendSqliteDB

 

folderid

folder id of the address-book

 

revision_out

The location to return the current revision.

[out][transfer full]

error

A location to store any error that may have occurred

 

Returns

Whether the revision was successfully fetched.

Since 3.8


e_book_backend_sqlitedb_set_revision ()

gboolean
e_book_backend_sqlitedb_set_revision (EBookBackendSqliteDB *ebsdb,
                                      const gchar *folderid,
                                      const gchar *revision,
                                      GError **error);

Sets the current revision for the address-book indicated by folderid to be revision .

Parameters

ebsdb

An EBookBackendSqliteDB

 

folderid

folder id of the address-book

 

revision

The new revision

 

error

A location to store any error that may have occurred

 

Returns

Whether the revision was successfully set.

Since 3.8


e_book_backend_sqlitedb_get_sync_data ()

gchar *
e_book_backend_sqlitedb_get_sync_data (EBookBackendSqliteDB *ebsdb,
                                       const gchar *folderid,
                                       GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_set_sync_data ()

gboolean
e_book_backend_sqlitedb_set_sync_data (EBookBackendSqliteDB *ebsdb,
                                       const gchar *folderid,
                                       const gchar *sync_data,
                                       GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_key_value ()

gchar *
e_book_backend_sqlitedb_get_key_value (EBookBackendSqliteDB *ebsdb,
                                       const gchar *folderid,
                                       const gchar *key,
                                       GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_set_key_value ()

gboolean
e_book_backend_sqlitedb_set_key_value (EBookBackendSqliteDB *ebsdb,
                                       const gchar *folderid,
                                       const gchar *key,
                                       const gchar *value,
                                       GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_contact_bdata ()

gchar *
e_book_backend_sqlitedb_get_contact_bdata
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                const gchar *uid,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_set_contact_bdata ()

gboolean
e_book_backend_sqlitedb_set_contact_bdata
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                const gchar *uid,
                                const gchar *value,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_has_partial_content ()

gboolean
e_book_backend_sqlitedb_get_has_partial_content
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                GError **error);

Returns

TRUE if the vcards stored in the db were downloaded partially. It is to indicate the stored vcards does not contain the full data.

Since 3.2


e_book_backend_sqlitedb_set_has_partial_content ()

gboolean
e_book_backend_sqlitedb_set_has_partial_content
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                gboolean partial_content,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_get_partially_cached_ids ()

GSList *
e_book_backend_sqlitedb_get_partially_cached_ids
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                GError **error);

FIXME: Document me.

Note: Obsolete, do not use, it always ends with an error

Since 3.2


e_book_backend_sqlitedb_delete_addressbook ()

gboolean
e_book_backend_sqlitedb_delete_addressbook
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *folderid,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_remove ()

gboolean
e_book_backend_sqlitedb_remove (EBookBackendSqliteDB *ebsdb,
                                GError **error);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_search_data_free ()

void
e_book_backend_sqlitedb_search_data_free
                               (EbSdbSearchData *s_data);

FIXME: Document me.

Since 3.2


e_book_backend_sqlitedb_check_summary_query ()

gboolean
e_book_backend_sqlitedb_check_summary_query
                               (EBookBackendSqliteDB *ebsdb,
                                const gchar *query,
                                gboolean *with_list_attrs);

Checks whether query contains only checks for the summary fields configured in ebsdb

Parameters

ebsdb

an EBookBackendSqliteDB

 

query

the query to check

 

with_list_attrs

Return location to store whether the query touches upon list attributes

 

Since 3.8


e_book_backend_sqlitedb_check_summary_fields ()

gboolean
e_book_backend_sqlitedb_check_summary_fields
                               (EBookBackendSqliteDB *ebsdb,
                                GHashTable *fields_of_interest);

Checks if all the specified fields are part of the configured summary fields for ebsdb

Parameters

ebsdb

An EBookBackendSqliteDB

 

fields_of_interest

A hash table containing the fields of interest

 

Since 3.8


e_book_backend_sqlitedb_is_summary_query ()

gboolean
e_book_backend_sqlitedb_is_summary_query
                               (const gchar *query);

e_book_backend_sqlitedb_is_summary_query has been deprecated since version 3.8 and should not be used in newly-written code.

Use e_book_backend_sqlitedb_check_summary_query() instead

Checks whether the query contains only checks for the default summary fields

Since 3.2


e_book_backend_sqlitedb_is_summary_fields ()

gboolean
e_book_backend_sqlitedb_is_summary_fields
                               (GHashTable *fields_of_interest);

e_book_backend_sqlitedb_is_summary_fields has been deprecated since version 3.8 and should not be used in newly-written code.

Use e_book_backend_sqlitedb_check_summary_fields() instead.

This only checks if all the fields are part of the default summary fields, not part of the configured summary fields.

Parameters

fields_of_interest

A hash table containing the fields of interest

 

Since 3.2


e_book_backend_sqlitedb_add_contact ()

gboolean
e_book_backend_sqlitedb_add_contact (EBookBackendSqliteDB *ebsdb,
                                     const gchar *folderid,
                                     EContact *contact,
                                     gboolean partial_content,
                                     GError **error);

e_book_backend_sqlitedb_add_contact has been deprecated since version 3.8 and should not be used in newly-written code.

Use e_book_backend_sqlitedb_new_contact() instead.

This is a convenience wrapper for e_book_backend_sqlitedb_add_contacts, which is the preferred means to add multiple contacts when possible.

Parameters

folderid

folder id

 

contact

EContact to be added

 

partial_content

contact does not contain full information. Used when the backend cache's partial information for auto-completion.

 

Returns

TRUE on success.

Since 3.2


e_book_backend_sqlitedb_add_contacts ()

gboolean
e_book_backend_sqlitedb_add_contacts (EBookBackendSqliteDB *ebsdb,
                                      const gchar *folderid,
                                      GSList *contacts,
                                      gboolean partial_content,
                                      GError **error);

e_book_backend_sqlitedb_add_contacts has been deprecated since version 3.8 and should not be used in newly-written code.

Use e_book_backend_sqlitedb_new_contacts() instead.

Parameters

folderid

folder id

 

contacts

list of EContacts

 

partial_content

contact does not contain full information. Used when the backend cache's partial information for auto-completion.

 

Returns

TRUE on success.

Since 3.2

Types and Values

struct EBookBackendSqliteDB

struct EBookBackendSqliteDB {
	GObject parent;
	EBookBackendSqliteDBPrivate *priv;
};

Contains only private data that should be read and manipulated using the functions below.

Since 3.2


enum EBookSDBError

Defines the types of possible errors reported by the EBookBackendSqliteDB

Members

E_BOOK_SDB_ERROR_CONSTRAINT

The error occurred due to an explicit constraint

 

E_BOOK_SDB_ERROR_CONTACT_NOT_FOUND

A contact was not found by UID (this is different from a query that returns no results, which is not an error).

 

E_BOOK_SDB_ERROR_OTHER

Another error occurred

 

E_BOOK_SDB_ERROR_NOT_SUPPORTED

A query was not supported

 

E_BOOK_SDB_ERROR_INVALID_QUERY

A query was invalid. This can happen if the sexp could not be parsed or if a phone number query contained non-phonenumber input.

 

EbSdbSearchData

typedef struct {
	gchar *vcard;
	gchar *uid;
	gchar *bdata;
} EbSdbSearchData;

FIXME: Document me.

Since 3.2