summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdebian/changelog8
-rwxr-xr-xinclude/contacts.h252
-rw-r--r--[-rwxr-xr-x]include/contacts_contact.h106
-rwxr-xr-xinclude/contacts_event.h71
-rw-r--r--[-rwxr-xr-x]include/contacts_group.h133
-rwxr-xr-xinclude/contacts_messenger.h33
-rwxr-xr-xinclude/contacts_number.h8
-rw-r--r--[-rwxr-xr-x]include/contacts_private.h10
-rwxr-xr-xinclude/contacts_search.h238
-rwxr-xr-xinclude/contacts_types.h159
-rwxr-xr-xpackaging/capi-social-contacts.spec6
-rwxr-xr-xsrc/contacts.c174
-rwxr-xr-xsrc/contacts_contact.c138
-rwxr-xr-xsrc/contacts_event.c56
-rwxr-xr-xsrc/contacts_group.c239
-rwxr-xr-xsrc/contacts_messenger.c20
-rwxr-xr-xsrc/contacts_number.c4
-rwxr-xr-xsrc/contacts_private.c51
-rwxr-xr-xsrc/contacts_search.c818
19 files changed, 2215 insertions, 309 deletions
diff --git a/debian/changelog b/debian/changelog
index 374ee6e..2a70db4 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+capi-social-contacts (0.1.6-1) unstable; urgency=low
+
+ * Release Tizen 2.0 beta
+ * Git: framework/api/contacts
+ * Tag: capi-social-contacts_0.1.6-1
+
+ -- DoHyung Jin <dh.jin@samsung.com> Tue, 24 Jul 2012 14:44:46 +0900
+
capi-social-contacts (0.1.1-30) unstable; urgency=low
* package build dependecy updated
diff --git a/include/contacts.h b/include/contacts.h
index b72099b..3d0bf57 100755
--- a/include/contacts.h
+++ b/include/contacts.h
@@ -76,17 +76,53 @@ int contacts_disconnect(void);
/**
* @brief Gets the contacts database version.
*
+ * @param[out] contacts_db_version The contacts database version
+ *
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ *
* @see contacts_connect()
* @see contact_query_contact_by_version()
*/
int contacts_get_db_version(int* contacts_db_version);
/**
+ * @brief Gets the contacts name display order.
+ *
+ * @param[out] name_display_order The name display order
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ */
+int contacts_get_name_display_order(contacts_name_display_order_e *name_display_order);
+
+/**
+ * @brief Sets the contacts name display order.
+ *
+ * @param[in] name_display_order The name display order
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ */
+int contacts_set_name_display_order(contacts_name_display_order_e name_display_order);
+
+/**
* @brief Registers a callback function to be invoked when the address book changes.
*
* @param[in] callback The callback function to register
@@ -99,6 +135,7 @@ int contacts_get_db_version(int* contacts_db_version);
* @pre This function requires an open connection to the contacts service by contacts_connect().
* @post contacts_db_changed_cb() will be invoked when the address book changes.
*
+ * @see contacts_connect()
* @see contacts_db_changed_cb()
* @see contacts_address_book_foreach_address_book_from_db()
* @see contacts_address_book_query_address_book_by_account_db_id()
@@ -132,6 +169,7 @@ int contacts_remove_address_book_db_changed_cb(contacts_db_changed_cb callback);
* @pre This function requires an open connection to the contacts service by contacts_connect().
* @post contacts_db_changed_cb() will be invoked when the contact changes.
*
+ * @see contacts_connect()
* @see contacts_db_changed_cb()
* @see contact_query_contact_by_version()
* @see contacts_remove_contact_db_changed_cb()
@@ -168,6 +206,7 @@ int contacts_remove_contact_db_changed_cb(contacts_db_changed_cb callback);
* @pre This function requires an open connection to the contacts service by contacts_connect().
* @post contacts_db_changed_cb() will be invoked when a contact changes.
*
+ * @see contacts_connect()
* @see contacts_db_changed_cb()
* @see contact_query_contact_by_version()
* @see contacts_remove_favorite_db_changed_cb()
@@ -194,7 +233,7 @@ int contacts_add_favorite_db_changed_cb(contacts_db_changed_cb callback, void *u
int contacts_remove_favorite_db_changed_cb(contacts_db_changed_cb callback);
/**
- * @brief Registers a callback function to be invoked when the favorite contacts changes.
+ * @brief Registers a callback function to be invoked when the group changes.
*
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
@@ -206,6 +245,7 @@ int contacts_remove_favorite_db_changed_cb(contacts_db_changed_cb callback);
* @pre This function requires an open connection to the contacts service by contacts_connect().
* @post contacts_db_changed_cb() will be invoked when a contact changes.
*
+ * @see contacts_connect()
* @see contacts_db_changed_cb()
* @see contacts_remove_group_db_changed_cb()
* @see contacts_group_insert_to_db()
@@ -229,6 +269,41 @@ int contacts_add_group_db_changed_cb(contacts_db_changed_cb callback, void *user
int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback);
/**
+ * @brief Registers a callback function to be invoked when a contact is added or removed from a specific group.
+ *
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre This function requires an open connection to the contacts service by contacts_connect().
+ * @post contacts_db_changed_cb() will be invoked when a contact changes.
+ *
+ * @see contacts_connect()
+ * @see contacts_db_changed_cb()
+ * @see contacts_remove_group_relation_changed_cb()
+ * @see contact_add_group()
+ * @see contact_remove_group()
+ */
+int contacts_add_group_relation_changed_cb(contacts_db_changed_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ *
+ * @param[in] callback The callback function to unregister
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_db_changed_cb()
+ * @see contacts_add_group_relation_changed_cb()
+ */
+int contacts_remove_group_relation_changed_cb(contacts_db_changed_cb callback);
+
+/**
* @brief Imports all contacts from SIM card to the contacts database.
*
* @return 0 on success, otherwise a negative error value.
@@ -236,6 +311,8 @@ int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback);
* @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
* @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
*/
int contacts_import_all_contacts_from_sim_card();
@@ -249,28 +326,21 @@ int contacts_import_all_contacts_from_sim_card();
*/
/**
- * @brief Gets the address book from the contacts databse.
- *
- * @details This funcstion creates a new address book handle from the contacts database by the given @a address_book_db_id. \n
- * @a address_book will be created, which is filled with address book informations.
+ * @brief Creates a handle to the address book.
*
- * @remarks @a address_book must be released with contacts_address_book_destroy() by you.
+ * @remarks @a address_book must be released with contacts_address_book_destroy() by you. \n
+ * The created handle not added to the contacts database until contacts_address_book_insert_to_db() is called.
*
- * @param[in] address_book_db_id The address book database ID to get from database
- * @param[out] address_book The address book handle associated with the address book database ID
+ * @param[out] address_book The address book handle
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
- * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
- *
- * @pre This function requires an open connection to contacts service by contacts_connect().
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
*
- * @see contacts_connect()
* @see contacts_address_book_destroy()
- * @see contacts_foreach_query_address_book_cb()
*/
-int contacts_address_book_get_from_db(int address_book_db_id, contacts_address_book_h *address_book);
+int contacts_address_book_create(contacts_address_book_h *address_book);
/**
* @brief Destroys the address book handle and releases all its resources.
@@ -281,11 +351,89 @@ int contacts_address_book_get_from_db(int address_book_db_id, contacts_address_b
* @retval #CONTACTS_ERROR_NONE Successful
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see contacts_address_book_create()
* @see contacts_address_book_get_from_db()
*/
int contacts_address_book_destroy(contacts_address_book_h address_book);
/**
+ * @brief Inserts a address book to the contacts database.
+ *
+ * @param[in] address_book The address book handle
+ * @param[out] address_book_db_id A address book ID to be assigned to the address book handle \n
+ * If inserting a new address book succeeds, database ID will be assigned to a new address book, otherwise @a address_book_db_id stays unchanged
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_address_book_delete_from_db()
+ * @see contacts_address_book_update_to_db()
+ */
+int contacts_address_book_insert_to_db(contacts_address_book_h address_book, int *address_book_db_id);
+
+/**
+ * @brief Deletes the address book from the contacts database.
+ *
+ * @param[in] address_book_db_id The address book ID to delete from contacts database
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_address_book_insert_to_db()
+ * @see contacts_address_book_update_to_db()
+ * @see contacts_address_book_get_db_id()
+ */
+int contacts_address_book_delete_from_db(int address_book_db_id);
+
+/**
+ * @brief Updates the address book to the contacts database.
+ *
+ * @param[in] address_book The address book handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_address_book_insert_to_db()
+ * @see contacts_address_book_delete_from_db()
+ */
+int contacts_address_book_update_to_db(contacts_address_book_h address_book);
+
+/**
+ * @brief Gets the address book from the contacts databse.
+ *
+ * @details This funcstion creates a new address book handle from the contacts database by the given @a address_book_db_id. \n
+ * @a address_book will be created, which is filled with address book information.
+ *
+ * @remarks @a address_book must be released with contacts_address_book_destroy() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to get from database
+ * @param[out] address_book The address book handle associated with the address book database ID
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_address_book_destroy()
+ * @see contacts_foreach_query_address_book_cb()
+ */
+int contacts_address_book_get_from_db(int address_book_db_id, contacts_address_book_h *address_book);
+
+/**
* @brief Gets the address book database ID for the given address book handle.
*
* @param[in] address_book The address book handle
@@ -301,21 +449,51 @@ int contacts_address_book_destroy(contacts_address_book_h address_book);
int contacts_address_book_get_db_id(contacts_address_book_h address_book, int *address_book_db_id);
/**
- * @brief Gets the address book name from the address book handle.
+ * @brief Sets the address book name.
+ *
+ * @param[in] address_book The contacts name handle
+ * @param[in] address_book_name The address book name to be returned
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_get_name()
+ */
+int contacts_address_book_set_name(contacts_address_book_h address_book, const char *address_book_name);
+
+/**
+ * @brief Gets the address book name.
*
* @remarks @a address_book_name must be released with free() by you.
*
- * @param[in] address_book The contacts name handle
- * @param[out] address_book_name The address book name to be returned \n
+ * @param[in] address_book The address book handle
+ * @param[out] address_book_name The address book name\n
* If requested data does not exist, @a detail is NULL
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_set_name()
*/
int contacts_address_book_get_name(contacts_address_book_h address_book, char **address_book_name);
/**
+ * @brief Sets the read only status of the address book to the address book handle.
+ *
+ * @param[in] address_book The contact handle
+ * @param[in] is_read_only @c true to make the address book read-only, otherwise @c false ( default : @c false )
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_get_read_only()
+ */
+int contacts_address_book_set_read_only(contacts_address_book_h address_book, bool is_read_only);
+
+/**
* @brief Gets the read only status of the address book from the address book handle.
*
* @param[in] address_book The contact handle
@@ -324,10 +502,26 @@ int contacts_address_book_get_name(contacts_address_book_h address_book, char **
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_set_read_only()
*/
int contacts_address_book_get_read_only(contacts_address_book_h address_book, bool *is_read_only);
/**
+ * @brief Sets the address book type to the address book handle.
+ *
+ * @param[in] address_book The address book handle
+ * @param[in] address_book_type The type of address book to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_get_type()
+ */
+int contacts_address_book_set_type(contacts_address_book_h address_book, contacts_address_book_type_e address_book_type);
+
+/**
* @brief Gets the address book type from the address book handle.
*
* @param[in] address_book The address book handle
@@ -336,10 +530,27 @@ int contacts_address_book_get_read_only(contacts_address_book_h address_book, bo
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_set_type()
*/
int contacts_address_book_get_type(contacts_address_book_h address_book, contacts_address_book_type_e *address_book_type);
/**
+ * @brief Sets the account database ID for the given address book handle.
+ *
+ * @param[in] address_book The address book handle
+ * @param[in] account_db_id The account database ID (default : 0) \n
+ * 0 means the address book is not related to any accounts.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_get_account_db_id()
+ */
+int contacts_address_book_set_account_db_id(contacts_address_book_h address_book, int account_db_id);
+
+/**
* @brief Gets the account database ID for the given address book handle.
*
* @param[in] address_book The address book handle
@@ -349,6 +560,8 @@ int contacts_address_book_get_type(contacts_address_book_h address_book, contact
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_address_book_set_account_db_id()
*/
int contacts_address_book_get_account_db_id(contacts_address_book_h address_book, int *account_db_id);
@@ -391,13 +604,10 @@ int contacts_address_book_foreach_address_book_from_db(contacts_foreach_query_ad
*/
int contacts_address_book_query_address_book_by_account_db_id(contacts_foreach_query_address_book_cb callback, int account_db_id, void *user_data);
-
/**
* @}
*/
-
-
#ifdef __cplusplus
}
#endif
diff --git a/include/contacts_contact.h b/include/contacts_contact.h
index 1410200..2660b62 100755..100644
--- a/include/contacts_contact.h
+++ b/include/contacts_contact.h
@@ -79,6 +79,7 @@ int contact_destroy(contact_h contact);
*
* @pre This function requires an open connection to contacts service by contacts_connect().
*
+ * @see contacts_connect()
* @see contact_update_to_db()
* @see contact_delete_from_db()
* @see contact_get_from_db()
@@ -96,6 +97,8 @@ int contact_insert_to_db(contact_h contact, int address_book_db_id, int *contact
* @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
* @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
* @see contact_insert_to_db()
* @see contact_update_to_db()
* @see contact_get_db_id()
@@ -104,7 +107,6 @@ int contact_delete_from_db(int contact_db_id);
/**
* @brief Updates the contact to the contacts database.
- * @details contact_get_db_id() is called internally to update in the contacts database
*
* @param[in] contact The contact handle
*
@@ -115,7 +117,8 @@ int contact_delete_from_db(int contact_db_id);
*
* @pre This function requires an open connection to contacts service by contacts_connect().
*
- * @see contact_insert_to_db()
+ * @see contacts_connect()
+ * @see contact_insert_to_db()
* @see contact_delete_from_db()
* @see contact_get_db_id()
*/
@@ -142,7 +145,7 @@ int contact_get_db_id(contact_h contact, int *contact_db_id);
* @brief Gets the contact from the contacts database.
*
* @details This function creates a new contact handle from the contacts database by the given @a contact_db_id. \n
- * @a contact will be created, which is filled with contact informations.
+ * @a contact will be created, which is filled with contact information.
*
* @remarks @a contact must be released with contact_destroy() by you.
*
@@ -173,6 +176,7 @@ int contact_get_from_db(int contact_db_id, contact_h *contact);
*
* @pre This function requires an open connection to the contacts service by contacts_connect().
*
+ * @see contacts_connect()
* @see contact_unset_favorite_to_db()
*/
int contact_set_favorite_to_db(int contact_db_id);
@@ -412,7 +416,7 @@ int contact_get_address_iterator(contact_h contact, contact_address_iterator_h *
*
* @param[in] contact The contact handle
* @param[out] birthday The contacts birthday handle \n
- * If a name handle has never set to the contact, it is NULL
+ * If a name handle has never set to the contact, it is NULL.
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
@@ -450,6 +454,49 @@ int contact_set_birthday(contact_h contact, contact_birthday_h birthday);
int contact_unset_birthday(contact_h contact);
/**
+ * @brief Gets the contacts anniversary handle from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] anniversary The contacts anniversary handle \n
+ * If a anniversary handle has never set to the contact, it is NULL.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_anniversary()
+ */
+int contact_get_anniversary(contact_h contact, contact_anniversary_h* anniversary);
+
+/**
+ * @brief Sets the contacts anniversary handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[in] anniversary The contacts anniversary handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_get_anniversary()
+ * @see contact_unset_anniversary()
+ */
+int contact_set_anniversary(contact_h contact, contact_anniversary_h anniversary);
+
+/**
+ * @brief Unsets the contacts anniversary handle to the contact handle.
+ *
+ * @param[in] contact The contact handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_set_anniversary()
+ */
+int contact_unset_anniversary(contact_h contact);
+
+/**
* @brief Gets the contacts company handle from the contact handle.
*
* @param[in] contact The contact handle
@@ -712,6 +759,7 @@ int contact_set_image(contact_h contact, const char *image_path);
* @see contact_set_ringtonepath()
*/
int contact_get_ringtonepath(contact_h contact, char **ringtone_path);
+
/**
* @brief Sets the ringtone path to the contact handle.
*
@@ -758,6 +806,22 @@ int contact_get_note(contact_h contact, char **note);
int contact_set_note(contact_h contact, const char *note);
/**
+ * @brief Gets the last modified time from the contact handle.
+ *
+ * @param[in] contact The contact handle
+ * @param[out] last_modified_time The last modified time to get \n
+ * If @a last_modified_time does not exist, it is 0
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_insert_to_db()
+ * @see contact_update_to_db()
+ */
+int contact_get_last_modified_time(contact_h contact, time_t *last_modified_time);
+
+/**
* @brief Gets the all contact count
*
*
@@ -885,6 +949,40 @@ int contact_get_total_count_not_related_to_group(int address_book_db_id, int *co
int contact_unset_frequent_contact(int contact_db_id);
/**
+ * @brief Sets a group relation to database
+ *
+ * @param[in] contact_db_id The contact database ID
+ * @param[in] group_db_id The group database ID
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ */
+int contact_set_group_relation_to_db(int contact_db_id, int group_db_id);
+
+/**
+ * @brief Unsets a group relation to database
+ *
+ * @param[in] contact_db_id The contact database ID
+ * @param[in] group_db_id The group database ID
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ */
+int contact_unset_group_relation_to_db(int contact_db_id, int group_db_id);
+
+/**
* @}
*/
diff --git a/include/contacts_event.h b/include/contacts_event.h
index da59581..41e8b3a 100755
--- a/include/contacts_event.h
+++ b/include/contacts_event.h
@@ -97,6 +97,77 @@ int contact_birthday_set_date(contact_birthday_h birthday, int year, int month,
* @}
*/
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_ANNIVERSARY_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a handle to contacts anniversary.
+ *
+ * @remarks @a anniversary must be released with contact_anniversary_destroy() by you. \n
+ * @a anniversary is not added to contacts database until contact_insert_to_db() is called.
+ *
+ * @param[out] anniversary A new contacts anniversary handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see contact_anniversary_destroy()
+ */
+int contact_anniversary_create(contact_anniversary_h *anniversary);
+
+/**
+ * @brief Destroys the handle to contacts anniversary.
+ *
+ * @param[in] anniversary The contacts anniversary handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_anniversary_create()
+ */
+int contact_anniversary_destroy(contact_anniversary_h anniversary);
+
+
+/**
+ * @brief Gets the anniversary date from the contacts anniversary handle.
+ *
+ * @param[in] anniversary The contacts anniversary handle
+ * @param[out] year The year of anniversary date
+ * @param[out] month The month of anniversary date
+ * @param[out] day The day of anniversary date
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_anniversary_set_date()
+ */
+int contact_anniversary_get_date(contact_anniversary_h anniversary, int *year, int *month, int *day);
+
+/**
+ * @brief Sets the date of anniversary.
+ *
+ * @param[in] anniversary The contacts anniversary handle
+ * @param[in] year The year of anniversary date
+ * @param[in] month The month of anniversary date
+ * @param[in] day The day of anniversary date
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_anniversary_get_date()
+ */
+int contact_anniversary_set_date(contact_anniversary_h anniversary, int year, int month, int day);
+
+/**
+ * @}
+ */
#ifdef __cplusplus
}
#endif
diff --git a/include/contacts_group.h b/include/contacts_group.h
index 0293517..73090df 100755..100644
--- a/include/contacts_group.h
+++ b/include/contacts_group.h
@@ -76,7 +76,8 @@ int contacts_group_destroy(contacts_group_h group);
* @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
* @pre This function requires an open connection to contacts service by contacts_connect().
-
+ *
+ * @see contacts_connect()
* @see contacts_group_delete_from_db()
* @see contacts_group_update_to_db()
*/
@@ -93,7 +94,8 @@ int contacts_group_insert_to_db(contacts_group_h group, int address_book_db_id,
* @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
* @pre This function requires an open connection to contacts service by contacts_connect().
-
+ *
+ * @see contacts_connect()
* @see contacts_group_insert_to_db()
* @see contacts_group_update_to_db()
*/
@@ -111,6 +113,8 @@ int contacts_group_delete_from_db(int group_db_id);
* @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
* @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
* @see contacts_group_insert_to_db()
* @see contacts_group_delete_from_db()
*/
@@ -134,6 +138,7 @@ int contacts_group_update_to_db(contacts_group_h group);
*
* @pre This function requires an open connection to contacts service by contacts_connect().
*
+ * @see contacts_connect()
* @see contacts_group_destroy()
* @see contacts_group_get_db_id()
*/
@@ -219,8 +224,25 @@ int contacts_group_get_ringtonepath(contacts_group_h group, char **ringtonepath)
int contacts_group_set_ringtonepath(contacts_group_h group, const char *ringtonepath);
/**
- * @brief Gets the number of contact belonging to the contacts group handle.
+ * @brief Gets the number of group belonging to the address book.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[out] count The number of contact belonging to the contacts group handle
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ */
+int contacts_group_get_count(int address_book_db_id, int *count);
+
+/**
+ * @brief Gets the number of contact belonging to the contacts group handle.
*
* @param[in] group The contacts group handle
* @param[out] count The number of contact belonging to the contacts group handle
@@ -248,6 +270,8 @@ int contacts_group_get_member_count_from_db(contacts_group_h group, int *count);
*
* @pre This function requires an open connection to Contacts Service by contacts_connect().
* @post This function invokes contacts_foreach_query_group_cb().
+ *
+ * @see contacts_connect()
* @see contacts_foreach_query_group_cb()
*/
int contacts_group_foreach_group_from_db(contacts_foreach_query_group_cb callback, void *user_data);
@@ -289,6 +313,109 @@ int contacts_group_get_address_book_db_id(contacts_group_h group, int *address_b
int contacts_group_query_group_by_address_book(contacts_foreach_query_group_cb callback, int address_book_db_id, void *user_data);
/**
+ * @brief Frees contacts group array
+ *
+ * @param[out] group_array The contact group array
+ * @param[out] length The length of the array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_search_group_by_address_book()
+ */
+int contacts_group_free_query_group_array(pcontacts_query_group_s *group_array);
+
+/**
+ * @brief Frees contacts group search array
+ *
+ * @param[out] group_version_array The contact group array
+ * @param[out] length The length of the array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contacts_group_search_group_by_version()
+ */
+int contacts_group_free_query_version_array(pcontacts_group_query_version_s *group_version_array);
+
+/**
+ * @brief Retrieves all contacts from all of address books with array
+ *
+ * @remarks @a group_array must be released with contacts_group_free_query_group_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[out] group_array The contacts group array
+ * @param[out] length The length of the array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contacts_group_free_query_group_array()
+ */
+int contacts_group_search_group_by_address_book(int address_book_db_id, pcontacts_query_group_s **group_array, int *length);
+
+/**
+ * @brief Retrieves all groups as array with the contacts database version.
+ *
+ * @details This function will find all changed groups since the given @a contacts_db_version
+ * @remarks @a group_array must be released with contacts_group_free_query_version_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[in] contacts_db_version The contacts database version to filter
+ * @param[out] group_array The contacts group array
+ * @param[out] length The length of the array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contacts_group_free_query_version_array()
+ */
+int contacts_group_search_group_by_version(int address_book_db_id, int contacts_db_version, pcontacts_group_query_version_s **group_array, int *length);
+
+/**
+ * @brief Retrieves all groups as array which has changed relation with contacts
+ *
+ * @remarks @a group_array must be released with contacts_group_free_query_version_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[in] contacts_db_version The contacts database version to filter
+ * @param[out] group_array The contacts group array
+ * @param[out] length The length of the array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contacts_group_free_query_version_array()
+ */
+int contacts_group_search_relation_changed_group_by_version(int address_book_db_id, int contacts_db_version, pcontacts_group_query_version_s **group_array, int *length);
+
+/**
* @}
*/
diff --git a/include/contacts_messenger.h b/include/contacts_messenger.h
index 4720d73..597575e 100755
--- a/include/contacts_messenger.h
+++ b/include/contacts_messenger.h
@@ -121,6 +121,38 @@ int contact_messenger_get_type(contact_messenger_h messenger, contact_messenger_
int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_type_e type);
/**
+ * @brief Gets the messenger provider name from the contacts messenger handle.
+ *
+ * @remarks @a provider_name must be released with free() by you.
+ *
+ * @param[in] messenger The contacts messenger handle
+ * @param[out] provider_name The provider name returned as string. \n
+ * If @a provider_name does not exist, it is NULL
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_messenger_set_provider_name()
+ */
+int contact_messenger_get_provider_name(contact_messenger_h messenger, char **provider_name);
+
+/**
+ * @brief Sets a messenger provider name to the contacts messenger handle.
+ *
+ * @remarks @a provider_name must be released with free() by you.
+ *
+ * @param[in] messenger The contacts messenger handle
+ * @param[in] provider_name The provider name to set
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see contact_messenger_get_provider_name()
+ */
+int contact_messenger_set_provider_name(contact_messenger_h messenger, const char *provider_name);
+
+/**
* @brief Moves the messenger iterator to the next position and gets a contacts messenger handle.
*
* @details If the next element for the current messenger list exists, then the iterator is moved to the next
@@ -142,7 +174,6 @@ int contact_messenger_iterator_next(contact_messenger_iterator_h *messenger_iter
/**
* @brief Checks whether there is a next contacts messenger handle on the list.
*
- *
* @param[in] messenger_iterator The contacts message list handle
*
* @return Return @c true If next element exists or @c false If nest element doesn't exist
diff --git a/include/contacts_number.h b/include/contacts_number.h
index 4023176..0f8ea88 100755
--- a/include/contacts_number.h
+++ b/include/contacts_number.h
@@ -67,7 +67,7 @@ int contact_number_destroy(contact_number_h number);
*
*
* @param[in] number The contacts number handle
- * @param[out] type The type of number to get
+ * @param[out] type The type of number to get \n Supports "OR"ing of #contact_number_type_e
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
@@ -75,13 +75,13 @@ int contact_number_destroy(contact_number_h number);
*
* @see contact_number_set_type()
*/
-int contact_number_get_type(contact_number_h number, contact_number_type_e *type);
+int contact_number_get_type(contact_number_h number, unsigned int *type);
/**
* @brief Sets a number type to the contacts number handle.
*
* @param[in] number The contacts number handle
- * @param[in] type The type of number to set
+ * @param[in] type The type of number to set \n Supports "OR"ing of #contact_number_type_e
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
@@ -89,7 +89,7 @@ int contact_number_get_type(contact_number_h number, contact_number_type_e *type
*
* @see contact_number_get_type()
*/
-int contact_number_set_type(contact_number_h number, contact_number_type_e type);
+int contact_number_set_type(contact_number_h number, unsigned int type);
/**
* @brief Gets the default status of the phone number from the contacts number handle.
diff --git a/include/contacts_private.h b/include/contacts_private.h
index 122b9e8..c165c6b 100755..100644
--- a/include/contacts_private.h
+++ b/include/contacts_private.h
@@ -206,7 +206,7 @@ typedef struct {
int id;
int type;
int date;
- }_contact_birthday_s;//CTS_EVENT_VAL_
+ }_contact_event_s;//CTS_EVENT_VAL_
/**
* @internal
@@ -437,10 +437,14 @@ typedef struct GSList contacts_iterator_s;
}
void _contacts_set_query_person_struct(contact_query_name_s* contact, CTSvalue* value);
-void _contacts_free_query_preson_struct_member_only(contact_query_name_s* person);
-void _contacts_free_query_preson_struct_all(gpointer data, gpointer user_data);
+void _contacts_free_query_person_struct_member_only(contact_query_name_s* person);
+void _contacts_free_query_person_struct_all(gpointer data, gpointer user_data);
void _contacts_free_query_number_struct_member_only(contact_query_number_s* contact);
void _contacts_free_query_number_struct_all(gpointer data, gpointer user_data);
+void _contacts_free_query_email_struct_member_only(contact_query_email_s* email);
+void _contacts_free_query_email_struct_all(gpointer data, gpointer user_data);
+void _contacts_free_query_group_struct_member_only(contacts_query_group_s* group);
+void _contacts_free_query_group_struct_all(gpointer data, gpointer user_data);
void _contacts_set_query_address_book_struct(contacts_query_address_book_s* addressbook, CTSvalue* value);
void _contacts_free_query_address_book_struct_member_only(contacts_query_address_book_s* addressbook);
diff --git a/include/contacts_search.h b/include/contacts_search.h
index d3fd03e..24d9708 100755
--- a/include/contacts_search.h
+++ b/include/contacts_search.h
@@ -45,8 +45,8 @@ extern "C"
* @pre This function requires an open connection to contacts service by contacts_connect().
* @post This function invokes contact_foreach_query_name_cb().
*
- * @see contact_foreach_query_name_cb()
* @see contacts_connect()
+ * @see contact_foreach_query_name_cb()
*/
int contact_foreach_contact_from_db(contact_foreach_query_name_cb callback, void *user_data);
@@ -64,6 +64,7 @@ int contact_foreach_contact_from_db(contact_foreach_query_name_cb callback, void
* @pre This function requires an open connection to contacts service by contacts_connect().
* @post This function invokes contact_foreach_query_favorites_cb().
*
+ * @see contacts_connect()
* @see contact_foreach_query_favorites_cb()
*/
int contact_foreach_favorite_contact_from_db(contact_foreach_query_favorites_cb callback, void *user_data);
@@ -82,16 +83,15 @@ int contact_foreach_favorite_contact_from_db(contact_foreach_query_favorites_cb
* @pre This function requires an open connection to contacts service by contacts_connect().
* @post This function invokes contact_foreach_query_name_cb().
*
+ * @see contacts_connect()
* @see contact_foreach_query_name_cb()
* @see contact_unset_frequent_contact()
- * @see contacts_connect()
*/
int contact_foreach_frequent_contact_from_db(contact_foreach_query_name_cb callback, void *user_data);
/**
* @brief Retrieves all contacts with the given name.
*
- *
* @param[in] callback The callback function to invoke
* @param[in] name_to_find The name for search
* @param[in] user_data The user data to be passed to the callback function
@@ -103,6 +103,7 @@ int contact_foreach_frequent_contact_from_db(contact_foreach_query_name_cb callb
*
* @pre This function requires an open connection to contacts service by contacts_connect().
* @post This function invokes contact_foreach_query_name_cb().
+ *
* @see contacts_connect()
* @see contact_foreach_query_name_cb()
*
@@ -110,29 +111,10 @@ int contact_foreach_frequent_contact_from_db(contact_foreach_query_name_cb callb
int contact_query_contact_by_name(contact_foreach_query_name_cb callback, const char *name_to_find, void *user_data);
/**
- * @brief Retrieves all contacts with the given group contacts database ID.
- *
- * @param[in] callback The callback function to invoke
- * @param[out] group_db_id The group contacts database ID to filter
- * @param[in] user_data The user data to be passed to the callback function
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #CONTACTS_ERROR_NONE Successful
- * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
- * @pre This function requires an open connection to contacts service by contacts_connect().
- * @post This function invokes contact_foreach_query_name_cb().
- *
- * @see contacts_connect()
- * @see contact_foreach_query_name_cb()
- */
-int contact_query_contact_by_group(contact_foreach_query_name_cb callback, int group_db_id, void *user_data);
-
-/**
* @brief Retrieves all contacts with the given address book database ID.
*
* @param[in] callback The callback function to invoke
- * @param[out] address_book_db_id The address book database ID to filter
+ * @param[in] address_book_db_id The address book database ID to filter
* @param[in] user_data The user data to be passed to the callback function
*
* @return 0 on success, otherwise a negative error value.
@@ -162,6 +144,7 @@ int contact_query_contact_by_address_book(contact_foreach_query_name_cb callback
*
* @pre This function requires an open connection to contacts service by contacts_connect().
* @post This function invokes contact_foreach_query_number_cb().
+ *
* @see contacts_connect()
* @see contact_foreach_query_number_cb()
*
@@ -182,6 +165,7 @@ int contact_query_contact_by_number(contact_foreach_query_number_cb callback, co
*
* @pre This function requires an open connection to Contacts Service by contacts_connect()
* @post This function invokes contact_foreach_query_email_cb().
+ *
* @see contacts_connect()
* @see contact_foreach_query_email_cb()
*/
@@ -194,7 +178,7 @@ int contact_query_contact_by_email(contact_foreach_query_email_cb callback, cons
*
* @param[in] callback The callback function to invoke
* @param[in] address_book_db_id The address book database ID to filter
- * @param[in] contacts_db_version The contacts database version to filter
+ * @param[in] contacts_db_version The contacts database version
* @param[in] user_data The user data to be passed to the callback function
*
* @return 0 on success, otherwise a negative error value.
@@ -232,10 +216,65 @@ int contact_query_contact_by_version(contact_foreach_query_version_cb callback,
int contact_query_contact_not_related_to_group(contact_foreach_query_name_cb callback, int address_book_db_id, void *user_data);
/**
- * @brief Retrieves all contacts from all of address books with array
+ * @brief Frees contact array
+ *
+ * @param[out] contact_array The contact array
*
- * @remarks @a contact_array must be released with contact_query_name_array_free() by you.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see contact_search_contact_by_address_book()
+ */
+int contact_free_query_name_array(pcontact_query_name_s* contact_array);
+
+/**
+ * @brief Frees contact number array
+ *
+ * @param[out] contact_number_array The contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_search_contact_has_number()
+ */
+int contact_free_query_number_array(pcontact_query_number_s *contact_number_array);
+
+/**
+ * @brief Frees contact email array
+ *
+ * @param[out] contact_email_array The contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_search_contact_by_email()
+ */
+int contact_free_query_email_array(pcontact_query_email_s *contact_email_array);
+
+/**
+ * @brief Frees contact version array
+ *
+ * @param[out] contact_version_array The contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see contact_search_contact_by_version()
+ */
+int contact_free_query_version_array(pcontact_query_version_s *contact_version_array);
+
+/**
+ * @brief Retrieves all contacts as array from address book
+ *
+ * @remarks @a contact_array must be released with contact_free_query_name_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
* @param[out] contact_array The contact array
* @param[out] length The length of the contact array
*
@@ -247,31 +286,41 @@ int contact_query_contact_not_related_to_group(contact_foreach_query_name_cb cal
*
* @pre This function requires an open connection to contacts service by contacts_connect().
*
- * @see contact_query_name_array_free()
* @see contacts_connect()
+ * @see contact_free_query_name_array()
*/
-int contact_get_all_contact_from_db(contact_query_name_array *contact_array, int *length);
+int contact_search_contact_by_address_book(int address_book_db_id, pcontact_query_name_s **contact_array, int *length);
/**
- * @brief Frees contact array
+ * @brief Retrieves all contacts with default phone number as array from address book
+ *
+ * @remarks @a contact_array must be released with contact_free_query_name_array() by you.
*
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
* @param[out] contact_array The contact array
* @param[out] length The length of the contact array
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
*
- * @see contact_get_all_contact_from_db()
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_free_query_number_array()
*/
-int contact_query_name_array_free(contact_query_name_array contact_array, int length);
+int contact_search_contact_with_default_number_by_address_book(int address_book_db_id, pcontact_query_number_s **contact_array, int *length);
/**
- * @brief Retrieves all number contacts from all of address books with array
+ * @brief Retrieves all phone numbers as array from all address books
*
- * @remarks @a contact_number_array must be released with contact_query_number_array_free() by you.
+ * @remarks @a contact_number_array must be released with contact_free_query_number_array() by you.
*
- * @param[out] contact_number_array The contact array
+ * @param[out] phone_number_array The contact array
* @param[out] length The length of the contact array
*
* @return 0 on success, otherwise a negative error value.
@@ -282,24 +331,133 @@ int contact_query_name_array_free(contact_query_name_array contact_array, int le
*
* @pre This function requires an open connection to contacts service by contacts_connect().
*
- * @see contact_query_number_array_free()
* @see contacts_connect()
+ * @see contact_free_query_number_array()
*/
-int contact_get_number_contact_from_db(contact_query_number_array *contact_number_array, int *length);
+int contact_get_all_phone_number(pcontact_query_number_s **phone_number_array, int *length);
/**
- * @brief Frees contact number array
+ * @brief Retrieves all contacts as array with the given email address.
+ *
+ * @remarks @a contact_email_array must be released with contact_free_query_email_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[in] email_to_find The email address to filter
+ * @param[out] contact_email_array The contact array
+ * @param[out] length The length of the contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_free_query_email_array()
+ */
+int contact_search_contact_by_email(int address_book_db_id, const char *email_to_find, pcontact_query_email_s **contact_email_array, int *length);
+
+/**
+ * @brief Retrieves all contacts as array with the given number.
+ *
+ * @remarks @a contact_number_array must be released with contact_free_query_number_array() by you.
*
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[in] number_to_find The number to filter
* @param[out] contact_number_array The contact array
- * @param[out] length The length of the contact array
+ * @param[out] length The length of the contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_free_query_number_array()
+ */
+int contact_search_contact_by_number(int address_book_db_id, const char *number_to_find, pcontact_query_number_s **contact_number_array, int *length);
+
+/**
+ * @brief Retrieves all contacts as array with the given name.
+ *
+ * @remarks @a contact_name_array must be released with contact_free_query_name_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[in] name_to_find The name to filter
+ * @param[out] contact_name_array The contact array
+ * @param[out] length The length of the contact array
*
* @return 0 on success, otherwise a negative error value.
* @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_free_query_name_array()
+ */
+int contact_search_contact_by_name(int address_book_db_id, const char *name_to_find, pcontact_query_name_s **contact_name_array, int *length);
+
+/**
+ * @brief Retrieves all contacts as array with the given group database ID.
+ *
+ * @remarks @a contact_name_array must be released with contact_free_query_name_array() by you.
+ *
+ * @param[in] group_db_id The group contacts database ID to filter
+ * @param[out] contact_name_array The contact array
+ * @param[out] length The length of the contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
+ *
+ * @see contacts_connect()
+ * @see contact_free_query_name_array()
+ */
+int contact_search_contact_by_group(int group_db_id, pcontact_query_name_s **contact_name_array, int *length);
+
+/**
+ * @brief Retrieves all contacts as array with the contacts database version.
+ *
+ * @details This function will find all changed contacts since the given @a contacts_db_version
+ * @remarks @a contact_version_array must be released with contact_free_query_version_array() by you.
+ *
+ * @param[in] address_book_db_id The address book database ID to filter \n
+ * #DEFAULT_ADDRESS_BOOK_DB_ID means the default address book on the device \n
+ * #ADDRESS_BOOK_FILTER_ALL means all address books on the device
+ * @param[in] contacts_db_version The contacts database version
+ * @param[out] contact_version_array The contact array
+ * @param[out] length The length of the contact array
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #CONTACTS_ERROR_NONE Successful
+ * @retval #CONTACTS_ERROR_OUT_OF_MEMORY Out of memory
* @retval #CONTACTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONTACTS_ERROR_DB_FAILED Database operation failure
+ *
+ * @pre This function requires an open connection to contacts service by contacts_connect().
*
- * @see contact_get_number_contact_from_db()
+ * @see contacts_connect()
+ * @see contact_free_query_version_array()
*/
-int contact_query_number_array_free(contact_query_number_array contact_number_array, int length);
+int contact_search_contact_by_version(int address_book_db_id, int contacts_db_version, pcontact_query_version_s **contact_version_array, int *length);
/**
* @}
diff --git a/include/contacts_types.h b/include/contacts_types.h
index 80fb46b..45481f0 100755
--- a/include/contacts_types.h
+++ b/include/contacts_types.h
@@ -43,6 +43,16 @@ typedef enum
CONTACTS_ERROR_NO_DATA = TIZEN_ERROR_SOCIAL_CLASS | 0x63, /**< Requested data does not exist */
CONTACTS_ERROR_ITERATOR_END = TIZEN_ERROR_SOCIAL_CLASS | 0x64 /**< List reached end */
} contacts_error_e;
+
+/**
+ * @brief Enumerations of contacts name display order.
+ */
+typedef enum
+{
+ CONTACTS_NAME_DISPLAY_ORDER_FIRST_LAST = 0, /**< (First name) (Last name) */
+ CONTACTS_NAME_DISPLAY_ORDER_LAST_FIRST /**< (Last name) (First name) */
+} contacts_name_display_order_e;
+
/**
* @}
*/
@@ -62,6 +72,15 @@ typedef enum
} contact_query_change_type_e;
/**
+ * @brief Enumerations for contact extend property types.
+ */
+typedef enum
+{
+ CONTACT_EXTEND_PROPERTY_TYPE_STRING = 0, /**< String property */
+ CONTACT_EXTEND_PROPERTY_TYPE_INTEGER /**< Integer property */
+} contact_extend_property_type_e;
+
+/**
* @}
*/
@@ -230,7 +249,13 @@ typedef struct _contact_address_s* contact_address_h;
* @brief The contacts birthday handle.
* @ingroup CAPI_SOCIAL_CONTACTS_BIRTHDAY_MODULE
*/
-typedef struct _contact_birthday_s* contact_birthday_h;
+typedef struct _contact_event_s* contact_birthday_h;
+
+/**
+ * @brief The contacts anniversary handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_ANNIVERSARY_MODULE
+ */
+typedef struct _contact_event_s* contact_anniversary_h;
/**
* @brief The contacts company handle.
@@ -263,12 +288,23 @@ typedef struct _contacts_group_s* contact_relatedgroup_h;
typedef struct _contact_web_s* contact_web_h;
/**
+ * @brief The contacts extend property handle.
+ * @ingroup CAPI_SOCIAL_CONTACTS_EXTEND_PROPERTY_MODULE
+ */
+typedef struct _contacts_extend_s* contact_extend_property_h;
+
+/**
* @brief The contacts group handle.
* @ingroup CAPI_SOCIAL_CONTACTS_GROUP_MODULE
*/
typedef struct _contacts_group_s* contacts_group_h;
/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
+ * @{
+ */
+
+/**
* @brief The structure of contact in search results.
*
* @see contact_foreach_query_name_cb()
@@ -278,17 +314,14 @@ typedef struct {
char* first_name; /**< Contact's first name (also known as given name) */
char* last_name; /**< Contact's last name (also known as family name) */
char* display_name; /**< Display name (how contact's name should be presented) */
+ int address_book_db_id; /**< Address book database id */
char* contact_image_path; /**< Path to persons picture */
}contact_query_name_s;
/**
- * @brief The array type of #contact_query_name_s
- *
- * @see contact_query_name_s
- * @see contact_get_all_contact_from_db()
- * @see contact_query_name_array_free()
+ * @brief The pointer type of contact_query_name_s
*/
-typedef contact_query_name_s** contact_query_name_array;
+typedef contact_query_name_s* pcontact_query_name_s;
/**
* @brief The structure of number in search results.
@@ -302,17 +335,14 @@ typedef struct
char* last_name; /**< Contact's last name (also known as family name) */
char* display_name; /**< Display name (how contact's name should be presented) */
char* phone_number; /**< Phone number string */
+ int address_book_db_id; /**< Address book database id */
char* contact_image_path; /**< Path to image with contact's picture */
} contact_query_number_s;
/**
- * @brief The array type of #contact_query_number_s
- *
- * @see contact_query_number_s
- * @see contact_get_number_contact_from_db()
- * @see contact_query_number_array_free()
+ * @brief The pointer type of contact_query_number_s
*/
-typedef contact_query_number_s** contact_query_number_array;
+typedef contact_query_number_s* pcontact_query_number_s;
/**
* @brief The structure of email in search results.
@@ -326,19 +356,14 @@ typedef struct
char* last_name; /**< Contact's last name (also known as family name) */
char* display_name; /**< Display name (how contact's name should be presented) */
char* email_address; /**< Email address string */
+ int address_book_db_id; /**< Address book database id */
char* contact_image_path; /**< Path to image with contact's picture */
} contact_query_email_s;
/**
- * @brief The structure of group in search results.
- * @see contacts_foreach_query_group_cb()
+ * @brief The pointer type of contact_query_number_s
*/
-typedef struct
-{
- int group_db_id; /**< Group database id */
- int address_book_db_id; /**< Address book database id */
- char* group_name; /**< Group name */
-} contacts_query_group_s;
+typedef contact_query_email_s* pcontact_query_email_s;
/**
* @brief The structure of favorite in search results.
@@ -346,27 +371,85 @@ typedef struct
*/
typedef struct
{
- int contact_db_id; /**< Contact's id in database */
+ int contact_db_id; /**< Contact's ID in database */
char* first_name; /**< Contact's first name (also known as given name) */
char* last_name; /**< Contact's last name (also known as family name) */
char* display_name; /**< Display name (how contact's name should be presented) */
char* contact_image_path; /**< Path to image with contact's picture */
- contact_number_type_e phone_type; /**< Phone number type (i.e.: work, cell) */
+ contact_number_type_e phone_type; /**< Phone number type (i.e.: work, cell) */
char* phone_number; /**< Phone number */
} contact_query_favorite_s;
/**
+ * @brief The pointer type of pcontact_query_favorite_s
+ */
+typedef contact_query_favorite_s* pcontact_query_favorite_s;
+
+/**
* @brief The structure of changed contact in search results.
* @see contact_foreach_query_version_cb()
*/
typedef struct
{
- int contact_db_id; /**< Id of changed contact */
- contact_query_change_type_e changed_type; /**< Type of change */
- int contacts_db_version; /**< Contacts database version of this contact */
+ int contact_db_id; /**< ID of changed contact */
+ contact_query_change_type_e changed_type; /**< Type of change */
+ int contacts_db_version; /**< Contacts database version of this contact */
+ int address_book_db_id; /**< Address book database id */
} contact_query_version_s;
/**
+ * @brief The pointer type of contact_query_version_s
+ */
+typedef contact_query_version_s* pcontact_query_version_s;
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_SOCIAL_CONTACTS_GROUP_MODULE
+ * @{
+ */
+
+/**
+ * @brief The structure of group in search results.
+ * @see contacts_foreach_query_group_cb()
+ */
+typedef struct
+{
+ int group_db_id; /**< Group database id */
+ int address_book_db_id; /**< Address book database id */
+ char* group_name; /**< Group name */
+ char* group_ringtonepath; /**< Group name */
+} contacts_query_group_s;
+
+/**
+ * @brief The pointer type of contacts_query_group_s
+ */
+typedef contacts_query_group_s* pcontacts_query_group_s;
+
+/**
+ * @brief The structure of changed contact in search results.
+ * @see contact_foreach_query_version_cb()
+ */
+typedef struct
+{
+ int group_db_id; /**< ID of changed group */
+ contact_query_change_type_e changed_type; /**< Type of change */
+ int contacts_db_version; /**< Contacts database version of this contact */
+ int address_book_db_id; /**< Address book database id */
+} contacts_group_query_version_s;
+
+/**
+ * @brief The pointer type of contacts_group_query_version_s
+ */
+typedef contacts_group_query_version_s* pcontacts_group_query_version_s;
+
+/**
+ * @}
+ */
+
+/**
* @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
* @brief The callback function to get the contact searched by name.
*
@@ -416,7 +499,7 @@ typedef bool (*contact_foreach_query_email_cb)(contact_query_email_s *query_emai
* @ingroup CAPI_SOCIAL_CONTACTS_CONTACT_MODULE
* @brief The callback function to get the contacts after the specific timestamp.
*
- * @param[in] query_time_last_modified The contact queried by time last modified
+ * @param[in] query_version The contact queried by version
* @param[in] user_data The user data passed from the foreach function
*
* @return @c true to continue with the next iteration of the loop or @c false to break out of the loop.
@@ -425,7 +508,7 @@ typedef bool (*contact_foreach_query_email_cb)(contact_query_email_s *query_emai
*
* @see contact_query_contact_by_version()
*/
-typedef bool (*contact_foreach_query_version_cb)(contact_query_version_s *query_time_last_modified, void *user_data);
+typedef bool (*contact_foreach_query_version_cb)(contact_query_version_s *query_version, void *user_data);
/**
@@ -605,21 +688,6 @@ typedef enum
*/
/**
- * @ingroup CAPI_SOCIAL_CONTACTS_MODULE
- * @defgroup CAPI_SOCIAL_CONTACTS_ADDRESS_BOOK_MODULE Address Book
- *
- * @brief Address book definition and Address book related operations.
- *
- * @section SOCIAL_CONTACTS_ADDRESS_BOOK_MODULE_HEADER Required Header
- * \#include <contacts.h>
- *
- * @section CAPI_SOCIAL_CONTACTS_ADDRESS_BOOK_OVERVIEW Overview
- * The address book API provides functions to get multiple address book information.
- *
- * <BR>
- */
-
-/**
* @addtogroup CAPI_SOCIAL_CONTACTS_ADDRESS_BOOK_MODULE
* @{
*/
@@ -643,6 +711,11 @@ typedef enum
#define DEFAULT_ADDRESS_BOOK_DB_ID 0
/**
+ * @brief Definition for all address book
+ */
+#define ADDRESS_BOOK_FILTER_ALL -1
+
+/**
* @brief The structure of address book in search results.
*
* @see contacts_foreach_query_address_book_cb()
diff --git a/packaging/capi-social-contacts.spec b/packaging/capi-social-contacts.spec
index 23c43c1..bcdd944 100755
--- a/packaging/capi-social-contacts.spec
+++ b/packaging/capi-social-contacts.spec
@@ -1,7 +1,7 @@
Name: capi-social-contacts
Summary: Contacts library in Tizen Native API
-Version: 0.1.1
-Release: 30
+Version: 0.1.7
+Release: 1
Group: TO_BE/FILLED_IN
License: TO BE FILLED IN
Source0: %{name}-%{version}.tar.gz
@@ -11,8 +11,6 @@ BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(contacts-service)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(utilX)
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(ui-gadget)
BuildRequires: pkgconfig(contacts-service)
BuildRequires: pkgconfig(edje)
BuildRequires: pkgconfig(evas)
diff --git a/src/contacts.c b/src/contacts.c
index 35a5222..7d1ca55 100755
--- a/src/contacts.c
+++ b/src/contacts.c
@@ -64,6 +64,27 @@ int contacts_get_db_version(int* contacts_db_version)
return CONTACTS_ERROR_NONE;
}
+int contacts_get_name_display_order(contacts_name_display_order_e *name_display_order)
+{
+ CONTACTS_NULL_ARG_CHECK(name_display_order);
+
+ if ((*name_display_order = contacts_svc_get_order(CTS_ORDER_OF_DISPLAY)) < 0) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_set_name_display_order(contacts_name_display_order_e name_display_order)
+{
+ CONTACTS_INVALID_ARG_CHECK(name_display_order < 0 || 1 < name_display_order);
+ if (CTS_SUCCESS == contacts_svc_set_order(CTS_ORDER_OF_DISPLAY, name_display_order)) {
+ return CONTACTS_ERROR_NONE;
+ }
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
int contacts_add_address_book_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
{
CONTACTS_NULL_ARG_CHECK(callback);
@@ -151,12 +172,36 @@ int contacts_add_group_db_changed_cb(contacts_db_changed_cb callback, void *user
int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback)
{
CONTACTS_NULL_ARG_CHECK(callback);
-
+
if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, callback) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
- }
-
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_add_group_relation_changed_cb(contacts_db_changed_cb callback, void *user_data)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_RELATION_CHANGE, callback, user_data) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_remove_group_relation_changed_cb(contacts_db_changed_cb callback)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_GROUP_RELATION_CHANGE, callback) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
return CONTACTS_ERROR_INVALID_PARAMETER;
}
@@ -253,6 +298,20 @@ int contacts_address_book_get_from_db(int address_book_db_id, contacts_address_b
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contacts_address_book_create(contacts_address_book_h *address_book)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_ADDRESSBOOK);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ *address_book = (contacts_address_book_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
int contacts_address_book_destroy(contacts_address_book_h address_book)
{
CONTACTS_NULL_ARG_CHECK(address_book);
@@ -265,6 +324,70 @@ int contacts_address_book_destroy(contacts_address_book_h address_book)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contacts_address_book_insert_to_db(contacts_address_book_h address_book, int *address_book_db_id)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+
+ int ret;
+ CTSvalue* value = (CTSvalue *)address_book;
+
+ ret = contacts_svc_insert_addressbook(value);
+ if(ret < CTS_SUCCESS) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ *address_book_db_id = ret;
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_address_book_delete_from_db(int address_book_db_id)
+{
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+
+ int ret;
+ ret = contacts_svc_delete_addressbook(address_book_db_id);
+ if (CTS_SUCCESS == ret)
+ return CONTACTS_ERROR_NONE;
+ else if (CTS_ERR_DB_FAILED == ret) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+int contacts_address_book_update_to_db(contacts_address_book_h address_book)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+
+ int ret;
+ ret = contacts_svc_update_addressbook((CTSvalue*)address_book);
+ if (CTS_SUCCESS == ret)
+ return CONTACTS_ERROR_NONE;
+ else if (CTS_ERR_DB_FAILED == ret) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
+
+int contacts_address_book_set_type(contacts_address_book_h address_book, contacts_address_book_type_e address_book_type)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+
+ int ret;
+ ret = contacts_svc_value_set_int((CTSvalue *)address_book, CTS_ADDRESSBOOK_VAL_ACC_TYPE_INT, address_book_type);
+ if (CTS_SUCCESS != ret) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
int contacts_address_book_get_db_id(contacts_address_book_h address_book, int *address_book_db_id)
{
CONTACTS_NULL_ARG_CHECK(address_book);
@@ -289,6 +412,21 @@ int contacts_address_book_get_name(contacts_address_book_h address_book, char **
return CONTACTS_ERROR_NONE;
}
+int contacts_address_book_set_name(contacts_address_book_h address_book, const char *address_book_name)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+ CONTACTS_NULL_ARG_CHECK(address_book_name);
+
+ int ret = contacts_svc_value_set_str((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_NAME_STR, address_book_name);
+ if (CTS_SUCCESS != ret) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
int contacts_address_book_get_read_only(contacts_address_book_h address_book, bool *is_read_only)
{
CONTACTS_NULL_ARG_CHECK(address_book);
@@ -300,6 +438,20 @@ int contacts_address_book_get_read_only(contacts_address_book_h address_book, bo
return CONTACTS_ERROR_NONE;
}
+int contacts_address_book_set_read_only(contacts_address_book_h address_book, bool is_read_only)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+
+ int ret = contacts_svc_value_set_int((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_MODE_INT, is_read_only);
+ if (CTS_SUCCESS != ret) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
int contacts_address_book_get_type(contacts_address_book_h address_book, contacts_address_book_type_e *address_book_type)
{
CONTACTS_NULL_ARG_CHECK(address_book);
@@ -320,7 +472,19 @@ int contacts_address_book_get_account_db_id(contacts_address_book_h address_book
*account_db_id = contacts_svc_value_get_int((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_ACC_ID_INT);
if(*account_db_id < 0) {
*account_db_id = 0;
- }
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_address_book_set_account_db_id(contacts_address_book_h address_book, int account_db_id)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+ int ret = contacts_svc_value_set_int((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_ACC_ID_INT, account_db_id);
+ if (CTS_SUCCESS != ret) {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
return CONTACTS_ERROR_NONE;
}
diff --git a/src/contacts_contact.c b/src/contacts_contact.c
index 5b66d59..7aaa8f5 100755
--- a/src/contacts_contact.c
+++ b/src/contacts_contact.c
@@ -478,14 +478,39 @@ int contact_get_birthday(contact_h contact, contact_birthday_h* birthday)
*birthday = NULL;
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
- if(cursor == NULL) {
- return CONTACTS_ERROR_NONE;
+
+ for (;cursor;cursor=cursor->next) {
+ if (CTS_EVENT_TYPE_BIRTH == contacts_svc_value_get_int(cursor->data, CTS_EVENT_VAL_TYPE_INT))
+ break;
}
- *birthday = (contact_birthday_h)cursor->data;
-
- return CONTACTS_ERROR_NONE;
+
+ if (NULL != cursor)
+ *birthday = (contact_birthday_h)cursor->data;
+
+ return CONTACTS_ERROR_NONE;
}
+int contact_get_anniversary(contact_h contact, contact_anniversary_h* anniversary)
+{
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(anniversary);
+
+ *anniversary = NULL;
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
+
+ for (;cursor;cursor=cursor->next) {
+ if (CTS_EVENT_TYPE_ANNIVERSARY == contacts_svc_value_get_int(cursor->data, CTS_EVENT_VAL_TYPE_INT))
+ break;
+ }
+
+ if (NULL != cursor)
+ *anniversary = (contact_anniversary_h)cursor->data;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
int contact_set_birthday(contact_h contact, contact_birthday_h birthday)
{
CONTACTS_NULL_ARG_CHECK(contact);
@@ -521,25 +546,81 @@ int contact_set_birthday(contact_h contact, contact_birthday_h birthday)
return ret;
}
-int contact_unset_birthday(contact_h contact)
+int contact_set_anniversary(contact_h contact, contact_anniversary_h anniversary)
{
CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(anniversary);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
+ int ret = 0;
+ bool need_to_free = false;
+ if(cursor == NULL) {
+ need_to_free = true;
+ } else {
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if(contacts_svc_value_get_int((CTSvalue*)cursor->data, CTS_EVENT_VAL_TYPE_INT) == CTS_EVENT_TYPE_ANNIVERSARY) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_EVENT_VAL_DELETE_BOOL, true);
+ }
+ }
+ }
+
+ cursor = g_slist_append((GSList*)cursor, anniversary);
+
+ if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, cursor) == CTS_SUCCESS) {
+ ret = CONTACTS_ERROR_NONE;
+ } else {
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ ret = CONTACTS_ERROR_INVALID_PARAMETER;
+ }
+
+ if(need_to_free == true) {
+ g_slist_free((GSList*)cursor);
+ }
+
+ return ret;
+}
+
+
+int contact_unset_birthday(contact_h contact)
+{
+ CONTACTS_NULL_ARG_CHECK(contact);
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
if(cursor == NULL) {
return CONTACTS_ERROR_NONE;
} else {
for(;cursor;cursor=g_slist_next(cursor)) {
if(contacts_svc_value_get_int((CTSvalue*)cursor->data, CTS_EVENT_VAL_TYPE_INT) == CTS_EVENT_TYPE_BIRTH) {
contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_EVENT_VAL_DELETE_BOOL, true);
- }
+ }
+ }
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_unset_anniversary(contact_h contact)
+{
+ CONTACTS_NULL_ARG_CHECK(contact);
+
+ GSList *cursor = NULL;
+ contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
+ if(cursor == NULL) {
+ return CONTACTS_ERROR_NONE;
+ } else {
+ for(;cursor;cursor=g_slist_next(cursor)) {
+ if(contacts_svc_value_get_int((CTSvalue*)cursor->data, CTS_EVENT_VAL_TYPE_INT) == CTS_EVENT_TYPE_ANNIVERSARY) {
+ contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_EVENT_VAL_DELETE_BOOL, true);
+ }
}
}
return CONTACTS_ERROR_NONE;
}
+
int contact_add_messenger(contact_h contact, contact_messenger_h messenger)
{
CONTACTS_NULL_ARG_CHECK(contact);
@@ -875,6 +956,18 @@ int contact_set_note(contact_h contact, const char* note)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contact_get_last_modified_time(contact_h contact, time_t *last_modified_time)
+{
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(last_modified_time);
+
+ CTSvalue* base = NULL;
+ if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS)
+ return CONTACTS_ERROR_NONE;
+
+ *last_modified_time = (time_t)contacts_svc_value_get_int(base, CTS_BASE_VAL_CHANGED_TIME_INT);
+ return CONTACTS_ERROR_NONE;
+}
int contact_get_total_count_from_db(int* count)
{
@@ -884,8 +977,6 @@ int contact_get_total_count_from_db(int* count)
return CONTACTS_ERROR_NONE;
}
-
-
int contact_get_from_vcard(const char *vcard_stream, contact_h *contact)
{
CONTACTS_NULL_ARG_CHECK(vcard_stream);
@@ -1061,3 +1152,32 @@ int contact_unset_frequent_contact(int contact_db_id)
return CONTACTS_ERROR_NONE;
}
+int contact_set_group_relation_to_db(int contact_db_id, int group_db_id)
+{
+ CONTACTS_INVALID_ARG_CHECK(contact_db_id < 1);
+ CONTACTS_INVALID_ARG_CHECK(group_db_id < 1);
+
+ int ret = contacts_svc_group_set_relation(group_db_id, contact_db_id);
+
+ if (ret == CTS_SUCCESS)
+ return CONTACTS_ERROR_NONE;
+
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
+int contact_unset_group_relation_to_db(int contact_db_id, int group_db_id)
+{
+ CONTACTS_INVALID_ARG_CHECK(contact_db_id < 1);
+ CONTACTS_INVALID_ARG_CHECK(group_db_id < 1);
+
+ int ret = contacts_svc_group_unset_relation(group_db_id, contact_db_id);
+
+ if (ret == CTS_SUCCESS)
+ return CONTACTS_ERROR_NONE;
+
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+}
+
+
diff --git a/src/contacts_event.c b/src/contacts_event.c
index 7ca2228..6d791c3 100755
--- a/src/contacts_event.c
+++ b/src/contacts_event.c
@@ -44,6 +44,22 @@ int contact_birthday_create(contact_birthday_h* birthday)
return CONTACTS_ERROR_NONE;
}
+int contact_anniversary_create(contact_anniversary_h* anniversary)
+{
+ CONTACTS_NULL_ARG_CHECK(anniversary);
+
+ CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_EVENT);
+ if(ret == NULL) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ contacts_svc_value_set_int(ret, CTS_EVENT_VAL_TYPE_INT, CTS_EVENT_TYPE_ANNIVERSARY);
+ *anniversary = (contact_anniversary_h)ret;
+
+ return CONTACTS_ERROR_NONE;
+}
+
+
int contact_birthday_destroy(contact_birthday_h birthday)
{
CONTACTS_NULL_ARG_CHECK(birthday);
@@ -56,6 +72,17 @@ int contact_birthday_destroy(contact_birthday_h birthday)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contact_anniversary_destroy(contact_anniversary_h anniversary)
+{
+ CONTACTS_NULL_ARG_CHECK(anniversary);
+
+ if(contacts_svc_value_free((CTSvalue*)anniversary) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month, int *day)
{
@@ -76,6 +103,26 @@ int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month
return CONTACTS_ERROR_NONE;
}
+int contact_anniversary_get_date(contact_anniversary_h anniversary, int *year, int *month, int *day)
+{
+ CONTACTS_NULL_ARG_CHECK(anniversary);
+ CONTACTS_NULL_ARG_CHECK(year);
+ CONTACTS_NULL_ARG_CHECK(month);
+ CONTACTS_NULL_ARG_CHECK(day);
+
+ CTSvalue * CTSevent = (CTSvalue *)anniversary;
+ int date = contacts_svc_value_get_int(CTSevent, CTS_EVENT_VAL_DATE_INT);
+ if(date == 0) {
+ *year = *month = *day = 0;
+ } else {
+ *year = date / 10000;
+ *month = date % 10000 / 100;
+ *day = date % 100;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+
int contact_birthday_set_date(contact_birthday_h birthday, int year, int month, int day)
{
CONTACTS_NULL_ARG_CHECK(birthday);
@@ -86,3 +133,12 @@ int contact_birthday_set_date(contact_birthday_h birthday, int year, int month,
return CONTACTS_ERROR_NONE;
}
+int contact_anniversary_set_date(contact_anniversary_h anniversary, int year, int month, int day)
+{
+ CONTACTS_NULL_ARG_CHECK(anniversary);
+
+ CTSvalue * CTSevent = (CTSvalue *)anniversary;
+ contacts_svc_value_set_int(CTSevent, CTS_EVENT_VAL_DATE_INT, year*10000 + month*100 + day);
+
+ return CONTACTS_ERROR_NONE;
+}
diff --git a/src/contacts_group.c b/src/contacts_group.c
index 8d6cf61..e1e9e68 100755
--- a/src/contacts_group.c
+++ b/src/contacts_group.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <dlog.h>
+#include <contacts_private.h>
#ifdef LOG_TAG
#undef LOG_TAG
@@ -184,6 +185,18 @@ int contacts_group_set_ringtonepath(contacts_group_h group, const char* ringtone
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contacts_group_get_count(int address_book_db_id, int *count)
+{
+ CONTACTS_NULL_ARG_CHECK(count);
+
+ if(ADDRESS_BOOK_FILTER_ALL == address_book_db_id)
+ *count = contacts_svc_count(CTS_GET_COUNT_ALL_GROUP);
+ else
+ *count = contacts_svc_count_with_int(CTS_GET_COUNT_GROUPS_IN_ADDRESSBOOK, address_book_db_id);
+
+ return CONTACTS_ERROR_NONE;
+}
+
int contacts_group_get_member_count_from_db(contacts_group_h group, int* count)
{
CONTACTS_NULL_ARG_CHECK(group);
@@ -282,5 +295,229 @@ int contacts_group_query_group_by_address_book(contacts_foreach_query_group_cb c
}
contacts_svc_iter_remove(iter);
- return CONTACTS_ERROR_NONE;}
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_free_query_group_array(pcontacts_query_group_s *group_array)
+{
+ CONTACTS_NULL_ARG_CHECK(group_array);
+ int i=0;
+ while (group_array[i] != NULL) {
+ _contacts_free_query_group_struct_member_only((contacts_query_group_s *)group_array[i]);
+ free(group_array[i++]);
+ }
+ free(group_array);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_free_query_version_array(pcontacts_group_query_version_s *group_version_array)
+{
+ CONTACTS_NULL_ARG_CHECK(group_version_array);
+ int i=0;
+ while (group_version_array[i] != NULL) {
+ free(group_version_array[i++]);
+ }
+ free(group_version_array);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_search_group_by_address_book(int address_book_db_id, pcontacts_query_group_s **group_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(length);
+ CONTACTS_NULL_ARG_CHECK(group_array);
+
+ CTSiter *iter = NULL;
+
+ if (address_book_db_id < 0) {
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_GROUP, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ }
+ else {
+ if(CTS_SUCCESS != contacts_svc_get_list_with_int(CTS_LIST_GROUPS_OF_ADDRESSBOOK_ID, address_book_db_id, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ }
+
+ GSList *grouplist = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contacts_query_group_s *query_data = NULL;
+ query_data = malloc(sizeof(contacts_query_group_s));
+ if (NULL == query_data) {
+ g_slist_foreach(grouplist, _contacts_free_query_group_struct_all, NULL);
+ g_slist_free(grouplist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->group_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_GROUP_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_GROUP_ADDRESSBOOK_ID_INT);
+ query_data->group_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_GROUP_NAME_STR));
+ query_data->group_ringtonepath = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_GROUP_RINGTONE_STR));
+
+ grouplist = g_slist_append(grouplist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(grouplist);
+ if (0 == *length) {
+ g_slist_foreach(grouplist, _contacts_free_query_group_struct_all, NULL);
+ g_slist_free(grouplist);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *group_array = malloc(sizeof(pcontacts_query_group_s) * (*length + 1));
+ if (NULL == group_array) {
+ g_slist_foreach(grouplist, _contacts_free_query_group_struct_all, NULL);
+ g_slist_free(grouplist);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = grouplist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*group_array)[i++] = cursor->data;
+ (*group_array)[i] = NULL;
+ g_slist_free(grouplist);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_svc_get_updated_groups(int addressbook_id, int version, CTSiter **iter);
+int contacts_group_search_group_by_version(int address_book_db_id, int contacts_db_version,
+ pcontacts_group_query_version_s **group_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(length);
+ CONTACTS_NULL_ARG_CHECK(group_array);
+ CONTACTS_INVALID_ARG_CHECK(contacts_db_version < 0);
+
+ CTSiter *iter = NULL;
+ GSList *versionlist = NULL;
+ *length = 0;
+
+ if(CTS_SUCCESS != contacts_svc_get_updated_groups(address_book_db_id, contacts_db_version, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contacts_group_query_version_s *query_data = NULL;
+ query_data = malloc(sizeof(contacts_group_query_version_s));
+ if (NULL == query_data) {
+ g_slist_free(versionlist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->group_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_ID_INT);
+ query_data->changed_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_TYPE_INT);
+ query_data->contacts_db_version = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_VER_INT);
+ query_data->address_book_db_id = address_book_db_id;
+ versionlist = g_slist_append(versionlist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(versionlist);
+ if (0 == *length) {
+ g_slist_free(versionlist);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *group_array = malloc(sizeof(pcontacts_group_query_version_s) * (*length + 1));
+ if (NULL == group_array) {
+ g_slist_free(versionlist);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = versionlist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*group_array)[i++] = cursor->data;
+ (*group_array)[i] = NULL;
+ g_slist_free(versionlist);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_svc_group_get_relation_changes(int addressbook_id, int version, CTSiter **iter);
+int contacts_group_search_relation_changed_group_by_version(int address_book_db_id, int contacts_db_version,
+ pcontacts_group_query_version_s **group_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(length);
+ CONTACTS_NULL_ARG_CHECK(group_array);
+ CONTACTS_INVALID_ARG_CHECK(contacts_db_version < 0);
+
+ CTSiter *iter = NULL;
+ GSList *versionlist = NULL;
+ *length = 0;
+
+ if(CTS_SUCCESS != contacts_svc_group_get_relation_changes(address_book_db_id, contacts_db_version, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contacts_group_query_version_s *query_data = NULL;
+ query_data = malloc(sizeof(contacts_group_query_version_s));
+ if (NULL == query_data) {
+ g_slist_free(versionlist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->group_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_ID_INT);
+ query_data->changed_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_TYPE_INT);
+ query_data->contacts_db_version = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_VER_INT);
+ query_data->address_book_db_id = address_book_db_id;
+
+ versionlist = g_slist_append(versionlist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(versionlist);
+ if (0 == *length) {
+ g_slist_free(versionlist);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *group_array = malloc(sizeof(pcontacts_group_query_version_s) * (*length + 1));
+ if (NULL == group_array) {
+ g_slist_free(versionlist);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = versionlist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*group_array)[i++] = cursor->data;
+ (*group_array)[i] = NULL;
+ g_slist_free(versionlist);
+
+ return CONTACTS_ERROR_NONE;
+}
diff --git a/src/contacts_messenger.c b/src/contacts_messenger.c
index 9d38375..89e167c 100755
--- a/src/contacts_messenger.c
+++ b/src/contacts_messenger.c
@@ -101,6 +101,26 @@ int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contact_messenger_get_provider_name(contact_messenger_h messenger, char **provider_name)
+{
+ CONTACTS_NULL_ARG_CHECK(messenger);
+ CONTACTS_NULL_ARG_CHECK(provider_name);
+
+ *provider_name = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_SERVICE_NAME_STR));
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_messenger_set_provider_name(contact_messenger_h messenger, const char *provider_name)
+{
+ CONTACTS_NULL_ARG_CHECK(messenger);
+
+ if (contacts_svc_value_set_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_SERVICE_NAME_STR, provider_name) == CTS_SUCCESS)
+ return CONTACTS_ERROR_NONE;
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
int contact_messenger_iterator_next(contact_messenger_iterator_h* messenger_iterator, contact_messenger_h* messenger)
{
CONTACTS_NULL_ARG_CHECK(messenger_iterator);
diff --git a/src/contacts_number.c b/src/contacts_number.c
index 408f056..1f57a1e 100755
--- a/src/contacts_number.c
+++ b/src/contacts_number.c
@@ -61,7 +61,7 @@ int contact_number_destroy(contact_number_h number)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
-int contact_number_get_type(contact_number_h number, contact_number_type_e* type)
+int contact_number_get_type(contact_number_h number, unsigned int* type)
{
if(number == NULL || type == NULL) {
LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
@@ -72,7 +72,7 @@ int contact_number_get_type(contact_number_h number, contact_number_type_e* type
return CONTACTS_ERROR_NONE;
}
-int contact_number_set_type(contact_number_h number, contact_number_type_e type)
+int contact_number_set_type(contact_number_h number, unsigned int type)
{
if(number == NULL) {
LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
diff --git a/src/contacts_private.c b/src/contacts_private.c
index 78a7561..2b2d5c9 100755
--- a/src/contacts_private.c
+++ b/src/contacts_private.c
@@ -28,10 +28,11 @@ void _contacts_set_query_person_struct(contact_query_name_s* contact, CTSvalue*
contact->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_FIRST_STR));
contact->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_LAST_STR));
contact->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_DISPLAY_STR));
+ contact->address_book_db_id = contacts_svc_value_get_int(value, CTS_LIST_CONTACT_ADDRESSBOOK_ID_INT);
contact->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_CONTACT_IMG_PATH_STR));
}
-void _contacts_free_query_preson_struct_member_only(contact_query_name_s* person)
+void _contacts_free_query_person_struct_member_only(contact_query_name_s* person)
{
person->contact_db_id = -1;
_contacts_safe_free(person->first_name);
@@ -50,7 +51,18 @@ void _contacts_free_query_number_struct_member_only(contact_query_number_s* cont
_contacts_safe_free(contact->contact_image_path);
}
-void _contacts_free_query_preson_struct_all(gpointer data, gpointer user_data)
+void _contacts_free_query_email_struct_member_only(contact_query_email_s* email)
+{
+ email->contact_db_id = -1;
+ _contacts_safe_free(email->first_name);
+ _contacts_safe_free(email->last_name);
+ _contacts_safe_free(email->display_name);
+ _contacts_safe_free(email->contact_image_path);
+ _contacts_safe_free(email->email_address);
+}
+
+
+void _contacts_free_query_person_struct_all(gpointer data, gpointer user_data)
{
if(data == NULL)
return;
@@ -72,8 +84,41 @@ void _contacts_free_query_number_struct_all(gpointer data, gpointer user_data)
_contacts_safe_free(person->first_name);
_contacts_safe_free(person->last_name);
_contacts_safe_free(person->display_name);
- _contacts_safe_free(person->phone_number);
_contacts_safe_free(person->contact_image_path);
+ _contacts_safe_free(person->phone_number);
+ _contacts_safe_free(data);
+}
+
+void _contacts_free_query_email_struct_all(gpointer data, gpointer user_data)
+{
+ if(data == NULL)
+ return;
+ contact_query_email_s* email = (contact_query_email_s*)data;
+ email->contact_db_id = -1;
+ _contacts_safe_free(email->first_name);
+ _contacts_safe_free(email->last_name);
+ _contacts_safe_free(email->display_name);
+ _contacts_safe_free(email->contact_image_path);
+ _contacts_safe_free(email->email_address);
+ _contacts_safe_free(data);
+}
+
+
+void _contacts_free_query_group_struct_member_only(contacts_query_group_s* group)
+{
+ group->group_db_id = -1;
+ _contacts_safe_free(group->group_name);
+ _contacts_safe_free(group->group_ringtonepath);
+}
+
+void _contacts_free_query_group_struct_all(gpointer data, gpointer user_data)
+{
+ if(data == NULL)
+ return;
+ contacts_query_group_s* group = (contacts_query_group_s*)data;
+ group->group_db_id = -1;
+ _contacts_safe_free(group->group_name);
+ _contacts_safe_free(group->group_ringtonepath);
_contacts_safe_free(data);
}
diff --git a/src/contacts_search.c b/src/contacts_search.c
index d50232c..f48912e 100755
--- a/src/contacts_search.c
+++ b/src/contacts_search.c
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
#include <tizen.h>
#include <stdlib.h>
#include <contacts.h>
@@ -47,7 +46,7 @@ int contact_foreach_contact_from_db(contact_foreach_query_name_cb cb, void* user
contact_query_name_s *query_data = NULL;
query_data = malloc(sizeof(contact_query_name_s));
if(query_data == NULL) {
- g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
+ g_slist_foreach(contactlist, _contacts_free_query_person_struct_all, NULL);
g_slist_free(contactlist);
contacts_svc_value_free(foreach_data);
contacts_svc_iter_remove(iter);
@@ -68,167 +67,12 @@ int contact_foreach_contact_from_db(contact_foreach_query_name_cb cb, void* user
break;
}
}
- g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
- g_slist_free(contactlist);
-
- return CONTACTS_ERROR_NONE;
-}
-
-int contact_get_all_contact_from_db(contact_query_name_array *contact_array, int *length)
-{
- CONTACTS_NULL_ARG_CHECK(contact_array);
- CONTACTS_NULL_ARG_CHECK(length);
-
- *contact_array = NULL;
- *length = 0;
- CTSiter *iter = NULL;
- if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter)) {
- LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
- return CONTACTS_ERROR_DB_FAILED;
- }
-
- GSList *contactlist = NULL;
- while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
- CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
-
- contact_query_name_s *query_data = NULL;
- query_data = malloc(sizeof(contact_query_name_s));
- if(query_data == NULL) {
- g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
- g_slist_free(contactlist);
- contacts_svc_value_free(foreach_data);
- contacts_svc_iter_remove(iter);
- LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
- return CONTACTS_ERROR_OUT_OF_MEMORY;
- }
- _contacts_set_query_person_struct(query_data, foreach_data);
- contactlist = g_slist_append(contactlist, query_data);
-
- contacts_svc_value_free(foreach_data);
- }
- contacts_svc_iter_remove(iter);
-
- *length = g_slist_length(contactlist);
- if(*length == 0) {
- g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
- g_slist_free(contactlist);
- return CONTACTS_ERROR_NONE;
- }
- *contact_array = malloc(sizeof(contact_query_name_s*) * (*length));
- if(*contact_array == NULL) {
- g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
- g_slist_free(contactlist);
- LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
- return CONTACTS_ERROR_OUT_OF_MEMORY;
- }
-
- GSList *cursor = contactlist;
- contact_query_name_s** pcontact_array = *contact_array;
- int i = 0;
- for(;cursor;cursor=g_slist_next(cursor)) {
- pcontact_array[i] = (contact_query_name_s*)(cursor->data);
- i++;
- }
- g_slist_free(contactlist);
-
- return CONTACTS_ERROR_NONE;
-}
-
-int contact_query_name_array_free(contact_query_name_array contact_array, int length)
-{
- CONTACTS_NULL_ARG_CHECK(contact_array);
- CONTACTS_INVALID_ARG_CHECK(length < 0);
-
- int i = 0;
- for(;i<length; i++) {
- _contacts_free_query_preson_struct_member_only(contact_array[i]);
- free(contact_array[i]);
- }
-
- free(contact_array);
- return CONTACTS_ERROR_NONE;
-}
-
-int contact_get_number_contact_from_db(contact_query_number_array *contact_number_array, int *length)
-{
- CONTACTS_NULL_ARG_CHECK(contact_number_array);
- CONTACTS_NULL_ARG_CHECK(length);
-
- *contact_number_array = NULL;
- *length = 0;
- CTSiter *iter = NULL;
- if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_NUMBER, &iter)) {
- LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
- return CONTACTS_ERROR_DB_FAILED;
- }
-
- GSList *contactlist = NULL;
- while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
- CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
-
- contact_query_number_s *query_data = NULL;
- query_data = malloc(sizeof(contact_query_number_s));
- if(query_data == NULL) {
- g_slist_foreach(contactlist, _contacts_free_query_number_struct_all, NULL);
- g_slist_free(contactlist);
- contacts_svc_value_free(foreach_data);
- contacts_svc_iter_remove(iter);
- LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
- return CONTACTS_ERROR_OUT_OF_MEMORY;
- }
- query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ID_INT);
- query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_FIRST_STR));
- query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_LAST_STR));
- query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_DISPLAY_STR));
- query_data->phone_number = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_NUM_OR_EMAIL_STR));
- query_data->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_IMG_PATH_STR));
-
- contactlist = g_slist_append(contactlist, query_data);
-
- contacts_svc_value_free(foreach_data);
- }
- contacts_svc_iter_remove(iter);
-
- *length = g_slist_length(contactlist);
- if(*length == 0) {
- g_slist_foreach(contactlist, _contacts_free_query_number_struct_all, NULL);
- g_slist_free(contactlist);
- return CONTACTS_ERROR_NONE;
- }
- *contact_number_array = malloc(sizeof(contact_query_number_s*) * (*length));
- if(*contact_number_array == NULL) {
- g_slist_foreach(contactlist, _contacts_free_query_number_struct_all, NULL);
- g_slist_free(contactlist);
- LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
- return CONTACTS_ERROR_OUT_OF_MEMORY;
- }
-
- GSList *cursor = contactlist;
- contact_query_number_s** pcontact_array = *contact_number_array;
- int i = 0;
- for(;cursor;cursor=g_slist_next(cursor)) {
- pcontact_array[i] = (contact_query_number_s*)(cursor->data);
- i++;
- }
+ g_slist_foreach(contactlist, _contacts_free_query_person_struct_all, NULL);
g_slist_free(contactlist);
return CONTACTS_ERROR_NONE;
}
-int contact_query_number_array_free(contact_query_number_array contact_number_array, int length)
-{
- CONTACTS_NULL_ARG_CHECK(contact_number_array);
- CONTACTS_INVALID_ARG_CHECK(length < 0);
-
- int i = 0;
- for(;i<length; i++) {
- _contacts_free_query_number_struct_member_only(contact_number_array[i]);
- }
-
- free(contact_number_array);
- return CONTACTS_ERROR_NONE;
-}
-
int contact_foreach_favorite_contact_from_db(contact_foreach_query_favorites_cb cb, void* user_data)
{
CONTACTS_NULL_ARG_CHECK(cb);
@@ -296,7 +140,7 @@ int contact_foreach_frequent_contact_from_db(contact_foreach_query_name_cb callb
func_ret = callback(&query_data, user_data);
contacts_svc_value_free(foreach_data);
- _contacts_free_query_preson_struct_member_only(&query_data);
+ _contacts_free_query_person_struct_member_only(&query_data);
if(func_ret == 0) {
break;
@@ -330,7 +174,7 @@ int contact_query_contact_by_name(contact_foreach_query_name_cb cb, const char*
func_ret = cb(&query_data, user_data);
contacts_svc_value_free(foreach_data);
- _contacts_free_query_preson_struct_member_only(&query_data);
+ _contacts_free_query_person_struct_member_only(&query_data);
if(func_ret == 0) {
break;
@@ -364,7 +208,7 @@ int contact_query_contact_by_group(contact_foreach_query_name_cb cb, int group_i
func_ret = cb(&query_data, user_data);
contacts_svc_value_free(foreach_data);
- _contacts_free_query_preson_struct_member_only(&query_data);
+ _contacts_free_query_person_struct_member_only(&query_data);
if(func_ret == 0) {
break;
@@ -378,7 +222,6 @@ int contact_query_contact_by_group(contact_foreach_query_name_cb cb, int group_i
int contact_query_contact_by_address_book(contact_foreach_query_name_cb callback, int address_book_db_id, void *user_data)
{
CONTACTS_NULL_ARG_CHECK(callback);
- CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
CTSiter *iter = NULL;
int func_ret = 0;
@@ -399,7 +242,7 @@ int contact_query_contact_by_address_book(contact_foreach_query_name_cb callback
func_ret = callback(&query_data, user_data);
contacts_svc_value_free(foreach_data);
- _contacts_free_query_preson_struct_member_only(&query_data);
+ _contacts_free_query_person_struct_member_only(&query_data);
if(func_ret == 0) {
break;
@@ -499,7 +342,6 @@ int contact_query_contact_by_number(contact_foreach_query_number_cb cb, const ch
int contact_query_contact_by_version(contact_foreach_query_version_cb cb, int address_book_db_id, int contacts_db_version, void* user_data)
{
CONTACTS_NULL_ARG_CHECK(cb);
- CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
CTSiter *iter = NULL;
int func_ret = 0;
@@ -535,7 +377,6 @@ int contact_query_contact_by_version(contact_foreach_query_version_cb cb, int ad
int contact_query_contact_not_related_to_group(contact_foreach_query_name_cb callback, int address_book_db_id, void *user_data)
{
CONTACTS_NULL_ARG_CHECK(callback);
- CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
CTSiter *iter = NULL;
int func_ret = 0;
@@ -556,7 +397,7 @@ int contact_query_contact_not_related_to_group(contact_foreach_query_name_cb cal
func_ret = callback(&query_data, user_data);
contacts_svc_value_free(foreach_data);
- _contacts_free_query_preson_struct_member_only(&query_data);
+ _contacts_free_query_person_struct_member_only(&query_data);
if(func_ret == 0) {
break;
@@ -567,3 +408,648 @@ int contact_query_contact_not_related_to_group(contact_foreach_query_name_cb cal
return CONTACTS_ERROR_NONE;
}
+
+int contact_free_query_name_array(pcontact_query_name_s* contact_array)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_array);
+ int i=0;
+ while (contact_array[i] != NULL) {
+ _contacts_free_query_person_struct_member_only((contact_query_name_s *)contact_array[i]);
+ free(contact_array[i++]);
+ }
+ free(contact_array);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_free_query_number_array(pcontact_query_number_s *contact_number_array)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_number_array);
+ int i=0;
+ while (contact_number_array[i] != NULL) {
+ _contacts_free_query_number_struct_member_only((contact_query_number_s *)contact_number_array[i]);
+ free(contact_number_array[i++]);
+ }
+ free(contact_number_array);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_free_query_email_array(pcontact_query_email_s *contact_email_array)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_email_array);
+ int i=0;
+ while (contact_email_array[i] != NULL) {
+ _contacts_free_query_email_struct_member_only((contact_query_email_s *)contact_email_array[i]);
+ free(contact_email_array[i++]);
+ }
+ free(contact_email_array);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_free_query_version_array(pcontact_query_version_s *contact_version_array)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_version_array);
+ int i=0;
+ while (contact_version_array[i] != NULL) {
+ free(contact_version_array[i++]);
+ }
+ free(contact_version_array);
+ return CONTACTS_ERROR_NONE;
+}
+
+
+int contact_search_contact_by_address_book(int address_book_db_id, pcontact_query_name_s **contact_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+
+ CTSiter *iter = NULL;
+ CTSfilter *filter = NULL;
+
+ if (ADDRESS_BOOK_FILTER_ALL == address_book_db_id)
+ filter = contacts_svc_list_filter_new(CTS_FILTERED_ALL_CONTACT_OSP, CTS_LIST_FILTER_NONE);
+ else
+ filter = contacts_svc_list_filter_new(CTS_FILTERED_ALL_CONTACT_OSP, CTS_LIST_FILTER_ADDRESBOOK_ID_INT, address_book_db_id, CTS_LIST_FILTER_NONE);
+
+ if (CTS_SUCCESS != contacts_svc_get_list_with_filter(filter, &iter)) {
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *list = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_name_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_name_s));
+ if (NULL == query_data) {
+ g_slist_foreach(list, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_OSP_CONTACT_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_OSP_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_OSP_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_OSP_DISPLAY_STR));
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_OSP_ADDRESSBOOK_ID_INT);
+ query_data->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_OSP_IMG_PATH_STR));
+
+ list = g_slist_append(list, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(list);
+ if (0 == *length) {
+ g_slist_foreach(list, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_array = malloc(sizeof(pcontact_query_name_s) * (*length + 1));
+ if (NULL == *contact_array) {
+ g_slist_foreach(list, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = list;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_array)[i++] = cursor->data;
+ (*contact_array)[i] = NULL;
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_search_contact_with_default_number_by_address_book(int address_book_db_id, pcontact_query_number_s **contact_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+
+ CTSiter *iter = NULL;
+ CTSfilter *filter = NULL;
+
+ if (ADDRESS_BOOK_FILTER_ALL == address_book_db_id)
+ filter = contacts_svc_list_filter_new(CTS_FILTERED_ALL_CONTACT_HAD_NUMBER, CTS_LIST_FILTER_NONE);
+ else
+ filter = contacts_svc_list_filter_new(CTS_FILTERED_ALL_CONTACT_HAD_NUMBER, CTS_LIST_FILTER_ADDRESBOOK_ID_INT,
+ address_book_db_id, CTS_LIST_FILTER_NONE);
+
+ if (CTS_SUCCESS != contacts_svc_get_list_with_filter(filter, &iter)) {
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *list = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_number_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_number_s));
+ if (NULL == query_data) {
+ g_slist_foreach(list, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_OSP_ADDRESSBOOK_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_DISPLAY_STR));
+ query_data->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_IMG_PATH_STR));
+ query_data->phone_number = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_NUM_OR_EMAIL_STR));
+
+ list = g_slist_append(list, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(list);
+ if (0 == *length) {
+ g_slist_foreach(list, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_array = malloc(sizeof(pcontact_query_number_s) * (*length + 1));
+ if (NULL == *contact_array) {
+ g_slist_foreach(list, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = list;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_array)[i++] = cursor->data;
+ (*contact_array)[i] = NULL;
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_all_phone_number(pcontact_query_number_s **phone_number_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(phone_number_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+
+ CTSiter *iter = NULL;
+
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_NUMBER, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ GSList *list = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_number_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_number_s));
+
+ if (NULL == query_data) {
+ g_slist_foreach(list, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ADDRESSBOOK_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_DISPLAY_STR));
+ query_data->contact_image_path = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_IMG_PATH_STR));
+ query_data->phone_number = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_NUM_OR_EMAIL_STR));
+
+ list = g_slist_append(list, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(list);
+ if (0 == *length) {
+ g_slist_foreach(list, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(list);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *phone_number_array = malloc(sizeof(pcontact_query_number_s) * (*length + 1));
+ if (NULL == *phone_number_array) {
+ g_slist_foreach(list, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(list);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = list;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*phone_number_array)[i++] = cursor->data;
+ (*phone_number_array)[i] = NULL;
+ g_slist_free(list);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_search_contact_by_email(int address_book_db_id, const char *email_to_find, pcontact_query_email_s **contact_email_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(email_to_find);
+ CONTACTS_NULL_ARG_CHECK(contact_email_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+
+ CTSiter *iter = NULL;
+ CTSfilter *filter = NULL;
+
+ if (ADDRESS_BOOK_FILTER_ALL == address_book_db_id)
+ filter = contacts_svc_list_str_filter_new(CTS_FILTERED_EMAILINFOS_WITH_EMAIL, email_to_find, CTS_LIST_FILTER_NONE);
+ else
+ filter = contacts_svc_list_str_filter_new(CTS_FILTERED_EMAILINFOS_WITH_EMAIL, email_to_find,
+ CTS_LIST_FILTER_ADDRESBOOK_ID_INT, address_book_db_id, CTS_LIST_FILTER_NONE);
+
+ if (CTS_SUCCESS != contacts_svc_get_list_with_filter(filter, &iter)) {
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *list = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_email_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_email_s));
+ if (NULL == query_data) {
+ g_slist_foreach(list, _contacts_free_query_email_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_EMAIL_CONTACT_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_OSP_ADDRESSBOOK_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_DISPLAY_STR));
+ query_data->contact_image_path= _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_CONTACT_IMG_PATH_STR));
+ query_data->email_address = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_EMAIL_ADDR_STR));
+
+ list = g_slist_append(list, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(list);
+ if (0 == *length) {
+ g_slist_foreach(list, _contacts_free_query_email_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_email_array = malloc(sizeof(pcontact_query_email_s) * (*length + 1));
+ if (NULL == *contact_email_array) {
+ g_slist_foreach(list, _contacts_free_query_email_struct_all, NULL);
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = list;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_email_array)[i++] = cursor->data;
+ (*contact_email_array)[i] = NULL;
+ g_slist_free(list);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_search_contact_by_number(int address_book_db_id, const char *number_to_find, pcontact_query_number_s **contact_number_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(number_to_find);
+ CONTACTS_NULL_ARG_CHECK(contact_number_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+
+ CTSiter *iter = NULL;
+ CTSfilter *filter = NULL;
+
+ if (ADDRESS_BOOK_FILTER_ALL == address_book_db_id)
+ filter = contacts_svc_list_str_filter_new(CTS_FILTERED_NUMBERINFOS_WITH_NUM, number_to_find, CTS_LIST_FILTER_NONE);
+ else
+ filter = contacts_svc_list_str_filter_new(CTS_FILTERED_NUMBERINFOS_WITH_NUM, number_to_find,
+ CTS_LIST_FILTER_ADDRESBOOK_ID_INT, address_book_db_id, CTS_LIST_FILTER_NONE);
+
+ if (CTS_SUCCESS != contacts_svc_get_list_with_filter(filter, &iter)) {
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *numlist = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_number_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_number_s));
+ if (NULL == query_data) {
+ g_slist_foreach(numlist, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(numlist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_NUM_CONTACT_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_OSP_ADDRESSBOOK_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_DISPLAY_STR));
+ query_data->contact_image_path= _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_CONTACT_IMG_PATH_STR));
+ query_data->phone_number = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_NUM_NUMBER_STR));
+
+ numlist = g_slist_append(numlist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(numlist);
+ if (0 == *length) {
+ g_slist_foreach(numlist, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(numlist);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_number_array = malloc(sizeof(pcontact_query_number_s) * (*length + 1));
+ if (NULL == *contact_number_array) {
+ g_slist_foreach(numlist, _contacts_free_query_number_struct_all, NULL);
+ g_slist_free(numlist);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = numlist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_number_array)[i++] = cursor->data;
+ (*contact_number_array)[i] = NULL;
+ g_slist_free(numlist);
+ contacts_svc_list_filter_free(filter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_search_contact_by_name(int address_book_db_id, const char *name_to_find, pcontact_query_name_s **contact_name_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(name_to_find);
+ CONTACTS_NULL_ARG_CHECK(contact_name_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+
+ CTSiter *iter = NULL;
+ CTSfilter *filter = NULL;
+
+ if (ADDRESS_BOOK_FILTER_ALL == address_book_db_id)
+ filter = contacts_svc_list_str_filter_new(CTS_FILTERED_CONTACTS_WITH_NAME, name_to_find, CTS_LIST_FILTER_NONE);
+ else
+ filter = contacts_svc_list_str_filter_new(CTS_FILTERED_CONTACTS_WITH_NAME, name_to_find,
+ CTS_LIST_FILTER_ADDRESBOOK_ID_INT, address_book_db_id, CTS_LIST_FILTER_NONE);
+
+ if (CTS_SUCCESS != contacts_svc_get_list_with_filter(filter, &iter)) {
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *namelist = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_name_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_name_s));
+ if (NULL == query_data) {
+ g_slist_foreach(namelist, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(namelist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_OSP_ADDRESSBOOK_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_DISPLAY_STR));
+ query_data->contact_image_path= _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_IMG_PATH_STR));
+
+ namelist = g_slist_append(namelist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(namelist);
+ if (0 == *length) {
+ g_slist_foreach(namelist, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(namelist);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_name_array = malloc(sizeof(pcontact_query_name_s) * (*length + 1));
+ if (NULL == *contact_name_array) {
+ g_slist_foreach(namelist, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(namelist);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = namelist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_name_array)[i++] = cursor->data;
+ (*contact_name_array)[i] = NULL;
+ g_slist_free(namelist);
+ contacts_svc_list_filter_free(filter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_search_contact_by_group(int group_db_id, pcontact_query_name_s **contact_name_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(contact_name_array);
+ CONTACTS_NULL_ARG_CHECK(length);
+ CONTACTS_INVALID_ARG_CHECK(group_db_id < 0);
+
+ CTSiter *iter = NULL;
+ CTSfilter *filter = NULL;
+
+ filter = contacts_svc_list_filter_new(CTS_FILTERED_ALL_CONTACT, CTS_LIST_FILTER_GROUP_ID_INT, group_db_id, CTS_LIST_FILTER_NONE);
+
+ if (CTS_SUCCESS != contacts_svc_get_list_with_filter(filter, &iter)) {
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ GSList *namelist = NULL;
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_name_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_name_s));
+ if (NULL == query_data) {
+ g_slist_foreach(namelist, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(namelist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ID_INT);
+ query_data->address_book_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CONTACT_ADDRESSBOOK_ID_INT);
+ query_data->first_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_FIRST_STR));
+ query_data->last_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_LAST_STR));
+ query_data->display_name = _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_DISPLAY_STR));
+ query_data->contact_image_path= _contacts_safe_strdup(contacts_svc_value_get_str(foreach_data, CTS_LIST_CONTACT_IMG_PATH_STR));
+
+ namelist = g_slist_append(namelist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(namelist);
+ if (0 == *length) {
+ g_slist_foreach(namelist, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(namelist);
+ contacts_svc_list_filter_free(filter);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_name_array = malloc(sizeof(pcontact_query_name_s) * (*length + 1));
+ if (NULL == *contact_name_array) {
+ g_slist_foreach(namelist, _contacts_free_query_person_struct_all, NULL);
+ g_slist_free(namelist);
+ contacts_svc_list_filter_free(filter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = namelist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_name_array)[i++] = cursor->data;
+ (*contact_name_array)[i] = NULL;
+ g_slist_free(namelist);
+ contacts_svc_list_filter_free(filter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_search_contact_by_version(int address_book_db_id, int contacts_db_version, pcontact_query_version_s **contact_version_array, int *length)
+{
+ CONTACTS_NULL_ARG_CHECK(length);
+ CONTACTS_NULL_ARG_CHECK(contact_version_array);
+ CONTACTS_INVALID_ARG_CHECK(contacts_db_version < 0);
+
+ CTSiter *iter = NULL;
+ GSList *versionlist = NULL;
+ *length = 0;
+
+ if(CTS_SUCCESS != contacts_svc_get_updated_contacts(address_book_db_id, contacts_db_version, &iter)) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ while(CTS_SUCCESS == contacts_svc_iter_next(iter)) {
+ CTSvalue* foreach_data = contacts_svc_iter_get_info(iter);
+ if(foreach_data == NULL) {
+ break;
+ }
+
+ contact_query_version_s *query_data = NULL;
+ query_data = malloc(sizeof(contact_query_version_s));
+ if (NULL == query_data) {
+ g_slist_free(versionlist);
+ contacts_svc_value_free(foreach_data);
+ contacts_svc_iter_remove(iter);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+ query_data->contact_db_id = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_ID_INT);
+ query_data->changed_type = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_TYPE_INT);
+ query_data->contacts_db_version = contacts_svc_value_get_int(foreach_data, CTS_LIST_CHANGE_VER_INT);
+ query_data->address_book_db_id = address_book_db_id;
+
+ versionlist = g_slist_append(versionlist, query_data);
+ contacts_svc_value_free(foreach_data);
+ }
+ contacts_svc_iter_remove(iter);
+
+ *length = g_slist_length(versionlist);
+ if (0 == *length) {
+ g_slist_free(versionlist);
+ return CONTACTS_ERROR_NONE;
+ }
+
+ *contact_version_array = malloc(sizeof(pcontact_query_version_s) * (*length + 1));
+ if (NULL == *contact_version_array) {
+ g_slist_free(versionlist);
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ GSList *cursor = versionlist;
+ int i = 0;
+ for (;cursor;cursor=g_slist_next(cursor))
+ (*contact_version_array)[i++] = cursor->data;
+ (*contact_version_array)[i] = NULL;
+ g_slist_free(versionlist);
+ return CONTACTS_ERROR_NONE;
+}
+