Sample

현재 위치

현재 위치

Page Example

Contacts Sample Overview

The Contacts sample application demonstrates how you can manage contacts using the Contacts API. The source code shows how to use the contacts database for creating and deleting contacts, making contacts favorites, viewing and changing contact information, creating and deleting contacts categories, adding contacts to categories, and viewing the favorites list.

The following figure illustrates the main screens of the application.

Figure: Contacts main views

The application opens with the Contacts screen, which displays a list of existing contacts. On the screen:

To create a new contact, click Create, fill in the contact details, and click Save. To select the address book into which the new contact is added, click >.

To view the details of a contact, click the contact in the list. The detail screen displays the contact details. On this screen:

To edit an existing contact, click Edit.

To delete the contact, click Delete.

To change the favorite status of the contact, click Fav on the top-right corner.

To view the category list of the default address book, press the device menu key, and click Categories. On the Categories screen, you can view the members of the existing category by clicking the category, or add new categories by clicking Create. After clicking a category, the category member screen opens. On this screen:

Provides functions to create the Contact details view. The file contains code that retrieves the contact information and shows it in the genlist.

create-group-view.c

Provides functions to create the Create group view. The file contains code that creates a new group in the database with a specific name.

edit-contact-view.c

Provides functions to create the Edit contact view. The file contains code to retrieve contact information from the database, to show and edit the information, to delete or save the contact.

favourites-view.c

Provides functions to create the Favorite contacts view. The file contains code that gets the favorite contacts and shows the information in a list.

group-details-view.c

Provides functions to create the Group details view. The file contains code to get and show group details and to remove the group.

group-edit-member-view.c

Provides functions to create the Edit group member view. The file contains code to add members to the group and to remove members from the group.

group-list-view.c

Provides functions to create the Groups list view. The file contains code to create a list of groups saved on the device, to set up the callback on click on group, to move to the Group details or Create group views.

person-list-view.c

Provides functions to create the Contacts list view. The file contains code to create a list of contacts, to set up a callback on click on contact, to set up a callback for the menu key and to move to the Categories list or Favorites list views.

window.c

Provides functions to create or destroy the main application window and to set the host layout.

Displaying and Retrieving Contacts

Figure: Contacts and favorites

To display contacts:

Initialize the application by creating the window, naviframe and the Person list view.

Contact retrieval is implemented in the <person-list-view.c> file. The sc_plist_view_add() function invokes the _plist_view_fill() function to retrieve the contact list from the database. These contacts fill the elm_list.

Favorites retrieval is implemented in the <favourites-view.c> file. The sc_favourites_view_add() function invokes the _favourites_view_fill() function to get the favorites list from the database, and these contacts fill the elm_list.

Managing Contacts

Figure: Managing contacts

To manage contacts:

Initialize contact details.

When the user clicks on a contact in the contacts list, the contact details view opens using the sc_cdetails_view_add() function . Then it fills the contact details using the _cdetails_view_fill() function.

To create a contact, the user presses the Create button in the Contacts list view. To edit a contact, the user can click Edit in the contact details view. In both cases, the sc_ec_view_add() function is invoked. It creates the new contact or edits the current one.

Managing Categories

To manage categories:

Create categories.

The category creation is implemented in the <create-group.c> file.

When the user clicks Create on the Categories screen, the Create Category view opens and the user can enter a category name. When the user clicks Save, the _gcreate_view_create_group_cb() smart callback is invoked. That callback calls the sc_gcreate_db_create_group() function to add the category to the specified address book.

The category member addition and removal are implemented in the <group-edit-member-view.> file.

When the user clicks Add Member on a specific category screen, the Add Member screen opens and the user can select a contact to add to the category. When the user clicks Add Member, the contacts_group_add_contact() function adds the selected contact to the category.

When the user clicks Remove Member on a specific category screen, the Remove Member screen opens and the user can select a member to remove from the category. When the user clicks Remove, the contacts_group_remove_contact() function removes the selected member from the category.