SeatonPreference

SeatonPreference — libseaton is a library that provides APIs to store and retrieve persistent data for services and applications.

Functions

Types and Values

Object Hierarchy

    GObject
    ╰── SeatonPreference

Description

libseaton is a library to store and retrieve persistent data. It is used by services as well as apps. The libseaton uses SQLite3 to store the persistent data. It however provides simple APIs instead of complex queries to get or set the data. The apps have to explicitly call the APIs to store the data it intends to save. The App FW will not make these calls explicitly. The database for apps and for services will be stored under the variable folder for that bundle ID (see https://wiki.apertis.org/Application_Layout).

Functions

seaton_preference_new ()

SeatonPreference *
seaton_preference_new (void);

Constructor.Use this API to create a new SeatonPreference object

Returns

SeatonPreference object


seaton_preference_remove ()

gint
seaton_preference_remove (SeatonPreference *pGobj,
                          gchar *pTableName,
                          const gchar *pKeyStr,
                          gchar *pCondStr);

This API will delete the persistent data identified by the "key" from the PDI database. * The calling thread is blocked until a reply is received.

Parameters

pGobj

The pdi object Parameter

 

pTableName

Column name

 

pKeyStr

The key Name

 

pCondStr

The Condition value or the Key

 

Returns

the error/success value


seaton_preference_set ()

gint
seaton_preference_set (SeatonPreference *pGobj,
                       gchar *pTableName,
                       const gchar *pUniqueKey,
                       gchar *pUniqueValue,
                       const gchar *pKeyStr,
                       gchar *pData);

API to update preference database given the key based on condition. The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pTableName

column name

 

pUniqueKey

The Unique Key

 

pUniqueValue

The unique value for the key

 

pKeyStr

The key Name

 

pData

The Data to be updated

 

Returns

the error/success value


seaton_preference_set_multiple ()

gint
seaton_preference_set_multiple (SeatonPreference *pGobj,
                                gchar *pTableName,
                                GHashTable *hash,
                                gchar *pConditon);

will update multiple rows (keys) in the database depending upon the conditions * The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pTableName

Table name

 

hash

hash table of keys with values to be updated

 

pConditon

the condition for the preference

 

Returns

the error/success value


seaton_preference_get ()

GPtrArray *
seaton_preference_get (SeatonPreference *pGobj,
                       gchar *pTableName,
                       const gchar *pKeyStr,
                       gchar *gCond);

will query the database and extract the key value pair from persistance database The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pTableName

The table name

 

pKeyStr

The key Name

 

gCond

the condition for the preference

 

Returns

an array of persistent key-value pairs


seaton_preference_get_multiple ()

GPtrArray *
seaton_preference_get_multiple (SeatonPreference *pGobj,
                                gchar *pTableName,
                                gchar *pWhereFrom,
                                gchar *gCond);

will query the database and extract multiple key and value pairs from persistance database * The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pTableName

The table name

 

pWhereFrom

the String from where the value is

 

gCond

the condition for the preference

 

Returns

an array of key-value pairs


seaton_preference_add_data ()

gint
seaton_preference_add_data (SeatonPreference *pGobj,
                            gchar *pTableName,
                            GHashTable *hash);

function will insert a new key-value pair in the persistence database The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pTableName

The table name

 

hash

The key and Value will be given

 

Returns

error/success


seaton_preference_install ()

gint
seaton_preference_install (SeatonPreference *pGobj,
                           gchar *pTableName,
                           SeatonFieldParam *pfieldparam,
                           gint inFieldSize);

will create the Data base Table structure with the name provided. Typically for apps, it is the app name itself. The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pTableName

The table name

 

pfieldparam

The field Information

 

inFieldSize

The field Size

 

Returns

error/success


seaton_preference_open ()

gint
seaton_preference_open (SeatonPreference *pGobj,
                        const char *pAppName,
                        const char *pFileName,
                        guint uinDBType);

will open the database in the specified location for reading The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pAppName

The unique name from which the Database is created or mapped

 

pFileName

The unique file for that particular application

 

uinDBType

per user db or system wide db

 

Returns

error/success


seaton_preference_close ()

gint
seaton_preference_close (SeatonPreference *pGobj);

will close the database handle. No further operations are possible.

This API should be called atleast in the GObject dispose function to ensure database integrity

The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

Returns

error/success


seaton_preference_check_exists ()

gboolean
seaton_preference_check_exists (SeatonPreference *pGobj,
                                const gchar *pAppName,
                                const char *pFileName,
                                guint uinDBType);

checks if db existes or not The calling thread is blocked until a reply is received.

Parameters

pGobj

The object Parameter

 

pAppName

Application Name

 

pFileName

File name

 

uinDBType

Type of the DB (SEATON_PREFERENCE_SERVICE_DB/SEATON_PREFERENCE_APP_INTERNAL_DB/SEATON_PREFERENCE_APP_USER_DB)

 

Returns

error/success

Types and Values

SEATON_PREFERENCE_APP_INTERNAL_DB

#define SEATON_PREFERENCE_APP_INTERNAL_DB 	0

App-specific internal DB that is visible across all multiusers.


SEATON_PREFERENCE_APP_USER_DB

#define SEATON_PREFERENCE_APP_USER_DB 		1

DB that is visible for particular user (active).


SEATON_PREFERENCE_SERVICE_DB

#define SEATON_PREFERENCE_SERVICE_DB 			2

DB which needs to be created by service.


enum SeatonErrorResults

Success or error status returned by most libseaton functions.

Members

SEATON_PREFERENCE_PM_OK

Successful result

 

SEATON_PREFERENCE_PM_BBE

Error-Bad Back-End

 

SEATON_PREFERENCE_PM_BDS

Bad Data Store

 

SEATON_PREFERENCE_PM_KNF

Key Not Found

 

SEATON_PREFERENCE_PM_NMS

No More Space

 

SEATON_PREFERENCE_PM_DSTB

Data Size Too Big

 

SEATON_PREFERENCE_PM_OOR

Out Of Range

 

SEATON_PREFERENCE_PM_BLOCKED

Data store is blocked

 

SEATON_PREFERENCE_PM_UE

Unknown Error

 

SEATON_PREFERENCE_PM_DBE

Bad Database

 

SeatonFieldParam

typedef struct {
	gchar *pKeyName;
	int inFieldType;
} SeatonFieldParam;

Description of a field parameter in the database.

Members

gchar *pKeyName;

Field parameter name

 

int inFieldType;

Data type of the field