[UTC][contacts-service2][Non-ARC]fix memory leak and revise utc for contacts db api
authorJongkyu Koo <jk.koo@samsung.com>
Fri, 8 Jul 2016 00:40:03 +0000 (09:40 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Fri, 8 Jul 2016 00:40:03 +0000 (09:40 +0900)
Change-Id: I1454f0d6654cb3758264fbedfd2512dfff856e6b
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
37 files changed:
src/utc/contacts-service2/utc-contacts-service-db-activity-photo.c
src/utc/contacts-service2/utc-contacts-service-db-activity.c
src/utc/contacts-service2/utc-contacts-service-db-address-book.c
src/utc/contacts-service2/utc-contacts-service-db-address.c
src/utc/contacts-service2/utc-contacts-service-db-company.c
src/utc/contacts-service2/utc-contacts-service-db-contact-updated-info.c
src/utc/contacts-service2/utc-contacts-service-db-contact.c
src/utc/contacts-service2/utc-contacts-service-db-email.c
src/utc/contacts-service2/utc-contacts-service-db-event.c
src/utc/contacts-service2/utc-contacts-service-db-extension.c
src/utc/contacts-service2/utc-contacts-service-db-group-member-updated-info.c
src/utc/contacts-service2/utc-contacts-service-db-group-relation.c
src/utc/contacts-service2/utc-contacts-service-db-group-updated-info.c
src/utc/contacts-service2/utc-contacts-service-db-group.c
src/utc/contacts-service2/utc-contacts-service-db-grouprel-updated-info.c
src/utc/contacts-service2/utc-contacts-service-db-image.c
src/utc/contacts-service2/utc-contacts-service-db-messenger.c
src/utc/contacts-service2/utc-contacts-service-db-my-profile-updated-info.c
src/utc/contacts-service2/utc-contacts-service-db-my-profile.c
src/utc/contacts-service2/utc-contacts-service-db-name.c
src/utc/contacts-service2/utc-contacts-service-db-nickname.c
src/utc/contacts-service2/utc-contacts-service-db-note.c
src/utc/contacts-service2/utc-contacts-service-db-number.c
src/utc/contacts-service2/utc-contacts-service-db-person.c
src/utc/contacts-service2/utc-contacts-service-db-phone-log-stat.c
src/utc/contacts-service2/utc-contacts-service-db-phone-log.c
src/utc/contacts-service2/utc-contacts-service-db-profile.c
src/utc/contacts-service2/utc-contacts-service-db-relationship.c
src/utc/contacts-service2/utc-contacts-service-db-sdn.c
src/utc/contacts-service2/utc-contacts-service-db-simple-contact.c
src/utc/contacts-service2/utc-contacts-service-db-sip.c
src/utc/contacts-service2/utc-contacts-service-db-speeddial.c
src/utc/contacts-service2/utc-contacts-service-db-url.c
src/utc/contacts-service2/utc-contacts-service-db.c
src/utc/contacts-service2/utc-contacts-service-sdn.c
src/utc/contacts-service2/utc-contacts-service-tc-utils.c
src/utc/contacts-service2/utc-contacts-service-tc-utils.h

index cb41005..f7b96d6 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_activity_photo(void);
 static int _ctsvc_tc_db_remove_changed_cb_activity_photo(void);
-static int _ctsvc_tc_db_get_record_activity_photo(void);
-static int _ctsvc_tc_db_get_records_with_query_activity_photo(void);
-static int _ctsvc_tc_db_get_all_records_activity_photo(void);
-static int _ctsvc_tc_db_get_count_activity_photo(void);
-static int _ctsvc_tc_db_get_count_with_query_activity_photo(void);
-static int _ctsvc_tc_db_insert_record_activity_photo(void);
-static int _ctsvc_tc_db_insert_records_activity_photo(void);
-static int _ctsvc_tc_db_update_record_activity_photo(void);
-static int _ctsvc_tc_db_update_records_activity_photo(void);
-static int _ctsvc_tc_db_delete_record_activity_photo(void);
-static int _ctsvc_tc_db_delete_records_activity_photo(void);
+static int _ctsvc_tc_db_get_record_activity_photo(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_activity_photo(int account_id);
+static int _ctsvc_tc_db_get_all_records_activity_photo(int account_id);
+static int _ctsvc_tc_db_get_count_activity_photo(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_activity_photo(int account_id);
+static int _ctsvc_tc_db_insert_record_activity_photo(int account_id);
+static int _ctsvc_tc_db_insert_records_activity_photo(int account_id);
+static int _ctsvc_tc_db_update_record_activity_photo(int account_id);
+static int _ctsvc_tc_db_update_records_activity_photo(int account_id);
+static int _ctsvc_tc_db_delete_record_activity_photo(int account_id);
+static int _ctsvc_tc_db_delete_records_activity_photo(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_activity_photo = {
@@ -87,19 +87,19 @@ static int _ctsvc_tc_db_remove_changed_cb_activity_photo(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_activity_photo(void)
+static int _ctsvc_tc_db_get_record_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -120,7 +120,6 @@ static int _ctsvc_tc_db_get_record_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -131,16 +130,14 @@ static int _ctsvc_tc_db_get_record_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_activity_photo(void)
+static int _ctsvc_tc_db_get_records_with_query_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -150,9 +147,10 @@ static int _ctsvc_tc_db_get_records_with_query_activity_photo(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -182,7 +180,6 @@ static int _ctsvc_tc_db_get_records_with_query_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -196,16 +193,14 @@ static int _ctsvc_tc_db_get_records_with_query_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_activity_photo(void)
+static int _ctsvc_tc_db_get_all_records_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -213,9 +208,10 @@ static int _ctsvc_tc_db_get_all_records_activity_photo(void)
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -236,7 +232,6 @@ static int _ctsvc_tc_db_get_all_records_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -248,27 +243,26 @@ static int _ctsvc_tc_db_get_all_records_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_activity_photo(void)
+static int _ctsvc_tc_db_get_count_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -290,7 +284,6 @@ static int _ctsvc_tc_db_get_count_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -301,17 +294,15 @@ static int _ctsvc_tc_db_get_count_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_activity_photo(void)
+static int _ctsvc_tc_db_get_count_with_query_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -320,9 +311,10 @@ static int _ctsvc_tc_db_get_count_with_query_activity_photo(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -355,7 +347,6 @@ static int _ctsvc_tc_db_get_count_with_query_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -368,25 +359,23 @@ static int _ctsvc_tc_db_get_count_with_query_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_activity_photo(void)
+static int _ctsvc_tc_db_insert_record_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -406,7 +395,6 @@ static int _ctsvc_tc_db_insert_record_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -417,26 +405,25 @@ static int _ctsvc_tc_db_insert_record_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_activity_photo(void)
+static int _ctsvc_tc_db_insert_records_activity_photo(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -477,7 +464,6 @@ static int _ctsvc_tc_db_insert_records_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -490,25 +476,23 @@ static int _ctsvc_tc_db_insert_records_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_activity_photo(void)
+static int _ctsvc_tc_db_update_record_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -535,7 +519,6 @@ static int _ctsvc_tc_db_update_record_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -546,26 +529,25 @@ static int _ctsvc_tc_db_update_record_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_activity_photo(void)
+static int _ctsvc_tc_db_update_records_activity_photo(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -619,7 +601,6 @@ static int _ctsvc_tc_db_update_records_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -632,24 +613,23 @@ static int _ctsvc_tc_db_update_records_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_activity_photo(void)
+static int _ctsvc_tc_db_delete_record_activity_photo(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -674,7 +654,6 @@ static int _ctsvc_tc_db_delete_record_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -684,26 +663,25 @@ static int _ctsvc_tc_db_delete_record_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_activity_photo(void)
+static int _ctsvc_tc_db_delete_records_activity_photo(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int activity_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -750,7 +728,6 @@ static int _ctsvc_tc_db_delete_records_activity_photo(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -763,7 +740,6 @@ static int _ctsvc_tc_db_delete_records_activity_photo(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 309e9a7..716880c 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_activity(void);
 static int _ctsvc_tc_db_remove_changed_cb_activity(void);
-static int _ctsvc_tc_db_get_record_activity(void);
-static int _ctsvc_tc_db_get_records_with_query_activity(void);
-static int _ctsvc_tc_db_get_all_records_activity(void);
-static int _ctsvc_tc_db_get_count_activity(void);
-static int _ctsvc_tc_db_get_count_with_query_activity(void);
-static int _ctsvc_tc_db_insert_record_activity(void);
-static int _ctsvc_tc_db_insert_records_activity(void);
-static int _ctsvc_tc_db_delete_record_activity(void);
-static int _ctsvc_tc_db_delete_records_activity(void);
+static int _ctsvc_tc_db_get_record_activity(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_activity(int account_id);
+static int _ctsvc_tc_db_get_all_records_activity(int account_id);
+static int _ctsvc_tc_db_get_count_activity(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_activity(int account_id);
+static int _ctsvc_tc_db_insert_record_activity(int account_id);
+static int _ctsvc_tc_db_insert_records_activity(int account_id);
+static int _ctsvc_tc_db_delete_record_activity(int account_id);
+static int _ctsvc_tc_db_delete_records_activity(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_activity = {
        .db_add_changed_cb = _ctsvc_tc_db_add_changed_cb_activity,
@@ -83,18 +83,18 @@ static int _ctsvc_tc_db_remove_changed_cb_activity(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_activity(void)
+static int _ctsvc_tc_db_get_record_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -113,7 +113,6 @@ static int _ctsvc_tc_db_get_record_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -123,16 +122,14 @@ static int _ctsvc_tc_db_get_record_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_activity(void)
+static int _ctsvc_tc_db_get_records_with_query_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -141,9 +138,10 @@ static int _ctsvc_tc_db_get_records_with_query_activity(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -172,7 +170,6 @@ static int _ctsvc_tc_db_get_records_with_query_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -185,25 +182,24 @@ static int _ctsvc_tc_db_get_records_with_query_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_activity(void)
+static int _ctsvc_tc_db_get_all_records_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -222,7 +218,6 @@ static int _ctsvc_tc_db_get_all_records_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -234,25 +229,24 @@ static int _ctsvc_tc_db_get_all_records_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
-static int _ctsvc_tc_db_get_count_activity(void)
+static int _ctsvc_tc_db_get_count_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -271,7 +265,6 @@ static int _ctsvc_tc_db_get_count_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -281,15 +274,13 @@ static int _ctsvc_tc_db_get_count_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
-static int _ctsvc_tc_db_get_count_with_query_activity(void)
+static int _ctsvc_tc_db_get_count_with_query_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -297,9 +288,10 @@ static int _ctsvc_tc_db_get_count_with_query_activity(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -330,7 +322,6 @@ static int _ctsvc_tc_db_get_count_with_query_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -343,24 +334,23 @@ static int _ctsvc_tc_db_get_count_with_query_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
-static int _ctsvc_tc_db_insert_record_activity(void)
+static int _ctsvc_tc_db_insert_record_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -378,7 +368,6 @@ static int _ctsvc_tc_db_insert_record_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -388,25 +377,24 @@ static int _ctsvc_tc_db_insert_record_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_activity(void)
+static int _ctsvc_tc_db_insert_records_activity(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -445,7 +433,6 @@ static int _ctsvc_tc_db_insert_records_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -457,23 +444,22 @@ static int _ctsvc_tc_db_insert_records_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_activity(void)
+static int _ctsvc_tc_db_delete_record_activity(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -496,7 +482,6 @@ static int _ctsvc_tc_db_delete_record_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -506,25 +491,24 @@ static int _ctsvc_tc_db_delete_record_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_activity(void)
+static int _ctsvc_tc_db_delete_records_activity(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -570,7 +554,6 @@ static int _ctsvc_tc_db_delete_records_activity(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -582,7 +565,6 @@ static int _ctsvc_tc_db_delete_records_activity(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 79cb983..f598f4f 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_address_book(void);
 static int _ctsvc_tc_db_remove_changed_cb_address_book(void);
-static int _ctsvc_tc_db_get_record_address_book(void);
-static int _ctsvc_tc_db_get_records_with_query_address_book(void);
-static int _ctsvc_tc_db_get_all_records_address_book(void);
-static int _ctsvc_tc_db_get_count_address_book(void);
-static int _ctsvc_tc_db_get_count_with_query_address_book(void);
-static int _ctsvc_tc_db_insert_record_address_book(void);
-static int _ctsvc_tc_db_update_record_address_book(void);
-static int _ctsvc_tc_db_delete_record_address_book(void);
+static int _ctsvc_tc_db_get_record_address_book(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_address_book(int account_id);
+static int _ctsvc_tc_db_get_all_records_address_book(int account_id);
+static int _ctsvc_tc_db_get_count_address_book(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_address_book(int account_id);
+static int _ctsvc_tc_db_insert_record_address_book(int account_id);
+static int _ctsvc_tc_db_update_record_address_book(int account_id);
+static int _ctsvc_tc_db_delete_record_address_book(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_address_book = {
@@ -81,16 +81,15 @@ static int _ctsvc_tc_db_remove_changed_cb_address_book(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_address_book(void)
+static int _ctsvc_tc_db_get_record_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
-
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -102,31 +101,29 @@ static int _ctsvc_tc_db_get_record_address_book(void)
                record = NULL;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
 
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_address_book(void)
+static int _ctsvc_tc_db_get_records_with_query_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -147,7 +144,6 @@ static int _ctsvc_tc_db_get_records_with_query_address_book(void)
                query = NULL;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -157,23 +153,21 @@ static int _ctsvc_tc_db_get_records_with_query_address_book(void)
        contacts_filter_destroy(filter);
        contacts_query_destroy(query);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_address_book(void)
+static int _ctsvc_tc_db_get_all_records_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
-
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -185,7 +179,6 @@ static int _ctsvc_tc_db_get_all_records_address_book(void)
                list = NULL;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -193,23 +186,21 @@ static int _ctsvc_tc_db_get_all_records_address_book(void)
        contacts_record_destroy(record, true);
        contacts_list_destroy(list, true);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_address_book(void)
+static int _ctsvc_tc_db_get_count_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
-
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -221,31 +212,29 @@ static int _ctsvc_tc_db_get_count_address_book(void)
                        break;
                }
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
 
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_address_book(void)
+static int _ctsvc_tc_db_get_count_with_query_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -269,7 +258,6 @@ static int _ctsvc_tc_db_get_count_with_query_address_book(void)
                query = NULL;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -278,21 +266,19 @@ static int _ctsvc_tc_db_get_count_with_query_address_book(void)
        contacts_query_destroy(query);
 
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_address_book(void)
+static int _ctsvc_tc_db_insert_record_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
-
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -304,29 +290,24 @@ static int _ctsvc_tc_db_insert_record_address_book(void)
                record = NULL;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
-
                return 0;
        } while (0);
 
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_address_book(void)
+static int _ctsvc_tc_db_update_record_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
-
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -344,27 +325,24 @@ static int _ctsvc_tc_db_update_record_address_book(void)
                record = NULL;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
-
                return 0;
        } while (0);
 
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_address_book(void)
+static int _ctsvc_tc_db_delete_record_address_book(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_record_create_address_book(account_id, PROPERTY_TYPE_CREATE1, &record))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_insert_record(record, &id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_record_destroy(record, true))) break;
@@ -379,13 +357,10 @@ static int _ctsvc_tc_db_delete_record_address_book(void)
                        ret = -1;
                        break;
                }
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
-
                return 0;
        } while (0);
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_address_book._uri, id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 5efac0d..9181895 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_address(void);
 static int _ctsvc_tc_db_remove_changed_cb_address(void);
-static int _ctsvc_tc_db_get_record_address(void);
-static int _ctsvc_tc_db_get_records_with_query_address(void);
-static int _ctsvc_tc_db_get_all_records_address(void);
-static int _ctsvc_tc_db_get_count_address(void);
-static int _ctsvc_tc_db_get_count_with_query_address(void);
-static int _ctsvc_tc_db_insert_record_address(void);
-static int _ctsvc_tc_db_insert_records_address(void);
-static int _ctsvc_tc_db_update_record_address(void);
-static int _ctsvc_tc_db_update_records_address(void);
-static int _ctsvc_tc_db_delete_record_address(void);
-static int _ctsvc_tc_db_delete_records_address(void);
+static int _ctsvc_tc_db_get_record_address(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_address(int account_id);
+static int _ctsvc_tc_db_get_all_records_address(int account_id);
+static int _ctsvc_tc_db_get_count_address(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_address(int account_id);
+static int _ctsvc_tc_db_insert_record_address(int account_id);
+static int _ctsvc_tc_db_insert_records_address(int account_id);
+static int _ctsvc_tc_db_update_record_address(int account_id);
+static int _ctsvc_tc_db_update_records_address(int account_id);
+static int _ctsvc_tc_db_delete_record_address(int account_id);
+static int _ctsvc_tc_db_delete_records_address(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_address = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_address(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_address(void)
+static int _ctsvc_tc_db_get_record_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_address(void)
+static int _ctsvc_tc_db_get_records_with_query_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_address(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_address(void)
+static int _ctsvc_tc_db_get_all_records_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_address(void)
+static int _ctsvc_tc_db_get_count_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_address(void)
+static int _ctsvc_tc_db_get_count_with_query_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_address(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_address(void)
+static int _ctsvc_tc_db_insert_record_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_address(void)
+static int _ctsvc_tc_db_insert_records_address(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_address(void)
+static int _ctsvc_tc_db_update_record_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_address(void)
+static int _ctsvc_tc_db_update_records_address(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_address(void)
+static int _ctsvc_tc_db_delete_record_address(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_address(void)
+static int _ctsvc_tc_db_delete_records_address(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_address(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_address(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index fa0c043..059f10e 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_company(void);
 static int _ctsvc_tc_db_remove_changed_cb_company(void);
-static int _ctsvc_tc_db_get_record_company(void);
-static int _ctsvc_tc_db_get_records_with_query_company(void);
-static int _ctsvc_tc_db_get_all_records_company(void);
-static int _ctsvc_tc_db_get_count_company(void);
-static int _ctsvc_tc_db_get_count_with_query_company(void);
-static int _ctsvc_tc_db_insert_record_company(void);
-static int _ctsvc_tc_db_insert_records_company(void);
-static int _ctsvc_tc_db_update_record_company(void);
-static int _ctsvc_tc_db_update_records_company(void);
-static int _ctsvc_tc_db_delete_record_company(void);
-static int _ctsvc_tc_db_delete_records_company(void);
+static int _ctsvc_tc_db_get_record_company(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_company(int account_id);
+static int _ctsvc_tc_db_get_all_records_company(int account_id);
+static int _ctsvc_tc_db_get_count_company(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_company(int account_id);
+static int _ctsvc_tc_db_insert_record_company(int account_id);
+static int _ctsvc_tc_db_insert_records_company(int account_id);
+static int _ctsvc_tc_db_update_record_company(int account_id);
+static int _ctsvc_tc_db_update_records_company(int account_id);
+static int _ctsvc_tc_db_delete_record_company(int account_id);
+static int _ctsvc_tc_db_delete_records_company(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_company = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_company(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_company(void)
+static int _ctsvc_tc_db_get_record_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_company(void)
+static int _ctsvc_tc_db_get_records_with_query_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_company(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_company(void)
+static int _ctsvc_tc_db_get_all_records_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_company(void)
+static int _ctsvc_tc_db_get_count_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_company(void)
+static int _ctsvc_tc_db_get_count_with_query_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_company(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_company(void)
+static int _ctsvc_tc_db_insert_record_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_company(void)
+static int _ctsvc_tc_db_insert_records_company(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_company(void)
+static int _ctsvc_tc_db_update_record_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_company(void)
+static int _ctsvc_tc_db_update_records_company(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_company(void)
+static int _ctsvc_tc_db_delete_record_company(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_company(void)
+static int _ctsvc_tc_db_delete_records_company(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_company(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_company(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index cf95944..00b0a0d 100755 (executable)
@@ -22,7 +22,7 @@
 #include "utc-contacts-service-db-contact.h"
 #include "utc-contacts-service-db-contact-updated-info.h"
 
-static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(void);
+static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_contact_updated_info = {
        .db_add_changed_cb = NULL,
@@ -49,10 +49,9 @@ ctsvc_tc_db_plugin_s _tc_db_contact_updated_info = {
        .db_search_records_with_range_for_snippet = NULL,
 };
 
-static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(void)
+static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -62,10 +61,11 @@ static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(void)
        contacts_list_h list = NULL;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
                if (0 != (ret = contacts_db_get_current_version(&version))) break;
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -80,7 +80,6 @@ static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -89,7 +88,6 @@ static int _ctsvc_tc_db_get_chages_by_version_contact_updated_info(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
index 97840ee..00d5309 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_contact(void);
 static int _ctsvc_tc_db_remove_changed_cb_contact(void);
-static int _ctsvc_tc_db_get_record_contact(void);
-static int _ctsvc_tc_db_get_records_with_query_contact(void);
-static int _ctsvc_tc_db_get_all_records_contact(void);
-static int _ctsvc_tc_db_get_count_contact(void);
-static int _ctsvc_tc_db_get_count_with_query_contact(void);
-static int _ctsvc_tc_db_insert_record_contact(void);
-static int _ctsvc_tc_db_insert_records_contact(void);
-static int _ctsvc_tc_db_update_record_contact(void);
-static int _ctsvc_tc_db_update_records_contact(void);
-static int _ctsvc_tc_db_delete_record_contact(void);
-static int _ctsvc_tc_db_delete_records_contact(void);
-static int _ctsvc_tc_db_replace_record_contact(void);
-static int _ctsvc_tc_db_replace_records_contact(void);
+static int _ctsvc_tc_db_get_record_contact(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_contact(int account_id);
+static int _ctsvc_tc_db_get_all_records_contact(int account_id);
+static int _ctsvc_tc_db_get_count_contact(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_contact(int account_id);
+static int _ctsvc_tc_db_insert_record_contact(int account_id);
+static int _ctsvc_tc_db_insert_records_contact(int account_id);
+static int _ctsvc_tc_db_update_record_contact(int account_id);
+static int _ctsvc_tc_db_update_records_contact(int account_id);
+static int _ctsvc_tc_db_delete_record_contact(int account_id);
+static int _ctsvc_tc_db_delete_records_contact(int account_id);
+static int _ctsvc_tc_db_replace_record_contact(int account_id);
+static int _ctsvc_tc_db_replace_records_contact(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_contact = {
@@ -86,17 +86,17 @@ static int _ctsvc_tc_db_remove_changed_cb_contact(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_contact(void)
+static int _ctsvc_tc_db_get_record_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -113,7 +113,6 @@ static int _ctsvc_tc_db_get_record_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -122,16 +121,14 @@ static int _ctsvc_tc_db_get_record_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_contact(void)
+static int _ctsvc_tc_db_get_records_with_query_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
@@ -139,9 +136,10 @@ static int _ctsvc_tc_db_get_records_with_query_contact(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -168,7 +166,6 @@ static int _ctsvc_tc_db_get_records_with_query_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -180,24 +177,23 @@ static int _ctsvc_tc_db_get_records_with_query_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_contact(void)
+static int _ctsvc_tc_db_get_all_records_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -214,7 +210,6 @@ static int _ctsvc_tc_db_get_all_records_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -224,25 +219,24 @@ static int _ctsvc_tc_db_get_all_records_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_contact(void)
+static int _ctsvc_tc_db_get_count_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -259,7 +253,6 @@ static int _ctsvc_tc_db_get_count_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -268,26 +261,25 @@ static int _ctsvc_tc_db_get_count_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_contact(void)
+static int _ctsvc_tc_db_get_count_with_query_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -316,7 +308,6 @@ static int _ctsvc_tc_db_get_count_with_query_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -327,23 +318,21 @@ static int _ctsvc_tc_db_get_count_with_query_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_contact(void)
+static int _ctsvc_tc_db_insert_record_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -359,7 +348,6 @@ static int _ctsvc_tc_db_insert_record_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -368,24 +356,23 @@ static int _ctsvc_tc_db_insert_record_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_contact(void)
+static int _ctsvc_tc_db_insert_records_contact(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -423,7 +410,6 @@ static int _ctsvc_tc_db_insert_records_contact(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -434,23 +420,21 @@ static int _ctsvc_tc_db_insert_records_contact(void)
        free(ids);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_contact(void)
+static int _ctsvc_tc_db_update_record_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -473,7 +457,6 @@ static int _ctsvc_tc_db_update_record_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -482,24 +465,23 @@ static int _ctsvc_tc_db_update_record_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_contact(void)
+static int _ctsvc_tc_db_update_records_contact(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -549,7 +531,6 @@ static int _ctsvc_tc_db_update_records_contact(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -560,22 +541,21 @@ static int _ctsvc_tc_db_update_records_contact(void)
        free(ids);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_contact(void)
+static int _ctsvc_tc_db_delete_record_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -596,7 +576,6 @@ static int _ctsvc_tc_db_delete_record_contact(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -604,24 +583,23 @@ static int _ctsvc_tc_db_delete_record_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_contact(void)
+static int _ctsvc_tc_db_delete_records_contact(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -664,7 +642,6 @@ static int _ctsvc_tc_db_delete_records_contact(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -675,23 +652,21 @@ static int _ctsvc_tc_db_delete_records_contact(void)
        free(ids);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_replace_record_contact(void)
+static int _ctsvc_tc_db_replace_record_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -713,7 +688,6 @@ static int _ctsvc_tc_db_replace_record_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -722,24 +696,23 @@ static int _ctsvc_tc_db_replace_record_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_replace_records_contact(void)
+static int _ctsvc_tc_db_replace_records_contact(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -787,7 +760,6 @@ static int _ctsvc_tc_db_replace_records_contact(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -798,7 +770,6 @@ static int _ctsvc_tc_db_replace_records_contact(void)
        free(ids);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index a346185..6327792 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_email(void);
 static int _ctsvc_tc_db_remove_changed_cb_email(void);
-static int _ctsvc_tc_db_get_record_email(void);
-static int _ctsvc_tc_db_get_records_with_query_email(void);
-static int _ctsvc_tc_db_get_all_records_email(void);
-static int _ctsvc_tc_db_get_count_email(void);
-static int _ctsvc_tc_db_get_count_with_query_email(void);
-static int _ctsvc_tc_db_insert_record_email(void);
-static int _ctsvc_tc_db_insert_records_email(void);
-static int _ctsvc_tc_db_update_record_email(void);
-static int _ctsvc_tc_db_update_records_email(void);
-static int _ctsvc_tc_db_delete_record_email(void);
-static int _ctsvc_tc_db_delete_records_email(void);
+static int _ctsvc_tc_db_get_record_email(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_email(int account_id);
+static int _ctsvc_tc_db_get_all_records_email(int account_id);
+static int _ctsvc_tc_db_get_count_email(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_email(int account_id);
+static int _ctsvc_tc_db_insert_record_email(int account_id);
+static int _ctsvc_tc_db_insert_records_email(int account_id);
+static int _ctsvc_tc_db_update_record_email(int account_id);
+static int _ctsvc_tc_db_update_records_email(int account_id);
+static int _ctsvc_tc_db_delete_record_email(int account_id);
+static int _ctsvc_tc_db_delete_records_email(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_email = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_email(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_email(void)
+static int _ctsvc_tc_db_get_record_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_email(void)
+static int _ctsvc_tc_db_get_records_with_query_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_email(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_email(void)
+static int _ctsvc_tc_db_get_all_records_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_email(void)
+static int _ctsvc_tc_db_get_count_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_email(void)
+static int _ctsvc_tc_db_get_count_with_query_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_email(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_email(void)
+static int _ctsvc_tc_db_insert_record_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_email(void)
+static int _ctsvc_tc_db_insert_records_email(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_email(void)
+static int _ctsvc_tc_db_update_record_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_email(void)
+static int _ctsvc_tc_db_update_records_email(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_email(void)
+static int _ctsvc_tc_db_delete_record_email(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_email(void)
+static int _ctsvc_tc_db_delete_records_email(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_email(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_email(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index e43f90b..6ca9f8d 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_event(void);
 static int _ctsvc_tc_db_remove_changed_cb_event(void);
-static int _ctsvc_tc_db_get_record_event(void);
-static int _ctsvc_tc_db_get_records_with_query_event(void);
-static int _ctsvc_tc_db_get_all_records_event(void);
-static int _ctsvc_tc_db_get_count_event(void);
-static int _ctsvc_tc_db_get_count_with_query_event(void);
-static int _ctsvc_tc_db_insert_record_event(void);
-static int _ctsvc_tc_db_insert_records_event(void);
-static int _ctsvc_tc_db_update_record_event(void);
-static int _ctsvc_tc_db_update_records_event(void);
-static int _ctsvc_tc_db_delete_record_event(void);
-static int _ctsvc_tc_db_delete_records_event(void);
+static int _ctsvc_tc_db_get_record_event(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_event(int account_id);
+static int _ctsvc_tc_db_get_all_records_event(int account_id);
+static int _ctsvc_tc_db_get_count_event(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_event(int account_id);
+static int _ctsvc_tc_db_insert_record_event(int account_id);
+static int _ctsvc_tc_db_insert_records_event(int account_id);
+static int _ctsvc_tc_db_update_record_event(int account_id);
+static int _ctsvc_tc_db_update_records_event(int account_id);
+static int _ctsvc_tc_db_delete_record_event(int account_id);
+static int _ctsvc_tc_db_delete_records_event(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_event = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_event(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_event(void)
+static int _ctsvc_tc_db_get_record_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_event(void)
+static int _ctsvc_tc_db_get_records_with_query_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_event(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_event(void)
+static int _ctsvc_tc_db_get_all_records_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_event(void)
+static int _ctsvc_tc_db_get_count_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_event(void)
+static int _ctsvc_tc_db_get_count_with_query_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_event(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_event(void)
+static int _ctsvc_tc_db_insert_record_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_event(void)
+static int _ctsvc_tc_db_insert_records_event(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_event(void)
+static int _ctsvc_tc_db_update_record_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_event(void)
+static int _ctsvc_tc_db_update_records_event(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_event(void)
+static int _ctsvc_tc_db_delete_record_event(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_event(void)
+static int _ctsvc_tc_db_delete_records_event(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_event(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_event(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 5b7fc69..ae62ef4 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_extension(void);
 static int _ctsvc_tc_db_remove_changed_cb_extension(void);
-static int _ctsvc_tc_db_get_record_extension(void);
-static int _ctsvc_tc_db_get_records_with_query_extension(void);
-static int _ctsvc_tc_db_get_all_records_extension(void);
-static int _ctsvc_tc_db_get_count_extension(void);
-static int _ctsvc_tc_db_get_count_with_query_extension(void);
-static int _ctsvc_tc_db_insert_record_extension(void);
-static int _ctsvc_tc_db_insert_records_extension(void);
-static int _ctsvc_tc_db_update_record_extension(void);
-static int _ctsvc_tc_db_update_records_extension(void);
-static int _ctsvc_tc_db_delete_record_extension(void);
-static int _ctsvc_tc_db_delete_records_extension(void);
+static int _ctsvc_tc_db_get_record_extension(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_extension(int account_id);
+static int _ctsvc_tc_db_get_all_records_extension(int account_id);
+static int _ctsvc_tc_db_get_count_extension(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_extension(int account_id);
+static int _ctsvc_tc_db_insert_record_extension(int account_id);
+static int _ctsvc_tc_db_insert_records_extension(int account_id);
+static int _ctsvc_tc_db_update_record_extension(int account_id);
+static int _ctsvc_tc_db_update_records_extension(int account_id);
+static int _ctsvc_tc_db_delete_record_extension(int account_id);
+static int _ctsvc_tc_db_delete_records_extension(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_extension = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_extension(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_extension(void)
+static int _ctsvc_tc_db_get_record_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_extension(void)
+static int _ctsvc_tc_db_get_records_with_query_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_extension(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_extension(void)
+static int _ctsvc_tc_db_get_all_records_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_extension(void)
+static int _ctsvc_tc_db_get_count_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_extension(void)
+static int _ctsvc_tc_db_get_count_with_query_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_extension(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_extension(void)
+static int _ctsvc_tc_db_insert_record_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_extension(void)
+static int _ctsvc_tc_db_insert_records_extension(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_extension(void)
+static int _ctsvc_tc_db_update_record_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_extension(void)
+static int _ctsvc_tc_db_update_records_extension(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_extension(void)
+static int _ctsvc_tc_db_delete_record_extension(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_extension(void)
+static int _ctsvc_tc_db_delete_records_extension(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_extension(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_extension(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 0616765..c9c81d8 100755 (executable)
@@ -22,7 +22,7 @@
 #include "utc-contacts-service-db-contact.h"
 #include "utc-contacts-service-db-group-member-updated-info.h"
 
-static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(void);
+static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_group_member_updated_info = {
        .db_add_changed_cb = NULL,
@@ -49,10 +49,9 @@ ctsvc_tc_db_plugin_s _tc_db_group_member_updated_info = {
        .db_search_records_with_range_for_snippet = NULL,
 };
 
-static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(void)
+static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -62,10 +61,11 @@ static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(void)
        contacts_list_h list = NULL;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
                if (0 != (ret = contacts_db_get_current_version(&version))) break;
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -80,7 +80,6 @@ static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -89,7 +88,6 @@ static int _ctsvc_tc_db_get_chages_by_version_group_member_updated_info(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
index c291e21..a234e0d 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_group_relation(void);
 static int _ctsvc_tc_db_remove_changed_cb_group_relation(void);
-static int _ctsvc_tc_db_get_records_with_query_group_relation(void);
-static int _ctsvc_tc_db_get_all_records_group_relation(void);
-static int _ctsvc_tc_db_get_count_group_relation(void);
-static int _ctsvc_tc_db_get_count_with_query_group_relation(void);
+static int _ctsvc_tc_db_get_records_with_query_group_relation(int account_id);
+static int _ctsvc_tc_db_get_all_records_group_relation(int account_id);
+static int _ctsvc_tc_db_get_count_group_relation(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_group_relation(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_group_relation = {
@@ -78,10 +78,9 @@ static int _ctsvc_tc_db_remove_changed_cb_group_relation(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_group_relation(void)
+static int _ctsvc_tc_db_get_records_with_query_group_relation(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -90,9 +89,10 @@ static int _ctsvc_tc_db_get_records_with_query_group_relation(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -113,7 +113,6 @@ static int _ctsvc_tc_db_get_records_with_query_group_relation(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -125,24 +124,23 @@ static int _ctsvc_tc_db_get_records_with_query_group_relation(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_group_relation(void)
+static int _ctsvc_tc_db_get_all_records_group_relation(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -155,7 +153,6 @@ static int _ctsvc_tc_db_get_all_records_group_relation(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -165,25 +162,24 @@ static int _ctsvc_tc_db_get_all_records_group_relation(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_group_relation(void)
+static int _ctsvc_tc_db_get_count_group_relation(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -197,7 +193,6 @@ static int _ctsvc_tc_db_get_count_group_relation(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -206,16 +201,14 @@ static int _ctsvc_tc_db_get_count_group_relation(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_group_relation(void)
+static int _ctsvc_tc_db_get_count_with_query_group_relation(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -223,9 +216,10 @@ static int _ctsvc_tc_db_get_count_with_query_group_relation(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -250,7 +244,6 @@ static int _ctsvc_tc_db_get_count_with_query_group_relation(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -261,7 +254,6 @@ static int _ctsvc_tc_db_get_count_with_query_group_relation(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index d503fa2..9ac65aa 100755 (executable)
@@ -21,7 +21,7 @@
 #include "utc-contacts-service-db-group.h"
 #include "utc-contacts-service-db-group-updated-info.h"
 
-static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(void);
+static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_group_updated_info = {
        .db_add_changed_cb = NULL,
@@ -48,10 +48,9 @@ ctsvc_tc_db_plugin_s _tc_db_group_updated_info = {
        .db_search_records_with_range_for_snippet = NULL,
 };
 
-static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(void)
+static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int version = 0;
@@ -60,10 +59,11 @@ static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(void)
        contacts_list_h list = NULL;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
                if (0 != (ret = contacts_db_get_current_version(&version))) break;
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -76,7 +76,6 @@ static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -84,7 +83,6 @@ static int _ctsvc_tc_db_get_chages_by_version_group_updated_info(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
index ed7f061..f484ba1 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_group(void);
 static int _ctsvc_tc_db_remove_changed_cb_group(void);
-static int _ctsvc_tc_db_get_record_group(void);
-static int _ctsvc_tc_db_get_records_with_query_group(void);
-static int _ctsvc_tc_db_get_all_records_group(void);
-static int _ctsvc_tc_db_get_count_group(void);
-static int _ctsvc_tc_db_get_count_with_query_group(void);
-static int _ctsvc_tc_db_insert_record_group(void);
-static int _ctsvc_tc_db_insert_records_group(void);
-static int _ctsvc_tc_db_update_record_group(void);
-static int _ctsvc_tc_db_update_records_group(void);
-static int _ctsvc_tc_db_delete_record_group(void);
-static int _ctsvc_tc_db_delete_records_group(void);
+static int _ctsvc_tc_db_get_record_group(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_group(int account_id);
+static int _ctsvc_tc_db_get_all_records_group(int account_id);
+static int _ctsvc_tc_db_get_count_group(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_group(int account_id);
+static int _ctsvc_tc_db_insert_record_group(int account_id);
+static int _ctsvc_tc_db_insert_records_group(int account_id);
+static int _ctsvc_tc_db_update_record_group(int account_id);
+static int _ctsvc_tc_db_update_records_group(int account_id);
+static int _ctsvc_tc_db_delete_record_group(int account_id);
+static int _ctsvc_tc_db_delete_records_group(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_group = {
@@ -83,16 +83,16 @@ static int _ctsvc_tc_db_remove_changed_cb_group(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_group(void)
+static int _ctsvc_tc_db_get_record_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -107,7 +107,6 @@ static int _ctsvc_tc_db_get_record_group(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -115,25 +114,24 @@ static int _ctsvc_tc_db_get_record_group(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_group(void)
+static int _ctsvc_tc_db_get_records_with_query_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -157,7 +155,6 @@ static int _ctsvc_tc_db_get_records_with_query_group(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -168,23 +165,22 @@ static int _ctsvc_tc_db_get_records_with_query_group(void)
        contacts_query_destroy(query);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_group(void)
+static int _ctsvc_tc_db_get_all_records_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -199,7 +195,6 @@ static int _ctsvc_tc_db_get_all_records_group(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -208,24 +203,23 @@ static int _ctsvc_tc_db_get_all_records_group(void)
        contacts_list_destroy(list, true);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_group(void)
+static int _ctsvc_tc_db_get_count_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -240,7 +234,6 @@ static int _ctsvc_tc_db_get_count_group(void)
                }
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -248,25 +241,24 @@ static int _ctsvc_tc_db_get_count_group(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_group(void)
+static int _ctsvc_tc_db_get_count_with_query_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -293,7 +285,6 @@ static int _ctsvc_tc_db_get_count_with_query_group(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -303,22 +294,20 @@ static int _ctsvc_tc_db_get_count_with_query_group(void)
 
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_group(void)
+static int _ctsvc_tc_db_insert_record_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -332,7 +321,6 @@ static int _ctsvc_tc_db_insert_record_group(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -340,23 +328,22 @@ static int _ctsvc_tc_db_insert_record_group(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_group(void)
+static int _ctsvc_tc_db_insert_records_group(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_list_create(&list))) break;
@@ -392,7 +379,6 @@ static int _ctsvc_tc_db_insert_records_group(void)
                ids_count = 0;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -402,22 +388,20 @@ static int _ctsvc_tc_db_insert_records_group(void)
        contacts_db_delete_records(_contacts_group._uri, ids, ids_count);
        free(ids);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_group(void)
+static int _ctsvc_tc_db_update_record_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -438,7 +422,6 @@ static int _ctsvc_tc_db_update_record_group(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -446,23 +429,22 @@ static int _ctsvc_tc_db_update_record_group(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_group(void)
+static int _ctsvc_tc_db_update_records_group(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_list_create(&list))) break;
@@ -510,7 +492,6 @@ static int _ctsvc_tc_db_update_records_group(void)
                ids_count = 0;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -520,21 +501,20 @@ static int _ctsvc_tc_db_update_records_group(void)
        contacts_db_delete_records(_contacts_group._uri, ids, ids_count);
        free(ids);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_group(void)
+static int _ctsvc_tc_db_delete_record_group(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_group(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -553,30 +533,28 @@ static int _ctsvc_tc_db_delete_record_group(void)
                }
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_group._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_group(void)
+static int _ctsvc_tc_db_delete_records_group(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_list_create(&list))) break;
@@ -617,7 +595,6 @@ static int _ctsvc_tc_db_delete_records_group(void)
                ids_count = 0;
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -627,7 +604,6 @@ static int _ctsvc_tc_db_delete_records_group(void)
        contacts_db_delete_records(_contacts_group._uri, ids, ids_count);
        free(ids);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 89295e1..a7d32c0 100755 (executable)
@@ -21,7 +21,7 @@
 #include "utc-contacts-service-db-contact.h"
 #include "utc-contacts-service-db-grouprel-updated-info.h"
 
-static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(void);
+static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_grouprel_updated_info = {
        .db_add_changed_cb = NULL,
@@ -48,10 +48,9 @@ ctsvc_tc_db_plugin_s _tc_db_grouprel_updated_info = {
        .db_search_records_with_range_for_snippet = NULL,
 };
 
-static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(void)
+static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -61,10 +60,11 @@ static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(void)
        contacts_list_h list = NULL;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
                if (0 != (ret = contacts_db_get_current_version(&version))) break;
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -79,7 +79,6 @@ static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -88,7 +87,6 @@ static int _ctsvc_tc_db_get_chages_by_version_grouprel_updated_info(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
index 6d57149..ee949d3 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_image(void);
 static int _ctsvc_tc_db_remove_changed_cb_image(void);
-static int _ctsvc_tc_db_get_record_image(void);
-static int _ctsvc_tc_db_get_records_with_query_image(void);
-static int _ctsvc_tc_db_get_all_records_image(void);
-static int _ctsvc_tc_db_get_count_image(void);
-static int _ctsvc_tc_db_get_count_with_query_image(void);
-static int _ctsvc_tc_db_insert_record_image(void);
-static int _ctsvc_tc_db_insert_records_image(void);
-static int _ctsvc_tc_db_update_record_image(void);
-static int _ctsvc_tc_db_update_records_image(void);
-static int _ctsvc_tc_db_delete_record_image(void);
-static int _ctsvc_tc_db_delete_records_image(void);
+static int _ctsvc_tc_db_get_record_image(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_image(int account_id);
+static int _ctsvc_tc_db_get_all_records_image(int account_id);
+static int _ctsvc_tc_db_get_count_image(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_image(int account_id);
+static int _ctsvc_tc_db_insert_record_image(int account_id);
+static int _ctsvc_tc_db_insert_records_image(int account_id);
+static int _ctsvc_tc_db_update_record_image(int account_id);
+static int _ctsvc_tc_db_update_records_image(int account_id);
+static int _ctsvc_tc_db_delete_record_image(int account_id);
+static int _ctsvc_tc_db_delete_records_image(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_image = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_image(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_image(void)
+static int _ctsvc_tc_db_get_record_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_image(void)
+static int _ctsvc_tc_db_get_records_with_query_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_image(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_image(void)
+static int _ctsvc_tc_db_get_all_records_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_image(void)
+static int _ctsvc_tc_db_get_count_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_image(void)
+static int _ctsvc_tc_db_get_count_with_query_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_image(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_image(void)
+static int _ctsvc_tc_db_insert_record_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_image(void)
+static int _ctsvc_tc_db_insert_records_image(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_image(void)
+static int _ctsvc_tc_db_update_record_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_image(void)
+static int _ctsvc_tc_db_update_records_image(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_image(void)
+static int _ctsvc_tc_db_delete_record_image(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_image(void)
+static int _ctsvc_tc_db_delete_records_image(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_image(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_image(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 8f6fd7c..d14764b 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_messenger(void);
 static int _ctsvc_tc_db_remove_changed_cb_messenger(void);
-static int _ctsvc_tc_db_get_record_messenger(void);
-static int _ctsvc_tc_db_get_records_with_query_messenger(void);
-static int _ctsvc_tc_db_get_all_records_messenger(void);
-static int _ctsvc_tc_db_get_count_messenger(void);
-static int _ctsvc_tc_db_get_count_with_query_messenger(void);
-static int _ctsvc_tc_db_insert_record_messenger(void);
-static int _ctsvc_tc_db_insert_records_messenger(void);
-static int _ctsvc_tc_db_update_record_messenger(void);
-static int _ctsvc_tc_db_update_records_messenger(void);
-static int _ctsvc_tc_db_delete_record_messenger(void);
-static int _ctsvc_tc_db_delete_records_messenger(void);
+static int _ctsvc_tc_db_get_record_messenger(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_messenger(int account_id);
+static int _ctsvc_tc_db_get_all_records_messenger(int account_id);
+static int _ctsvc_tc_db_get_count_messenger(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_messenger(int account_id);
+static int _ctsvc_tc_db_insert_record_messenger(int account_id);
+static int _ctsvc_tc_db_insert_records_messenger(int account_id);
+static int _ctsvc_tc_db_update_record_messenger(int account_id);
+static int _ctsvc_tc_db_update_records_messenger(int account_id);
+static int _ctsvc_tc_db_delete_record_messenger(int account_id);
+static int _ctsvc_tc_db_delete_records_messenger(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_messenger = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_messenger(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_messenger(void)
+static int _ctsvc_tc_db_get_record_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_messenger(void)
+static int _ctsvc_tc_db_get_records_with_query_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_messenger(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_messenger(void)
+static int _ctsvc_tc_db_get_all_records_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_messenger(void)
+static int _ctsvc_tc_db_get_count_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_messenger(void)
+static int _ctsvc_tc_db_get_count_with_query_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_messenger(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_messenger(void)
+static int _ctsvc_tc_db_insert_record_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_messenger(void)
+static int _ctsvc_tc_db_insert_records_messenger(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_messenger(void)
+static int _ctsvc_tc_db_update_record_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_messenger(void)
+static int _ctsvc_tc_db_update_records_messenger(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_messenger(void)
+static int _ctsvc_tc_db_delete_record_messenger(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_messenger(void)
+static int _ctsvc_tc_db_delete_records_messenger(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_messenger(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_messenger(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index b5e5a4f..82ddfca 100755 (executable)
@@ -22,7 +22,7 @@
 #include "utc-contacts-service-db-my-profile.h"
 #include "utc-contacts-service-db-contact-updated-info.h"
 
-static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(void);
+static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_my_profile_updated_info = {
        .db_add_changed_cb = NULL,
@@ -49,10 +49,9 @@ ctsvc_tc_db_plugin_s _tc_db_my_profile_updated_info = {
        .db_search_records_with_range_for_snippet = NULL,
 };
 
-static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(void)
+static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(int account_id)
 {
        int ret = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int my_profile_id = 0;
        int version = 0;
@@ -61,10 +60,11 @@ static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(void)
        contacts_list_h list = NULL;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
                if (0 != (ret = contacts_db_get_current_version(&version))) break;
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_my_profile(address_book_id, &my_profile_id))) break;
 
@@ -77,7 +77,6 @@ static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, my_profile_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -85,7 +84,6 @@ static int _ctsvc_tc_db_get_chages_by_version_my_profile_updated_info(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_my_profile._uri, my_profile_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
index a6c8bae..c559dd3 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_my_profile(void);
 static int _ctsvc_tc_db_remove_changed_cb_my_profile(void);
-static int _ctsvc_tc_db_get_record_my_profile(void);
-static int _ctsvc_tc_db_get_records_with_query_my_profile(void);
-static int _ctsvc_tc_db_get_all_records_my_profile(void);
-static int _ctsvc_tc_db_get_count_my_profile(void);
-static int _ctsvc_tc_db_get_count_with_query_my_profile(void);
-static int _ctsvc_tc_db_insert_record_my_profile(void);
-static int _ctsvc_tc_db_update_record_my_profile(void);
-static int _ctsvc_tc_db_delete_record_my_profile(void);
+static int _ctsvc_tc_db_get_record_my_profile(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_my_profile(int account_id);
+static int _ctsvc_tc_db_get_all_records_my_profile(int account_id);
+static int _ctsvc_tc_db_get_count_my_profile(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_my_profile(int account_id);
+static int _ctsvc_tc_db_insert_record_my_profile(int account_id);
+static int _ctsvc_tc_db_update_record_my_profile(int account_id);
+static int _ctsvc_tc_db_delete_record_my_profile(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_my_profile = {
@@ -81,16 +81,16 @@ static int _ctsvc_tc_db_remove_changed_cb_my_profile(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_my_profile(void)
+static int _ctsvc_tc_db_get_record_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -105,7 +105,6 @@ static int _ctsvc_tc_db_get_record_my_profile(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -113,25 +112,24 @@ static int _ctsvc_tc_db_get_record_my_profile(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_my_profile(void)
+static int _ctsvc_tc_db_get_records_with_query_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -156,7 +154,6 @@ static int _ctsvc_tc_db_get_records_with_query_my_profile(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -167,23 +164,22 @@ static int _ctsvc_tc_db_get_records_with_query_my_profile(void)
        contacts_query_destroy(query);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_my_profile(void)
+static int _ctsvc_tc_db_get_all_records_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -198,7 +194,6 @@ static int _ctsvc_tc_db_get_all_records_my_profile(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -207,24 +202,23 @@ static int _ctsvc_tc_db_get_all_records_my_profile(void)
        contacts_list_destroy(list, true);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_my_profile(void)
+static int _ctsvc_tc_db_get_count_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -239,7 +233,6 @@ static int _ctsvc_tc_db_get_count_my_profile(void)
                }
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -247,25 +240,24 @@ static int _ctsvc_tc_db_get_count_my_profile(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_my_profile(void)
+static int _ctsvc_tc_db_get_count_with_query_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -292,7 +284,6 @@ static int _ctsvc_tc_db_get_count_with_query_my_profile(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -302,22 +293,20 @@ static int _ctsvc_tc_db_get_count_with_query_my_profile(void)
 
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_my_profile(void)
+static int _ctsvc_tc_db_insert_record_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -331,7 +320,6 @@ static int _ctsvc_tc_db_insert_record_my_profile(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -339,22 +327,20 @@ static int _ctsvc_tc_db_insert_record_my_profile(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_my_profile(void)
+static int _ctsvc_tc_db_update_record_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -375,7 +361,6 @@ static int _ctsvc_tc_db_update_record_my_profile(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_my_profile._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -383,21 +368,20 @@ static int _ctsvc_tc_db_update_record_my_profile(void)
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_my_profile(void)
+static int _ctsvc_tc_db_delete_record_my_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
 
                if (0 != (ret = ctsvc_tc_record_create_my_profile(address_book_id, PROPERTY_TYPE_CREATE1, &record))) break;
@@ -416,14 +400,12 @@ static int _ctsvc_tc_db_delete_record_my_profile(void)
                }
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
        contacts_record_destroy(record, true);
        contacts_db_delete_record(_contacts_my_profile._uri, id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index d278514..07151ca 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_name(void);
 static int _ctsvc_tc_db_remove_changed_cb_name(void);
-static int _ctsvc_tc_db_get_record_name(void);
-static int _ctsvc_tc_db_get_records_with_query_name(void);
-static int _ctsvc_tc_db_get_all_records_name(void);
-static int _ctsvc_tc_db_get_count_name(void);
-static int _ctsvc_tc_db_get_count_with_query_name(void);
-static int _ctsvc_tc_db_insert_record_name(void);
-static int _ctsvc_tc_db_insert_records_name(void);
-static int _ctsvc_tc_db_update_record_name(void);
-static int _ctsvc_tc_db_update_records_name(void);
-static int _ctsvc_tc_db_delete_record_name(void);
-static int _ctsvc_tc_db_delete_records_name(void);
+static int _ctsvc_tc_db_get_record_name(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_name(int account_id);
+static int _ctsvc_tc_db_get_all_records_name(int account_id);
+static int _ctsvc_tc_db_get_count_name(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_name(int account_id);
+static int _ctsvc_tc_db_insert_record_name(int account_id);
+static int _ctsvc_tc_db_insert_records_name(int account_id);
+static int _ctsvc_tc_db_update_record_name(int account_id);
+static int _ctsvc_tc_db_update_records_name(int account_id);
+static int _ctsvc_tc_db_delete_record_name(int account_id);
+static int _ctsvc_tc_db_delete_records_name(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_name = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_name(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_name(void)
+static int _ctsvc_tc_db_get_record_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_name(void)
+static int _ctsvc_tc_db_get_records_with_query_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_name(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_name(void)
+static int _ctsvc_tc_db_get_all_records_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_name(void)
+static int _ctsvc_tc_db_get_count_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_name(void)
+static int _ctsvc_tc_db_get_count_with_query_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_name(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_name(void)
+static int _ctsvc_tc_db_insert_record_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,26 +380,25 @@ static int _ctsvc_tc_db_insert_record_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_name(void)
+static int _ctsvc_tc_db_insert_records_name(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id1 = 0;
        int contact_id2 = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id1))) break;
@@ -453,7 +440,6 @@ static int _ctsvc_tc_db_insert_records_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id2))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -466,24 +452,22 @@ static int _ctsvc_tc_db_insert_records_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id2);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_name(void)
+static int _ctsvc_tc_db_update_record_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -508,7 +492,6 @@ static int _ctsvc_tc_db_update_record_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -518,26 +501,25 @@ static int _ctsvc_tc_db_update_record_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_name(void)
+static int _ctsvc_tc_db_update_records_name(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id1 = 0;
        int contact_id2 = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id1))) break;
@@ -591,7 +573,6 @@ static int _ctsvc_tc_db_update_records_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id2))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -604,23 +585,22 @@ static int _ctsvc_tc_db_update_records_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id2);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_name(void)
+static int _ctsvc_tc_db_delete_record_name(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id))) break;
@@ -643,7 +623,6 @@ static int _ctsvc_tc_db_delete_record_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -652,26 +631,25 @@ static int _ctsvc_tc_db_delete_record_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_name(void)
+static int _ctsvc_tc_db_delete_records_name(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id1 = 0;
        int contact_id2 = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_empty_contact(address_book_id, group_id, &contact_id1))) break;
@@ -718,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_name(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id2))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -731,7 +708,6 @@ static int _ctsvc_tc_db_delete_records_name(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id2);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 6888100..fdf6583 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_nickname(void);
 static int _ctsvc_tc_db_remove_changed_cb_nickname(void);
-static int _ctsvc_tc_db_get_record_nickname(void);
-static int _ctsvc_tc_db_get_records_with_query_nickname(void);
-static int _ctsvc_tc_db_get_all_records_nickname(void);
-static int _ctsvc_tc_db_get_count_nickname(void);
-static int _ctsvc_tc_db_get_count_with_query_nickname(void);
-static int _ctsvc_tc_db_insert_record_nickname(void);
-static int _ctsvc_tc_db_insert_records_nickname(void);
-static int _ctsvc_tc_db_update_record_nickname(void);
-static int _ctsvc_tc_db_update_records_nickname(void);
-static int _ctsvc_tc_db_delete_record_nickname(void);
-static int _ctsvc_tc_db_delete_records_nickname(void);
+static int _ctsvc_tc_db_get_record_nickname(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_nickname(int account_id);
+static int _ctsvc_tc_db_get_all_records_nickname(int account_id);
+static int _ctsvc_tc_db_get_count_nickname(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_nickname(int account_id);
+static int _ctsvc_tc_db_insert_record_nickname(int account_id);
+static int _ctsvc_tc_db_insert_records_nickname(int account_id);
+static int _ctsvc_tc_db_update_record_nickname(int account_id);
+static int _ctsvc_tc_db_update_records_nickname(int account_id);
+static int _ctsvc_tc_db_delete_record_nickname(int account_id);
+static int _ctsvc_tc_db_delete_records_nickname(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_nickname = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_nickname(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_nickname(void)
+static int _ctsvc_tc_db_get_record_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_nickname(void)
+static int _ctsvc_tc_db_get_records_with_query_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_nickname(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_nickname(void)
+static int _ctsvc_tc_db_get_all_records_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_nickname(void)
+static int _ctsvc_tc_db_get_count_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_nickname(void)
+static int _ctsvc_tc_db_get_count_with_query_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_nickname(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_nickname(void)
+static int _ctsvc_tc_db_insert_record_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_nickname(void)
+static int _ctsvc_tc_db_insert_records_nickname(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_nickname(void)
+static int _ctsvc_tc_db_update_record_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_nickname(void)
+static int _ctsvc_tc_db_update_records_nickname(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_nickname(void)
+static int _ctsvc_tc_db_delete_record_nickname(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_nickname(void)
+static int _ctsvc_tc_db_delete_records_nickname(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_nickname(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_nickname(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index f4a88ab..a5bf5b9 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_note(void);
 static int _ctsvc_tc_db_remove_changed_cb_note(void);
-static int _ctsvc_tc_db_get_record_note(void);
-static int _ctsvc_tc_db_get_records_with_query_note(void);
-static int _ctsvc_tc_db_get_all_records_note(void);
-static int _ctsvc_tc_db_get_count_note(void);
-static int _ctsvc_tc_db_get_count_with_query_note(void);
-static int _ctsvc_tc_db_insert_record_note(void);
-static int _ctsvc_tc_db_insert_records_note(void);
-static int _ctsvc_tc_db_update_record_note(void);
-static int _ctsvc_tc_db_update_records_note(void);
-static int _ctsvc_tc_db_delete_record_note(void);
-static int _ctsvc_tc_db_delete_records_note(void);
+static int _ctsvc_tc_db_get_record_note(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_note(int account_id);
+static int _ctsvc_tc_db_get_all_records_note(int account_id);
+static int _ctsvc_tc_db_get_count_note(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_note(int account_id);
+static int _ctsvc_tc_db_insert_record_note(int account_id);
+static int _ctsvc_tc_db_insert_records_note(int account_id);
+static int _ctsvc_tc_db_update_record_note(int account_id);
+static int _ctsvc_tc_db_update_records_note(int account_id);
+static int _ctsvc_tc_db_delete_record_note(int account_id);
+static int _ctsvc_tc_db_delete_records_note(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_note = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_note(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_note(void)
+static int _ctsvc_tc_db_get_record_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_note(void)
+static int _ctsvc_tc_db_get_records_with_query_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_note(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_note(void)
+static int _ctsvc_tc_db_get_all_records_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_note(void)
+static int _ctsvc_tc_db_get_count_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_note(void)
+static int _ctsvc_tc_db_get_count_with_query_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_note(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_note(void)
+static int _ctsvc_tc_db_insert_record_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_note(void)
+static int _ctsvc_tc_db_insert_records_note(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_note(void)
+static int _ctsvc_tc_db_update_record_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_note(void)
+static int _ctsvc_tc_db_update_records_note(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_note(void)
+static int _ctsvc_tc_db_delete_record_note(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_note(void)
+static int _ctsvc_tc_db_delete_records_note(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_note(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_note(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index d5ac668..1a17aff 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_number(void);
 static int _ctsvc_tc_db_remove_changed_cb_number(void);
-static int _ctsvc_tc_db_get_record_number(void);
-static int _ctsvc_tc_db_get_records_with_query_number(void);
-static int _ctsvc_tc_db_get_all_records_number(void);
-static int _ctsvc_tc_db_get_count_number(void);
-static int _ctsvc_tc_db_get_count_with_query_number(void);
-static int _ctsvc_tc_db_insert_record_number(void);
-static int _ctsvc_tc_db_insert_records_number(void);
-static int _ctsvc_tc_db_update_record_number(void);
-static int _ctsvc_tc_db_update_records_number(void);
-static int _ctsvc_tc_db_delete_record_number(void);
-static int _ctsvc_tc_db_delete_records_number(void);
+static int _ctsvc_tc_db_get_record_number(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_number(int account_id);
+static int _ctsvc_tc_db_get_all_records_number(int account_id);
+static int _ctsvc_tc_db_get_count_number(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_number(int account_id);
+static int _ctsvc_tc_db_insert_record_number(int account_id);
+static int _ctsvc_tc_db_insert_records_number(int account_id);
+static int _ctsvc_tc_db_update_record_number(int account_id);
+static int _ctsvc_tc_db_update_records_number(int account_id);
+static int _ctsvc_tc_db_delete_record_number(int account_id);
+static int _ctsvc_tc_db_delete_records_number(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_number = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_number(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_number(void)
+static int _ctsvc_tc_db_get_record_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_number(void)
+static int _ctsvc_tc_db_get_records_with_query_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_number(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_number(void)
+static int _ctsvc_tc_db_get_all_records_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_number(void)
+static int _ctsvc_tc_db_get_count_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_number(void)
+static int _ctsvc_tc_db_get_count_with_query_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_number(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_number(void)
+static int _ctsvc_tc_db_insert_record_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_number(void)
+static int _ctsvc_tc_db_insert_records_number(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_number(void)
+static int _ctsvc_tc_db_update_record_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_number(void)
+static int _ctsvc_tc_db_update_records_number(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_number(void)
+static int _ctsvc_tc_db_delete_record_number(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_number(void)
+static int _ctsvc_tc_db_delete_records_number(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_number(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_number(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 1400e08..e9a5ad4 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_person(void);
 static int _ctsvc_tc_db_remove_changed_cb_person(void);
-static int _ctsvc_tc_db_get_record_person(void);
-static int _ctsvc_tc_db_get_records_with_query_person(void);
-static int _ctsvc_tc_db_get_all_records_person(void);
-static int _ctsvc_tc_db_get_count_person(void);
-static int _ctsvc_tc_db_get_count_with_query_person(void);
-static int _ctsvc_tc_db_update_record_person(void);
-static int _ctsvc_tc_db_update_records_person(void);
-static int _ctsvc_tc_db_delete_record_person(void);
-static int _ctsvc_tc_db_delete_records_person(void);
-static int _ctsvc_tc_db_search_records_person(void);
-static int _ctsvc_tc_db_search_records_with_query_person(void);
-static int _ctsvc_tc_db_search_records_with_range_person(void);
-static int _ctsvc_tc_db_search_records_for_snippet_person(void);
-static int _ctsvc_tc_db_search_records_with_query_for_snippet_person(void);
-static int _ctsvc_tc_db_search_records_with_range_for_snippet_person(void);
+static int _ctsvc_tc_db_get_record_person(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_person(int account_id);
+static int _ctsvc_tc_db_get_all_records_person(int account_id);
+static int _ctsvc_tc_db_get_count_person(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_person(int account_id);
+static int _ctsvc_tc_db_update_record_person(int account_id);
+static int _ctsvc_tc_db_update_records_person(int account_id);
+static int _ctsvc_tc_db_delete_record_person(int account_id);
+static int _ctsvc_tc_db_delete_records_person(int account_id);
+static int _ctsvc_tc_db_search_records_person(int account_id);
+static int _ctsvc_tc_db_search_records_with_query_person(int account_id);
+static int _ctsvc_tc_db_search_records_with_range_person(int account_id);
+static int _ctsvc_tc_db_search_records_for_snippet_person(int account_id);
+static int _ctsvc_tc_db_search_records_with_query_for_snippet_person(int account_id);
+static int _ctsvc_tc_db_search_records_with_range_for_snippet_person(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_person = {
@@ -90,17 +90,17 @@ static int _ctsvc_tc_db_remove_changed_cb_person(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_person(void)
+static int _ctsvc_tc_db_get_record_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -112,7 +112,6 @@ static int _ctsvc_tc_db_get_record_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_person._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -121,16 +120,14 @@ static int _ctsvc_tc_db_get_record_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_person(void)
+static int _ctsvc_tc_db_get_records_with_query_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
@@ -138,9 +135,10 @@ static int _ctsvc_tc_db_get_records_with_query_person(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -161,7 +159,6 @@ static int _ctsvc_tc_db_get_records_with_query_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_person._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -173,24 +170,23 @@ static int _ctsvc_tc_db_get_records_with_query_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_person(void)
+static int _ctsvc_tc_db_get_all_records_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -203,7 +199,6 @@ static int _ctsvc_tc_db_get_all_records_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_person._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -213,25 +208,24 @@ static int _ctsvc_tc_db_get_all_records_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_person(void)
+static int _ctsvc_tc_db_get_count_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -244,7 +238,6 @@ static int _ctsvc_tc_db_get_count_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_person._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -253,26 +246,25 @@ static int _ctsvc_tc_db_get_count_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_person(void)
+static int _ctsvc_tc_db_get_count_with_query_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -297,7 +289,6 @@ static int _ctsvc_tc_db_get_count_with_query_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_person._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -308,23 +299,21 @@ static int _ctsvc_tc_db_get_count_with_query_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_person(void)
+static int _ctsvc_tc_db_update_record_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -343,7 +332,6 @@ static int _ctsvc_tc_db_update_record_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_person._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -352,24 +340,23 @@ static int _ctsvc_tc_db_update_record_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_person(void)
+static int _ctsvc_tc_db_update_records_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -405,7 +392,6 @@ static int _ctsvc_tc_db_update_records_person(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -415,22 +401,21 @@ static int _ctsvc_tc_db_update_records_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_person(void)
+static int _ctsvc_tc_db_delete_record_person(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_person(address_book_id, group_id, PROPERTY_TYPE_CREATE1, &id))) break;
@@ -447,7 +432,6 @@ static int _ctsvc_tc_db_delete_record_person(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -455,24 +439,23 @@ static int _ctsvc_tc_db_delete_record_person(void)
        contacts_db_delete_record(_contacts_person._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_person(void)
+static int _ctsvc_tc_db_delete_records_person(int account_id)
 {
        int ret = 0;
        int ids[2] = {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -501,7 +484,6 @@ static int _ctsvc_tc_db_delete_records_person(void)
 
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -511,24 +493,23 @@ static int _ctsvc_tc_db_delete_records_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_search_records_person(void)
+static int _ctsvc_tc_db_search_records_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -549,7 +530,6 @@ static int _ctsvc_tc_db_search_records_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_records(_contacts_person._uri, ids, ids_count))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -558,26 +538,25 @@ static int _ctsvc_tc_db_search_records_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_search_records_with_query_person(void)
+static int _ctsvc_tc_db_search_records_with_query_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -603,7 +582,6 @@ static int _ctsvc_tc_db_search_records_with_query_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_records(_contacts_person._uri, ids, ids_count))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -612,24 +590,23 @@ static int _ctsvc_tc_db_search_records_with_query_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_search_records_with_range_person(void)
+static int _ctsvc_tc_db_search_records_with_range_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -651,7 +628,6 @@ static int _ctsvc_tc_db_search_records_with_range_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_records(_contacts_person._uri, ids, ids_count))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -660,24 +636,23 @@ static int _ctsvc_tc_db_search_records_with_range_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_search_records_for_snippet_person(void)
+static int _ctsvc_tc_db_search_records_for_snippet_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -699,7 +674,6 @@ static int _ctsvc_tc_db_search_records_for_snippet_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_records(_contacts_person._uri, ids, ids_count))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -708,26 +682,25 @@ static int _ctsvc_tc_db_search_records_for_snippet_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_search_records_with_query_for_snippet_person(void)
+static int _ctsvc_tc_db_search_records_with_query_for_snippet_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -754,7 +727,6 @@ static int _ctsvc_tc_db_search_records_with_query_for_snippet_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_records(_contacts_person._uri, ids, ids_count))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -763,24 +735,23 @@ static int _ctsvc_tc_db_search_records_with_query_for_snippet_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_search_records_with_range_for_snippet_person(void)
+static int _ctsvc_tc_db_search_records_with_range_for_snippet_person(int account_id)
 {
        int ret = 0;
        int ids[2]= {0};
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -803,7 +774,6 @@ static int _ctsvc_tc_db_search_records_with_range_for_snippet_person(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_records(_contacts_person._uri, ids, ids_count))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -812,7 +782,6 @@ static int _ctsvc_tc_db_search_records_with_range_for_snippet_person(void)
        contacts_db_delete_records(_contacts_person._uri, ids, ids_count);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index fd3df76..597b4f5 100755 (executable)
 #include "utc-contacts-service-db-contact.h"
 #include "utc-contacts-service-db-phone-log.h"
 
-static int _ctsvc_tc_db_get_records_with_query_phone_log_stat(void);
-static int _ctsvc_tc_db_get_all_records_phone_log_stat(void);
-static int _ctsvc_tc_db_get_count_phone_log_stat(void);
-static int _ctsvc_tc_db_get_count_with_query_phone_log_stat(void);
+static int _ctsvc_tc_db_get_records_with_query_phone_log_stat(int account_id);
+static int _ctsvc_tc_db_get_all_records_phone_log_stat(int account_id);
+static int _ctsvc_tc_db_get_count_phone_log_stat(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_phone_log_stat(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_phone_log_stat = {
        .db_add_changed_cb = NULL,
@@ -54,7 +54,7 @@ ctsvc_tc_db_plugin_s _tc_db_phone_log_stat = {
        .db_search_records_with_range_for_snippet = NULL,
 };
 
-static int _ctsvc_tc_db_get_records_with_query_phone_log_stat(void)
+static int _ctsvc_tc_db_get_records_with_query_phone_log_stat(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -97,7 +97,7 @@ static int _ctsvc_tc_db_get_records_with_query_phone_log_stat(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_phone_log_stat(void)
+static int _ctsvc_tc_db_get_all_records_phone_log_stat(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -131,7 +131,7 @@ static int _ctsvc_tc_db_get_all_records_phone_log_stat(void)
 }
 
 
-static int _ctsvc_tc_db_get_count_phone_log_stat(void)
+static int _ctsvc_tc_db_get_count_phone_log_stat(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -161,7 +161,7 @@ static int _ctsvc_tc_db_get_count_phone_log_stat(void)
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_phone_log_stat(void)
+static int _ctsvc_tc_db_get_count_with_query_phone_log_stat(int account_id)
 {
        int ret = 0;
        int id = 0;
index 3f62df1..899a96a 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_phone_log(void);
 static int _ctsvc_tc_db_remove_changed_cb_phone_log(void);
-static int _ctsvc_tc_db_get_record_phone_log(void);
-static int _ctsvc_tc_db_get_records_with_query_phone_log(void);
-static int _ctsvc_tc_db_get_all_records_phone_log(void);
-static int _ctsvc_tc_db_get_count_phone_log(void);
-static int _ctsvc_tc_db_get_count_with_query_phone_log(void);
-static int _ctsvc_tc_db_insert_record_phone_log(void);
-static int _ctsvc_tc_db_insert_records_phone_log(void);
-static int _ctsvc_tc_db_update_record_phone_log(void);
-static int _ctsvc_tc_db_update_records_phone_log(void);
-static int _ctsvc_tc_db_delete_record_phone_log(void);
-static int _ctsvc_tc_db_delete_records_phone_log(void);
+static int _ctsvc_tc_db_get_record_phone_log(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_phone_log(int account_id);
+static int _ctsvc_tc_db_get_all_records_phone_log(int account_id);
+static int _ctsvc_tc_db_get_count_phone_log(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_phone_log(int account_id);
+static int _ctsvc_tc_db_insert_record_phone_log(int account_id);
+static int _ctsvc_tc_db_insert_records_phone_log(int account_id);
+static int _ctsvc_tc_db_update_record_phone_log(int account_id);
+static int _ctsvc_tc_db_update_records_phone_log(int account_id);
+static int _ctsvc_tc_db_delete_record_phone_log(int account_id);
+static int _ctsvc_tc_db_delete_records_phone_log(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_phone_log = {
@@ -86,7 +86,7 @@ static int _ctsvc_tc_db_remove_changed_cb_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_phone_log(void)
+static int _ctsvc_tc_db_get_record_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -114,7 +114,7 @@ static int _ctsvc_tc_db_get_record_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_phone_log(void)
+static int _ctsvc_tc_db_get_records_with_query_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -158,7 +158,7 @@ static int _ctsvc_tc_db_get_records_with_query_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_phone_log(void)
+static int _ctsvc_tc_db_get_all_records_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -192,7 +192,7 @@ static int _ctsvc_tc_db_get_all_records_phone_log(void)
 }
 
 
-static int _ctsvc_tc_db_get_count_phone_log(void)
+static int _ctsvc_tc_db_get_count_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -222,7 +222,7 @@ static int _ctsvc_tc_db_get_count_phone_log(void)
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_phone_log(void)
+static int _ctsvc_tc_db_get_count_with_query_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -266,7 +266,7 @@ static int _ctsvc_tc_db_get_count_with_query_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_phone_log(void)
+static int _ctsvc_tc_db_insert_record_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -293,7 +293,7 @@ static int _ctsvc_tc_db_insert_record_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_phone_log(void)
+static int _ctsvc_tc_db_insert_records_phone_log(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
@@ -345,7 +345,7 @@ static int _ctsvc_tc_db_insert_records_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_phone_log(void)
+static int _ctsvc_tc_db_update_record_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -378,7 +378,7 @@ static int _ctsvc_tc_db_update_record_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_phone_log(void)
+static int _ctsvc_tc_db_update_records_phone_log(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
@@ -441,7 +441,7 @@ static int _ctsvc_tc_db_update_records_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_phone_log(void)
+static int _ctsvc_tc_db_delete_record_phone_log(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -471,7 +471,7 @@ static int _ctsvc_tc_db_delete_record_phone_log(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_phone_log(void)
+static int _ctsvc_tc_db_delete_records_phone_log(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
index f12c464..dc642a0 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_profile(void);
 static int _ctsvc_tc_db_remove_changed_cb_profile(void);
-static int _ctsvc_tc_db_get_record_profile(void);
-static int _ctsvc_tc_db_get_records_with_query_profile(void);
-static int _ctsvc_tc_db_get_all_records_profile(void);
-static int _ctsvc_tc_db_get_count_profile(void);
-static int _ctsvc_tc_db_get_count_with_query_profile(void);
-static int _ctsvc_tc_db_insert_record_profile(void);
-static int _ctsvc_tc_db_insert_records_profile(void);
-static int _ctsvc_tc_db_update_record_profile(void);
-static int _ctsvc_tc_db_update_records_profile(void);
-static int _ctsvc_tc_db_delete_record_profile(void);
-static int _ctsvc_tc_db_delete_records_profile(void);
+static int _ctsvc_tc_db_get_record_profile(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_profile(int account_id);
+static int _ctsvc_tc_db_get_all_records_profile(int account_id);
+static int _ctsvc_tc_db_get_count_profile(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_profile(int account_id);
+static int _ctsvc_tc_db_insert_record_profile(int account_id);
+static int _ctsvc_tc_db_insert_records_profile(int account_id);
+static int _ctsvc_tc_db_update_record_profile(int account_id);
+static int _ctsvc_tc_db_update_records_profile(int account_id);
+static int _ctsvc_tc_db_delete_record_profile(int account_id);
+static int _ctsvc_tc_db_delete_records_profile(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_profile = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_profile(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_profile(void)
+static int _ctsvc_tc_db_get_record_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_profile(void)
+static int _ctsvc_tc_db_get_records_with_query_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_profile(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_profile(void)
+static int _ctsvc_tc_db_get_all_records_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_profile(void)
+static int _ctsvc_tc_db_get_count_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_profile(void)
+static int _ctsvc_tc_db_get_count_with_query_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_profile(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_profile(void)
+static int _ctsvc_tc_db_insert_record_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_profile(void)
+static int _ctsvc_tc_db_insert_records_profile(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_profile(void)
+static int _ctsvc_tc_db_update_record_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_profile(void)
+static int _ctsvc_tc_db_update_records_profile(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_profile(void)
+static int _ctsvc_tc_db_delete_record_profile(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_profile(void)
+static int _ctsvc_tc_db_delete_records_profile(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_profile(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_profile(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 2b3897f..f6b9294 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_relationship(void);
 static int _ctsvc_tc_db_remove_changed_cb_relationship(void);
-static int _ctsvc_tc_db_get_record_relationship(void);
-static int _ctsvc_tc_db_get_records_with_query_relationship(void);
-static int _ctsvc_tc_db_get_all_records_relationship(void);
-static int _ctsvc_tc_db_get_count_relationship(void);
-static int _ctsvc_tc_db_get_count_with_query_relationship(void);
-static int _ctsvc_tc_db_insert_record_relationship(void);
-static int _ctsvc_tc_db_insert_records_relationship(void);
-static int _ctsvc_tc_db_update_record_relationship(void);
-static int _ctsvc_tc_db_update_records_relationship(void);
-static int _ctsvc_tc_db_delete_record_relationship(void);
-static int _ctsvc_tc_db_delete_records_relationship(void);
+static int _ctsvc_tc_db_get_record_relationship(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_relationship(int account_id);
+static int _ctsvc_tc_db_get_all_records_relationship(int account_id);
+static int _ctsvc_tc_db_get_count_relationship(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_relationship(int account_id);
+static int _ctsvc_tc_db_insert_record_relationship(int account_id);
+static int _ctsvc_tc_db_insert_records_relationship(int account_id);
+static int _ctsvc_tc_db_update_record_relationship(int account_id);
+static int _ctsvc_tc_db_update_records_relationship(int account_id);
+static int _ctsvc_tc_db_delete_record_relationship(int account_id);
+static int _ctsvc_tc_db_delete_records_relationship(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_relationship = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_relationship(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_relationship(void)
+static int _ctsvc_tc_db_get_record_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_relationship(void)
+static int _ctsvc_tc_db_get_records_with_query_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_relationship(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_relationship(void)
+static int _ctsvc_tc_db_get_all_records_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_relationship(void)
+static int _ctsvc_tc_db_get_count_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_relationship(void)
+static int _ctsvc_tc_db_get_count_with_query_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_relationship(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_relationship(void)
+static int _ctsvc_tc_db_insert_record_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_relationship(void)
+static int _ctsvc_tc_db_insert_records_relationship(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_relationship(void)
+static int _ctsvc_tc_db_update_record_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_relationship(void)
+static int _ctsvc_tc_db_update_records_relationship(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_relationship(void)
+static int _ctsvc_tc_db_delete_record_relationship(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_relationship(void)
+static int _ctsvc_tc_db_delete_records_relationship(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_relationship(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_relationship(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index a4bc6bc..22aade4 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_sdn(void);
 static int _ctsvc_tc_db_remove_changed_cb_sdn(void);
-static int _ctsvc_tc_db_get_record_sdn(void);
-static int _ctsvc_tc_db_get_records_with_query_sdn(void);
-static int _ctsvc_tc_db_get_all_records_sdn(void);
-static int _ctsvc_tc_db_get_count_sdn(void);
-static int _ctsvc_tc_db_get_count_with_query_sdn(void);
+static int _ctsvc_tc_db_get_record_sdn(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_sdn(int account_id);
+static int _ctsvc_tc_db_get_all_records_sdn(int account_id);
+static int _ctsvc_tc_db_get_count_sdn(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_sdn(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_sdn = {
        .db_add_changed_cb = _ctsvc_tc_db_add_changed_cb_sdn,
@@ -92,7 +92,7 @@ static int _ctsvc_tc_db_get_sdn_id(int *p_id)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_sdn(void)
+static int _ctsvc_tc_db_get_record_sdn(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -113,7 +113,7 @@ static int _ctsvc_tc_db_get_record_sdn(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_sdn(void)
+static int _ctsvc_tc_db_get_records_with_query_sdn(int account_id)
 {
        int ret = 0;
        int id = 0;
@@ -152,7 +152,7 @@ static int _ctsvc_tc_db_get_records_with_query_sdn(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_sdn(void)
+static int _ctsvc_tc_db_get_all_records_sdn(int account_id)
 {
        int ret = 0;
        contacts_record_h record = NULL;
@@ -177,7 +177,7 @@ static int _ctsvc_tc_db_get_all_records_sdn(void)
 }
 
 
-static int _ctsvc_tc_db_get_count_sdn(void)
+static int _ctsvc_tc_db_get_count_sdn(int account_id)
 {
        int ret = 0;
        int count = 0;
@@ -199,7 +199,7 @@ static int _ctsvc_tc_db_get_count_sdn(void)
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_sdn(void)
+static int _ctsvc_tc_db_get_count_with_query_sdn(int account_id)
 {
        int ret = 0;
        int id = 0;
index 858cc84..0a2c27f 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_simple_contact(void);
 static int _ctsvc_tc_db_remove_changed_cb_simple_contact(void);
-static int _ctsvc_tc_db_get_record_simple_contact(void);
-static int _ctsvc_tc_db_get_records_with_query_simple_contact(void);
-static int _ctsvc_tc_db_get_all_records_simple_contact(void);
-static int _ctsvc_tc_db_get_count_simple_contact(void);
-static int _ctsvc_tc_db_get_count_with_query_simple_contact(void);
+static int _ctsvc_tc_db_get_record_simple_contact(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_simple_contact(int account_id);
+static int _ctsvc_tc_db_get_all_records_simple_contact(int account_id);
+static int _ctsvc_tc_db_get_count_simple_contact(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_simple_contact(int account_id);
 
 ctsvc_tc_db_plugin_s _tc_db_simple_contact = {
        .db_add_changed_cb = _ctsvc_tc_db_add_changed_cb_simple_contact,
@@ -77,17 +77,17 @@ static int _ctsvc_tc_db_remove_changed_cb_simple_contact(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_simple_contact(void)
+static int _ctsvc_tc_db_get_record_simple_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -104,7 +104,6 @@ static int _ctsvc_tc_db_get_record_simple_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -113,16 +112,14 @@ static int _ctsvc_tc_db_get_record_simple_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_simple_contact(void)
+static int _ctsvc_tc_db_get_records_with_query_simple_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
@@ -130,9 +127,10 @@ static int _ctsvc_tc_db_get_records_with_query_simple_contact(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -159,7 +157,6 @@ static int _ctsvc_tc_db_get_records_with_query_simple_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -171,24 +168,23 @@ static int _ctsvc_tc_db_get_records_with_query_simple_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_simple_contact(void)
+static int _ctsvc_tc_db_get_all_records_simple_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -205,7 +201,6 @@ static int _ctsvc_tc_db_get_all_records_simple_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -215,25 +210,24 @@ static int _ctsvc_tc_db_get_all_records_simple_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_simple_contact(void)
+static int _ctsvc_tc_db_get_count_simple_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -250,7 +244,6 @@ static int _ctsvc_tc_db_get_count_simple_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -259,26 +252,25 @@ static int _ctsvc_tc_db_get_count_simple_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_simple_contact(void)
+static int _ctsvc_tc_db_get_count_with_query_simple_contact(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
 
@@ -307,7 +299,6 @@ static int _ctsvc_tc_db_get_count_with_query_simple_contact(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -318,7 +309,6 @@ static int _ctsvc_tc_db_get_count_with_query_simple_contact(void)
        contacts_db_delete_record(_contacts_contact._uri, id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 06cc2b6..0f071da 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_sip(void);
 static int _ctsvc_tc_db_remove_changed_cb_sip(void);
-static int _ctsvc_tc_db_get_record_sip(void);
-static int _ctsvc_tc_db_get_records_with_query_sip(void);
-static int _ctsvc_tc_db_get_all_records_sip(void);
-static int _ctsvc_tc_db_get_count_sip(void);
-static int _ctsvc_tc_db_get_count_with_query_sip(void);
-static int _ctsvc_tc_db_insert_record_sip(void);
-static int _ctsvc_tc_db_insert_records_sip(void);
-static int _ctsvc_tc_db_update_record_sip(void);
-static int _ctsvc_tc_db_update_records_sip(void);
-static int _ctsvc_tc_db_delete_record_sip(void);
-static int _ctsvc_tc_db_delete_records_sip(void);
+static int _ctsvc_tc_db_get_record_sip(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_sip(int account_id);
+static int _ctsvc_tc_db_get_all_records_sip(int account_id);
+static int _ctsvc_tc_db_get_count_sip(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_sip(int account_id);
+static int _ctsvc_tc_db_insert_record_sip(int account_id);
+static int _ctsvc_tc_db_insert_records_sip(int account_id);
+static int _ctsvc_tc_db_update_record_sip(int account_id);
+static int _ctsvc_tc_db_update_records_sip(int account_id);
+static int _ctsvc_tc_db_delete_record_sip(int account_id);
+static int _ctsvc_tc_db_delete_records_sip(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_sip = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_sip(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_sip(void)
+static int _ctsvc_tc_db_get_record_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_sip(void)
+static int _ctsvc_tc_db_get_records_with_query_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_sip(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_sip(void)
+static int _ctsvc_tc_db_get_all_records_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_sip(void)
+static int _ctsvc_tc_db_get_count_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_sip(void)
+static int _ctsvc_tc_db_get_count_with_query_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_sip(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_sip(void)
+static int _ctsvc_tc_db_insert_record_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_sip(void)
+static int _ctsvc_tc_db_insert_records_sip(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_sip(void)
+static int _ctsvc_tc_db_update_record_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_sip(void)
+static int _ctsvc_tc_db_update_records_sip(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_sip(void)
+static int _ctsvc_tc_db_delete_record_sip(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_sip(void)
+static int _ctsvc_tc_db_delete_records_sip(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_sip(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_sip(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 3cd6838..1ff7418 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_speeddial(void);
 static int _ctsvc_tc_db_remove_changed_cb_speeddial(void);
-static int _ctsvc_tc_db_get_record_speeddial(void);
-static int _ctsvc_tc_db_get_records_with_query_speeddial(void);
-static int _ctsvc_tc_db_get_all_records_speeddial(void);
-static int _ctsvc_tc_db_get_count_speeddial(void);
-static int _ctsvc_tc_db_get_count_with_query_speeddial(void);
-static int _ctsvc_tc_db_insert_record_speeddial(void);
-static int _ctsvc_tc_db_insert_records_speeddial(void);
-static int _ctsvc_tc_db_update_record_speeddial(void);
-static int _ctsvc_tc_db_update_records_speeddial(void);
-static int _ctsvc_tc_db_delete_record_speeddial(void);
-static int _ctsvc_tc_db_delete_records_speeddial(void);
+static int _ctsvc_tc_db_get_record_speeddial(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_speeddial(int account_id);
+static int _ctsvc_tc_db_get_all_records_speeddial(int account_id);
+static int _ctsvc_tc_db_get_count_speeddial(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_speeddial(int account_id);
+static int _ctsvc_tc_db_insert_record_speeddial(int account_id);
+static int _ctsvc_tc_db_insert_records_speeddial(int account_id);
+static int _ctsvc_tc_db_update_record_speeddial(int account_id);
+static int _ctsvc_tc_db_update_records_speeddial(int account_id);
+static int _ctsvc_tc_db_delete_record_speeddial(int account_id);
+static int _ctsvc_tc_db_delete_records_speeddial(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_speeddial = {
@@ -87,19 +87,19 @@ static int _ctsvc_tc_db_remove_changed_cb_speeddial(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_speeddial(void)
+static int _ctsvc_tc_db_get_record_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int number_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -121,7 +121,6 @@ static int _ctsvc_tc_db_get_record_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -132,16 +131,14 @@ static int _ctsvc_tc_db_get_record_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_speeddial(void)
+static int _ctsvc_tc_db_get_records_with_query_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -151,9 +148,10 @@ static int _ctsvc_tc_db_get_records_with_query_speeddial(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -183,7 +181,6 @@ static int _ctsvc_tc_db_get_records_with_query_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -197,16 +194,14 @@ static int _ctsvc_tc_db_get_records_with_query_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_speeddial(void)
+static int _ctsvc_tc_db_get_all_records_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -214,9 +209,10 @@ static int _ctsvc_tc_db_get_all_records_speeddial(void)
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -237,7 +233,6 @@ static int _ctsvc_tc_db_get_all_records_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -249,27 +244,26 @@ static int _ctsvc_tc_db_get_all_records_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_speeddial(void)
+static int _ctsvc_tc_db_get_count_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int number_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -291,7 +285,6 @@ static int _ctsvc_tc_db_get_count_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -302,17 +295,15 @@ static int _ctsvc_tc_db_get_count_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_speeddial(void)
+static int _ctsvc_tc_db_get_count_with_query_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -321,9 +312,10 @@ static int _ctsvc_tc_db_get_count_with_query_speeddial(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -356,7 +348,6 @@ static int _ctsvc_tc_db_get_count_with_query_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -369,25 +360,23 @@ static int _ctsvc_tc_db_get_count_with_query_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_speeddial(void)
+static int _ctsvc_tc_db_insert_record_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int number_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -407,7 +396,6 @@ static int _ctsvc_tc_db_insert_record_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -418,17 +406,15 @@ static int _ctsvc_tc_db_insert_record_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_speeddial(void)
+static int _ctsvc_tc_db_insert_records_speeddial(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -436,9 +422,10 @@ static int _ctsvc_tc_db_insert_records_speeddial(void)
        int number_id2 = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -482,7 +469,6 @@ static int _ctsvc_tc_db_insert_records_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -496,26 +482,24 @@ static int _ctsvc_tc_db_insert_records_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_speeddial(void)
+static int _ctsvc_tc_db_update_record_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int number_id = 0;
        int number_id2 = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -544,7 +528,6 @@ static int _ctsvc_tc_db_update_record_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -556,17 +539,15 @@ static int _ctsvc_tc_db_update_record_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_speeddial(void)
+static int _ctsvc_tc_db_update_records_speeddial(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -576,9 +557,10 @@ static int _ctsvc_tc_db_update_records_speeddial(void)
        int number_id4 = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -640,7 +622,6 @@ static int _ctsvc_tc_db_update_records_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -656,24 +637,23 @@ static int _ctsvc_tc_db_update_records_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_speeddial(void)
+static int _ctsvc_tc_db_delete_record_speeddial(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int number_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -698,7 +678,6 @@ static int _ctsvc_tc_db_delete_record_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -708,17 +687,15 @@ static int _ctsvc_tc_db_delete_record_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_speeddial(void)
+static int _ctsvc_tc_db_delete_records_speeddial(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -726,9 +703,10 @@ static int _ctsvc_tc_db_delete_records_speeddial(void)
        int number_id2 = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -777,7 +755,6 @@ static int _ctsvc_tc_db_delete_records_speeddial(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -792,7 +769,6 @@ static int _ctsvc_tc_db_delete_records_speeddial(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index 0401877..470809c 100755 (executable)
 
 static int _ctsvc_tc_db_add_changed_cb_url(void);
 static int _ctsvc_tc_db_remove_changed_cb_url(void);
-static int _ctsvc_tc_db_get_record_url(void);
-static int _ctsvc_tc_db_get_records_with_query_url(void);
-static int _ctsvc_tc_db_get_all_records_url(void);
-static int _ctsvc_tc_db_get_count_url(void);
-static int _ctsvc_tc_db_get_count_with_query_url(void);
-static int _ctsvc_tc_db_insert_record_url(void);
-static int _ctsvc_tc_db_insert_records_url(void);
-static int _ctsvc_tc_db_update_record_url(void);
-static int _ctsvc_tc_db_update_records_url(void);
-static int _ctsvc_tc_db_delete_record_url(void);
-static int _ctsvc_tc_db_delete_records_url(void);
+static int _ctsvc_tc_db_get_record_url(int account_id);
+static int _ctsvc_tc_db_get_records_with_query_url(int account_id);
+static int _ctsvc_tc_db_get_all_records_url(int account_id);
+static int _ctsvc_tc_db_get_count_url(int account_id);
+static int _ctsvc_tc_db_get_count_with_query_url(int account_id);
+static int _ctsvc_tc_db_insert_record_url(int account_id);
+static int _ctsvc_tc_db_insert_records_url(int account_id);
+static int _ctsvc_tc_db_update_record_url(int account_id);
+static int _ctsvc_tc_db_update_records_url(int account_id);
+static int _ctsvc_tc_db_delete_record_url(int account_id);
+static int _ctsvc_tc_db_delete_records_url(int account_id);
 
 
 ctsvc_tc_db_plugin_s _tc_db_url = {
@@ -86,18 +86,18 @@ static int _ctsvc_tc_db_remove_changed_cb_url(void)
        return ret;
 }
 
-static int _ctsvc_tc_db_get_record_url(void)
+static int _ctsvc_tc_db_get_record_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -116,7 +116,6 @@ static int _ctsvc_tc_db_get_record_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -126,16 +125,14 @@ static int _ctsvc_tc_db_get_record_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_records_with_query_url(void)
+static int _ctsvc_tc_db_get_records_with_query_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -144,9 +141,10 @@ static int _ctsvc_tc_db_get_records_with_query_url(void)
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -174,7 +172,6 @@ static int _ctsvc_tc_db_get_records_with_query_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -187,25 +184,24 @@ static int _ctsvc_tc_db_get_records_with_query_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_get_all_records_url(void)
+static int _ctsvc_tc_db_get_all_records_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_record_h record_p = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -224,7 +220,6 @@ static int _ctsvc_tc_db_get_all_records_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -235,26 +230,25 @@ static int _ctsvc_tc_db_get_all_records_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 
 }
 
 
-static int _ctsvc_tc_db_get_count_url(void)
+static int _ctsvc_tc_db_get_count_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        int count = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -274,7 +268,6 @@ static int _ctsvc_tc_db_get_count_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -284,17 +277,15 @@ static int _ctsvc_tc_db_get_count_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
 
-static int _ctsvc_tc_db_get_count_with_query_url(void)
+static int _ctsvc_tc_db_get_count_with_query_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
@@ -302,9 +293,10 @@ static int _ctsvc_tc_db_get_count_with_query_url(void)
        contacts_record_h record = NULL;
        contacts_query_h query = NULL;
        contacts_filter_h filter = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -335,7 +327,6 @@ static int _ctsvc_tc_db_get_count_with_query_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -347,24 +338,22 @@ static int _ctsvc_tc_db_get_count_with_query_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_record_url(void)
+static int _ctsvc_tc_db_insert_record_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -382,7 +371,6 @@ static int _ctsvc_tc_db_insert_record_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -392,25 +380,24 @@ static int _ctsvc_tc_db_insert_record_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_insert_records_url(void)
+static int _ctsvc_tc_db_insert_records_url(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -450,7 +437,6 @@ static int _ctsvc_tc_db_insert_records_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -462,24 +448,22 @@ static int _ctsvc_tc_db_insert_records_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_record_url(void)
+static int _ctsvc_tc_db_update_record_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
-
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -504,7 +488,6 @@ static int _ctsvc_tc_db_update_record_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -514,25 +497,24 @@ static int _ctsvc_tc_db_update_record_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_update_records_url(void)
+static int _ctsvc_tc_db_update_records_url(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -584,7 +566,6 @@ static int _ctsvc_tc_db_update_records_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -596,23 +577,22 @@ static int _ctsvc_tc_db_update_records_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_record_url(void)
+static int _ctsvc_tc_db_delete_record_url(int account_id)
 {
        int ret = 0;
        int id = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -635,7 +615,6 @@ static int _ctsvc_tc_db_delete_record_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -644,25 +623,24 @@ static int _ctsvc_tc_db_delete_record_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
 
-static int _ctsvc_tc_db_delete_records_url(void)
+static int _ctsvc_tc_db_delete_records_url(int account_id)
 {
        int ret = 0;
        int *ids = NULL;
        int ids_count = 0;
-       int account_id = 0;
        int address_book_id = 0;
        int group_id = 0;
        int contact_id = 0;
        contacts_record_h record = NULL;
        contacts_list_h list = NULL;
+       if (account_id <= 0)
+               return -1;
 
        do {
-               if (0 != (ret = ctsvc_tc_util_account_insert(&account_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_address_book(account_id, &address_book_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_group(address_book_id, &group_id))) break;
                if (0 != (ret = ctsvc_tc_db_insert_record_contact(address_book_id, group_id, &contact_id))) break;
@@ -707,7 +685,6 @@ static int _ctsvc_tc_db_delete_records_url(void)
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_contact._uri, contact_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_group._uri, group_id))) break;
                if (CONTACTS_ERROR_NONE != (ret = contacts_db_delete_record(_contacts_address_book._uri, address_book_id))) break;
-               if (0 != (ret = ctsvc_tc_util_account_delete(account_id))) break;
 
                return 0;
        } while (0);
@@ -719,7 +696,6 @@ static int _ctsvc_tc_db_delete_records_url(void)
        contacts_db_delete_record(_contacts_contact._uri, contact_id);
        contacts_db_delete_record(_contacts_group._uri, group_id);
        contacts_db_delete_record(_contacts_address_book._uri, address_book_id);
-       ctsvc_tc_util_account_delete(account_id);
 
        return ret;
 }
index af933d6..76b9b74 100755 (executable)
@@ -187,13 +187,21 @@ int utc_contacts_service2_db_get_record_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_get_record) {
-                       ret = tc_db_plugin->db_get_record();
+                       ret = tc_db_plugin->db_get_record(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -237,13 +245,21 @@ int utc_contacts_service2_db_get_all_records_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_get_all_records) {
-                       ret = tc_db_plugin->db_get_all_records();
+                       ret = tc_db_plugin->db_get_all_records(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -285,13 +301,21 @@ int utc_contacts_service2_db_get_records_with_query_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_get_records_with_query) {
-                       ret = tc_db_plugin->db_get_records_with_query();
+                       ret = tc_db_plugin->db_get_records_with_query(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -339,13 +363,22 @@ int utc_contacts_service2_db_get_changes_by_version_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
+
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_get_changes_by_version) {
-                       ret = tc_db_plugin->db_get_changes_by_version();
+                       ret = tc_db_plugin->db_get_changes_by_version(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -390,13 +423,21 @@ int utc_contacts_service2_db_get_count_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_get_count) {
-                       ret = tc_db_plugin->db_get_count();
+                       ret = tc_db_plugin->db_get_count(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -438,13 +479,21 @@ int utc_contacts_service2_db_get_count_with_query_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_get_count_with_query) {
-                       ret = tc_db_plugin->db_get_count_with_query();
+                       ret = tc_db_plugin->db_get_count_with_query(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -563,13 +612,21 @@ int utc_contacts_service2_db_insert_record_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_insert_record) {
-                       ret = tc_db_plugin->db_insert_record();
+                       ret = tc_db_plugin->db_insert_record(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -603,13 +660,21 @@ int utc_contacts_service2_db_insert_records_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_insert_records) {
-                       ret = tc_db_plugin->db_insert_records();
+                       ret = tc_db_plugin->db_insert_records(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -645,13 +710,21 @@ int utc_contacts_service2_db_update_record_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_update_record) {
-                       ret = tc_db_plugin->db_update_record();
+                       ret = tc_db_plugin->db_update_record(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -685,13 +758,21 @@ int utc_contacts_service2_db_update_records_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_update_records) {
-                       ret = tc_db_plugin->db_update_records();
+                       ret = tc_db_plugin->db_update_records(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -723,17 +804,26 @@ int utc_contacts_service2_db_update_records_n(void)
 int utc_contacts_service2_db_replace_record_p(void)
 {
        assert_eq(_startup_err, 0);
-
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
+
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_replace_record) {
-                       ret = tc_db_plugin->db_replace_record();
+                       ret = tc_db_plugin->db_replace_record(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
 
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
+
        return 0;
 }
 
@@ -766,13 +856,21 @@ int utc_contacts_service2_db_replace_records_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_replace_records) {
-                       ret = tc_db_plugin->db_replace_records();
+                       ret = tc_db_plugin->db_replace_records(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -820,13 +918,21 @@ int utc_contacts_service2_db_delete_record_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_delete_record) {
-                       ret = tc_db_plugin->db_delete_record();
+                       ret = tc_db_plugin->db_delete_record(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -869,13 +975,21 @@ int utc_contacts_service2_db_delete_records_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_delete_records) {
-                       ret = tc_db_plugin->db_delete_records();
+                       ret = tc_db_plugin->db_delete_records(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -917,13 +1031,21 @@ int utc_contacts_service2_db_search_records_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_search_records) {
-                       ret = tc_db_plugin->db_search_records();
+                       ret = tc_db_plugin->db_search_records(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -964,13 +1086,21 @@ int utc_contacts_service2_db_search_records_with_query_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_search_records_with_query) {
-                       ret = tc_db_plugin->db_search_records_with_query();
+                       ret = tc_db_plugin->db_search_records_with_query(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -1020,13 +1150,21 @@ int utc_contacts_service2_db_search_records_with_range_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_search_records_with_range) {
-                       ret = tc_db_plugin->db_search_records_with_range();
+                       ret = tc_db_plugin->db_search_records_with_range(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -1069,13 +1207,21 @@ int utc_contacts_service2_db_search_records_for_snippet_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_search_records_for_snippet) {
-                       ret = tc_db_plugin->db_search_records_for_snippet();
+                       ret = tc_db_plugin->db_search_records_for_snippet(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -1118,13 +1264,21 @@ int utc_contacts_service2_db_search_records_with_query_for_snippet_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_search_records_with_query_for_snippet) {
-                       ret = tc_db_plugin->db_search_records_with_query_for_snippet();
+                       ret = tc_db_plugin->db_search_records_with_query_for_snippet(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
@@ -1174,13 +1328,21 @@ int utc_contacts_service2_db_search_records_with_range_for_snippet_p(void)
 
        int i;
        int ret;
+       int account_id =0;
+
+       ret = ctsvc_tc_util_account_insert(&account_id);
+       assert_eq(0, ret);
        for (i=0;i<VIEW_MAX;i++) {
                ctsvc_tc_db_plugin_s *tc_db_plugin = _ctsvc_tc_get_db_plugin(i);
                if (tc_db_plugin && tc_db_plugin->db_search_records_with_range_for_snippet) {
-                       ret = tc_db_plugin->db_search_records_with_range_for_snippet();
+                       ret = tc_db_plugin->db_search_records_with_range_for_snippet(account_id);
+                       if (0 != ret)
+                               ctsvc_tc_util_account_delete(account_id);
                        assert_eq(0, ret);
                }
        }
+       ret = ctsvc_tc_util_account_delete(account_id);
+       assert_eq(0, ret);
 
        return 0;
 }
index 8dfc0dd..cf180c2 100755 (executable)
@@ -61,11 +61,11 @@ int utc_contacts_service2_sdn_db_p(void)
        do {
                if (0 != (ret = _tc_db_sdn.db_add_changed_cb())) break;
                if (0 != (ret = _tc_db_sdn.db_remove_changed_cb())) break;
-               if (0 != (ret = _tc_db_sdn.db_get_record())) break;
-               if (0 != (ret = _tc_db_sdn.db_get_records_with_query())) break;
-               if (0 != (ret = _tc_db_sdn.db_get_all_records())) break;
-               if (0 != (ret = _tc_db_sdn.db_get_count())) break;
-               if (0 != (ret = _tc_db_sdn.db_get_count_with_query())) break;
+               if (0 != (ret = _tc_db_sdn.db_get_record(0))) break;
+               if (0 != (ret = _tc_db_sdn.db_get_records_with_query(0))) break;
+               if (0 != (ret = _tc_db_sdn.db_get_all_records(0))) break;
+               if (0 != (ret = _tc_db_sdn.db_get_count(0))) break;
+               if (0 != (ret = _tc_db_sdn.db_get_count_with_query(0))) break;
                return 0;
        } while (0);
        assert_eq(0, ret);
index e87115b..70144ab 100755 (executable)
@@ -62,8 +62,6 @@ void ctsvc_tc_util_db_changed_cb(const char *view_uri, void *user_data) { }
 void ctsvc_tc_util_setting_name_display_order_chagned_cb(contacts_name_display_order_e name_display_order, void* user_data) {}
 void ctsvc_tc_util_setting_name_sorting_order_chagned_cb(contacts_name_sorting_order_e name_display_order, void* user_data) {}
 
-
-
 int ctsvc_tc_util_account_insert(int *account_id)
 {
        if (NULL == account_id)
@@ -78,7 +76,10 @@ int ctsvc_tc_util_account_insert(int *account_id)
                if (0 != (ret = account_set_package_name(account, CTSVC_TC_UTIL_ACCOUNT_PACKAGE_NAME))) break;
                if (0 != (ret = account_insert_to_db(account, account_id))) break;
                if (0 != (ret = account_destroy(account))) break;
+               account = NULL;
        } while (0);
+
+       account_destroy(account);
        return ret;
 }
 
@@ -91,6 +92,7 @@ int ctsvc_tc_util_account_delete(int account_id)
        do {
                if (0 != (ret = account_delete_from_db_by_id(account_id))) break;
        } while (0);
+
        return ret;
 }
 
index f72ed27..34b398e 100755 (executable)
@@ -74,6 +74,7 @@ char* ctsvc_tc_util_get_file_path(const char *file);
 #define STRING_EQUAL 0
 
 typedef int (*tc)(void);
+typedef int (*tc_with_account_id)(int account_id);
 
 typedef struct {
        tc add_bool;
@@ -110,26 +111,26 @@ typedef struct {
 typedef struct {
        tc db_add_changed_cb;
        tc db_remove_changed_cb;
-       tc db_get_record;
-       tc db_get_records_with_query;
-       tc db_get_all_records;
-       tc db_get_changes_by_version;
-       tc db_get_count;
-       tc db_get_count_with_query;
-       tc db_insert_record;
-       tc db_insert_records;
-       tc db_update_record;
-       tc db_update_records;
-       tc db_delete_record;
-       tc db_delete_records;
-       tc db_replace_record;
-       tc db_replace_records;
-       tc db_search_records;
-       tc db_search_records_with_query;
-       tc db_search_records_with_range;
-       tc db_search_records_for_snippet;
-       tc db_search_records_with_query_for_snippet;
-       tc db_search_records_with_range_for_snippet;
+       tc_with_account_id db_get_record;
+       tc_with_account_id db_get_records_with_query;
+       tc_with_account_id db_get_all_records;
+       tc_with_account_id db_get_changes_by_version;
+       tc_with_account_id db_get_count;
+       tc_with_account_id db_get_count_with_query;
+       tc_with_account_id db_insert_record;
+       tc_with_account_id db_insert_records;
+       tc_with_account_id db_update_record;
+       tc_with_account_id db_update_records;
+       tc_with_account_id db_delete_record;
+       tc_with_account_id db_delete_records;
+       tc_with_account_id db_replace_record;
+       tc_with_account_id db_replace_records;
+       tc_with_account_id db_search_records;
+       tc_with_account_id db_search_records_with_query;
+       tc_with_account_id db_search_records_with_range;
+       tc_with_account_id db_search_records_for_snippet;
+       tc_with_account_id db_search_records_with_query_for_snippet;
+       tc_with_account_id db_search_records_with_range_for_snippet;
 } ctsvc_tc_db_plugin_s;
 
 typedef enum {