AddressBook is a comfortable front-end to organize the addresses of your friends, business partners, etc. It enables you to manage your contacts efficiently and comfortably. Since it is based on the libabenabler it supports resources, which can be used to load and save your contacts to many different locations ¡ª not just the local file system, but also to SIM Card, or even network servers.
AddressBook depends on the following libraries:
l Gtk+-2.0 GTK+ is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off projects to complete application suites.
l libgemwidget A Gtk+ for Embedded library contains widgets which are mostly used in embedded devices.
l libgpephone Shared code for applications developed for the phone application framework providing easy access to softkey definitions and communication.
l libabenabler A graphic independent enabler which can provide all the basic routines for PIM Address Books and other applications who wants to use the address book functions.
l libiac The package provides various interfaces to make the service oriented communication between applications much easier than using low-level D-Bus routines ever before.
l libim
l liblipsevent
This chapter addresses the things that you as a programmer should know about AddressBook when developing it. It helps to understand its architecture and implementation. Armed with this knowledge, you will be better equipped to make AddressBook run with higher performance, avoids potential pitfalls such as deadlocks or unexpected errors and even import any new features on your needs. You will see how AddressBook works in relation to your code, and you can be more confident that you are attacking the problem from the right direction. Address Book's design and concepts are all very straightforward and easy to understand. And there are only a few things you need to know. This chapter lays them out for you.
Before we get started discussing the principle data structures, let's have a basic view on the architecture of AddressBook.

Figure 2.1 Architecture of Address Book
As we can see in the figure 2.1, the elements which are currently being developed in Address Book are separated into two different parts: UI components and Functionalities units.
All the UI components in Address Book are implemented in sub-directory named "src/widgets", while the Functionalities units are implemented in other codes of sub-directory "src".
UI components contain a lot of basic widgets which are common used in Address Book but not implemented yet in Gtk+/ GEM library. Some of them are derived from existing Gtk+ / GEM widgets but extends their functionalities to meet requirement of Address Book such as ABookListView, and ABookMarkView. Others are newly created to import new features never been included in Gtk+/ GEM widgets which may be just only used in Address Book.
Functionality units are consisted of three main parts: threads, service and enabler layer. Threads part supplies the functionalities of how to create UI relative threads in Address Book. Service part covers all the services that Address Book can provide to other application in system. The enabler layer encapsulates the address book enabler functionalities and defines a special subset for this Address Book.
All existing UI components are list in table 2.1:
Table 2.1 UI components list
|
Component |
Functionality |
|
ABookContactView |
Display and Edit contact information. |
|
ABookContactViewSim |
Display and Edit contact information in SIM Card. |
|
ABookCategoryView |
Display and Edit category information. |
|
ABookViewCell |
Display a specific item used in contact view such as name, number or address. |
|
ABookViewCellStd |
Display a specific item which is combined with a label widget and an entry widget. |
|
ABookViewCellImg |
Display a specific item which is consisted with a label widget, an entry widget and image widget buddy. |
|
ABookItemsView |
Put all ABookViewCell in a single widget to represent a kind of view in Address Book, for example contact view |
|
ABookListView |
A list of contacts' basic information name and image |
|
ABookMarkView |
A list view but have extends multi-selection feature |
|
ABookMemberView |
A list of contacts' basic information which are belonged to a specific category |
|
ABookNumberChooser |
A phone number selection dialog popup when dialing a contact who has more than one phone number |
All the view in the Address Book are classified into 9 types:
Main view is GtkNoteBook with four tabs which stand for four kind classifications in Address Book: Contact, Category, SIM Card and NAB (Network Address Book). Each of them has a list of its members with their essential information such as name and image of head portrait or status (in NAB).
Activate one of members in the list will pop up a related detail window for that member. The pop-up window instance will be created with type in one of ABookContactView, ABookContactViewSim, ABookCategoryView, ABookMemberView according to which member you have activated. For example, if you activate a member named "Family" in list of categories in Category tab of main view, it pop-up a member view(ABookMemberView) of family category, while if you activate a contact name "Person 001" in list of contacts in SIM Card tab, a contact detail (ABookContactViewSIM) will be pop-upped.
All the windows used in Address Book are managed by an internal window management module. The module holds handlers of windows display in Address Book when they are created first time. And management module will only hide the window which users want to close and just show it again when users use it next time. This means that each window will be only created once in lifecycle of Address Book. It enhances the performance of Address Book.
All resources (image only) used in Address Book are allocated and release by unique interfaces abook_picture_load() and abook_picture_find(). These interfaces ensure the same resource file will be only loaded once in lifecycle and shared by any widgets which want to use it to make high performance on runtime.
Functionality units contain three elements: Threads, Enabler call-backs, Services.
Enabler layer encapsulates original libabenabler interfaces to provide more easily and specially used functions to current Address Book. It holds three session handler in current implementation: Local flash address book, SIM card address book and Network address book and provides functions to retrieve them corresponding. Address Book passes specific session handler to interfaces of libabenabler to invoke the real process of related address book.
Address Book uses routine of enabler to communicate with low-level database manager (SQLite currently) to add, remove or update contacts and categories information for users' requirements. Currently all the interfaces in libabenabler are implemented synchronously and some of them will take few seconds which will lead a block in UI call-backs and makes the UI is not friendly enough. An effective approach to avoid this is to start a thread in background and popup a notification window showing the progress of operations to users. Threads units uses g_thread_create() and GtkNotification object to achieve this for Address Book.
Address Book publish a set of IAC (Internal Application Communication) interfaces to let other application use some functionalities which is graphic relative or enable can not provide in Address Book. Currently these interfaces include:
Table 2.2 IAC Services of Address Book
|
Method |
Argument |
Argument |
Functionality |
|
voice_find |
NONE |
NONE |
Retrieve a contact phone number for voice call application |
|
mul_select |
NONE |
NONE |
Retrieve a set of {number, name} pairs for message application to select contacts when send message |
|
add_contact |
[Number<STRING>] |
NONE |
Popup Contact Edit View for user and save information as a newly-created contact |