fix to update person usage even if phonelog inserted without person_id 76/62776/3 accepted/tizen_tv accepted/tizen/common/20160318.150027 accepted/tizen/ivi/20160318.114017 accepted/tizen/mobile/20160318.113838 accepted/tizen/tv/20160318.113939 accepted/tizen/wearable/20160318.113927 submit/tizen/20160318.070450
authorJongkyu Koo <jk.koo@samsung.com>
Fri, 18 Mar 2016 06:25:53 +0000 (15:25 +0900)
committerJongkyu Koo <jk.koo@samsung.com>
Fri, 18 Mar 2016 06:56:21 +0000 (15:56 +0900)
Change-Id: Ia81421889943547d63e91c4ae2d68f346a25f56f
Signed-off-by: Jongkyu Koo <jk.koo@samsung.com>
server/ctsvc_server_person.c
server/ctsvc_server_phonelog.c
server/ctsvc_server_phonelog.h
server/db/ctsvc_db_plugin_contact.c
server/db/ctsvc_db_plugin_contact_helper.c
server/db/ctsvc_db_plugin_number_helper.c
server/db/ctsvc_db_plugin_phonelog.c

index 720bc80..5516c02 100644 (file)
@@ -541,7 +541,7 @@ void ctsvc_db_person_delete_callback(sqlite3_context  *context,
         * update phonelog
         * CASE : do not know the proper new person_id
         */
-       ctsvc_db_phone_log_update_person_id(NULL, person_id, -1, false);
+       ctsvc_db_phone_log_update_person_id(NULL, person_id, -1, false, NULL);
 #endif /* ENABLE_LOG_FEATURE */
        sqlite3_result_null(context);
        return;
@@ -996,7 +996,7 @@ int ctsvc_person_link_person(int base_person_id, int person_id)
         * Because, when deleting, ctsvc_db_person_delete_callback will be called
         * the logic takes more time to find proper person_id (base_person_id)
         */
-       ctsvc_db_phone_log_update_person_id(NULL, person_id, base_person_id, true);
+       ctsvc_db_phone_log_update_person_id(NULL, person_id, base_person_id, true, NULL);
 #endif /* ENABLE_LOG_FEATURE */
 
        snprintf(query, sizeof(query), "DELETE FROM %s WHERE person_id = %d",
@@ -1267,7 +1267,7 @@ int ctsvc_person_unlink_contact(int person_id, int contact_id, int *out_person_i
 
 #ifdef ENABLE_LOG_FEATURE
        /* update phonelog */
-       ctsvc_db_phone_log_update_person_id(NULL, person_id, id, false);
+       ctsvc_db_phone_log_update_person_id(NULL, person_id, id, false, NULL);
 #endif /* ENABLE_LOG_FEATURE */
 
        if (out_person_id)
@@ -1299,7 +1299,7 @@ int ctsvc_person_do_garbage_collection(void)
                ctsvc_person_aggregate(person_id);
 #ifdef ENABLE_LOG_FEATURE
                /* update phonelog */
-               ctsvc_db_phone_log_update_person_id(NULL, person_id, -1, false);
+               ctsvc_db_phone_log_update_person_id(NULL, person_id, -1, false, NULL);
 #endif /* ENABLE_LOG_FEATURE */
        }
        ctsvc_stmt_finalize(stmt);
index 4af78c3..89c2872 100644 (file)
@@ -208,7 +208,7 @@ static int __ctsvc_db_phone_log_find_person_id(char *number, char *normal_num,
 }
 
 int ctsvc_db_phone_log_update_person_id(const char *number, int old_person_id,
-               int candidate_person_id, bool person_link)
+               int candidate_person_id, bool person_link, int *found_person_id)
 {
        CTS_FN_CALL;
        int ret;
@@ -323,6 +323,9 @@ int ctsvc_db_phone_log_update_person_id(const char *number, int old_person_id,
                                        minmatch_address, -1, &number_type);
                        if (new_person_id <= 0)
                                continue;
+
+                       if (found_person_id)
+                               *found_person_id = new_person_id;
                } else if (number && 0 < old_person_id) {
                        /* CASE : number update/delete (contact update/delete) => find new_person_id by address */
                        /* CASE : phonelog insert with person_id */
index f1a3375..da3d894 100644 (file)
@@ -28,6 +28,6 @@ int ctsvc_phone_log_reset_statistics_by_sim(int sim_slot_no);
 int ctsvc_phone_log_delete(contacts_phone_log_delete_e op, ...);
 void ctsvc_db_phone_log_delete_callback(sqlite3_context  *context,
                int argc, sqlite3_value **argv);
-int ctsvc_db_phone_log_update_person_id(const char *number, int old_person_id, int candidate_person_id, bool person_link);
+int ctsvc_db_phone_log_update_person_id(const char *number, int old_person_id, int candidate_person_id, bool person_link, int *found_person_id);
 
 #endif /* __CTSVC_SERVER_PHONELOG_H__ */
index 538f2fd..048dcc6 100644 (file)
@@ -2215,7 +2215,7 @@ static int __ctsvc_db_contact_insert_record(contacts_record_h record, int *id)
                        do {
                                contacts_list_get_current_record_p((contacts_list_h)contact->numbers, (contacts_record_h*)&number_record);
                                if (number_record->number)
-                                       ctsvc_db_phone_log_update_person_id(number_record->number, -1, contact->person_id, false);
+                                       ctsvc_db_phone_log_update_person_id(number_record->number, -1, contact->person_id, false, NULL);
                        } while (CONTACTS_ERROR_NONE == contacts_list_next((contacts_list_h)contact->numbers));
                }
        }
