2 The architecture of Libchenabler
Libchenabler
Libchenabler is a library for creating call history applications. It works on UNIX-like platforms. Libchenabler hides the details of the database and provides some basic interfaces for the call history application, the voicecall application and other applications.
If the applications are created on Libchenabler, it is easy to change the data structure of the database without modifying the applications.
Libchenabler depends on the following libraries:
¡¤ GLib
A general-purpose utility library, not specific to graphical user interfaces. GLib provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on.
¡¤ Librecord
A general-purpose utility library which encapsulate most of the operations of the database, and current edition mainly support Sqlite3 database.
Call history enabler (libchenabler) defines a set of important concepts such as category, field and template. It is very important to understand the concepts before using the libchenabler.
Field has a number of attributes such as a value type (e.g. call id, date, type, duration, phone number, etc), a printable label (e.g. "CALL_ID", "DATE", "TYPE", "DURATION", "PHONENUMBER", etc), a maximal size, etc. Also a field may have a value. Fields are created from field templates.
Template defines the initial values of a field's attributes (the value type, the label, the maximal size, etc) and the field semantics (i.e. call id, date, type, etc.). The enabler defines a standard field template. It is recommended that application developers who use the libchenabler should create template according to the standard one (which is in the database subdirectory). Once created, a field keeps a reference to its template. Therefore, for a given field, it's always possible to know the field template it has been created from and consequently the semantics of the field.
CallHistory is an item in the voice call history, representing an item in the call log. A history is a collection of fields, such as call id, date, type, duration, phone number, etc.
History maintains a set of call history items and the template.
Database/
The database folder should contain those files, and application users should define the VOC_DATA_PATH env to specify the location of those files.
The Libchenabler will first read the admin.db to find out the location and name of vochistory.db. And the vochistory.db stores the call history items according to "vochistory.templ" template.
Src/
Define the call history item structure. Provide a set of APIs to operate to the call history item.
struct voch_callhistory_t
This is the basic voicecall history item structure but it only contains a pointer points to a record which is auto created according to the template file (vochistory.templ,see details in "record" library). So, if application users want to add or delete some members of the call history structure, he only need to modify the template file.
Some functions are provided to operate this structure.
voch_err_t voch_callhistory_set_field (voch_callhistory_t *history, voch_fid_t fid, const void *value);
voch_err_t voch_callhistory_get_field (voch_callhistory_t *history, voch_fid_t fid, void **value);
The two functions are the basic functions to get or set the value of the structure. The modification will apply to the database.
Manage (get, move, etc.) history items from/to the database.
void voch_init (void);
Find the admin.db and build up a instance of the template according to "vochistory.templ", create a hashtable to store all database
voch_err_t voch_connect (uint32_t index, voch_sid_t *sid);
Open the database file "vochistory.db" and get ready to querying and modifying the database.
voch_err_t voch_disconnect (voch_sid_t sid);
Close the database.
voch_err_t voch_create_history (voch_sid_t sid, voch_callhistory_t **history);
Create a "voch_callhistory_t" with no data;
voch_callhistory_t **voch_get_historys_by_type (voch_sid_t sid, voch_call_type_t type);
Get all the history items with the type from the database,create and return "voch_callhistory_t" for each items.
For example:
If Application developers want to get the voch_callhistory_t with "INCOMING" type, he should do as following:
1) Invoke voch_connect(0,&sid) to open the database and get session id of this session
2) Call voch_get_historys_by_type(sid, INCOMING) to return the pointers to the "voch_callhistory_t".
3) Now use the functions provide by "vochcallhistory.c" to get and set the details of each "voch_callhistory_t".
Environment of the Voice Call History interface
TYPE definition of the Voice Call interface
Internal head file
Internal head file
Error definitions
Environment of the Voice Call History interface
Template related structure and API definitions
Include/
Manage (get, move, etc.) history items from/to the database.
Define the call history item structure. Provide a set of APIs to operate to the call history item.
Template related structure and API definitions
Error definitions
TYPE definition of the Voice Call interface