summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/contacts.c226
-rwxr-xr-xsrc/contacts_address.c40
-rwxr-xr-xsrc/contacts_company.c25
-rwxr-xr-xsrc/contacts_contact.c404
-rwxr-xr-xsrc/contacts_email.c54
-rwxr-xr-xsrc/contacts_event.c25
-rwxr-xr-xsrc/contacts_group.c134
-rwxr-xr-xsrc/contacts_messenger.c43
-rwxr-xr-xsrc/contacts_private.c40
-rwxr-xr-xsrc/contacts_search.c302
10 files changed, 865 insertions, 428 deletions
diff --git a/src/contacts.c b/src/contacts.c
index db041f4..35a5222 100755
--- a/src/contacts.c
+++ b/src/contacts.c
@@ -21,6 +21,7 @@
#include <contacts-svc.h>
#include <contacts_private.h>
#include <dlog.h>
+#include <string.h>
#ifdef LOG_TAG
#undef LOG_TAG
@@ -51,10 +52,7 @@ int contacts_disconnect(void)
int contacts_get_db_version(int* contacts_db_version)
{
- if(contacts_db_version == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contacts_db_version);
if(contacts_svc_begin_trans() != CTS_SUCCESS) {
LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
@@ -66,13 +64,34 @@ int contacts_get_db_version(int* contacts_db_version)
return CONTACTS_ERROR_NONE;
}
-int contacts_add_contact_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
+int contacts_add_address_book_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_ADDRESSBOOK_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_address_book_db_changed_cb(contacts_db_changed_cb callback)
{
- if(callback == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_ADDRESSBOOK_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;
+}
+
+int contacts_add_contact_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, callback, user_data) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
}
@@ -83,10 +102,7 @@ int contacts_add_contact_db_changed_cb(contacts_db_changed_cb callback, void *us
int contacts_remove_contact_db_changed_cb(contacts_db_changed_cb callback)
{
- if(callback == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(callback);
if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE, callback) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -98,10 +114,7 @@ int contacts_remove_contact_db_changed_cb(contacts_db_changed_cb callback)
int contacts_add_favorite_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
{
- if(callback == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(callback);
if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_FAVORITE_CHANGE, callback, user_data) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -113,11 +126,8 @@ int contacts_add_favorite_db_changed_cb(contacts_db_changed_cb callback, void *u
int contacts_remove_favorite_db_changed_cb(contacts_db_changed_cb callback)
{
- if(callback == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
-
+ CONTACTS_NULL_ARG_CHECK(callback);
+
if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_FAVORITE_CHANGE, callback) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
}
@@ -128,10 +138,7 @@ int contacts_remove_favorite_db_changed_cb(contacts_db_changed_cb callback)
int contacts_add_group_db_changed_cb(contacts_db_changed_cb callback, void *user_data)
{
- if(callback == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(callback);
if(contacts_svc_subscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, callback, user_data) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -143,10 +150,7 @@ int contacts_add_group_db_changed_cb(contacts_db_changed_cb callback, void *user
int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback)
{
- if(callback == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(callback);
if(contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_GROUP_CHANGE, callback) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -156,3 +160,167 @@ int contacts_remove_group_db_changed_cb(contacts_db_changed_cb callback)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contacts_import_all_contacts_from_sim_card()
+{
+ int ret = contacts_svc_import_sim();
+ if(CTS_ERR_DB_FAILED == ret || CTS_ERR_DB_NOT_OPENED == ret) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_address_book_foreach_address_book_from_db(contacts_foreach_query_address_book_cb callback, void *user_data)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_ADDRESSBOOK, &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_query_address_book_s query_data;
+ _contacts_set_query_address_book_struct(&query_data, foreach_data);
+
+ func_ret = callback(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_address_book_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+
+ contacts_svc_iter_remove(iter);
+ return CONTACTS_ERROR_NONE;
+}
+
+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)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_int(CTS_LIST_ADDRESSBOOKS_OF_ACCOUNT_ID, account_db_id, &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_query_address_book_s query_data;
+ _contacts_set_query_address_book_struct(&query_data, foreach_data);
+
+ func_ret = callback(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_address_book_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_address_book_get_from_db(int address_book_db_id, contacts_address_book_h *address_book)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+
+ int ret = CTS_SUCCESS;
+ if((ret=contacts_svc_get_addressbook(address_book_db_id, (CTSvalue**)address_book)) == CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_DB_FAILED || ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_RECORD_NOT_FOUND) {
+ 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_destroy(contacts_address_book_h address_book)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+
+ if(contacts_svc_value_free((CTSvalue*)address_book) == 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_address_book_get_db_id(contacts_address_book_h address_book, int *address_book_db_id)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+ CONTACTS_NULL_ARG_CHECK(address_book_db_id);
+
+ *address_book_db_id = 0;
+ *address_book_db_id = contacts_svc_value_get_int((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_ID_INT);
+ if(*address_book_db_id < 0) {
+ *address_book_db_id = 0;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_address_book_get_name(contacts_address_book_h address_book, char **address_book_name)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+ CONTACTS_NULL_ARG_CHECK(address_book_name);
+
+ *address_book_name = NULL;
+ *address_book_name = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_NAME_STR));
+
+ 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);
+ CONTACTS_NULL_ARG_CHECK(is_read_only);
+
+ *is_read_only = false;
+ *is_read_only = contacts_svc_value_get_int((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_MODE_INT);
+
+ 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);
+ CONTACTS_NULL_ARG_CHECK(address_book_type);
+
+ *address_book_type = CONTACTS_ADDRESS_BOOK_TYPE_OTHER;
+ *address_book_type = contacts_svc_value_get_int((CTSvalue*)address_book, CTS_ADDRESSBOOK_VAL_ACC_TYPE_INT);
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_address_book_get_account_db_id(contacts_address_book_h address_book, int *account_db_id)
+{
+ CONTACTS_NULL_ARG_CHECK(address_book);
+ CONTACTS_NULL_ARG_CHECK(account_db_id);
+
+ *account_db_id = 0;
+ *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;
+}
+
diff --git a/src/contacts_address.c b/src/contacts_address.c
index bb7f23e..e1adc80 100755
--- a/src/contacts_address.c
+++ b/src/contacts_address.c
@@ -33,10 +33,8 @@
int contact_address_create(contact_address_h* address)
{
- if(address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(address);
+
CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_POSTAL);
if(ret == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
@@ -50,10 +48,8 @@ int contact_address_create(contact_address_h* address)
int contact_address_destroy(contact_address_h address)
{
- if(address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(address);
+
if(contacts_svc_value_free((CTSvalue*)address) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
}
@@ -64,10 +60,9 @@ int contact_address_destroy(contact_address_h address)
int contact_address_get_type(contact_address_h address, contact_address_type_e* type)
{
- if(type == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(address);
+ CONTACTS_NULL_ARG_CHECK(type);
+
CTSvalue * CTSaddress = (CTSvalue *)address;
*type = contacts_svc_value_get_int(CTSaddress, CTS_POSTAL_VAL_TYPE_INT);
@@ -88,10 +83,9 @@ int contact_address_set_type(contact_address_h address, contact_address_type_e t
int contact_address_get_detail(contact_address_h address, contact_address_detail_e detail_type, char** data)
{
- if(address == NULL || data == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(address);
+ CONTACTS_NULL_ARG_CHECK(data);
+
*data = NULL;
CTSvalue * CTSaddress = (CTSvalue *)address;
switch(detail_type)
@@ -128,10 +122,9 @@ int contact_address_get_detail(contact_address_h address, contact_address_detail
int contact_address_set_detail(contact_address_h address, contact_address_detail_e detail_type, const char* data)
{
- if(address == NULL || data == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(address);
+ CONTACTS_NULL_ARG_CHECK(data);
+
CTSvalue * CTSaddress = (CTSvalue *)address;
int ret = CTS_ERR_ARG_INVALID;
switch(detail_type)
@@ -167,10 +160,9 @@ int contact_address_set_detail(contact_address_h address, contact_address_detail
int contact_address_iterator_next(contact_address_iterator_h* address_iterator, contact_address_h* address)
{
- if(address_iterator == NULL || address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(address_iterator);
+ CONTACTS_NULL_ARG_CHECK(address);
+
*address = NULL;
GSList* gslist = (GSList*)*address_iterator;
gslist = _contacts_gslist_next_until_not_deleted(gslist);
diff --git a/src/contacts_company.c b/src/contacts_company.c
index 7bdcd17..5b5fd2f 100755
--- a/src/contacts_company.c
+++ b/src/contacts_company.c
@@ -32,10 +32,8 @@
int contact_company_create(contact_company_h* company)
{
- if(company == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(company);
+
CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_COMPANY);
if(ret == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
@@ -48,10 +46,7 @@ int contact_company_create(contact_company_h* company)
int contact_company_destroy(contact_company_h company)
{
- if(company == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(company);
if(contacts_svc_value_free((CTSvalue*)company) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -63,10 +58,9 @@ int contact_company_destroy(contact_company_h company)
int contact_company_get_detail(contact_company_h company, contact_company_detail_e detail_type, char** data)
{
- if(company == NULL || data == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(company);
+ CONTACTS_NULL_ARG_CHECK(data);
+
CTSvalue * CTScompany = (CTSvalue *)company;
*data = NULL;
switch(detail_type)
@@ -94,10 +88,9 @@ int contact_company_get_detail(contact_company_h company, contact_company_detail
int contact_company_set_detail(contact_company_h company, contact_company_detail_e detail_type, const char* data)
{
- if(company == NULL || data == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(company);
+ CONTACTS_NULL_ARG_CHECK(data);
+
CTSvalue * CTScompany = (CTSvalue *)company;
int ret = CTS_ERR_ARG_INVALID;
switch(detail_type)
diff --git a/src/contacts_contact.c b/src/contacts_contact.c
index a8901a0..5b66d59 100755
--- a/src/contacts_contact.c
+++ b/src/contacts_contact.c
@@ -32,10 +32,8 @@
int contact_create(contact_h* contact)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+
CTSstruct* ret_val = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
if(ret_val == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
@@ -48,10 +46,7 @@ int contact_create(contact_h* contact)
int contact_destroy(contact_h contact)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
if(contacts_svc_struct_free((CTSstruct*)contact) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -61,14 +56,13 @@ int contact_destroy(contact_h contact)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
-int contact_insert_to_db(contact_h contact, int *db_id)
+int contact_insert_to_db(contact_h contact, int address_book_db_id, int *db_id)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+
int contact_index = -1;
- contact_index = contacts_svc_insert_contact(0, (CTSstruct*)contact);
+ contact_index = contacts_svc_insert_contact(address_book_db_id, (CTSstruct*)contact);
if(contact_index < 0) {
LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
return CONTACTS_ERROR_DB_FAILED;
@@ -82,10 +76,7 @@ int contact_insert_to_db(contact_h contact, int *db_id)
int contact_delete_from_db(int db_id)
{
- if(db_id < 0) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_INVALID_ARG_CHECK(db_id <= 0);
int ret = CTS_SUCCESS;
if((ret=contacts_svc_delete_contact(db_id)) == CTS_SUCCESS) {
@@ -100,10 +91,7 @@ int contact_delete_from_db(int db_id)
int contact_update_to_db(contact_h contact)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
int ret = CTS_SUCCESS;
if((ret=contacts_svc_update_contact((CTSstruct*)contact)) == CTS_SUCCESS) {
@@ -118,10 +106,8 @@ int contact_update_to_db(contact_h contact)
int contact_get_from_db(int db_id, contact_h* contact)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_INVALID_ARG_CHECK(db_id <= 0);
int ret = CTS_SUCCESS;
if((ret=contacts_svc_get_contact(db_id, (CTSstruct**)contact)) == CTS_SUCCESS) {
@@ -136,10 +122,9 @@ int contact_get_from_db(int db_id, contact_h* contact)
int contact_get_db_id(contact_h contact, int* db_id)
{
- if(contact == NULL || db_id == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(db_id);
+
int ret = 0;
*db_id = 0;
CTSvalue* base = NULL;
@@ -155,10 +140,7 @@ int contact_get_db_id(contact_h contact, int* db_id)
int contact_add_group(contact_h contact, int group_db_id)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
bool need_to_free = false;
GSList *cursor = NULL;
@@ -199,10 +181,7 @@ int contact_add_group(contact_h contact, int group_db_id)
int contact_remove_group(contact_h contact, int group_db_id)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
int ret = CONTACTS_ERROR_INVALID_PARAMETER;
GSList *group_relation_list = NULL;
@@ -232,10 +211,8 @@ int contact_remove_group(contact_h contact, int group_db_id)
int contact_get_name(contact_h contact, contact_name_h* name)
{
- if(contact == NULL || name == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(name);
*name = NULL;
int ret = CTS_SUCCESS;
@@ -251,10 +228,8 @@ int contact_get_name(contact_h contact, contact_name_h* name)
int contact_set_name(contact_h contact, contact_name_h name)
{
- if(contact == NULL || name == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(name);
if(contacts_svc_struct_store_value((CTSstruct*)contact, CTS_CF_NAME_VALUE, (CTSvalue*)name) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -266,10 +241,8 @@ int contact_set_name(contact_h contact, contact_name_h name)
int contact_get_default_number(contact_h contact, contact_number_h* number)
{
- if(contact == NULL || number == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(number);
*number = NULL;
GSList *cursor = NULL;
@@ -286,10 +259,8 @@ int contact_get_default_number(contact_h contact, contact_number_h* number)
int contact_add_number(contact_h contact, contact_number_h number)
{
- if(contact == NULL || number == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(number);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, &cursor);
@@ -314,10 +285,8 @@ int contact_add_number(contact_h contact, contact_number_h number)
int contact_remove_number(contact_h contact, contact_number_h number)
{
- if(contact == NULL || number == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(number);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NUMBER_LIST, &cursor);
@@ -334,10 +303,8 @@ int contact_remove_number(contact_h contact, contact_number_h number)
int contact_get_number_iterator(contact_h contact, contact_number_iterator_h* number_iterator)
{
- if(contact == NULL || number_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(number_iterator);
*number_iterator = NULL;
int ret = CTS_SUCCESS;
@@ -353,10 +320,8 @@ int contact_get_number_iterator(contact_h contact, contact_number_iterator_h* nu
int contact_add_email(contact_h contact, contact_email_h email)
{
- if(contact == NULL || email == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(email);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EMAIL_LIST, &cursor);
@@ -383,10 +348,8 @@ int contact_add_email(contact_h contact, contact_email_h email)
int contact_remove_email(contact_h contact, contact_email_h email)
{
- if(contact == NULL || email == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(email);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EMAIL_LIST, &cursor);
@@ -403,10 +366,8 @@ int contact_remove_email(contact_h contact, contact_email_h email)
int contact_get_email_iterator(contact_h contact, contact_email_iterator_h* email_iterator)
{
- if(contact == NULL || email_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(email_iterator);
*email_iterator = NULL;
int ret = CTS_SUCCESS;
@@ -422,10 +383,8 @@ int contact_get_email_iterator(contact_h contact, contact_email_iterator_h* emai
int contact_add_address(contact_h contact, contact_address_h address)
{
- if(contact == NULL || address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(address);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_POSTAL_ADDR_LIST, &cursor);
@@ -452,10 +411,8 @@ int contact_add_address(contact_h contact, contact_address_h address)
int contact_remove_address(contact_h contact, contact_address_h address)
{
- if(contact == NULL || address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(address);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_POSTAL_ADDR_LIST, &cursor);
@@ -472,10 +429,8 @@ int contact_remove_address(contact_h contact, contact_address_h address)
int contact_get_address_iterator(contact_h contact, contact_address_iterator_h* address_iterator)
{
- if(contact == NULL || address_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(address_iterator);
*address_iterator = NULL;
int ret = CTS_SUCCESS;
@@ -491,10 +446,8 @@ int contact_get_address_iterator(contact_h contact, contact_address_iterator_h*
int contact_get_company(contact_h contact, contact_company_h* company)
{
- if(contact == NULL || company == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(company);
if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_COMPANY_VALUE, (CTSvalue**)company) == CTS_SUCCESS){
return CONTACTS_ERROR_NONE;
@@ -506,10 +459,8 @@ int contact_get_company(contact_h contact, contact_company_h* company)
int contact_set_company(contact_h contact, contact_company_h company)
{
- if(contact == NULL || company == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(company);
if(contacts_svc_struct_store_value((CTSstruct*)contact, CTS_CF_COMPANY_VALUE, (CTSvalue*)company) == CTS_SUCCESS){
return CONTACTS_ERROR_NONE;
@@ -521,10 +472,8 @@ int contact_set_company(contact_h contact, contact_company_h company)
int contact_get_birthday(contact_h contact, contact_birthday_h* birthday)
{
- if(contact == NULL || birthday == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(birthday);
*birthday = NULL;
GSList *cursor = NULL;
@@ -539,10 +488,8 @@ int contact_get_birthday(contact_h contact, contact_birthday_h* birthday)
int contact_set_birthday(contact_h contact, contact_birthday_h birthday)
{
- if(contact == NULL || birthday == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(birthday);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, &cursor);
@@ -551,14 +498,15 @@ int contact_set_birthday(contact_h contact, contact_birthday_h birthday)
if(cursor == NULL) {
need_to_free = true;
} else {
- if((contact_birthday_h)cursor->data != birthday) {
- contacts_svc_value_set_bool((CTSvalue*)cursor->data, CTS_EVENT_VAL_DELETE_BOOL, true);
- }
+ 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);
+ }
+ }
}
cursor = g_slist_append((GSList*)cursor, birthday);
-
if(contacts_svc_struct_store_list((CTSstruct*)contact, CTS_CF_EVENT_LIST, cursor) == CTS_SUCCESS) {
ret = CONTACTS_ERROR_NONE;
} else {
@@ -573,12 +521,29 @@ int contact_set_birthday(contact_h contact, contact_birthday_h birthday)
return ret;
}
-int contact_add_messenger(contact_h contact, contact_messenger_h messenger)
+int contact_unset_birthday(contact_h contact)
{
- if(contact == NULL || messenger == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
+ 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_add_messenger(contact_h contact, contact_messenger_h messenger)
+{
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(messenger);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, &cursor);
@@ -605,10 +570,8 @@ int contact_add_messenger(contact_h contact, contact_messenger_h messenger)
int contact_remove_messenger(contact_h contact, contact_messenger_h messenger)
{
- if(contact == NULL || messenger == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(messenger);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, &cursor);
@@ -625,10 +588,8 @@ int contact_remove_messenger(contact_h contact, contact_messenger_h messenger)
int contact_get_messenger_iterator(contact_h contact, contact_messenger_iterator_h* messenger_iterator)
{
- if(contact == NULL || messenger_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(messenger_iterator);
int ret = CTS_SUCCESS;
if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_MESSENGER_LIST, (GSList**)messenger_iterator)) == CTS_SUCCESS){
@@ -643,10 +604,8 @@ int contact_get_messenger_iterator(contact_h contact, contact_messenger_iterator
int contact_add_nickname(contact_h contact, contact_nickname_h nickname)
{
- if(contact == NULL || nickname == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(nickname);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, &cursor);
@@ -674,10 +633,8 @@ int contact_add_nickname(contact_h contact, contact_nickname_h nickname)
int contact_remove_nickname(contact_h contact, contact_nickname_h nickname)
{
- if(contact == NULL || nickname == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(nickname);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, &cursor);
@@ -694,10 +651,8 @@ int contact_remove_nickname(contact_h contact, contact_nickname_h nickname)
int contact_get_nickname_iterator(contact_h contact, contact_nickname_iterator_h* nickname_iterator)
{
- if(contact == NULL || nickname_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(nickname_iterator);
int ret = CTS_SUCCESS;
if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_NICKNAME_LIST, (GSList**)nickname_iterator)) == CTS_SUCCESS){
@@ -712,10 +667,8 @@ int contact_get_nickname_iterator(contact_h contact, contact_nickname_iterator_h
int contact_add_web(contact_h contact, contact_web_h web)
{
- if(contact == NULL || web == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(web);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, &cursor);
@@ -742,10 +695,8 @@ int contact_add_web(contact_h contact, contact_web_h web)
int contact_remove_web(contact_h contact, contact_web_h web)
{
- if(contact == NULL || web == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(web);
GSList *cursor = NULL;
contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, &cursor);
@@ -762,10 +713,8 @@ int contact_remove_web(contact_h contact, contact_web_h web)
int contact_get_web_iterator(contact_h contact, contact_web_iterator_h* web_iterator)
{
- if(contact == NULL || web_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(web_iterator);
int ret = CTS_SUCCESS;
if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_WEB_ADDR_LIST, (GSList**)web_iterator)) == CTS_SUCCESS){
@@ -780,10 +729,8 @@ int contact_get_web_iterator(contact_h contact, contact_web_iterator_h* web_iter
int contact_get_relatedgroup_iterator(contact_h contact, contact_relatedgroup_iterator_h* relatedgroup_iterator)
{
- if(contact == NULL || relatedgroup_iterator == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(relatedgroup_iterator);
int ret = CTS_SUCCESS;
if((ret = contacts_svc_struct_get_list((CTSstruct*)contact, CTS_CF_GROUPREL_LIST, (GSList**)relatedgroup_iterator)) == CTS_SUCCESS) {
@@ -798,10 +745,9 @@ int contact_get_relatedgroup_iterator(contact_h contact, contact_relatedgroup_it
int contact_set_image(contact_h contact, const char* src_img)
{
- if(contact == NULL || src_img == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(src_img);
+
int ret = CONTACTS_ERROR_INVALID_PARAMETER;
int ret_temp = 0;
CTSvalue* base = NULL;
@@ -828,10 +774,9 @@ int contact_set_image(contact_h contact, const char* src_img)
int contact_get_image(contact_h contact, char** img_path)
{
- if(contact == NULL || img_path == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(img_path);
+
*img_path = NULL;
CTSvalue* base = NULL;
if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
@@ -845,10 +790,9 @@ int contact_get_image(contact_h contact, char** img_path)
int contact_get_ringtonepath(contact_h contact, char** ringtone_path)
{
- if(contact == NULL || ringtone_path == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(ringtone_path);
+
*ringtone_path = NULL;
CTSvalue* base = NULL;
if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
@@ -861,10 +805,9 @@ int contact_get_ringtonepath(contact_h contact, char** ringtone_path)
int contact_set_ringtonepath(contact_h contact, const char* ringtone_path)
{
- if(contact == NULL || ringtone_path == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(ringtone_path);
+
int ret = CTS_SUCCESS;
CTSvalue* base = NULL;
if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
@@ -891,10 +834,9 @@ int contact_set_ringtonepath(contact_h contact, const char* ringtone_path)
int contact_get_note(contact_h contact, char** note)
{
- if(contact == NULL || note == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(note);
+
*note = NULL;
CTSvalue* base = NULL;
if(contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base) != CTS_SUCCESS) {
@@ -907,10 +849,9 @@ int contact_get_note(contact_h contact, char** note)
int contact_set_note(contact_h contact, const char* note)
{
- if(contact == NULL || note == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(note);
+
int ret = CTS_SUCCESS;
CTSvalue* base = NULL;
if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
@@ -937,10 +878,8 @@ int contact_set_note(contact_h contact, const char* note)
int contact_get_total_count_from_db(int* count)
{
- if(count == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(count);
+
*count = contacts_svc_count(CTS_GET_ALL_CONTACT);
return CONTACTS_ERROR_NONE;
}
@@ -949,10 +888,8 @@ int contact_get_total_count_from_db(int* count)
int contact_get_from_vcard(const char *vcard_stream, contact_h *contact)
{
- if(vcard_stream == NULL || contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(vcard_stream);
+ CONTACTS_NULL_ARG_CHECK(contact);
if(contacts_svc_get_contact_from_vcard((const void*)vcard_stream, (CTSstruct**)contact) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -964,10 +901,8 @@ int contact_get_from_vcard(const char *vcard_stream, contact_h *contact)
int contact_get_vcard_from_contact(contact_h contact, char **vcard_stream)
{
- if(vcard_stream == NULL || contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(vcard_stream);
if(contacts_svc_get_vcard_from_contact((const CTSstruct*)contact, vcard_stream) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -977,12 +912,42 @@ int contact_get_vcard_from_contact(contact_h contact, char **vcard_stream)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+contacts_vcard_stream_cb _parse_multiple_vcard_cb = NULL;
+
+int contact_parse_multiple_vcard_fw_cb(const char *a_vcard_stream, void *data)
+{
+ if(_parse_multiple_vcard_cb) {
+ bool ret = _parse_multiple_vcard_cb(a_vcard_stream, data);
+ if(ret == false)
+ return 1; // return 1 means end foreach in F/W
+ else
+ return 0; // return 0 means continue foreach in F/W
+ }
+ return 1; // return 1 means end foreach in F/W
+}
+
+int contact_parse_multiple_vcard_file(contacts_vcard_stream_cb callback, const char *multiple_vcard_file_path, void *user_data)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+ CONTACTS_NULL_ARG_CHECK(multiple_vcard_file_path);
+
+ _parse_multiple_vcard_cb = callback;
+ int ret = contacts_svc_vcard_foreach(multiple_vcard_file_path, contact_parse_multiple_vcard_fw_cb, user_data);
+
+ if(ret == CTS_SUCCESS || ret == CTS_ERR_FINISH_ITER) {
+ return CONTACTS_ERROR_NONE;
+ } else if(ret == CTS_ERR_OUT_OF_MEMORY) {
+ LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
+ return CONTACTS_ERROR_OUT_OF_MEMORY;
+ }
+
+ LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
+ return CONTACTS_ERROR_INVALID_PARAMETER;
+}
+
int contact_set_favorite_to_db(int contact_db_id)
{
- if(contact_db_id <= 0) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_INVALID_ARG_CHECK(contact_db_id <= 0);
if(CTS_SUCCESS == contacts_svc_set_favorite(CTS_FAVOR_CONTACT, contact_db_id)) {
return CONTACTS_ERROR_NONE;
@@ -994,10 +959,7 @@ int contact_set_favorite_to_db(int contact_db_id)
int contact_unset_favorite_to_db(int contact_db_id)
{
- if(contact_db_id <= 0) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_INVALID_ARG_CHECK(contact_db_id <= 0);
if(CTS_SUCCESS == contacts_svc_unset_favorite(CTS_FAVOR_CONTACT, contact_db_id)) {
return CONTACTS_ERROR_NONE;
@@ -1009,10 +971,8 @@ int contact_unset_favorite_to_db(int contact_db_id)
int contact_get_favorite(contact_h contact, bool *is_favorite)
{
- if(contact == NULL || is_favorite == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(is_favorite);
*is_favorite = false;
CTSvalue* base = NULL;
@@ -1026,11 +986,8 @@ int contact_get_favorite(contact_h contact, bool *is_favorite)
int contact_set_favorite(contact_h contact, bool is_favorite)
{
- if(contact == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
-
+ CONTACTS_NULL_ARG_CHECK(contact);
+
int ret = CTS_SUCCESS;
CTSvalue* base = NULL;
if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
@@ -1055,3 +1012,52 @@ int contact_set_favorite(contact_h contact, bool is_favorite)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
+int contact_get_address_book_db_id(contact_h contact, int *address_book_db_id)
+{
+ CONTACTS_NULL_ARG_CHECK(contact);
+ CONTACTS_NULL_ARG_CHECK(address_book_db_id);
+
+ int ret = 0;
+ *address_book_db_id = 0;
+ CTSvalue* base = NULL;
+ if((ret = contacts_svc_struct_get_value((CTSstruct*)contact, CTS_CF_BASE_INFO_VALUE, &base)) != CTS_SUCCESS) {
+ return CONTACTS_ERROR_NONE;
+ }
+ *address_book_db_id = contacts_svc_value_get_int(base, CTS_BASE_VAL_ADDRESSBOOK_ID_INT);
+ if(*address_book_db_id < 0) {
+ *address_book_db_id = 0;
+ }
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_total_count_in_address_book(int address_book_db_id, int *count)
+{
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+ CONTACTS_NULL_ARG_CHECK(count);
+
+ *count = contacts_svc_count_with_int(CTS_GET_COUNT_CONTACTS_IN_ADDRESSBOOK, address_book_db_id);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_get_total_count_not_related_to_group(int address_book_db_id, int *count)
+{
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+ CONTACTS_NULL_ARG_CHECK(count);
+
+ *count = contacts_svc_count_with_int(CTS_GET_COUNT_NO_GROUP_CONTACTS_IN_ADDRESSBOOK, address_book_db_id);
+ return CONTACTS_ERROR_NONE;
+}
+
+int contact_unset_frequent_contact(int contact_db_id)
+{
+ CONTACTS_INVALID_ARG_CHECK(contact_db_id < 1);
+ int ret = contacts_svc_reset_outgoing_count(contact_db_id);
+
+ if(ret == CTS_ERR_DB_NOT_OPENED || ret == CTS_ERR_DB_FAILED) {
+ LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
+ return CONTACTS_ERROR_DB_FAILED;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
diff --git a/src/contacts_email.c b/src/contacts_email.c
index 8edf26b..143c3ff 100755
--- a/src/contacts_email.c
+++ b/src/contacts_email.c
@@ -32,10 +32,8 @@
int contact_email_create(contact_email_h* email)
{
- if(email == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(email);
+
CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_EMAIL);
if(ret == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
@@ -48,10 +46,7 @@ int contact_email_create(contact_email_h* email)
int contact_email_destroy(contact_email_h email)
{
- if(email == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(email);
if(contacts_svc_value_free((CTSvalue*)email) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -64,47 +59,39 @@ int contact_email_destroy(contact_email_h email)
int contact_email_get_type(contact_email_h email, contact_email_type_e* type)
{
- if(email == NULL || type == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
- CTSvalue * CTSemail = (CTSvalue *)email;
- *type = contacts_svc_value_get_int(CTSemail, CTS_EMAIL_VAL_TYPE_INT);
+ CONTACTS_NULL_ARG_CHECK(email);
+ CONTACTS_NULL_ARG_CHECK(type);
+
+ *type = contacts_svc_value_get_int((CTSvalue *)email, CTS_EMAIL_VAL_TYPE_INT);
return CONTACTS_ERROR_NONE;
}
int contact_email_set_type(contact_email_h email, contact_email_type_e type)
{
- if(email == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
- CTSvalue * CTSemail = (CTSvalue *)email;
- contacts_svc_value_set_int(CTSemail, CTS_NUM_VAL_TYPE_INT, type);
+ CONTACTS_NULL_ARG_CHECK(email);
+
+ contacts_svc_value_set_int((CTSvalue*)email, CTS_EMAIL_VAL_TYPE_INT, type);
return CONTACTS_ERROR_NONE;
}
int contact_email_get_address(contact_email_h email, char** address)
{
- if(email == NULL || address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(email);
+ CONTACTS_NULL_ARG_CHECK(address);
+
*address = NULL;
- CTSvalue * CTSemail = (CTSvalue *)email;
- *address = _contacts_safe_strdup(contacts_svc_value_get_str(CTSemail, CTS_EMAIL_VAL_ADDR_STR));
+ *address = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)email, CTS_EMAIL_VAL_ADDR_STR));
return CONTACTS_ERROR_NONE;
}
int contact_email_set_address(contact_email_h email, const char* address)
{
- if(email == NULL || address == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(email);
+ CONTACTS_NULL_ARG_CHECK(address);
+
CTSvalue * CTSemail = (CTSvalue *)email;
contacts_svc_value_set_str(CTSemail, CTS_EMAIL_VAL_ADDR_STR,address);
@@ -114,10 +101,9 @@ int contact_email_set_address(contact_email_h email, const char* address)
int contact_email_iterator_next(contact_email_iterator_h* email_iterator, contact_email_h* email)
{
- if(email_iterator == NULL || email == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(email_iterator);
+ CONTACTS_NULL_ARG_CHECK(email);
+
*email = NULL;
GSList* gslist = (GSList*)*email_iterator;
gslist = _contacts_gslist_next_until_not_deleted(gslist);
diff --git a/src/contacts_event.c b/src/contacts_event.c
index dd51aa7..7ca2228 100755
--- a/src/contacts_event.c
+++ b/src/contacts_event.c
@@ -31,10 +31,8 @@
int contact_birthday_create(contact_birthday_h* birthday)
{
- if(birthday == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(birthday);
+
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);
@@ -48,10 +46,7 @@ int contact_birthday_create(contact_birthday_h* birthday)
int contact_birthday_destroy(contact_birthday_h birthday)
{
- if(birthday == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(birthday);
if(contacts_svc_value_free((CTSvalue*)birthday) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -64,10 +59,10 @@ int contact_birthday_destroy(contact_birthday_h birthday)
int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month, int *day)
{
- if(birthday == NULL || year == NULL || month == NULL || day == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(birthday);
+ CONTACTS_NULL_ARG_CHECK(year);
+ CONTACTS_NULL_ARG_CHECK(month);
+ CONTACTS_NULL_ARG_CHECK(day);
CTSvalue * CTSevent = (CTSvalue *)birthday;
int date = contacts_svc_value_get_int(CTSevent, CTS_EVENT_VAL_DATE_INT);
@@ -83,10 +78,8 @@ int contact_birthday_get_date(contact_birthday_h birthday, int *year, int *month
int contact_birthday_set_date(contact_birthday_h birthday, int year, int month, int day)
{
- if(birthday == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(birthday);
+
CTSvalue * CTSevent = (CTSvalue *)birthday;
contacts_svc_value_set_int(CTSevent, CTS_EVENT_VAL_DATE_INT, year*10000 + month*100 + day);
diff --git a/src/contacts_group.c b/src/contacts_group.c
index ba86f14..8d6cf61 100755
--- a/src/contacts_group.c
+++ b/src/contacts_group.c
@@ -32,10 +32,7 @@
int contacts_group_create(contacts_group_h* group)
{
- if(group == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_GROUP);
if(ret == NULL) {
@@ -49,10 +46,7 @@ int contacts_group_create(contacts_group_h* group)
int contacts_group_destroy(contacts_group_h group)
{
- if(group == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
if(contacts_svc_value_free((CTSvalue*)group) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -62,13 +56,13 @@ int contacts_group_destroy(contacts_group_h group)
return CONTACTS_ERROR_INVALID_PARAMETER;
}
-int contacts_group_insert_to_db(contacts_group_h group, int* db_id)
+int contacts_group_insert_to_db(contacts_group_h group, int address_book_db_id, int* db_id)
{
- if(group == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
- int group_index = contacts_svc_insert_group(0, (CTSvalue*)group);
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(db_id);
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+
+ int group_index = contacts_svc_insert_group(address_book_db_id, (CTSvalue*)group);
if(group_index < 0) {
LOGE("[%s] CONTACTS_ERROR_DB_FAILED(0x%08x)", __FUNCTION__, CONTACTS_ERROR_DB_FAILED);
return CONTACTS_ERROR_DB_FAILED;
@@ -81,10 +75,7 @@ int contacts_group_insert_to_db(contacts_group_h group, int* db_id)
int contacts_group_update_to_db(contacts_group_h group)
{
- if(group == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
int ret = CTS_SUCCESS;
if((ret=contacts_svc_update_group((CTSvalue*)group)) == CTS_SUCCESS) {
@@ -100,10 +91,7 @@ int contacts_group_update_to_db(contacts_group_h group)
int contacts_group_delete_from_db(int db_id)
{
- if(db_id < 0) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_INVALID_ARG_CHECK(db_id <= 0);
int ret = CTS_SUCCESS;
if((ret=contacts_svc_delete_group(db_id)) == CTS_SUCCESS) {
@@ -119,10 +107,9 @@ int contacts_group_delete_from_db(int db_id)
int contacts_group_get_db_id(contacts_group_h group, int* db_id)
{
- if(group == NULL || db_id == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(db_id);
+
*db_id = contacts_svc_value_get_int((CTSvalue*)group, CTS_GROUP_VAL_ID_INT);
if(*db_id < 0) {
*db_id = 0;
@@ -133,10 +120,8 @@ int contacts_group_get_db_id(contacts_group_h group, int* db_id)
int contacts_group_get_from_db(int db_id, contacts_group_h* group)
{
- if(group == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_INVALID_ARG_CHECK(db_id <= 0);
+ CONTACTS_NULL_ARG_CHECK(group);
int ret = CTS_SUCCESS;
if((ret=contacts_svc_get_group(db_id, (CTSvalue**)group)) == CTS_SUCCESS) {
@@ -152,8 +137,9 @@ int contacts_group_get_from_db(int db_id, contacts_group_h* group)
int contacts_group_get_name(contacts_group_h group, char** name)
{
- if(group == NULL || name == NULL)
- return CONTACTS_ERROR_INVALID_PARAMETER;
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(name);
+
*name = NULL;
*name = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)group, CTS_GROUP_VAL_NAME_STR));
@@ -162,10 +148,8 @@ int contacts_group_get_name(contacts_group_h group, char** name)
int contacts_group_set_name(contacts_group_h group, const char* name)
{
- if(group == NULL || name == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(name);
if(contacts_svc_value_set_str((CTSvalue*)group, CTS_GROUP_VAL_NAME_STR, name) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -178,10 +162,9 @@ int contacts_group_set_name(contacts_group_h group, const char* name)
int contacts_group_get_ringtonepath(contacts_group_h group, char** ringtonepath)
{
- if(ringtonepath == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(ringtonepath);
+
*ringtonepath = NULL;
*ringtonepath = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)group, CTS_GROUP_VAL_RINGTONE_STR));
@@ -190,10 +173,8 @@ int contacts_group_get_ringtonepath(contacts_group_h group, char** ringtonepath)
int contacts_group_set_ringtonepath(contacts_group_h group, const char* ringtonepath)
{
- if(group == NULL || ringtonepath == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(ringtonepath);
if(contacts_svc_value_set_str((CTSvalue*)group, CTS_GROUP_VAL_RINGTONE_STR, ringtonepath) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -205,10 +186,9 @@ int contacts_group_set_ringtonepath(contacts_group_h group, const char* ringtone
int contacts_group_get_member_count_from_db(contacts_group_h group, int* count)
{
- if(count == NULL || group == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(count);
+
int group_id = contacts_svc_value_get_int((CTSvalue*)group, CTS_GROUP_VAL_ID_INT);
if(group_id < 0) {
LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
@@ -219,12 +199,10 @@ int contacts_group_get_member_count_from_db(contacts_group_h group, int* count)
return CONTACTS_ERROR_NONE;
}
-int contacts_group_foreach_group_from_db(contacts_foreach_group_cb cb, void* user_data)
+int contacts_group_foreach_group_from_db(contacts_foreach_query_group_cb cb, void* user_data)
{
- if(cb == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(cb);
+
CTSiter *iter = NULL;
int func_ret = 0;
if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_GROUP, &iter)) {
@@ -240,6 +218,7 @@ int contacts_group_foreach_group_from_db(contacts_foreach_group_cb cb, void* use
contacts_query_group_s query_data;
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));
func_ret = cb(&query_data, user_data);
@@ -256,3 +235,52 @@ int contacts_group_foreach_group_from_db(contacts_foreach_group_cb cb, void* use
return CONTACTS_ERROR_NONE;
}
+int contacts_group_get_address_book_db_id(contacts_group_h group, int *address_book_db_id)
+{
+ CONTACTS_NULL_ARG_CHECK(group);
+ CONTACTS_NULL_ARG_CHECK(address_book_db_id);
+
+ *address_book_db_id = contacts_svc_value_get_int((CTSvalue*)group, CTS_GROUP_VAL_ADDRESSBOOK_ID_INT);
+ if(*address_book_db_id < 0) {
+ *address_book_db_id = 0;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
+
+int contacts_group_query_group_by_address_book(contacts_foreach_query_group_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;
+ 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;
+ }
+
+ 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;
+ 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));
+
+ func_ret = callback(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_safe_free(query_data.group_name);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+
+ contacts_svc_iter_remove(iter);
+ return CONTACTS_ERROR_NONE;}
+
diff --git a/src/contacts_messenger.c b/src/contacts_messenger.c
index 777ef22..9d38375 100755
--- a/src/contacts_messenger.c
+++ b/src/contacts_messenger.c
@@ -32,10 +32,8 @@
int contact_messenger_create(contact_messenger_h* messenger)
{
- if(messenger == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger);
+
CTSvalue* ret = contacts_svc_value_new(CTS_VALUE_MESSENGER);
if(ret == NULL) {
LOGE("[%s] CONTACTS_ERROR_OUT_OF_MEMORY(0x%08x)", __FUNCTION__, CONTACTS_ERROR_OUT_OF_MEMORY);
@@ -48,10 +46,8 @@ int contact_messenger_create(contact_messenger_h* messenger)
int contact_messenger_destroy(contact_messenger_h messenger)
{
- if(messenger == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger);
+
if(contacts_svc_value_free((CTSvalue*)messenger) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
}
@@ -62,10 +58,9 @@ int contact_messenger_destroy(contact_messenger_h messenger)
int contact_messenger_get_id(contact_messenger_h messenger, char** id)
{
- if(messenger == NULL || id == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger);
+ CONTACTS_NULL_ARG_CHECK(id);
+
*id = NULL;
*id = _contacts_safe_strdup(contacts_svc_value_get_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_IM_ID_STR));
@@ -74,10 +69,8 @@ int contact_messenger_get_id(contact_messenger_h messenger, char** id)
int contact_messenger_set_id(contact_messenger_h messenger, const char* id)
{
- if(messenger == NULL || id == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger);
+ CONTACTS_NULL_ARG_CHECK(id);
if(contacts_svc_value_set_str((CTSvalue*)messenger, CTS_MESSENGER_VAL_IM_ID_STR, id) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -89,10 +82,8 @@ int contact_messenger_set_id(contact_messenger_h messenger, const char* id)
int contact_messenger_get_type(contact_messenger_h messenger, contact_messenger_type_e *type)
{
- if(messenger == NULL || type == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger);
+ CONTACTS_NULL_ARG_CHECK(type);
*type = contacts_svc_value_get_int((CTSvalue*)messenger, CTS_MESSENGER_VAL_TYPE_INT);
return CONTACTS_ERROR_NONE;
@@ -100,10 +91,7 @@ int contact_messenger_get_type(contact_messenger_h messenger, contact_messenger_
int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_type_e type)
{
- if(messenger == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger);
if(contacts_svc_value_set_int((CTSvalue*)messenger, CTS_MESSENGER_VAL_TYPE_INT, type) == CTS_SUCCESS) {
return CONTACTS_ERROR_NONE;
@@ -115,10 +103,9 @@ int contact_messenger_set_type(contact_messenger_h messenger, contact_messenger_
int contact_messenger_iterator_next(contact_messenger_iterator_h* messenger_iterator, contact_messenger_h* messenger)
{
- if(messenger_iterator == NULL || messenger == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(messenger_iterator);
+ CONTACTS_NULL_ARG_CHECK(messenger);
+
*messenger = NULL;
GSList* gslist = (GSList*)*messenger_iterator;
gslist = _contacts_gslist_next_until_not_deleted(gslist);
diff --git a/src/contacts_private.c b/src/contacts_private.c
index 23cf4ae..78a7561 100755
--- a/src/contacts_private.c
+++ b/src/contacts_private.c
@@ -40,6 +40,16 @@ void _contacts_free_query_preson_struct_member_only(contact_query_name_s* person
_contacts_safe_free(person->contact_image_path);
}
+void _contacts_free_query_number_struct_member_only(contact_query_number_s* contact)
+{
+ contact->contact_db_id = -1;
+ _contacts_safe_free(contact->first_name);
+ _contacts_safe_free(contact->last_name);
+ _contacts_safe_free(contact->display_name);
+ _contacts_safe_free(contact->phone_number);
+ _contacts_safe_free(contact->contact_image_path);
+}
+
void _contacts_free_query_preson_struct_all(gpointer data, gpointer user_data)
{
if(data == NULL)
@@ -53,6 +63,36 @@ void _contacts_free_query_preson_struct_all(gpointer data, gpointer user_data)
_contacts_safe_free(data);
}
+void _contacts_free_query_number_struct_all(gpointer data, gpointer user_data)
+{
+ if(data == NULL)
+ return;
+ contact_query_number_s* person = (contact_query_number_s*)data;
+ person->contact_db_id = -1;
+ _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(data);
+}
+
+void _contacts_set_query_address_book_struct(contacts_query_address_book_s* addressbook, CTSvalue* value)
+{
+ addressbook->address_book_db_id = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_ID_INT);
+ addressbook->address_book_name = _contacts_safe_strdup(contacts_svc_value_get_str(value, CTS_LIST_ADDRESSBOOK_NAME_STR));
+ addressbook->address_book_type = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_ACC_TYPE_INT);
+ addressbook->account_db_id = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_ACC_ID_INT);
+ addressbook->address_book_is_read_only = contacts_svc_value_get_int(value, CTS_LIST_ADDRESSBOOK_MODE_INT);
+}
+
+void _contacts_free_query_address_book_struct_member_only(contacts_query_address_book_s* addressbook)
+{
+ addressbook->address_book_db_id = 0;
+ _contacts_safe_free(addressbook->address_book_name);
+ addressbook->address_book_type = 1;
+}
+
GSList* _contacts_gslist_next_until_not_deleted(GSList* list)
{
if(list == NULL)
diff --git a/src/contacts_search.c b/src/contacts_search.c
index f854c26..fe7edb7 100755
--- a/src/contacts_search.c
+++ b/src/contacts_search.c
@@ -32,10 +32,7 @@
int contact_foreach_contact_from_db(contact_foreach_query_name_cb cb, void* user_data)
{
- if(cb == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(cb);
CTSiter *iter = NULL;
int func_ret = 0;
if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_CONTACT, &iter)) {
@@ -73,16 +70,168 @@ int contact_foreach_contact_from_db(contact_foreach_query_name_cb cb, void* user
}
g_slist_foreach(contactlist, _contacts_free_query_preson_struct_all, NULL);
g_slist_free(contactlist);
-
+
return CONTACTS_ERROR_NONE;
}
-int contact_foreach_favorite_contact_from_db(contact_foreach_favorites_cb cb, void* user_data)
+int contact_get_all_contact_from_db(contact_query_name_array *contact_array, int *length)
{
- if(cb == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ 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_CONTACT_HAD_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_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);
CTSiter *iter = NULL;
int func_ret = 0;
if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_ALL_CONTACT_FAVORITE, &iter)) {
@@ -124,12 +273,44 @@ int contact_foreach_favorite_contact_from_db(contact_foreach_favorites_cb cb, vo
return CONTACTS_ERROR_NONE;
}
+int contact_foreach_frequent_contact_from_db(contact_foreach_query_name_cb callback, void *user_data)
+{
+ CONTACTS_NULL_ARG_CHECK(callback);
+
+ CTSiter *iter = NULL;
+ int func_ret = 0;
+ if(CTS_SUCCESS != contacts_svc_get_list(CTS_LIST_OFTEN_USED_CONTACT, &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_name_s query_data;
+ _contacts_set_query_person_struct(&query_data, foreach_data);
+
+ func_ret = callback(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_preson_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
int contact_query_contact_by_name(contact_foreach_query_name_cb cb, const char* name_to_find, void* user_data)
{
- if(cb == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(cb);
+
CTSiter *iter = NULL;
int func_ret = 0;
if(CTS_SUCCESS != contacts_svc_get_list_with_str(CTS_LIST_CONTACTS_WITH_NAME, name_to_find, &iter)) {
@@ -162,10 +343,8 @@ int contact_query_contact_by_name(contact_foreach_query_name_cb cb, const char*
int contact_query_contact_by_group(contact_foreach_query_name_cb cb, int group_id, void* user_data)
{
- if(cb == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(cb);
+
CTSiter *iter = NULL;
int func_ret = 0;
if(CTS_SUCCESS != contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_OF_GROUP_ID, group_id, &iter)) {
@@ -196,6 +375,41 @@ int contact_query_contact_by_group(contact_foreach_query_name_cb cb, int group_i
return CONTACTS_ERROR_NONE;
}
+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;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_int(CTS_LIST_MEMBERS_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;
+ }
+
+ 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;
+ _contacts_set_query_person_struct(&query_data, foreach_data);
+
+ func_ret = callback(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_preson_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+
int contact_query_contact_by_email(contact_foreach_query_email_cb cb, const char* email_to_find, void* user_data)
{
if(cb == NULL) {
@@ -271,11 +485,7 @@ int contact_query_contact_by_number(contact_foreach_query_number_cb cb, const ch
func_ret = cb(&query_data, user_data);
contacts_svc_value_free(foreach_data);
- _contacts_safe_free(query_data.first_name);
- _contacts_safe_free(query_data.last_name);
- _contacts_safe_free(query_data.display_name);
- _contacts_safe_free(query_data.phone_number);
- _contacts_safe_free(query_data.contact_image_path);
+ _contacts_free_query_number_struct_member_only(&query_data);
if(func_ret == 0) {
break;
@@ -286,15 +496,14 @@ int contact_query_contact_by_number(contact_foreach_query_number_cb cb, const ch
return CONTACTS_ERROR_NONE;
}
-int contact_query_contact_by_version(contact_foreach_query_version_cb cb, int contacts_db_version, void* user_data)
+int contact_query_contact_by_version(contact_foreach_query_version_cb cb, int address_book_db_id, int contacts_db_version, void* user_data)
{
- if(cb == NULL) {
- LOGE("[%s] CONTACTS_ERROR_INVALID_PARAMETER(0x%08x)", __FUNCTION__, CONTACTS_ERROR_INVALID_PARAMETER);
- return CONTACTS_ERROR_INVALID_PARAMETER;
- }
+ CONTACTS_NULL_ARG_CHECK(cb);
+ CONTACTS_INVALID_ARG_CHECK(address_book_db_id < 0);
+
CTSiter *iter = NULL;
int func_ret = 0;
- if(CTS_SUCCESS != contacts_svc_get_updated_contacts(0, contacts_db_version, &iter)) {
+ 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;
}
@@ -323,3 +532,38 @@ int contact_query_contact_by_version(contact_foreach_query_version_cb cb, int co
return CONTACTS_ERROR_NONE;
}
+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;
+ if(CTS_SUCCESS != contacts_svc_get_list_with_int(CTS_LIST_NO_GROUP_MEMBERS_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;
+ }
+
+ 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;
+ _contacts_set_query_person_struct(&query_data, foreach_data);
+
+ func_ret = callback(&query_data, user_data);
+
+ contacts_svc_value_free(foreach_data);
+ _contacts_free_query_preson_struct_member_only(&query_data);
+
+ if(func_ret == 0) {
+ break;
+ }
+ }
+ contacts_svc_iter_remove(iter);
+
+ return CONTACTS_ERROR_NONE;
+}
+