PebbleOS
Loading...
Searching...
No Matches
Data Structures | Functions
Contacts database

Contacts (BlobDBIdContacts), keyed by contact UUID. More...

Data Structures

struct  SerializedContact
 Serialized contact, the value of a contacts database record. More...
 

Functions

int contacts_db_get_serialized_contact (const Uuid *uuid, SerializedContact **contact_out)
 Read the serialized record of a contact.
 
void contacts_db_free_serialized_contact (SerializedContact *contact)
 Free a record returned by contacts_db_get_serialized_contact().
 
void contacts_db_init (void)
 Initialize the contacts database.
 
status_t contacts_db_insert (const uint8_t *key, int key_len, const uint8_t *val, int val_len)
 Insert or replace a record in the contacts database.
 
int contacts_db_get_len (const uint8_t *key, int key_len)
 Get the length of a record in the contacts database.
 
status_t contacts_db_read (const uint8_t *key, int key_len, uint8_t *val_out, int val_out_len)
 Read a record from the contacts database.
 
status_t contacts_db_delete (const uint8_t *key, int key_len)
 Delete a record from the contacts database.
 
status_t contacts_db_flush (void)
 Delete all records of the contacts database.
 
status_t contacts_db_compact (void)
 Compact the settings file backing the contacts database.
 

Detailed Description

Contacts (BlobDBIdContacts), keyed by contact UUID.


Data Structure Documentation

◆ SerializedContact

struct SerializedContact

Serialized contact, the value of a contacts database record.

Data Fields
uint8_t data[] Serialized attributes followed by serialized addresses.
uint32_t flags Contact flags.
uint8_t num_addresses Number of serialized addresses in data.
uint8_t num_attributes Number of serialized attributes in data.
Uuid uuid Contact UUID.

Function Documentation

◆ contacts_db_compact()

status_t contacts_db_compact ( void  )

Compact the settings file backing the contacts database.

Returns
S_SUCCESS on success, an error code otherwise.

◆ contacts_db_delete()

status_t contacts_db_delete ( const uint8_t *  key,
int  key_len 
)

Delete a record from the contacts database.

The key is the contact UUID.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ contacts_db_flush()

status_t contacts_db_flush ( void  )

Delete all records of the contacts database.

Returns
S_SUCCESS on success, an error code otherwise.

◆ contacts_db_free_serialized_contact()

void contacts_db_free_serialized_contact ( SerializedContact *  contact)

Free a record returned by contacts_db_get_serialized_contact().

Parameters
contactRecord to free.

◆ contacts_db_get_len()

int contacts_db_get_len ( const uint8_t *  key,
int  key_len 
)

Get the length of a record in the contacts database.

The key is the contact UUID.

Parameters
keyKey data.
key_lenLength of key in bytes.
Returns
Length of the value in bytes, 0 if not found, or a negative error code.

◆ contacts_db_get_serialized_contact()

int contacts_db_get_serialized_contact ( const Uuid *  uuid,
SerializedContact **  contact_out 
)

Read the serialized record of a contact.

Meant for the contacts service; other callers likely want contacts_get_contact_by_uuid().

Parameters
uuidContact UUID.
[out]contact_outTask heap allocated record, NULL if not found. Free it with contacts_db_free_serialized_contact().
Returns
Length of the SerializedContact::data field in bytes, 0 if not found.

◆ contacts_db_init()

void contacts_db_init ( void  )

Initialize the contacts database.

◆ contacts_db_insert()

status_t contacts_db_insert ( const uint8_t *  key,
int  key_len,
const uint8_t *  val,
int  val_len 
)

Insert or replace a record in the contacts database.

The key is the contact UUID and the value a SerializedContact.

Parameters
keyKey data.
key_lenLength of key in bytes.
valValue data.
val_lenLength of val in bytes.
Returns
S_SUCCESS on success, an error code otherwise.

◆ contacts_db_read()

status_t contacts_db_read ( const uint8_t *  key,
int  key_len,
uint8_t *  val_out,
int  val_out_len 
)

Read a record from the contacts database.

The key is the contact UUID.

Parameters
keyKey data.
key_lenLength of key in bytes.
[out]val_outBuffer for the value.
val_out_lenSize of val_out in bytes.
Returns
S_SUCCESS on success, an error code otherwise.