+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
/**
* @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
* @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()
* @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()
* @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()
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
* @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()
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.
* @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();
*/
/**
- * @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.
* @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
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
* @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
* @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
* @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);
*/
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
*
* @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()
* @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()
/**
* @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
*
*
* @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()
*/
* @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.
*
*
* @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);
*
* @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
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
* @see contact_set_ringtonepath()
*/
int contact_get_ringtonepath(contact_h contact, char **ringtone_path);
+
/**
* @brief Sets the ringtone path to the contact handle.
*
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
*
*
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);
+
+/**
* @}
*/
* @}
*/
+/**
+ * @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
* @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()
*/
* @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()
*/
* @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()
*/
*
* @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()
*/
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
*
* @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);
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);
+
+/**
* @}
*/
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
/**
* @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
*
*
* @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
*
* @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
*
* @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.
int id;
int type;
int date;
- }_contact_birthday_s;//CTS_EVENT_VAL_
+ }_contact_event_s;//CTS_EVENT_VAL_
/**
* @internal
}
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);
* @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);
* @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);
* @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
*
* @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_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.
*
* @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()
*
*
* @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()
*/
*
* @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.
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
*
*
* @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.
*
* @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);
/**
* @}
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;
+
/**
* @}
*/
} 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;
+
+/**
* @}
*/
* @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.
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()
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.
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.
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.
*/
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.
*
* @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.
*
* @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);
/**
*/
/**
- * @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
* @{
*/
#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()
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
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)
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);
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;
}
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);
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);
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);
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);
*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;
}
*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);
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);
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)
{
return CONTACTS_ERROR_NONE;
}
-
-
int contact_get_from_vcard(const char *vcard_stream, contact_h *contact)
{
CONTACTS_NULL_ARG_CHECK(vcard_stream);
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;
+}
+
+
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);
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)
{
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);
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;
+}
#include <stdlib.h>
#include <string.h>
#include <dlog.h>
+#include <contacts_private.h>
#ifdef LOG_TAG
#undef LOG_TAG
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);
}
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;
+}
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);
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);
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);
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);
_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;
_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);
}
* limitations under the License.
*/
-
#include <tizen.h>
#include <stdlib.h>
#include <contacts.h>
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);
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);
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;
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;
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;
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;
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;
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;
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;
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;
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;
+}
+