index 8f449ff..02dbeb0 100644 (file)
@@ -303,7 +303,7 @@ int ctsvc_db_contact_delete(int contact_id)
 
 #ifdef ENABLE_LOG_FEATURE
                /* update phonelog */
-               ctsvc_db_phone_log_update_person_id(NULL, person_id, -1, false);
+               ctsvc_db_phone_log_update_person_id(NULL, person_id, -1, false, NULL);
 #endif /* ENABLE_LOG_FEATURE */
        } else {
                ctsvc_set_person_noti();
index ae7e5d6..a8b5bb3 100644 (file)
@@ -116,7 +116,7 @@ int ctsvc_db_number_insert(contacts_record_h record, int contact_id, bool is_my_
                                "WHERE data.id = %d", number_id);
                ret = ctsvc_query_get_first_int_result(query, &person_id);
                if (0 < person_id)
-                       ctsvc_db_phone_log_update_person_id(number->number, -1, person_id, false);
+                       ctsvc_db_phone_log_update_person_id(number->number, -1, person_id, false, NULL);
 #endif /* ENABLE_LOG_FEATURE */
                ctsvc_set_number_noti();
        }
@@ -263,9 +263,9 @@ int ctsvc_db_number_update(contacts_record_h record, bool is_my_profile)
 #ifdef ENABLE_LOG_FEATURE
                /* update phone log */
                if (0 < person_id && pre_number)
-                       ctsvc_db_phone_log_update_person_id(pre_number, person_id, -1, false);
+                       ctsvc_db_phone_log_update_person_id(pre_number, person_id, -1, false, NULL);
                if (0 < person_id)
-                       ctsvc_db_phone_log_update_person_id(number->number, -1, person_id, false);
+                       ctsvc_db_phone_log_update_person_id(number->number, -1, person_id, false, NULL);
                ctsvc_stmt_finalize(stmt);
 #endif /* ENABLE_LOG_FEATURE */
        } while (0);
@@ -328,7 +328,7 @@ int ctsvc_db_number_delete(int id, bool is_my_profile)
 #ifdef ENABLE_LOG_FEATURE
        /* update phone log */
        if (0 < person_id && pre_number)
-               ctsvc_db_phone_log_update_person_id(pre_number, person_id, -1, false);
+               ctsvc_db_phone_log_update_person_id(pre_number, person_id, -1, false, NULL);
        ctsvc_stmt_finalize(stmt);
 #endif /* ENABLE_LOG_FEATURE */
 
index e55edb8..eba9a2a 100644 (file)
@@ -480,7 +480,7 @@ static int  __ctsvc_db_phonelog_insert(ctsvc_phonelog_s *phonelog, int *id)
        ctsvc_stmt_finalize(stmt);
 
        /* update phonelog */
-       ctsvc_db_phone_log_update_person_id(phonelog->address, phonelog->person_id, -1, false);
+       ctsvc_db_phone_log_update_person_id(phonelog->address, phonelog->person_id, -1, false, &phonelog->person_id);
 
        ctsvc_set_phonelog_noti();
        return CONTACTS_ERROR_NONE;