Apply tizen coding rule 42/160842/2
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 20 Nov 2017 08:04:57 +0000 (17:04 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 20 Nov 2017 08:35:12 +0000 (17:35 +0900)
Change-Id: I0919bb31b4e61d3cfc07246b5126e19baa7bc99b

31 files changed:
agent/download-agent-dl-info.c
agent/download-agent-dl-mgr.c
agent/download-agent-encoding.c
agent/download-agent-file.c
agent/download-agent-http-mgr.c
agent/download-agent-http-msg-handler.c
agent/download-agent-mime-util.c
agent/download-agent-plugin-conf.c
agent/download-agent-plugin-drm.c
agent/download-agent-plugin-libcurl.c
agent/include/download-agent-debug.h
agent/include/download-agent-defs.h
agent/include/download-agent-dl-info.h
agent/include/download-agent-pthread.h
agent/include/download-agent-type.h
packaging/download-provider.spec
provider-interface/download-provider-interface.c
provider-interface/include/download-provider-interface.h
provider/download-provider-client-manager.c
provider/download-provider-client.c
provider/download-provider-db.c
provider/download-provider-main.c
provider/download-provider-network.c
provider/download-provider-notification-manager.c
provider/download-provider-notification.c
provider/download-provider-notify.c
provider/download-provider-plugin-download-agent.c
provider/download-provider-pthread.c
provider/download-provider-queue-manager.c
provider/download-provider-smack.c
provider/include/download-provider-log.h

index 2925f78..4655962 100644 (file)
@@ -57,9 +57,9 @@ da_ret_t init_openssl_locks(void)
                DA_LOGE("Failed to OPENSSL_malloc");
                return DA_ERR_FAIL_TO_MEMALLOC;
        }
-       for (index = 0; index < crypto_num_locks; index++) {
+       for (index = 0; index < crypto_num_locks; index++)
                pthread_mutex_init(&(g_openssl_locks_list[index]), NULL);
-       }
+
        CRYPTO_set_id_callback((unsigned long (*)())thread_id);
        CRYPTO_set_locking_callback((void (*)())openssl_lock_callback);
 
@@ -70,9 +70,9 @@ da_ret_t deinit_openssl_locks(void)
        DA_LOGD("");
        int index;
        int crypto_num_locks = CRYPTO_num_locks();
-       for (index = 0; index < crypto_num_locks; index++) {
+       for (index = 0; index < crypto_num_locks; index++)
                pthread_mutex_destroy(&(g_openssl_locks_list[index]));
-       }
+
        CRYPTO_set_id_callback(NULL);
        CRYPTO_set_locking_callback(NULL);
        OPENSSL_free(g_openssl_locks_list);
@@ -90,20 +90,20 @@ static void __init_da_info(int id)
 
        da_info = (da_info_t *)calloc(1, sizeof(da_info_t));
        if (!da_info) {
-               DA_LOGE("Fail to calloc. id[%d]",id);
+               DA_LOGE("Fail to calloc. id[%d]", id);
                da_info_list[id] = DA_NULL;
                return;
        }
        file_info = (file_info_t *)calloc(1, sizeof(file_info_t));
        if (!file_info) {
-               DA_LOGE("Fail to calloc. id[%d]",id);
+               DA_LOGE("Fail to calloc. id[%d]", id);
                free(da_info);
                da_info_list[id] = DA_NULL;
                return;
        }
        http_info = (http_info_t *)calloc(1, sizeof(http_info_t));
        if (!http_info) {
-               DA_LOGE("Fail to calloc. id[%d]",id);
+               DA_LOGE("Fail to calloc. id[%d]", id);
                free(da_info);
                free(file_info);
                da_info_list[id] = DA_NULL;
@@ -111,7 +111,7 @@ static void __init_da_info(int id)
        }
        req_info = (req_info_t *)calloc(1, sizeof(req_info_t));
        if (!req_info) {
-               DA_LOGE("Fail to calloc. id[%d]",id);
+               DA_LOGE("Fail to calloc. id[%d]", id);
                free(da_info);
                free(file_info);
                free(http_info);
@@ -248,7 +248,7 @@ da_ret_t copy_user_input_data(da_info_t *da_info, const char *url,
                        int i = 0;
                        int count = ext_data->request_header_count;
                        req_info->req_header = (char **)calloc(count, sizeof(char *));
-                       if(DA_NULL == req_info->req_header) {
+                       if (DA_NULL == req_info->req_header) {
                                DA_LOGE("Fail to calloc");
                                free(req_info);
                                da_info->req_info = DA_NULL;
@@ -392,7 +392,7 @@ void destroy_file_info(file_info_t *file_info)
 void reset_http_info_for_resume(http_info_t *http_info)
 {
        if (http_info) {
-               DA_LOGI("[TEST] location_url[%p]",http_info->location_url);
+               DA_LOGI("[TEST] location_url[%p]", http_info->location_url);
                NULL_CHECK_AND_FREE(http_info->location_url);
                http_info->location_url = DA_NULL;
                NULL_CHECK_AND_FREE(http_info->proxy_addr);
@@ -416,7 +416,7 @@ void reset_http_info_for_resume(http_info_t *http_info)
 void reset_http_info(http_info_t *http_info)
 {
        if (http_info) {
-               DA_LOGI("[TEST] location_url[%p]",http_info->location_url);
+               DA_LOGI("[TEST] location_url[%p]", http_info->location_url);
                free(http_info->location_url);
                http_info->location_url = DA_NULL;
                free(http_info->proxy_addr);
@@ -471,7 +471,7 @@ void destroy_da_info_list()
        int i = 0;
        DA_MUTEX_LOCK(&mutex_da_info_list);
        for (i = 0; i < DA_MAX_ID; i++) {
-               if(DA_NULL != da_info_list[i]) {
+               if (DA_NULL != da_info_list[i]) {
                        if (da_info_list[i]->req_info) {
                                __destroy_req_info(da_info_list[i]->req_info);
                                da_info_list[i]->req_info = DA_NULL;
index 06e4b5f..2da7d99 100755 (executable)
@@ -100,9 +100,8 @@ da_ret_t start_download(da_info_t *da_info)
        da_info->thread_id = tid;
        DA_LOGI("Thread create:thread id[%lu]", da_info->thread_id);
 ERR:
-       if (DA_RESULT_OK != ret) {
+       if (DA_RESULT_OK != ret)
                destroy_da_info(da_info->da_id);
-       }
        return ret;
 }
 
@@ -114,9 +113,8 @@ da_ret_t cancel_download(int dl_id, da_bool_t is_enable_cb)
        DA_LOGV("");
 
        ret = get_da_info_with_da_id(dl_id, &da_info);
-       if (ret != DA_RESULT_OK || !da_info) {
+       if (ret != DA_RESULT_OK || !da_info)
                return DA_ERR_INVALID_ARGUMENT;
-       }
        da_info->is_cb_update = is_enable_cb;
        ret = request_to_cancel_http_download(da_info);
        if (ret != DA_RESULT_OK)
@@ -135,9 +133,8 @@ da_ret_t suspend_download(int dl_id, da_bool_t is_enable_cb)
        DA_LOGV("");
 
        ret = get_da_info_with_da_id(dl_id, &da_info);
-       if (ret != DA_RESULT_OK || !da_info) {
+       if (ret != DA_RESULT_OK || !da_info)
                return DA_ERR_INVALID_ARGUMENT;
-       }
        da_info->is_cb_update = is_enable_cb;
        ret = request_to_suspend_http_download(da_info);
        if (ret != DA_RESULT_OK)
@@ -156,9 +153,8 @@ da_ret_t resume_download(int dl_id)
        DA_LOGV("");
 
        ret = get_da_info_with_da_id(dl_id, &da_info);
-       if (ret != DA_RESULT_OK || !da_info) {
+       if (ret != DA_RESULT_OK || !da_info)
                return DA_ERR_INVALID_ARGUMENT;
-       }
        da_info->is_cb_update = DA_TRUE;
        ret = request_to_resume_http_download(da_info);
        if (ret != DA_RESULT_OK)
index c5f8db2..ff0b08e 100755 (executable)
@@ -52,7 +52,7 @@ da_bool_t is_base64_encoded_word(const char *in_str)
        if (found_str) {
                if (found_str == haystack) {
                        haystack = haystack + strlen(haystack) - strlen(second_needle);
-                       if(!strcmp(haystack, second_needle))
+                       if (!strcmp(haystack, second_needle))
                                return DA_TRUE;
                }
        }
@@ -75,7 +75,7 @@ da_ret_t decode_base64_encoded_str(const char *in_encoded_str,
        DA_SECURE_LOGD("input str = [%s]", in_encoded_str);
 
        org_str = in_encoded_str;
-       if(!org_str) {
+       if (!org_str) {
                DA_LOGE("Input string is NULL");
                ret = DA_ERR_INVALID_ARGUMENT;
                goto ERR;
@@ -83,11 +83,10 @@ da_ret_t decode_base64_encoded_str(const char *in_encoded_str,
 
        ret = _parsing_base64_encoded_str(org_str, &charset_type,
                &encoding_type, &raw_encoded_str);
-       if(ret != DA_RESULT_OK) {
+       if (ret != DA_RESULT_OK)
                goto ERR;
-       }
 
-       if(encoding_type != 'B') {
+       if (encoding_type != 'B') {
                DA_LOGE("Encoded Word is not encoded with Base64, but %c. We can only handle Base64.", encoding_type);
                ret = DA_ERR_INVALID_ARGUMENT;
                goto ERR;
@@ -102,10 +101,10 @@ da_ret_t decode_base64_encoded_str(const char *in_encoded_str,
        g_encoded_text = (const gchar*)raw_encoded_str;
        g_decoded_text = g_base64_decode(g_encoded_text, &g_decoded_text_len);
 
-       if(g_decoded_text) {
+       if (g_decoded_text) {
                DA_SECURE_LOGD("g_decoded_text = [%s]", g_decoded_text);
                decoded_str = (char*)calloc(1, g_decoded_text_len+1);
-               if(!decoded_str) {
+               if (!decoded_str) {
                        DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
                        ret = DA_ERR_FAIL_TO_MEMALLOC;
                        goto ERR;
@@ -117,17 +116,16 @@ da_ret_t decode_base64_encoded_str(const char *in_encoded_str,
 
 ERR:
        *out_decoded_ascii_str = decoded_str;
-       if(charset_type) {
+       if (charset_type) {
                free(charset_type);
                charset_type = NULL;
        }
-       if(raw_encoded_str) {
+       if (raw_encoded_str) {
                free(raw_encoded_str);
                raw_encoded_str = NULL;
        }
-       if(g_decoded_text) {
+       if (g_decoded_text)
                g_free(g_decoded_text);
-       }
        return ret;
 }
 
index 5dd5ff7..6cd6507 100755 (executable)
@@ -60,30 +60,28 @@ da_ret_t __saved_file_open(file_info_t *file_info)
        }
 
        file_info->file_handle = fd;
-       //DA_SECURE_LOGD("file path for saving[%s]", file_info->file_path);
-
 ERR:
-       if (DA_RESULT_OK != ret) {
+       if (DA_RESULT_OK != ret)
                file_info->file_handle = DA_NULL;
-       }
+
        return ret;
 }
 
 da_ret_t __divide_file_name_into_pure_name_N_extesion(const char *in_file_name, char *url, char **out_pure_file_name, char **out_extension)
 {
-    char *file_name = DA_NULL;
-    char *tmp_ptr = DA_NULL;
-    char temp_file[DA_MAX_FILE_NAME_LEN + 1] = {0,};
-    char tmp_ext[DA_MAX_STR_LEN] = {0,};
-    int len = 0;
-    da_ret_t ret = DA_RESULT_OK;
+       char *file_name = DA_NULL;
+       char *tmp_ptr = DA_NULL;
+       char temp_file[DA_MAX_FILE_NAME_LEN + 1] = {0,};
+       char tmp_ext[DA_MAX_STR_LEN] = {0,};
+       int len = 0;
+       da_ret_t ret = DA_RESULT_OK;
 
-    DA_LOGD("");
+       DA_LOGD("");
 
-    if (!in_file_name)
-        return DA_ERR_INVALID_ARGUMENT;
+       if (!in_file_name)
+               return DA_ERR_INVALID_ARGUMENT;
 
-    file_name = (char *)in_file_name;
+       file_name = (char *)in_file_name;
 
        tmp_ptr = strrchr(file_name, '.');
        if (tmp_ptr)
@@ -110,33 +108,33 @@ da_ret_t __divide_file_name_into_pure_name_N_extesion(const char *in_file_name,
                }
        }
 
-    if (!out_pure_file_name)
-        return ret;
-
-    if (tmp_ptr)
-        len = tmp_ptr - file_name - 1;
-    else
-        len = strlen(file_name);
-
-    if (len >= DA_MAX_FILE_NAME_LEN) {
-        strncpy((char*) temp_file, file_name, DA_MAX_FILE_NAME_LEN);
-        temp_file[DA_MAX_FILE_NAME_LEN] = '\0';
-    } else {
-        strncpy((char*) temp_file, file_name, len);
-        temp_file[len] = '\0';
-    }
-
-    delete_prohibited_char((char*) temp_file,
-            strlen((char*) temp_file));
-    if (strlen(temp_file) < 1) {
-        *out_pure_file_name = strdup(NO_NAME_TEMP_STR);
-    } else {
-        *out_pure_file_name = strdup(
-                (const char*) temp_file);
-    }
-
-    DA_LOGD( "pure file name [%s]", *out_pure_file_name);
-    return ret;
+       if (!out_pure_file_name)
+               return ret;
+
+       if (tmp_ptr)
+               len = tmp_ptr - file_name - 1;
+       else
+               len = strlen(file_name);
+
+       if (len >= DA_MAX_FILE_NAME_LEN) {
+               strncpy((char*) temp_file, file_name, DA_MAX_FILE_NAME_LEN);
+               temp_file[DA_MAX_FILE_NAME_LEN] = '\0';
+       } else {
+               strncpy((char*) temp_file, file_name, len);
+               temp_file[len] = '\0';
+       }
+
+       delete_prohibited_char((char*) temp_file,
+                       strlen((char*) temp_file));
+       if (strlen(temp_file) < 1) {
+               *out_pure_file_name = strdup(NO_NAME_TEMP_STR);
+       } else {
+               *out_pure_file_name = strdup(
+                               (const char*) temp_file);
+       }
+
+       DA_LOGD("pure file name [%s]", *out_pure_file_name);
+       return ret;
 }
 
 da_ret_t __file_write_buf_make_buf(file_info_t *file_info)
@@ -267,7 +265,7 @@ da_ret_t __file_write_buf_directly_write(file_info_t *file_info,
                goto ERR;
        }
        file_info->bytes_written_to_file += write_success_len;
-       DA_LOGV( "write %llu bytes", write_success_len);
+       DA_LOGV("write %llu bytes", write_success_len);
        file_info->is_updated = DA_TRUE;
 
 ERR:
@@ -289,25 +287,25 @@ char *__get_extension_name(char *mime_type,
 
        /* Priority 1 */
        if (mime_type && !is_ambiguous_MIME_Type(mime_type)) {
-           if (url) {
-               DA_LOGV("If the file extension exists and mime type exists, choose the file extension over mime type");
-               da_bool_t b_ret = da_get_extension_name_from_url(url, &extension);
-               if (b_ret && extension)
-                   return extension;
-           }
-           char *extension = DA_NULL;
-           da_ret_t ret = get_extension_from_mime_type(mime_type, &extension);
-           if (ret == DA_RESULT_OK && extension)
-               return extension;
+               if (url) {
+                       DA_LOGV("If the file extension exists and mime type exists, choose the file extension over mime type");
+                       da_bool_t b_ret = da_get_extension_name_from_url(url, &extension);
+                       if (b_ret && extension)
+                               return extension;
+               }
+               char *extension = DA_NULL;
+               da_ret_t ret = get_extension_from_mime_type(mime_type, &extension);
+               if (ret == DA_RESULT_OK && extension)
+                       return extension;
        }
        /* Priority 2-1 */
        if (file_name_from_header) {
-           char *extension = DA_NULL;
-           DA_SECURE_LOGI("Content-Disposition :[%s]", file_name_from_header);
-           __divide_file_name_into_pure_name_N_extesion(file_name_from_header, DA_NULL,
-                   DA_NULL, &extension);
-           if (extension)
-               return extension;
+               char *extension = DA_NULL;
+               DA_SECURE_LOGI("Content-Disposition :[%s]", file_name_from_header);
+               __divide_file_name_into_pure_name_N_extesion(file_name_from_header, DA_NULL,
+                               DA_NULL, &extension);
+               if (extension)
+                       return extension;
        }
        /* Priority 2-2 */
        if (url) {
@@ -335,16 +333,16 @@ da_ret_t __get_candidate_file_name(const char *user_file_name, char *url,
 
        /* Priority 1 */
        if (user_file_name) {
-           __divide_file_name_into_pure_name_N_extesion(
-                   user_file_name, url, out_pure_file_name, out_extension);
+               __divide_file_name_into_pure_name_N_extesion(
+                               user_file_name, url, out_pure_file_name, out_extension);
        }
        if (*out_pure_file_name)
                return ret;
        /* Priority 2 */
        if (file_name_from_header) {
-           DA_SECURE_LOGI("Content-Disposition:[%s]", file_name_from_header);
-           __divide_file_name_into_pure_name_N_extesion(file_name_from_header, DA_NULL,
-                   out_pure_file_name, DA_NULL);
+               DA_SECURE_LOGI("Content-Disposition:[%s]", file_name_from_header);
+               __divide_file_name_into_pure_name_N_extesion(file_name_from_header, DA_NULL,
+                               out_pure_file_name, DA_NULL);
        }
        if (*out_pure_file_name)
                return ret ;
@@ -401,7 +399,7 @@ da_ret_t __decide_file_path(da_info_t *da_info)
         * it try to parse the file name from the location url */
        if (http_info->location_url) {
                url = http_info->location_url;
-               DA_LOGI("[TEST] location_url[%s][%p]",http_info->location_url, http_info->location_url);
+               DA_LOGI("[TEST] location_url[%s][%p]", http_info->location_url, http_info->location_url);
        } else
                url = req_info->url;
 
@@ -427,10 +425,10 @@ da_ret_t __decide_file_path(da_info_t *da_info)
        DA_SECURE_LOGI("candidate file name [%s]", file_name);
 
        if (!extension
-               && file_info->mime_type
-               && strncmp(file_info->mime_type, "application/json", strlen("application/json"))
-               && strncmp(file_info->mime_type, "application/x-xz", strlen("application/x-xz"))
-               && strncmp(file_info->mime_type, "application/rss+xml", strlen("application/rss+xml"))) {
+                       && file_info->mime_type
+                       && strncmp(file_info->mime_type, "application/json", strlen("application/json"))
+                       && strncmp(file_info->mime_type, "application/x-xz", strlen("application/x-xz"))
+                       && strncmp(file_info->mime_type, "application/rss+xml", strlen("application/rss+xml"))) {
                extension = __get_extension_name(file_info->mime_type,
                                file_name_from_header, url);
        }
@@ -446,21 +444,21 @@ da_ret_t __decide_file_path(da_info_t *da_info)
 
        // for resume
        tmp_file_path = get_full_path_avoided_duplication(install_dir,
-               file_info->pure_file_name, file_info->extension);
+                       file_info->pure_file_name, file_info->extension);
        if (tmp_file_path) {
-           file_info->file_path = tmp_file_path;
-           tmp_file_path = DA_NULL;
+               file_info->file_path = tmp_file_path;
+               tmp_file_path = DA_NULL;
        } else {
-           ret = DA_ERR_FAIL_TO_ACCESS_FILE;
-           goto ERR;
+               ret = DA_ERR_FAIL_TO_ACCESS_FILE;
+               goto ERR;
        }
 
 ERR:
        DA_SECURE_LOGI("decided file path [%s]", file_info->file_path);
-       if(file_name)
-           free(file_name);
-       if(extension)
-           free(extension);
+       if (file_name)
+               free(file_name);
+       if (extension)
+               free(extension);
        return ret;
 }
 
@@ -506,7 +504,7 @@ da_ret_t __decide_file_path_for_resume(file_info_t *file_info)
                free(file_name);
        }
        if (extension && !file_info->extension) {
-               DA_LOGV( "candidate extension [%s]", extension);
+               DA_LOGV("candidate extension [%s]", extension);
                file_info->extension = extension;
                extension = DA_NULL;
        } else {
@@ -531,17 +529,16 @@ da_ret_t start_file_writing(da_info_t *da_info)
 
        /* resume case */
        if (req_info->etag || req_info->temp_file_path) {
-           char *file_path = DA_NULL;
-           char *origin_path = DA_NULL;
-           file_path = req_info->temp_file_path;
-           if (!file_path)
-               return DA_ERR_INVALID_ARGUMENT;
-           origin_path = file_info->file_path;
-           file_info->file_path = strdup(file_path);
-           free(origin_path);
-           if(file_info) {
-               ret = __decide_file_path_for_resume(file_info);
-           }
+               char *file_path = DA_NULL;
+               char *origin_path = DA_NULL;
+               file_path = req_info->temp_file_path;
+               if (!file_path)
+                       return DA_ERR_INVALID_ARGUMENT;
+               origin_path = file_info->file_path;
+               file_info->file_path = strdup(file_path);
+               free(origin_path);
+               if (file_info)
+                       ret = __decide_file_path_for_resume(file_info);
        } else {
                ret = __decide_file_path(da_info);
        }
@@ -629,7 +626,8 @@ ERR:
 }
 
 #ifdef _RAF_SUPPORT
-da_ret_t file_write_complete_for_raf(file_info_t *file_info) {
+da_ret_t file_write_complete_for_raf(file_info_t *file_info)
+{
        da_ret_t ret = DA_RESULT_OK;
        char *buffer = DA_NULL;
        da_size_t wrriten_size = 0;
@@ -651,14 +649,13 @@ da_ret_t file_write_complete_for_raf(file_info_t *file_info) {
        file_info->file_handle = DA_NULL;
        if (wrriten_size < file_size) {
                DA_LOGD("Try truncate");
-               if (truncate(file_info->file_path, wrriten_size) < 0) {
+               if (truncate(file_info->file_path, wrriten_size) < 0)
                        DA_LOGE("Fail to ftruncate: errno[%d]", errno);
-               }
                DA_LOGD("Try truncate done");
        }
 
-       ERR:
-               return ret;
+ERR:
+       return ret;
 }
 #endif
 
@@ -770,7 +767,7 @@ void get_file_size(char *file_path, da_size_t *out_file_size)
        stat_ret = stat(file_path, &dir_state);
        if (stat_ret == 0) {
                if (dir_state.st_mode & S_IFREG) {
-                       DA_LOGV( "size = %lu", dir_state.st_size);
+                       DA_LOGV("size = %lu", dir_state.st_size);
                        *out_file_size = dir_state.st_size;
                }
        }
@@ -800,7 +797,7 @@ char *get_full_path_avoided_duplication(const char *in_dir,
                return DA_NULL;
 
        //DA_SECURE_LOGI("in_candidate_file_name=[%s],in_extension=[%s]",
-                       //in_candidate_file_name, in_extension);
+       //in_candidate_file_name, in_extension);
 
        if (extension)
                extension_len = strlen(extension);
@@ -814,7 +811,7 @@ char *get_full_path_avoided_duplication(const char *in_dir,
 
        /* first 1 for "/", second 1 for ".", last 1 for DA_NULL */
        final_path_len = dir_path_len + 1 + strlen(file_name) + 1
-                       + suffix_len + extension_len + 1;
+               + suffix_len + extension_len + 1;
 
        final_path = (char*)calloc(1, final_path_len);
        if (!final_path) {
@@ -917,9 +914,8 @@ void remove_file(const char *file_path)
 
        if (file_path && is_file_exist(file_path)) {
                DA_SECURE_LOGD("remove file [%s]", file_path);
-               if (unlink(file_path) < 0) {
+               if (unlink(file_path) < 0)
                        DA_LOGE("file removing failed.");
-               }
        }
 }
 
@@ -941,22 +937,22 @@ da_ret_t get_available_memory(const char *dir_path, da_size_t len)
        //fs_ret = storage_get_internal_memory_size(&filesys_info);
 
        if (fs_ret != 0) {
-       //      DA_LOGE("statfs error[%s]", strerror(errno));
+               //      DA_LOGE("statfs error[%s]", strerror(errno));
                return DA_ERR_INVALID_ARGUMENT;
-       //      return DA_ERR_INVALID_INSTALL_PATH;
+               //      return DA_ERR_INVALID_INSTALL_PATH;
        }
 
        double available_size =  (double)filesys_info.f_frsize * filesys_info.f_bavail;
        double total_size = (double)filesys_info.f_frsize * filesys_info.f_blocks;
        DA_SECURE_LOGI(" total = %lf ", total_size);
-       DA_SECURE_LOGI(" available = %lf ",available_size);
+       DA_SECURE_LOGI(" available = %lf ", available_size);
 
        DA_LOGV("Available Memory(f_bavail) : %lu", filesys_info.f_bavail);
        DA_LOGV("Available Memory(f_bsize) : %d", filesys_info.f_bsize);
        DA_LOGD("Available Memory(kbytes) : %lu", (filesys_info.f_bavail/1024)*filesys_info.f_bsize);
        DA_LOGV("Content: %llu", len);
        if (available_size < (len
-                       + SAVE_FILE_BUFFERING_SIZE_50KB)) /* 50KB buffering */
+                               + SAVE_FILE_BUFFERING_SIZE_50KB)) /* 50KB buffering */
                ret = DA_ERR_DISK_FULL;
 
        return ret;
index f7c62d4..617a890 100755 (executable)
@@ -36,7 +36,7 @@ void __http_update_cb(http_raw_data_t *data, void *user_param);
 static const char *__get_state_str(http_state_t state)
 {
        char *str = NULL;
-       switch(state) {
+       switch (state) {
        case HTTP_STATE_READY_TO_DOWNLOAD:
                str = CONVERT_STR(HTTP_STATE_READY_TO_DOWNLOAD);
                break;
@@ -122,8 +122,7 @@ void __parsing_user_request_header(char *user_request_header,
                goto ERR;
        }
        temp_pos = (char *)user_request_header;
-       while (*temp_pos)
-       {
+       while (*temp_pos) {
                if (temp_pos == pos || *temp_pos == ' ') {
                        len =  temp_pos - user_request_header;
                        break;
@@ -141,8 +140,7 @@ void __parsing_user_request_header(char *user_request_header,
        }
        strncpy(field, user_request_header, len);
        pos++;
-       while (*pos)
-       {
+       while (*pos) {
                if (*pos != ' ')
                        break;
                pos++;
@@ -217,7 +215,7 @@ da_ret_t __set_http_request_hdr(req_info_t *req_info, http_info_t *http_info, fi
                                }
                                if (value) {
                                        free(value);
-                                       value= NULL;
+                                       value = NULL;
                                }
                        } else {
                                if (field) {
@@ -226,7 +224,7 @@ da_ret_t __set_http_request_hdr(req_info_t *req_info, http_info_t *http_info, fi
                                }
                                if (value) {
                                        free(value);
-                                       value= NULL;
+                                       value = NULL;
                                }
                                DA_LOGE("Fail to parse user request header");
                        }
@@ -422,7 +420,7 @@ int __check_wait_for_auto_retry(http_info_t *http_info)
        if (ret == ETIMEDOUT) {
                DA_LOGI("Waiting is done by timeout");
        } else if (ret != 0) {
-               DA_LOGE("fail to pthread_cond_waittime[%d]",ret);
+               DA_LOGE("fail to pthread_cond_waittime[%d]", ret);
        } else {
                DA_LOGI("Waiting is done by control");
                DA_MUTEX_LOCK(&(http_info->mutex_state));
@@ -456,7 +454,7 @@ da_ret_t request_http_download(da_info_t *da_info)
                DA_MUTEX_LOCK(&(http_info->mutex_state));
                http_state = http_info->state;
                DA_MUTEX_UNLOCK(&(http_info->mutex_state));
-               DA_LOGD("http_state[%s][%d]",__get_state_str(http_info->state), da_info->da_id);
+               DA_LOGD("http_state[%s][%d]", __get_state_str(http_info->state), da_info->da_id);
                switch (http_state) {
                case HTTP_STATE_READY_TO_DOWNLOAD:
                        DA_MUTEX_LOCK(&(http_info->mutex_state));
@@ -465,7 +463,7 @@ da_ret_t request_http_download(da_info_t *da_info)
                        ret = __start_new_transaction(da_info);
                        DA_MUTEX_LOCK(&(http_info->mutex_state));
                        http_state = http_info->state;
-                       DA_LOGD("http_state[%s][%d]",__get_state_str(http_info->state), da_info->da_id);
+                       DA_LOGD("http_state[%s][%d]", __get_state_str(http_info->state), da_info->da_id);
                        http_info->error_code = ret;
                        DA_MUTEX_UNLOCK(&(http_info->mutex_state));
                        if (ret == DA_ERR_NETWORK_FAIL && http_state != HTTP_STATE_PAUSED) {
@@ -501,7 +499,7 @@ da_ret_t request_http_download(da_info_t *da_info)
                        send_client_paused_info(da_info);
                        DA_LOGD("Waiting thread for paused state");
                        DA_MUTEX_LOCK(&(http_info->mutex_http));
-                       pthread_cond_wait(&(http_info->cond_http),&(http_info->mutex_http));
+                       pthread_cond_wait(&(http_info->cond_http), &(http_info->mutex_http));
                        DA_MUTEX_UNLOCK(&(http_info->mutex_http));
                        DA_LOGD("Wake up thread due to resume");
                        break;
@@ -543,9 +541,9 @@ da_ret_t request_http_download(da_info_t *da_info)
                        break;
                }
        } while (need_wait == DA_TRUE);
-       DA_LOGD("Final http_state[%s][%d] err[%d]",__get_state_str(http_info->state), da_info->da_id, ret);
+       DA_LOGD("Final http_state[%s][%d] err[%d]", __get_state_str(http_info->state), da_info->da_id, ret);
        if (http_info->state != HTTP_STATE_PAUSED)
-               send_client_finished_info(da_info ,ret);
+               send_client_finished_info(da_inforet);
        DA_LOGI("=== Exiting http_download ret[%d] ===", ret);
        return ret;
 }
@@ -811,7 +809,7 @@ da_ret_t request_to_resume_http_download(da_info_t *da_info)
                                break;
                        }
                        retry_count++;
-               } while(retry_count < 10000);
+               } while (retry_count < 10000);
                if (ret != DA_RESULT_OK || retry_count >= 10000)
                        PI_http_cancel(http_info);
                break;
@@ -878,12 +876,11 @@ da_ret_t __check_resume_download_is_available(
 
        if (remained_content_len > 0) {
                if (req_info->install_path)
-                               dir_path = (const char *)req_info->install_path;
-               else
-               {
-                               tzplatform_set_user(slot->credential.uid);
-                               dir_path = DA_DEFAULT_INSTALL_PATH_FOR_PHONE;
-                               tzplatform_reset_user();
+                       dir_path = (const char *)req_info->install_path;
+               else {
+                       tzplatform_set_user(slot->credential.uid);
+                       dir_path = DA_DEFAULT_INSTALL_PATH_FOR_PHONE;
+                       tzplatform_reset_user();
                }
                ret = get_available_memory(dir_path, remained_content_len);
                if (ret != DA_RESULT_OK)
@@ -1016,11 +1013,11 @@ da_ret_t __handle_http_status_code(http_info_t *http_info,
        case 305:
        case 306:
        case 307:
-               DA_LOGV("HTTP Status is %d - redirection!",http_status);
+               DA_LOGV("HTTP Status is %d - redirection!", http_status);
                if (http_msg_response_get_location(http_msg_response, &location)) {
                        DA_SECURE_LOGD("location  = %s\n", location);
                        http_info->location_url = location;
-                       DA_LOGI("[TEST] location_url[%p]",http_info->location_url);
+                       DA_LOGI("[TEST] location_url[%p]", http_info->location_url);
                }
                DA_MUTEX_LOCK(&(http_info->mutex_state));
                http_info->state = HTTP_STATE_REDIRECTED;
@@ -1067,7 +1064,7 @@ da_ret_t __check_before_downloading(da_info_t *da_info, http_state_t state)
        NULL_CHECK_RET(req_info);
        file_info = da_info->file_info;
        NULL_CHECK_RET(file_info);
-       DA_LOGD("state:%s",__get_state_str(state));
+       DA_LOGD("state:%s", __get_state_str(state));
        // resume case
        if (req_info->temp_file_path && file_info->bytes_written_to_file > 0) {
                ret = start_file_append(file_info);
@@ -1279,7 +1276,7 @@ da_ret_t __handle_event_http_packet(http_raw_data_t *raw_data, da_info_t *da_inf
 #endif
                // send event every 1 second.
                if ((t = time(DA_NULL)) > 0) {
-                       if ((localtime_r(&t,&lc_time)) != DA_NULL) {
+                       if ((localtime_r(&t, &lc_time)) != DA_NULL) {
                                if (da_info->update_time != lc_time.tm_sec) {
                                        da_info->update_time = lc_time.tm_sec;
                                        ret = send_client_update_progress_info(da_info);
@@ -1395,11 +1392,10 @@ da_ret_t __handle_event_http_final(http_raw_data_t *raw_data, da_info_t *da_info
        case HTTP_STATE_DOWNLOADING:
                DA_LOGD("case HTTP_STATE_DOWNLOADING");
 #ifdef _RAF_SUPPORT
-               if (http_info->is_raf_mode_confirmed == DA_TRUE) {
+               if (http_info->is_raf_mode_confirmed == DA_TRUE)
                        ret = file_write_complete_for_raf(file_info);
-               } else {
+               else
                        ret = file_write_complete(file_info);
-               }
 #else
                ret = file_write_complete(file_info);
 #endif
@@ -1408,7 +1404,7 @@ da_ret_t __handle_event_http_final(http_raw_data_t *raw_data, da_info_t *da_info
                        goto ERR;
                }
                ret = __check_file_size_with_header_content_size(file_info);
-               if(ret != DA_RESULT_OK) {
+               if (ret != DA_RESULT_OK) {
                        discard_download(file_info) ;
                        goto ERR;
                }
@@ -1442,11 +1438,10 @@ da_ret_t __handle_event_http_final(http_raw_data_t *raw_data, da_info_t *da_info
                break;
        case HTTP_STATE_REQUEST_CANCEL:
 #ifdef _RAF_SUPPORT
-               if (http_info->is_raf_mode_confirmed == DA_TRUE) {
+               if (http_info->is_raf_mode_confirmed == DA_TRUE)
                        ret = file_write_complete_for_raf(file_info);
-               } else {
+               else
                        ret = file_write_complete(file_info);
-               }
 #else
                ret = file_write_complete(file_info);
 #endif
@@ -1462,11 +1457,10 @@ da_ret_t __handle_event_http_final(http_raw_data_t *raw_data, da_info_t *da_info
                break;
        default:
 #ifdef _RAF_SUPPORT
-               if (http_info->is_raf_mode_confirmed == DA_TRUE) {
+               if (http_info->is_raf_mode_confirmed == DA_TRUE)
                        ret = file_write_complete_for_raf(file_info);
-               } else {
+               else
                        ret = file_write_complete(file_info);
-               }
 #else
                ret = file_write_complete(file_info);
 #endif
@@ -1504,7 +1498,7 @@ void __http_update_cb(http_raw_data_t *data, void *user_param)
        raw_data = data;
        da_info = (da_info_t *)user_param;
 
-       switch(data->type) {
+       switch (data->type) {
        case HTTP_EVENT_GOT_HEADER:
                __handle_event_http_header(raw_data, da_info);
                break;
index a3fe0d2..e038b55 100755 (executable)
@@ -24,9 +24,9 @@
 #include "download-agent-encoding.h"
 
 // '.' and ';' are request from Vodafone
-#define IS_TERMINATING_CHAR(c)                 ( ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
-#define IS_TERMINATING_CHAR_EX(c)              ( ((c) == '"') || ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
-#define IS_URI_TERMINATING_CHAR(c)             ( ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
+#define IS_TERMINATING_CHAR(c)                 (((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20))
+#define IS_TERMINATING_CHAR_EX(c)              (((c) == '"') || ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20))
+#define IS_URI_TERMINATING_CHAR(c)             (((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20))
 
 enum parsing_type {
        WITH_PARSING_OPTION,
@@ -34,19 +34,19 @@ enum parsing_type {
 };
 
 static da_ret_t __http_header_add_field(http_header_t **head,
-       const char *field, const char *value, enum parsing_type type);
+               const char *field, const char *value, enum parsing_type type);
 static void __http_header_destroy_all_field(http_header_t **head);
 static da_bool_t __get_http_header_for_field(
-       http_msg_response_t *http_msg_response, const char *in_field,
-       http_header_t **out_header);
+               http_msg_response_t *http_msg_response, const char *in_field,
+               http_header_t **out_header);
 static void __exchange_header_value(http_header_t *header,
-       const char *in_raw_value);
+               const char *in_raw_value);
 static http_header_options_t *__create_http_header_option(const char *field,
-       const char *value);
+               const char *value);
 static void __http_header_destroy_all_option(http_header_options_t **head);
 static da_bool_t __get_http_header_option_for_field(
-       http_header_options_t *header_option, const char *in_field,
-       char **out_value);
+               http_header_options_t *header_option, const char *in_field,
+               char **out_value);
 static http_header_options_t *__parsing_N_create_option_str(char *org_str);
 static http_header_options_t *__parsing_options(char *org_str);
 static void __parsing_raw_value(http_header_t *http_header);
@@ -55,10 +55,10 @@ da_ret_t http_msg_request_create(http_msg_request_t **http_msg_request)
 {
        http_msg_request_t *temp_http_msg_request = NULL;
 
-//     DA_LOGV("");
+       //      DA_LOGV("");
 
        temp_http_msg_request = (http_msg_request_t *)calloc(1,
-               sizeof(http_msg_request_t));
+                       sizeof(http_msg_request_t));
        if (!temp_http_msg_request) {
                *http_msg_request = NULL;
                DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
@@ -71,7 +71,7 @@ da_ret_t http_msg_request_create(http_msg_request_t **http_msg_request)
        temp_http_msg_request->http_body = NULL;
 
        *http_msg_request = temp_http_msg_request;
-       DA_LOGV( "http_msg_request: %x", (unsigned int)(*http_msg_request));
+       DA_LOGV("http_msg_request: %x", (unsigned int)(*http_msg_request));
 
        return DA_RESULT_OK;
 }
@@ -102,7 +102,7 @@ void http_msg_request_destroy(http_msg_request_t **http_msg_request)
 }
 
 da_ret_t http_msg_request_set_url(http_msg_request_t *http_msg_request,
-       const char *url)
+               const char *url)
 {
        DA_LOGV("");
 
@@ -122,7 +122,7 @@ da_ret_t http_msg_request_set_url(http_msg_request_t *http_msg_request,
 }
 
 da_ret_t http_msg_request_get_url(http_msg_request_t *http_msg_request,
-       const char **url)
+               const char **url)
 {
        DA_LOGV("");
 
@@ -141,7 +141,7 @@ da_ret_t http_msg_request_get_url(http_msg_request_t *http_msg_request,
 }
 
 da_ret_t http_msg_request_add_field(http_msg_request_t *http_msg_request,
-       const char *field, const char *value)
+               const char *field, const char *value)
 {
        //      DA_LOGV("");
 
@@ -160,7 +160,7 @@ da_ret_t http_msg_response_create(http_msg_response_t **http_msg_response)
        DA_LOGV("");
 
        temp_http_msg_response = (http_msg_response_t *)calloc(1,
-               sizeof(http_msg_response_t));
+                       sizeof(http_msg_response_t));
        if (!temp_http_msg_response) {
                DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
                return DA_ERR_FAIL_TO_MEMALLOC;
@@ -185,7 +185,7 @@ void http_msg_response_destroy(http_msg_response_t **http_msg_response)
 }
 
 da_ret_t http_msg_response_add_field(http_msg_response_t *http_msg_response,
-       const char *field, const char *value)
+               const char *field, const char *value)
 {
        DA_LOGV("");
 
@@ -197,7 +197,7 @@ da_ret_t http_msg_response_add_field(http_msg_response_t *http_msg_response,
 }
 
 da_ret_t __http_header_add_field(http_header_t **head,
-       const char *field, const char *value, enum parsing_type type)
+               const char *field, const char *value, enum parsing_type type)
 {
        http_header_t *pre = NULL;
        http_header_t *cur = NULL;
@@ -209,7 +209,7 @@ da_ret_t __http_header_add_field(http_header_t **head,
                pre = cur;
                /* Replace default value with user wanted value
                 * Remove the value which is stored before and add a new value.
-               */
+                */
                if (cur->field && cur->raw_value &&
                                strncasecmp(cur->field, field, strlen(field)) == 0) {
                        DA_SECURE_LOGD("Remove value for replacement [%s][%s]", cur->field, cur->raw_value);
@@ -219,7 +219,7 @@ da_ret_t __http_header_add_field(http_header_t **head,
                        }
                        if (cur->raw_value) {
                                free(cur->raw_value);
-                               cur->raw_value= NULL;
+                               cur->raw_value = NULL;
                        }
                }
                cur = cur->next;
@@ -282,12 +282,12 @@ void __http_header_destroy_all_field(http_header_t **head)
 }
 
 http_header_options_t *__create_http_header_option(const char *field,
-       const char *value)
+               const char *value)
 {
        http_header_options_t *option = NULL;
 
        option = (http_header_options_t *)calloc(1,
-               sizeof(http_header_options_t));
+                       sizeof(http_header_options_t));
        if (option) {
                if (field)
                        option->field = strdup(field);
@@ -325,7 +325,7 @@ void __http_header_destroy_all_option(http_header_options_t **head)
 }
 
 da_ret_t http_msg_request_get_iter(http_msg_request_t *http_msg_request,
-       http_msg_iter_t *http_msg_iter)
+               http_msg_iter_t *http_msg_iter)
 {
        DA_LOGV("");
 
@@ -340,7 +340,7 @@ da_ret_t http_msg_request_get_iter(http_msg_request_t *http_msg_request,
 }
 
 da_ret_t http_msg_response_get_iter(http_msg_response_t *http_msg_response,
-       http_msg_iter_t *http_msg_iter)
+               http_msg_iter_t *http_msg_iter)
 {
        if (!http_msg_response) {
                DA_LOGE("DA_ERR_INVALID_ARGUMENT");
@@ -352,7 +352,7 @@ da_ret_t http_msg_response_get_iter(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t http_msg_get_field_with_iter(http_msg_iter_t *http_msg_iter,
-       char **out_field, char **out_value)
+               char **out_field, char **out_value)
 {
        http_header_t *cur = *http_msg_iter;
 
@@ -367,7 +367,7 @@ da_bool_t http_msg_get_field_with_iter(http_msg_iter_t *http_msg_iter,
 }
 
 da_bool_t http_msg_get_header_with_iter(http_msg_iter_t *http_msg_iter,
-       char **out_field, http_header_t **out_header)
+               char **out_field, http_header_t **out_header)
 {
        http_header_t *cur = *http_msg_iter;
 
@@ -447,13 +447,13 @@ http_header_options_t *__parsing_N_create_option_str(char *org_str)
                option_field = (char *)calloc(1, option_field_len + 1);
                if (option_field)
                        strncpy(option_field, working_pos_field_start,
-                               option_field_len);
+                                       option_field_len);
        }
        if (option_value_len > 0 && working_pos_value_start) {
                option_value = (char *)calloc(1, option_value_len + 1);
                if (option_value)
                        strncpy(option_value, working_pos_value_start,
-                               option_value_len);
+                                       option_value_len);
        }
        if (working_str) {
                free(working_str);
@@ -461,11 +461,11 @@ http_header_options_t *__parsing_N_create_option_str(char *org_str)
        }
 
        DA_SECURE_LOGD("option_field = [%s], option_value = [%s]",
-               option_field, option_value);
+                       option_field, option_value);
 
        if (option_field || option_value) {
                option = __create_http_header_option(
-                       option_field, option_value);
+                               option_field, option_value);
                if (option_field) {
                        free(option_field);
                        option_field = NULL;
@@ -581,14 +581,14 @@ void __parsing_raw_value(http_header_t *http_header_field)
        http_header_options_t *cur = NULL;
        cur = http_header_field->options;
        while (cur) {
-//             DA_SECURE_LOGD("field = [%s], value = [%s]", cur->field, cur->value);
+               //              DA_SECURE_LOGD("field = [%s], value = [%s]", cur->field, cur->value);
                cur = cur->next;
        }
 }
 
 da_bool_t __get_http_header_option_for_field(
-       http_header_options_t *header_option, const char *in_field,
-       char **out_value)
+               http_header_options_t *header_option, const char *in_field,
+               char **out_value)
 {
        http_header_options_t *cur = NULL;
 
@@ -616,7 +616,7 @@ da_bool_t __get_http_header_option_for_field(
 }
 
 da_bool_t __get_http_header_for_field(http_msg_response_t *http_msg_response,
-       const char *in_field, http_header_t **out_header)
+               const char *in_field, http_header_t **out_header)
 {
        http_msg_iter_t http_msg_iter = DA_NULL;
        http_header_t *header = NULL;
@@ -637,7 +637,7 @@ da_bool_t __get_http_header_for_field(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t __get_http_req_header_for_field(http_msg_request_t *http_msg_request,
-       const char *in_field, http_header_t **out_header)
+               const char *in_field, http_header_t **out_header)
 {
        http_msg_iter_t http_msg_iter = DA_NULL;
        http_header_t *header = NULL;
@@ -678,7 +678,7 @@ void __exchange_header_value(http_header_t *header, const char *in_raw_value)
 }
 
 da_bool_t http_msg_response_get_content_type(
-       http_msg_response_t *http_msg_response, char **out_type)
+               http_msg_response_t *http_msg_response, char **out_type)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -698,7 +698,7 @@ da_bool_t http_msg_response_get_content_type(
 }
 
 void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
-       const char *in_type)
+               const char *in_type)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -712,7 +712,7 @@ void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
                        HTTP_FIELD_CONTENT_TYPE, &header);
        if (b_ret) {
                if (header->raw_value && (!strncmp(header->raw_value, in_type,
-                       strlen(header->raw_value))))
+                                               strlen(header->raw_value))))
                        return;
 
                DA_SECURE_LOGD("exchange Content-Type to [%s] from [%s]", in_type, header->value);
@@ -724,7 +724,7 @@ void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t http_msg_response_get_content_length(
-       http_msg_response_t *http_msg_response, da_size_t *out_length)
+               http_msg_response_t *http_msg_response, da_size_t *out_length)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -734,7 +734,7 @@ da_bool_t http_msg_response_get_content_length(
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_CONTENT_LENGTH, &header);
        if (!b_ret) {
-               DA_LOGV( "no Content-Length");
+               DA_LOGV("no Content-Length");
                return DA_FALSE;
        }
 
@@ -745,8 +745,8 @@ da_bool_t http_msg_response_get_content_length(
 }
 
 da_bool_t http_msg_response_get_content_disposition(
-       http_msg_response_t *http_msg_response, http_msg_t *http_msg, char **out_disposition,
-       char **out_file_name)
+               http_msg_response_t *http_msg_response, http_msg_t *http_msg, char **out_disposition,
+               char **out_file_name)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -762,7 +762,7 @@ da_bool_t http_msg_response_get_content_disposition(
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_CONTENT_DISPOSITION, &header);
        if (!b_ret) {
-               DA_LOGV( "no Content-Disposition");
+               DA_LOGV("no Content-Disposition");
                return DA_FALSE;
        }
        if (out_disposition)
@@ -771,9 +771,9 @@ da_bool_t http_msg_response_get_content_disposition(
                return DA_FALSE;
 
        b_ret = __get_http_header_option_for_field(header->options, "filename",
-               &file_name);
+                       &file_name);
        if (!b_ret) {
-               DA_LOGV( "no option");
+               DA_LOGV("no option");
                return DA_FALSE;
        }
 
@@ -799,7 +799,7 @@ da_bool_t http_msg_response_get_content_disposition(
                        if (b_ret) {
                                DA_LOGV("It's base64 encoded-word string");
                                if (DA_RESULT_OK == decode_base64_encoded_str(
-                                       wanted_str, &decoded_str)) {
+                                                       wanted_str, &decoded_str)) {
                                        DA_SECURE_LOGD("base64 decoded str = [%s]", decoded_str);
                                        free(wanted_str);
                                        wanted_str = decoded_str;
@@ -811,10 +811,9 @@ da_bool_t http_msg_response_get_content_disposition(
                                DA_LOGV("It's NOT base64 encoded-word string");
                        }
 
-                       if(http_msg->curl){
+                       if (http_msg->curl) {
                                decoded_str = curl_easy_unescape(http_msg->curl, wanted_str, wanted_str_len, NULL);
-                       }
-                       else{
+                       } else{
                                CURL* handle = curl_easy_init();
                                decoded_str = curl_easy_unescape(handle, wanted_str, wanted_str_len, NULL);
                                curl_easy_cleanup(handle);
@@ -833,8 +832,7 @@ da_bool_t http_msg_response_get_content_disposition(
 
                                *out_file_name = file_name;
                                return DA_TRUE;
-                       }
-                       else{
+                       } else{
                                DA_LOGE("Fail to url decode.");
                                NULL_CHECK_AND_FREE(wanted_str);
                                *out_file_name = NULL;
@@ -848,7 +846,7 @@ da_bool_t http_msg_response_get_content_disposition(
 }
 
 da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -858,7 +856,7 @@ da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_ETAG,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no ETag");
+               DA_LOGV("no ETag");
                return DA_FALSE;
        }
        if (out_value)
@@ -869,7 +867,7 @@ da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
 
 #ifdef _RAF_SUPPORT
 da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -879,7 +877,7 @@ da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_RAF_MODE,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no RAF mode");
+               DA_LOGV("no RAF mode");
                return DA_FALSE;
        }
        if (out_value)
@@ -890,7 +888,7 @@ da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
 #endif
 
 da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -900,7 +898,7 @@ da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_DATA, &header);
        if (!b_ret) {
-               DA_LOGV( "no Date");
+               DA_LOGV("no Date");
                return DA_FALSE;
        }
        if (out_value)
@@ -910,7 +908,7 @@ da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t http_msg_response_get_location(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -920,7 +918,7 @@ da_bool_t http_msg_response_get_location(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_LOCATION, &header);
        if (!b_ret) {
-               DA_LOGV( "no Location");
+               DA_LOGV("no Location");
                return DA_FALSE;
        }
        if (out_value)
@@ -963,11 +961,10 @@ char *__stristr(const char *long_str, const char *find_str)
 
        while (i < length_long) {
                if (isalpha(long_str[i]) != 0) {
-                       if (isupper(long_str[i]) != 0) {
+                       if (isupper(long_str[i]) != 0)
                                org_ptr[i] = long_str[i];
-                       } else {
+                       else
                                org_ptr[i] = toupper(long_str[i]);
-                       }
                } else {
                        org_ptr[i] = long_str[i];
                }
@@ -978,11 +975,10 @@ char *__stristr(const char *long_str, const char *find_str)
 
        while (i < length_find) {
                if (isalpha(find_str[i]) != 0) {
-                       if (isupper(find_str[i]) != 0) {
+                       if (isupper(find_str[i]) != 0)
                                look_ptr[i] = find_str[i];
-                       } else {
+                       else
                                look_ptr[i] = toupper(find_str[i]);
-                       }
                } else {
                        look_ptr[i] = find_str[i];
                }
@@ -1007,9 +1003,9 @@ char *__stristr(const char *long_str, const char *find_str)
 
 /* This is not used. But it can be needed if there is no http header parser at http library.*/
 da_bool_t extract_attribute_from_header(
-        char *szHeadStr,
-        const char *szFindStr,
-        char **ppRtnValue)
+               char *szHeadStr,
+               const char *szFindStr,
+               char **ppRtnValue)
 {
        char *pValuePos = NULL;
        int index = 0;
@@ -1026,9 +1022,8 @@ da_bool_t extract_attribute_from_header(
 
                return DA_FALSE;
        }
-       if (ppRtnValue == NULL) {
+       if (ppRtnValue == NULL)
                return DA_FALSE;
-       }
 
        pValuePos = __stristr(szHeadStr, (char*)szFindStr);
        if (pValuePos == NULL) {
@@ -1041,17 +1036,15 @@ da_bool_t extract_attribute_from_header(
        while (pValuePos[index] != ':' && pValuePos[index] != '=') {
                index++;
 
-               if (pValuePos[index] == '\0') {
+               if (pValuePos[index] == '\0')
                        return DA_FALSE;
-               }
        }
 
        index++;
 
        /* jump space */
-       while (pValuePos[index] == ' ') {
+       while (pValuePos[index] == ' ')
                index++;
-       }
 
        /* jump quatation mark */
        while (pValuePos[index] == '"') {
@@ -1061,21 +1054,18 @@ da_bool_t extract_attribute_from_header(
 
        startPos = index;
 
-       /* Find the end of data. */
-       if (0 == strncasecmp(szFindStr, HTTP_FIELD_LOCATION,
-                       strlen(HTTP_FIELD_LOCATION)))//terminate character list does not contain ';' in case of URI
-       {
-               while (DA_FALSE == IS_URI_TERMINATING_CHAR(pValuePos[index])) {
+       /* Find the end of data.
+        * terminate character list does not contain ';' in case of URI
+        */
+       if (0 == strncasecmp(szFindStr, HTTP_FIELD_LOCATION, strlen(HTTP_FIELD_LOCATION))) {
+               while (DA_FALSE == IS_URI_TERMINATING_CHAR(pValuePos[index]))
                        index++;
-               }
        } else if (need_to_end_quataion_mark) {
-               while (DA_FALSE == IS_TERMINATING_CHAR_EX(pValuePos[index])) {
+               while (DA_FALSE == IS_TERMINATING_CHAR_EX(pValuePos[index]))
                        index++;
-               }
        } else {
-               while (DA_FALSE == IS_TERMINATING_CHAR(pValuePos[index])) {
+               while (DA_FALSE == IS_TERMINATING_CHAR(pValuePos[index]))
                        index++;
-               }
        }
 
        strLen = index - startPos;
@@ -1105,7 +1095,7 @@ ERR:
 }
 
 da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -1115,7 +1105,7 @@ da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
        b_ret = __get_http_req_header_for_field(http_msg_request, HTTP_FIELD_IF_RANGE,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no If Range");
+               DA_LOGV("no If Range");
                return DA_FALSE;
        }
        if (out_value)
@@ -1125,7 +1115,7 @@ da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
 }
 
 da_bool_t http_msg_request_get_range(http_msg_request_t *http_msg_request,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -1135,7 +1125,7 @@ da_bool_t http_msg_request_get_range(http_msg_request_t *http_msg_request,
        b_ret = __get_http_req_header_for_field(http_msg_request, HTTP_FIELD_RANGE,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no Range");
+               DA_LOGV("no Range");
                return DA_FALSE;
        }
        if (out_value)
index 57e28e0..f005715 100755 (executable)
 
 #define MAX_EXT_NAME_LEN 12
 #define MAX_EXT_TABLE_INDEX 16
-Ext_translation_table ext_trans_table [MAX_EXT_TABLE_INDEX] = {
-               {"*.xla",                       "*.xls"},
-               {"*.pot",                       "*.ppt"},
-               {"*.xsl",                       "*.xml"},
-               {"*.spl",                       "*.swf"},
-               {"*.oga",                       "*.ogg"},
-               {"*.jpe",                       "*.jpg"},//5
-               {"*.CSSL",                      "*.css"},
-               {"*.htm",                       "*.html"},
-               {"*.hxx",                       "*.hpp"},
-               {"*.c++",                       "*.cpp"},
-               {"CMakeLists.txt",      "*.cmake"},//10
-               {"*.ime",                       "*.imy"},
-               {"Makefile",            "makefile"},
-               {"*.3g2",                       "*.3gp"},
-               {"*.mp2",                       "*.mpg"},
-               {"*.divx",                      "*.avi"},//15
-       };
+Ext_translation_table ext_trans_table[MAX_EXT_TABLE_INDEX] = {
+       {"*.xla",                       "*.xls"},
+       {"*.pot",                       "*.ppt"},
+       {"*.xsl",                       "*.xml"},
+       {"*.spl",                       "*.swf"},
+       {"*.oga",                       "*.ogg"},
+       {"*.jpe",                       "*.jpg"},//5
+       {"*.CSSL",                      "*.css"},
+       {"*.htm",                       "*.html"},
+       {"*.hxx",                       "*.hpp"},
+       {"*.c++",                       "*.cpp"},
+       {"CMakeLists.txt",      "*.cmake"},//10
+       {"*.ime",                       "*.imy"},
+       {"Makefile",            "makefile"},
+       {"*.3g2",                       "*.3gp"},
+       {"*.mp2",                       "*.mpg"},
+       {"*.divx",                      "*.avi"},//15
+};
 /* This is samsung mime policy
  * 1. if the mime is audio/m4a, the extension name is defined as "m4a" for launching music player
-*/
+ */
 #ifdef _SAMSUNG_MIME_POLICY
 #define MAX_SEC_MIME_TABLE_INDEX 1
 struct sec_mime_table_t {
        char *mime;
        char *ext;
 };
-struct sec_mime_table_t sec_mime_table [MAX_SEC_MIME_TABLE_INDEX] = {
+struct sec_mime_table_t sec_mime_table[MAX_SEC_MIME_TABLE_INDEX] = {
        {"audio/m4a",           "m4a"},
 };
 #endif
 
 const char *ambiguous_MIME_Type_list[] = {
-               "text/plain",
-               "application/octet-stream"
+       "text/plain",
+       "application/octet-stream"
 };
 
 /* Because xdgmime is not thread safety, this mutex is necessary */
@@ -77,7 +77,7 @@ da_bool_t is_ambiguous_MIME_Type(const char *in_mime_type)
        int list_size = sizeof(ambiguous_MIME_Type_list) / sizeof(const char *);
        for (index = 0 ; index < list_size ; index++) {
                if (0 == strncmp(in_mime_type, ambiguous_MIME_Type_list[index],
-                               strlen(ambiguous_MIME_Type_list[index]))) {
+                                       strlen(ambiguous_MIME_Type_list[index]))) {
                        //DA_SECURE_LOGD("It is ambiguous! [%s]", ambiguous_MIME_Type_list[index]);
                        return DA_TRUE;
                }
@@ -101,7 +101,7 @@ da_ret_t da_mime_get_ext_name(char *mime, char **ext)
                DA_LOGE("Invalid mime type");
                goto ERR;
        }
-//     DA_SECURE_LOGD("mime str[%s]ptr[%p]len[%d]",mime,mime,strlen(mime));
+       //      DA_SECURE_LOGD("mime str[%s]ptr[%p]len[%d]",mime,mime,strlen(mime));
        /* unaliased_mimetype means representative mime among similar types */
        DA_MUTEX_LOCK(&mutex_for_xdgmime);
        unaliased_mimetype = xdg_mime_unalias_mime_type(mime);
@@ -112,7 +112,7 @@ da_ret_t da_mime_get_ext_name(char *mime, char **ext)
                DA_MUTEX_UNLOCK(&mutex_for_xdgmime);
                goto ERR;
        }
-       DA_SECURE_LOGD("unaliased_mimetype[%s]\n",unaliased_mimetype);
+       DA_SECURE_LOGD("unaliased_mimetype[%s]\n", unaliased_mimetype);
 
        /* Get extension name from shared-mime-info */
        extlist = xdg_mime_get_file_names_from_mime_type(unaliased_mimetype);
@@ -122,8 +122,7 @@ da_ret_t da_mime_get_ext_name(char *mime, char **ext)
                ret = DA_ERR_INVALID_MIME_TYPE;
                DA_LOGV("No extension list");
 #ifdef _SAMSUNG_MIME_POLICY
-               for (i = 0; i < MAX_SEC_MIME_TABLE_INDEX; i++)
-               {
+               for (i = 0; i < MAX_SEC_MIME_TABLE_INDEX; i++) {
                        if (strncmp(sec_mime_table[i].mime, mime, strlen(mime)) == 0) {
                                strncpy(ext_temp, sec_mime_table[i].ext, DA_MAX_STR_LEN-1);
                                ret = DA_RESULT_OK;
@@ -132,7 +131,6 @@ da_ret_t da_mime_get_ext_name(char *mime, char **ext)
                }
 #endif
        } else { /* For drm case, this else statement is needed */
-//             DA_LOGD("extlist[%s]\n",*extlist);
                strncpy(ext_temp, *extlist, DA_MAX_STR_LEN - 1);
                /* If only one extension name is existed, don't enter here */
                while (*extlist != NULL) {
@@ -140,24 +138,20 @@ da_ret_t da_mime_get_ext_name(char *mime, char **ext)
                        /* If there are existed many extension names,
                         *  try to search common extension name from table
                         *  with first mime type at extension list*/
-                       for (i = 0; i < MAX_EXT_TABLE_INDEX; i++)
-                       {
-                               if (strncmp(ext_trans_table[i].standard,*extlist,
-                                               strlen(*extlist)) == 0) {
+                       for (i = 0; i < MAX_EXT_TABLE_INDEX; i++) {
+                               if (strncmp(ext_trans_table[i].standard, *extlist,
+                                                       strlen(*extlist)) == 0) {
                                        memset(ext_temp, 0x00, DA_MAX_STR_LEN);
-                                       strncpy(ext_temp,ext_trans_table[i].normal, DA_MAX_STR_LEN-1);
+                                       strncpy(ext_temp, ext_trans_table[i].normal, DA_MAX_STR_LEN-1);
                                        break;
                                }
                        }
-                       DA_LOGV("index[%d]\n",i);
+                       DA_LOGV("index[%d]\n", i);
                        /* If there is a mime at extension transform table */
-                       if (i < MAX_EXT_TABLE_INDEX) {
+                       if (i < MAX_EXT_TABLE_INDEX)
                                break;
-                       }
-//                     DA_LOGD("extlist[%s]\n",*extlist);
                        extlist++;
                }
-//             DA_SECURE_LOGD("extension from shared mime info[%s]",ext_temp);
        }
 
        if (strlen(ext_temp) < 1) {
@@ -180,16 +174,16 @@ da_ret_t da_mime_get_ext_name(char *mime, char **ext)
        if (ret != DA_RESULT_OK)
                goto ERR;
 
-       temp = strchr(ext_temp,'.');
+       temp = strchr(ext_temp, '.');
        if (temp == NULL)
                temp = ext_temp;
        else
                temp++;
 
-       DA_SECURE_LOGD("final extension name:[%s]",temp);
+       DA_SECURE_LOGD("final extension name:[%s]", temp);
        *ext = (char*)calloc(1, strlen(temp) + 1);
        if (*ext != DA_NULL) {
-               strncpy(*ext, temp,strlen(temp));
+               strncpy(*ext, temp, strlen(temp));
        } else  {
                ret = DA_ERR_FAIL_TO_MEMALLOC ;
                goto ERR ;
@@ -213,23 +207,21 @@ da_bool_t da_get_extension_name_from_url(char *url, char **ext)
                return ret;
        }
 
-       if ((temp_str = strrchr(url,'/'))) {
-               if ((buff = strrchr(temp_str,'.'))) {
+       if ((temp_str = strrchr(url, '/'))) {
+               if ((buff = strrchr(temp_str, '.'))) {
                        char *q = DA_NULL;
                        buff++;
 
                        /* check extention length refer to https://en.wikipedia.org/wiki/List_of_filename_extensions */
-                       if(strlen(buff) > MAX_EXT_NAME_LEN){
+                       if (strlen(buff) > MAX_EXT_NAME_LEN)
                                return ret;
-                       }
 
                        /* check to exist "?" after extension name */
-                       q = strrchr(buff,'?');
-                       if (q) {
+                       q = strrchr(buff, '?');
+                       if (q)
                                buf_len = strlen(buff) - strlen(q);
-                       } else {
+                       else
                                buf_len = strlen(buff);
-                       }
                        *ext = (char*) calloc(1, buf_len + 1) ;
 
                        if (DA_NULL == *ext) {
@@ -237,8 +229,8 @@ da_bool_t da_get_extension_name_from_url(char *url, char **ext)
                                DA_LOGE("Memory Fail");
                                goto ERR;
                        }
-                       strncpy(*ext,buff,buf_len);
-                       DA_SECURE_LOGD("extention name[%s]",*ext);
+                       strncpy(*ext, buff, buf_len);
+                       DA_SECURE_LOGD("extention name[%s]", *ext);
                        return ret;
                }
        }
@@ -261,7 +253,7 @@ da_bool_t da_get_file_name_from_url(char *url, char **name)
        int i = 0;
        int j = 0;
        int len_name = 0;
-    char name_buff[DA_MAX_FILE_NAME_LEN + 1] = {0,};
+       char name_buff[DA_MAX_FILE_NAME_LEN + 1] = {0,};
 
        DA_LOGV("");
 
@@ -275,87 +267,85 @@ da_bool_t da_get_file_name_from_url(char *url, char **name)
                ret = DA_FALSE;
                DA_LOGE("Invalid Argument");
                goto ERR;
-    }
+       }
 
        buff = (char*) calloc(1, strlen(url) +1);
-       if(DA_NULL == buff) {
+       if (DA_NULL == buff) {
                ret = DA_FALSE;
                DA_LOGE("Memory Fail");
                goto ERR;
-    }
+       }
 
-       while((c = url[i++]) != 0) {
-               if(c == '%') {
+       while ((c = url[i++]) != 0) {
+               if (c == '%') {
                        char buffer[3] = {0,};
                        buffer[0] = url[i++];
                        buffer[1] = url[i++];
-                       buff[j++] = (char)strtol(buffer,NULL,16);
+                       buff[j++] = (char)strtol(buffer, NULL, 16);
                } else {
                        buff[j++] = c;
                }
        }
        End = strstr(buff, "?");
        if (DA_NULL != End) {
-           Start = End -1;
-           while(*(Start) != '/') {
-               Start--;
-           }
-           if ((*(Start) == '/') && ((len_name = (End - Start)) > 1)) {
-               Start++;
-               if (DA_MAX_FILE_NAME_LEN <= len_name)   {
-                   strncpy(name_buff, Start, DA_MAX_FILE_NAME_LEN);
-                   name_buff[DA_MAX_FILE_NAME_LEN] = '\0';
-               } else {
-                   strncpy(name_buff, Start, len_name);
-                   name_buff[len_name] = '\0';
-               }
-           } else {
-               ret = DA_FALSE;
-               goto ERR ; /*Name not found*/
-           }
+               Start = End -1;
+               while (*(Start) != '/')
+                       Start--;
+
+               if ((*(Start) == '/') && ((len_name = (End - Start)) > 1)) {
+                       Start++;
+                       if (DA_MAX_FILE_NAME_LEN <= len_name)   {
+                               strncpy(name_buff, Start, DA_MAX_FILE_NAME_LEN);
+                               name_buff[DA_MAX_FILE_NAME_LEN] = '\0';
+                       } else {
+                               strncpy(name_buff, Start, len_name);
+                               name_buff[len_name] = '\0';
+                       }
+               } else {
+                       ret = DA_FALSE;
+                       goto ERR ; /*Name not found*/
+               }
        } else {
-               int urlLen = strlen (buff);
+               int urlLen = strlen(buff);
                int Start_pos = 0;
                Start_pos = urlLen - 1;
 
-               while(Start_pos > 0) {
-                       if(buff[Start_pos] == '/')
+               while (Start_pos > 0) {
+                       if (buff[Start_pos] == '/')
                                break;
                        Start_pos--;
                }
                Start_pos++;
                if (Start_pos == 0 || urlLen - Start_pos <= 0) {
-                   ret = DA_FALSE;
-                   goto ERR;
+                       ret = DA_FALSE;
+                       goto ERR;
                }
-               while(Start_pos < urlLen) {
-                   name_buff[len_name++] = buff[Start_pos++];
-                   if (DA_MAX_FILE_NAME_LEN <= len_name) {
-                       name_buff[DA_MAX_FILE_NAME_LEN] ='\0';
-                       break;
-                   }
+               while (Start_pos < urlLen) {
+                       name_buff[len_name++] = buff[Start_pos++];
+                       if (DA_MAX_FILE_NAME_LEN <= len_name) {
+                               name_buff[DA_MAX_FILE_NAME_LEN] = '\0';
+                               break;
+                       }
                }
        }
 
        if (len_name) {
                End = strrchr(name_buff, '.');
-               if (End != NULL) {
+               if (End != NULL)
                        *End = '\0';
-               }
-//             DA_SECURE_LOGD("file name BEFORE removing prohibited character = %s", name_buff);
+               //              DA_SECURE_LOGD("file name BEFORE removing prohibited character = %s", name_buff);
                delete_prohibited_char(name_buff, strlen(name_buff));
                len_name = strlen(name_buff);
                *name = (char*) calloc(1, len_name + 1);
-               if (*name) {
-                       strncpy(*name, name_buff,len_name);
-               }
+               if (*name)
+                       strncpy(*name, name_buff, len_name);
        }
-//     DA_SECURE_LOGD("Extracted file name : %s", *name);
+       //      DA_SECURE_LOGD("Extracted file name : %s", *name);
 ERR:
        if (buff) {
-               free (buff);
+               free(buff);
                buff = DA_NULL;
-    }
+       }
        return ret;
 }
 
@@ -365,19 +355,19 @@ void delete_prohibited_char(char *szTarget, int str_len)
        int i = 0;
        int j = 0;
        int tar_len = 0;
-    DA_LOGD("");
-       if(szTarget == NULL || str_len <= 0 || strlen(szTarget) != str_len) {
+       DA_LOGD("");
+       if (szTarget == NULL || str_len <= 0 || strlen(szTarget) != str_len) {
                DA_LOGE("Invaild Parameter\n");
                return;
        }
 
        chk_str = (char *)calloc(1, str_len + 1);
-       if(chk_str == NULL)
+       if (chk_str == NULL)
                return;
 
-       while(szTarget[j] != '\0') {
-               if(IS_PROHIBITED_CHAR(szTarget[j]) == DA_FALSE &&
-                                       IS_SPACE_CHARACTER(szTarget[j]) == DA_FALSE) {
+       while (szTarget[j] != '\0') {
+               if (IS_PROHIBITED_CHAR(szTarget[j]) == DA_FALSE &&
+                               IS_SPACE_CHARACTER(szTarget[j]) == DA_FALSE) {
                        chk_str[i] = szTarget[j];
                        i++;
                }
@@ -387,19 +377,17 @@ void delete_prohibited_char(char *szTarget, int str_len)
        chk_str[i] = '\0';
        tar_len = strlen(chk_str);
 
-       if(tar_len <= 0)
+       if (tar_len <= 0)
                szTarget[0] = '\0';
        else {
-               for(i = 0; i < tar_len; i++)
-               {
+               for (i = 0; i < tar_len; i++)
                        szTarget[i] = chk_str[i];
-               }
                szTarget[i] = '\0';
        }
 
-       if(chk_str != NULL)     {
+       if (chk_str != NULL)
                free(chk_str);
-       }
+
        return;
 }
 
@@ -442,13 +430,13 @@ da_ret_t get_extension_from_mime_type(char *mime_type, char **extension)
                ret = DA_ERR_INVALID_ARGUMENT;
                goto ERR;
        }
-//     DA_SECURE_LOGD("input mime type = %s", mime_type);
+       //      DA_SECURE_LOGD("input mime type = %s", mime_type);
        if (DA_RESULT_OK != (ret = da_mime_get_ext_name(mime_type, &ext))) {
                DA_LOGE("can't find proper extension!");
                goto ERR;
        }
        *extension = ext;
-//     DA_SECURE_LOGD("found extension = %s", *extension);
+       //      DA_SECURE_LOGD("found extension = %s", *extension);
 
 ERR:
        return ret;
index 9d9e1b8..4d3c5c5 100755 (executable)
@@ -62,8 +62,8 @@ char *get_proxy_address(void)
        connection_h handle = NULL;
        connection_address_family_e family = CONNECTION_ADDRESS_FAMILY_IPV4;
 
-    DA_LOGV("");
-    if (connection_create(&handle) < 0) {
+       DA_LOGV("");
+       if (connection_create(&handle) < 0) {
                DA_LOGE("Fail to create connection handle");
                return NULL;
        }
@@ -83,7 +83,7 @@ char *get_proxy_address(void)
                return proxy;
        }
 
-    if (connection_destroy(handle) < 0) {
+       if (connection_destroy(handle) < 0) {
                DA_LOGE("Fail to desctory connection handle");
                return NULL;
        }
index 22e6f34..cd828cf 100644 (file)
@@ -29,11 +29,10 @@ void __EDRM_clean_up()
 {
        int ret = 0;
        ret = drm_trusted_handle_request(DRM_TRUSTED_REQ_TYPE_CLIENT_CLEAN_UP, NULL, NULL);
-   if (DRM_RETURN_SUCCESS == ret) {
-          DA_LOGD( "Clean up successfull");
-   } else {
-          DA_LOGE("ret[%0x%x]",ret);
-   }
+       if (DRM_RETURN_SUCCESS == ret)
+               DA_LOGD("Clean up successfull");
+       else
+               DA_LOGE("ret[%0x%x]", ret);
 }
 
 da_bool_t EDRM_convert(const char *in_file_path, char **out_file_path)
@@ -54,7 +53,7 @@ da_bool_t EDRM_convert(const char *in_file_path, char **out_file_path)
        ret = drm_trusted_convert_dm(&input, &output);
 
        if (DRM_TRUSTED_RETURN_SUCCESS != ret) {
-               DA_LOGE("ret[%0x%x]",ret);
+               DA_LOGE("ret[%0x%x]", ret);
                __EDRM_clean_up();
                return DA_FALSE;
        } else {
index 4d76a2c..4501f8d 100755 (executable)
@@ -68,7 +68,7 @@ int __translate_error_code(int curl_error)
 
 int my_trace(CURL *handle, curl_infotype type, char *data, size_t size, void *user)
 {
-       switch(type) {
+       switch (type) {
        case CURLINFO_TEXT:
                if (data)
                        DA_SECURE_LOGI("[curl] Info:%s", data);
@@ -91,13 +91,6 @@ int my_trace(CURL *handle, curl_infotype type, char *data, size_t size, void *us
                if (data)
                        DA_SECURE_LOGI("[curl] %s", data);
                break;
-#if 0
-       case CURLINFO_DATA_IN:
-               DA_LOGD("[curl] Recv data");
-               if (data)
-                       DA_SECURE_LOGI("[curl] %d", strlen(data));
-               break;
-#endif
        case CURLINFO_SSL_DATA_IN:
                DA_SECURE_LOGI("[curl] Recv SSL data");
                break;
@@ -143,19 +136,18 @@ void __parse_raw_header(const char *raw_data, http_info_t *http_info)
        }
        memcpy(field, raw_data, len);
        field[len] = '\0';
-               ptr++;
-       while(ptr) {
+       ptr++;
+       while (ptr) {
                if (*ptr == ' ')
                        ptr++;
                else
                        break;
        }
        ptr2 = strchr(raw_data, '\n');
-       if (ptr2) {
+       if (ptr2)
                len = ptr2 - ptr -1;
-       } else {
+       else
                len = strlen(ptr);
-       }
        value = (char *)calloc(len + 1, sizeof(char));
        if (!value) {
                DA_LOGE("Fail to calloc");
@@ -187,7 +179,7 @@ void __store_header(void *msg, da_info_t *da_info, size_t header_size,
        // FIXME later : check status code and redirection case check.
 
        if (strncmp(msg, HTTP_FIELD_END_OF_FIELD,
-                       strlen(HTTP_FIELD_END_OF_FIELD)) == 0) {
+                               strlen(HTTP_FIELD_END_OF_FIELD)) == 0) {
                long status = 0;
                CURLcode res;
                CURL *curl;
@@ -199,9 +191,8 @@ void __store_header(void *msg, da_info_t *da_info, size_t header_size,
                        return;
                }
                DA_LOGV("status code[%d]", (int)status);
-               if (http_info->http_msg_response) {
+               if (http_info->http_msg_response)
                        http_info->http_msg_response->status_code = (int)status;
-               }
                raw_data = (http_raw_data_t *)calloc(1, sizeof(http_raw_data_t));
                if (!raw_data) {
                        DA_LOGE("Fail to calloc");
@@ -211,14 +202,13 @@ void __store_header(void *msg, da_info_t *da_info, size_t header_size,
                raw_data->status_code = (int)status;
                raw_data->type = HTTP_EVENT_GOT_HEADER;
 
-               if (http_info->update_cb) {
+               if (http_info->update_cb)
                        http_info->update_cb(raw_data, da_info);
-               } else {
+               else
                        free(raw_data);
-               }
                return;
        }
-       DA_LOGI("%s",(char *)msg);
+       DA_LOGI("%s", (char *)msg);
        __parse_raw_header((const char *)msg, http_info);
 }
 
@@ -239,9 +229,9 @@ size_t __http_gotheaders_cb(void *ptr, size_t size, size_t nmemb, void *userdata
                __store_header(ptr, da_info, (size * nmemb), DA_NULL);
        else
                DA_LOGV("ignore because content sniffing is turned on");
-/*
+       /*
 #ifdef _RAF_SUPPORT
-       DA_LOGI("[RAF] __http_gotheaders_cb done");
+DA_LOGI("[RAF] __http_gotheaders_cb done");
 #endif
 */
        return (size * nmemb);
@@ -381,7 +371,7 @@ struct curl_slist *__fill_soup_msg_header(CURL *curl, http_info_t *info)
                                        DA_LOGE("Fail to memalloc");
                                        break;
                                }
-//                             DA_SECURE_LOGI("[%s] %s", field, value);
+                               //                              DA_SECURE_LOGI("[%s] %s", field, value);
                                snprintf(buff, len + 1, "%s:%s", field, value);
                                headers = curl_slist_append(headers, (const char *)buff);
                                free(buff);
@@ -415,16 +405,16 @@ int __http_progress_cb(void *clientp, double dltotal, double dlnow,
        da_info_t *da_info = DA_NULL;
        http_info_t *http_info = DA_NULL;
        http_raw_data_t *raw_data = DA_NULL;
-/*
-       if (dlnow > 0 || ulnow > 0)
-               DA_LOGI("[RAF]dlnow/ulnow[%llu/%llu][%llu,%llu]", (da_size_t)dlnow, (da_size_t)ulnow, (da_size_t)dltotal, (da_size_t)ultotal);
-*/
-
-/*
-       if (dlnow == 0) {
-               DA_LOGI("[RAF]dlnow is zero. Why is this callback called although there is zero size?");
-       }
-*/
+       /*
+          if (dlnow > 0 || ulnow > 0)
+          DA_LOGI("[RAF]dlnow/ulnow[%llu/%llu][%llu,%llu]", (da_size_t)dlnow, (da_size_t)ulnow, (da_size_t)dltotal, (da_size_t)ultotal);
+          */
+
+       /*
+          if (dlnow == 0) {
+          DA_LOGI("[RAF]dlnow is zero. Why is this callback called although there is zero size?");
+          }
+          */
        NULL_CHECK_RET_OPT(clientp, -1);
        da_info = (da_info_t *)clientp;
        http_info = da_info->http_info;
@@ -516,11 +506,6 @@ da_ret_t PI_http_start(da_info_t *da_info)
                break;
        }
 
-       if (using_content_sniffing) {
-               /* FIXME later*/
-       } else {
-               /* FIXME later*/
-       }
        headers = __fill_soup_msg_header(curl, http_info);
 
        curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, __http_gotheaders_cb); // can replace to started_cb
@@ -535,7 +520,7 @@ da_ret_t PI_http_start(da_info_t *da_info)
 #else
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
 #endif
-//     curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
+       //      curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, err_buffer);
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L);
@@ -557,7 +542,7 @@ da_ret_t PI_http_start(da_info_t *da_info)
        http_msg->curl = curl;
        curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, tpkp_curl_ssl_ctx_callback);
        res = curl_easy_perform(curl);
-       DA_LOGD("perform done! res[%d]",res);
+       DA_LOGD("perform done! res[%d]", res);
        if (res != CURLE_OK) {
                //DA_LOGE("Fail to send data :%d[%s]", res, curl_easy_strerror(res));
                DA_LOGE("Fail to send data :%d[%s]", res, curl_easy_strerror(res));
@@ -626,8 +611,8 @@ da_ret_t PI_http_disconnect(http_info_t *info)
        DA_MUTEX_LOCK(&(http_msg->mutex));
        if (http_msg->is_paused)
                PI_http_unpause(info);
-        if (http_msg->curl)
-                curl_easy_cleanup(http_msg->curl);
+       if (http_msg->curl)
+               curl_easy_cleanup(http_msg->curl);
 
        http_msg->curl = DA_NULL;
        http_msg->is_paused = DA_FALSE;
@@ -674,11 +659,11 @@ da_ret_t PI_http_pause(http_info_t *info)
        DA_LOGE("curl_easy_pause call");
        res = curl_easy_pause(http_msg->curl, CURLPAUSE_ALL);
        DA_LOGE("curl_easy_pause:%d", res);
-       if (res == CURLE_OK) {
+       if (res == CURLE_OK)
                http_msg->is_paused = DA_TRUE;
-       } else {
+       else
                ret = DA_ERR_CANNOT_SUSPEND;
-       }
+
        DA_MUTEX_UNLOCK(&(http_msg->mutex));
        return ret;
 }
index 3caabb5..e414eb1 100755 (executable)
 #include <pthread.h>
 
 // ansi color
-#define COLOR_RED              "\033[0;31m"
-#define COLOR_GREEN    "\033[0;32m"
-#define COLOR_BROWN    "\033[0;33m"
-#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_RED              "\033[0;31m"
+#define COLOR_GREEN            "\033[0;32m"
+#define COLOR_BROWN            "\033[0;33m"
+#define COLOR_LIGHTBLUE        "\033[0;37m"
 #define COLOR_END              "\033[0;m"
 
 #ifdef _ENABLE_DLOG
 #include <syscall.h>
 #include <dlog.h>
 
-       #ifdef LOG_TAG
-       #undef LOG_TAG
-       #endif /*  LOG_TAG */
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /*  LOG_TAG */
 
-       #define LOG_TAG "DP_DA"
-       #define DA_LOGV(format, ...) ((void)0)//LOGD("[%ld]:"format, syscall(__NR_gettid), ##__VA_ARGS__)
-       #define DA_LOGD(format, ...) LOGD(COLOR_LIGHTBLUE "[%ld]:"format COLOR_END, syscall(__NR_gettid), ##__VA_ARGS__)
-       #define DA_LOGI(format, ...) LOGI(COLOR_BROWN "[%ld]:"format COLOR_END, syscall(__NR_gettid), ##__VA_ARGS__)
-       #define DA_LOGE(format, ...) LOGE(COLOR_RED "[%ld]:"format COLOR_END, syscall(__NR_gettid), ##__VA_ARGS__)
-       #define DA_SECURE_LOGD(format, ...) SECURE_LOGD(COLOR_GREEN format COLOR_END, ##__VA_ARGS__)
-       #define DA_SECURE_LOGI(format, ...) SECURE_LOGI(COLOR_GREEN format COLOR_END, ##__VA_ARGS__)
-       #define DA_SECURE_LOGE(format, ...) SECURE_LOGE(COLOR_GREEN format COLOR_END, ##__VA_ARGS__)
+#define LOG_TAG "DP_DA"
+#define DA_LOGV(format, ...) ((void)0)//LOGD("[%ld]:"format, syscall(__NR_gettid), ##__VA_ARGS__)
+#define DA_LOGD(format, ...) LOGD(COLOR_LIGHTBLUE "[%ld]:"format COLOR_END, syscall(__NR_gettid), ##__VA_ARGS__)
+#define DA_LOGI(format, ...) LOGI(COLOR_BROWN "[%ld]:"format COLOR_END, syscall(__NR_gettid), ##__VA_ARGS__)
+#define DA_LOGE(format, ...) LOGE(COLOR_RED "[%ld]:"format COLOR_END, syscall(__NR_gettid), ##__VA_ARGS__)
+#define DA_SECURE_LOGD(format, ...) SECURE_LOGD(COLOR_GREEN format COLOR_END, ##__VA_ARGS__)
+#define DA_SECURE_LOGI(format, ...) SECURE_LOGI(COLOR_GREEN format COLOR_END, ##__VA_ARGS__)
+#define DA_SECURE_LOGE(format, ...) SECURE_LOGE(COLOR_GREEN format COLOR_END, ##__VA_ARGS__)
 #else
 
 #include <unistd.h>
 #include <syscall.h>
 
-       #define DA_LOGD(format, ...) do {\
-                               fprintf(stderr, "[DA][%ld][%s():%d] "format"\n",syscall(__NR_gettid), __FUNCTION__,__LINE__, ##__VA_ARGS__);\
-       }while(0)
-       #define DA_LOGE(format, ...) do {\
-                               fprintf(stderr, "[DA][%ld][ERR][%s():%d]\n",syscall(__NR_gettid), __FUNCTION__,__LINE__, ##__VA_ARGS__);\
-       }while(0)
-       #define DA_LOGV DA_LOGD
-       #define DA_LOGI DA_LOGD
-       #define DA_SECURE_LOGD(format, ...) ((void)0)
-       #define DA_SECURE_LOGI(format, ...) ((void)0)
-       #define DA_SECURE_LOGE(format, ...) ((void)0)
+#define DA_LOGD(format, ...) do {\
+       fprintf(stderr, "[DA][%ld][%s():%d] "format"\n", syscall(__NR_gettid), __FUNCTION__, __LINE__, ##__VA_ARGS__);\
+} while (0)
+#define DA_LOGE(format, ...) do {\
+       fprintf(stderr, "[DA][%ld][ERR][%s():%d]\n", syscall(__NR_gettid), __FUNCTION__, __LINE__, ##__VA_ARGS__);\
+} while (0)
+#define DA_LOGV DA_LOGD
+#define DA_LOGI DA_LOGD
+#define DA_SECURE_LOGD(format, ...) ((void)0)
+#define DA_SECURE_LOGI(format, ...) ((void)0)
+#define DA_SECURE_LOGE(format, ...) ((void)0)
 #endif /* _ENABLE_DLOG */
 
 #endif /* DOWNLOAD_AGENT_DEBUG_H */
index a3319d0..9bb800e 100755 (executable)
 #define DA_RESULT_OK   0
 
 #define DA_TRUE                1
-#define DA_FALSE               0
-#define DA_NULL                (void *)0
+#define DA_FALSE       0
+#define DA_NULL                (void *)0
 #define DA_INVALID_ID  -1
 
-#define DA_RESULT_USER_CANCELED -10 
+#define DA_RESULT_USER_CANCELED -10
 
 // InputError Input error (-100 ~ -199)
 // Client passed wrong parameter
@@ -49,8 +49,8 @@
 #define DA_ERR_ALREADY_CANCELED                -160
 #define DA_ERR_ALREADY_SUSPENDED       -161
 #define DA_ERR_ALREADY_RESUMED         -162
-#define DA_ERR_CANNOT_SUSPEND          -170
-#define DA_ERR_CANNOT_RESUME           -171
+#define DA_ERR_CANNOT_SUSPEND          -170
+#define DA_ERR_CANNOT_RESUME           -171
 #define DA_ERR_INVALID_STATE           -190
 #define DA_ERR_ALREADY_MAX_DOWNLOAD    -191
 #define DA_ERR_UNSUPPORTED_PROTOCAL    -192
 #define DA_ERR_FAIL_TO_MEMALLOC                -200
 #define DA_ERR_FAIL_TO_CREATE_THREAD           -210
 #define DA_ERR_FAIL_TO_ACCESS_FILE     -230
-#define DA_ERR_DISK_FULL       -240
+#define DA_ERR_DISK_FULL                       -240
 
 // Network error (-400 ~ -499)
 #define DA_ERR_NETWORK_FAIL                            -400
 #define DA_ERR_UNREACHABLE_SERVER              -410
 #define DA_ERR_CONNECTION_FAIL                 -420
-#define DA_ERR_HTTP_TIMEOUT            -430
+#define DA_ERR_HTTP_TIMEOUT                            -430
 #define DA_ERR_SSL_FAIL                                        -440
 #define DA_ERR_TOO_MANY_REDIRECTS              -450
 #define DA_ERR_NETWORK_UNAUTHORIZED    -460
index e5f618d..123a8dd 100644 (file)
@@ -76,7 +76,7 @@ typedef enum {
 } http_event_type_t;
 
 typedef struct _http_header_options_t http_header_options_t;
-struct _http_header_options_t{
+struct _http_header_options_t {
        char *field;
        char *value;
        http_header_options_t *next;
@@ -84,7 +84,7 @@ struct _http_header_options_t{
 
 typedef struct _http_header_t http_header_t;
 typedef http_header_t *http_msg_iter_t;
-struct _http_header_t{
+struct _http_header_t {
        char *field;
        char *value;
        http_header_options_t *options;
@@ -92,7 +92,7 @@ struct _http_header_t{
        http_header_t *next;
 };
 
-typedef struct{
+typedef struct {
        char *http_method;
        char *url;
        http_header_t *head;
@@ -100,7 +100,7 @@ typedef struct{
 } http_msg_request_t;
 
 
-typedef struct{
+typedef struct {
        int status_code;
        http_header_t *head;
 } http_msg_response_t;
@@ -173,11 +173,11 @@ extern da_info_t *da_info_list[DA_MAX_ID];
 
 #define GET_STATE_MUTEX(INFO) (INFO->mutex_state)
 #define GET_STATE(INFO) (INFO->state)
-#define CHANGE_STATE(STATE,INFO) {\
-       DA_MUTEX_LOCK (&GET_STATE_MUTEX(INFO));\
+#define CHANGE_STATE(STATE, INFO) {\
+       DA_MUTEX_LOCK(&GET_STATE_MUTEX(INFO));\
        GET_STATE(INFO) = STATE;\
        DA_LOGV("Changed state[%d]", GET_STATE(INFO));\
-       DA_MUTEX_UNLOCK (&GET_STATE_MUTEX(INFO));\
+       DA_MUTEX_UNLOCK(&GET_STATE_MUTEX(INFO));\
        }
 
 da_ret_t init_openssl_locks(void);
index 2748581..b3433a4 100755 (executable)
        int ret = 0;\
        do {\
                ret = pthread_mutex_init(mutex_add, attr);\
-               if (0 == ret){\
+               if (0 == ret) {\
                        break;\
-               }\
-               else if (EINVAL == ret){\
+               } \
+               else if (EINVAL == ret) {\
                        DA_LOGE("pthread_mutex_init FAIL with EINVAL.");\
                        break;\
-               }\
-               else if (ENOMEM == ret){\
+               } \
+               else if (ENOMEM == ret) {\
                        DA_LOGE("pthread_mutex_init FAIL with ENOMEM.");\
                        break;\
-               }\
+               } \
                else{\
                        DA_LOGE("pthread_mutex_init FAIL with %d.", ret);\
                        break;\
-               }\
-       } while(1);\
+               } \
+       } while (1);\
 }
 
 #define DA_COND_INIT(cond_add, attr) do {\
-       if (0 != pthread_cond_init(cond_add, attr)){\
+       if (0 != pthread_cond_init(cond_add, attr)) {\
                DA_LOGE("pthread_cond_init FAIL");\
-       }\
-} while(0)
+       } \
+} while (0)
 
 #define DA_MUTEX_LOCK(mutex_add) {\
        int ret = 0;\
        do {\
                ret = pthread_mutex_lock(mutex_add);\
-               if (0 == ret){\
+               if (0 == ret) {\
                        break;\
-               }\
-               else if (EINVAL == ret){\
+               } \
+               else if (EINVAL == ret) {\
                        DA_LOGE("pthread_mutex_lock FAIL with EINVAL.");\
                        break;\
-               }\
-               else if (EDEADLK == ret){\
+               } \
+               else if (EDEADLK == ret) {\
                        DA_LOGE("pthread_mutex_lock FAIL with EDEADLK.");\
                        break;\
-               }\
+               } \
                else{\
                        DA_LOGE("pthread_mutex_lock FAIL with %d.", ret);\
                        break;\
-               }\
-       } while(1);\
+               } \
+       } while (1);\
 }
 
 #define DA_MUTEX_UNLOCK(mutex_add) {\
        int ret = 0;\
        do {\
                ret = pthread_mutex_unlock(mutex_add);\
-               if (0 == ret){\
+               if (0 == ret) {\
                        break;\
-               }\
+               } \
                else if (EINVAL == ret) {\
                        DA_LOGE("pthread_mutex_unlock FAIL with EINVAL.");\
                        break;\
-               }\
+               } \
                else if (EPERM == ret) {\
                        DA_LOGE("pthread_mutex_unlock FAIL with EPERM.");\
                        break;\
-               }\
+               } \
                else {\
                        DA_LOGE("pthread_mutex_unlock FAIL with %d.", ret);\
                        break;\
-               }\
-       } while(1);\
+               } \
+       } while (1);\
 }
 
 #define DA_COND_SIGNAL(cond_add) do {\
                if (0 != pthread_cond_signal(cond_add)) {\
                        DA_LOGE("pthread_cond_signal FAIL");\
-               }\
-       } while(0)
+               } \
+       } while (0)
 
 #define DA_COND_WAIT(cond_add, mutex_add) do {\
-               if (0 != pthread_cond_wait(cond_add, mutex_add)){\
+               if (0 != pthread_cond_wait(cond_add, mutex_add)) {\
                        DA_LOGE("pthread_cond_wait FAIL");\
-               }\
-       } while(0)
+               } \
+       } while (0)
 
 #define DA_COND_TIMED_WAIT(cond_add, mutex_add, time) do {\
-               if (0 != pthread_cond_timedwait(cond_add, mutex_add, time)){\
+               if (0 != pthread_cond_timedwait(cond_add, mutex_add, time)) {\
                        DA_LOGE("pthread_cond_wait FAIL");\
-               }\
-       } while(0)
+               } \
+       } while (0)
 
 
 #define DA_COND_DESTROY(cond_add)      do {\
-               if (0 != pthread_cond_destroy(cond_add)){\
+               if (0 != pthread_cond_destroy(cond_add)) {\
                        DA_LOGE("pthread_cond_destroy FAIL");\
-               }\
-       } while(0)
+               } \
+       } while (0)
 
 #define DA_MUTEX_DESTROY(mutex_add) {\
        int ret = 0;\
        do {\
                ret = pthread_mutex_destroy(mutex_add);\
-               if (0 == ret){\
+               if (0 == ret) {\
                        break;\
-               }\
-               else if (EINVAL == ret){\
+               } \
+               else if (EINVAL == ret) {\
                        DA_LOGE("pthread_mutex_destroy FAIL with EINVAL.");\
                        break;\
-               }\
-               else if (EBUSY == ret){\
+               } \
+               else if (EBUSY == ret) {\
                        DA_LOGE("pthread_mutex_destroy FAIL with EBUSY.");\
                        break;\
-               }\
+               } \
                else {\
                        DA_LOGE("pthread_mutex_destroy FAIL with %d.", ret);\
                        break;\
-               }\
-       } while(1);\
+               } \
+       } while (1);\
 }
 #endif
index 2e2d525..41aa67b 100755 (executable)
@@ -31,7 +31,7 @@ typedef unsigned long long da_size_t;
 #define DA_MAX_FULL_PATH_LEN    PATH_MAX - 1 /* 4096 -1 chars in a path name excluding NULL */
 #define DA_MAX_FILE_NAME_LEN    NAME_MAX /* 255 chars in a file name excluding NULL */
 #define DA_MAX_STR_LEN                 256
-#define DA_MAX_MIME_STR_LEN            256
+#define DA_MAX_MIME_STR_LEN            256
 #define DA_MAX_PROXY_ADDR_LEN  64              // e.g. 100.200.300.400:10000
 
 #define SCHEME_HTTP            "http://"
@@ -45,38 +45,38 @@ typedef unsigned long long da_size_t;
 
 #define NULL_CHECK(DATA) {\
        if (!DATA) {\
-               DA_LOGE("NULL CHECK!:%s",(#DATA));\
+               DA_LOGE("NULL CHECK!:%s", (#DATA));\
                return;\
-       }\
+       } \
 }
 
 #define NULL_CHECK_RET(DATA) {\
        if (!DATA) {\
-               DA_LOGE("NULL CHECK!:%s",(#DATA));\
+               DA_LOGE("NULL CHECK!:%s", (#DATA));\
                return DA_ERR_INVALID_ARGUMENT;\
-       }\
+       } \
 }
 
 #define NULL_CHECK_GOTO(DATA) {\
        if (!DATA) {\
-               DA_LOGE("NULL CHECK!:%s",(#DATA));\
+               DA_LOGE("NULL CHECK!:%s", (#DATA));\
                ret = DA_ERR_INVALID_ARGUMENT;\
                goto ERR;\
-       }\
+       } \
 }
 
 #define NULL_CHECK_RET_OPT(DATA, RET_DATA) {\
        if (!DATA) {\
-               DA_LOGE("NULL CHECK!:%s",(#DATA));\
+               DA_LOGE("NULL CHECK!:%s", (#DATA));\
                return RET_DATA;\
-       }\
+       } \
 }
 
 #define NULL_CHECK_AND_FREE(DATA) {\
-       if(DATA) {\
+       if (DATA) {\
                free(DATA);\
-               DATA=DA_NULL;\
-       }\
+               DATA = DA_NULL;\
+       } \
 }
 #endif
 
index 14c90f8..0fc9baf 100755 (executable)
@@ -1,7 +1,7 @@
 %define _ux_define tizen2.3
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.1.88
+Version:    2.1.89
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
index ccf4675..fd0dc50 100755 (executable)
        if (dp_errorcode != DP_ERROR_NONE) {\
                CLIENT_MUTEX_UNLOCK(&g_function_mutex);\
                return __dp_interface_convert_errorcode(dp_errorcode);\
-       }\
-} while(0)
+       } \
+} while (0)
 
 #define DP_PRE_CHECK_ID do {\
        if (id <= 0) {\
                TRACE_ERROR("[CHECK ID] (%d)", id);\
                return DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER;\
-       }\
-} while(0)
+       } \
+} while (0)
 
 #define DOWNLOAD_FILENAME_MAX 256
 
@@ -255,7 +255,7 @@ static void __clear_interface()
        if (g_dp_client != NULL) {
                if (g_dp_client->channel >= 0)
                        close(g_dp_client->channel);
-               g_dp_client->channel= -1;
+               g_dp_client->channel = -1;
                if (g_dp_client->notify >= 0)
                        close(g_dp_client->notify);
                g_dp_client->notify = -1;
@@ -270,9 +270,8 @@ static int __bp_disconnect(const char *funcname)
        TRACE_DEBUG("%s", funcname);
        if (g_dp_event_thread_id > 0 &&
                        pthread_kill(g_dp_event_thread_id, 0) != ESRCH) {
-               if (pthread_cancel(g_dp_event_thread_id) != 0) {
+               if (pthread_cancel(g_dp_event_thread_id) != 0)
                        TRACE_ERROR("pthread:%d", (int)g_dp_event_thread_id);
-               }
                g_dp_event_thread_id = 0;
        }
        __clear_interface();
@@ -289,7 +288,7 @@ static void *__dp_event_manager(void *arg)
 
        size_t path_size = sizeof(NOTIFY_DIR) + 11;
        char notify_fifo[path_size];
-       snprintf((char *)&notify_fifo, path_size,"%s/%d", NOTIFY_DIR, getpid());
+       snprintf((char *)&notify_fifo, path_size, "%s/%d", NOTIFY_DIR, getpid());
        TRACE_DEBUG("IPC ESTABILISH %s", notify_fifo);
        g_dp_client->notify = open(notify_fifo, O_RDONLY, 0600);
        if (g_dp_client->notify < 0) {
@@ -305,8 +304,7 @@ static void *__dp_event_manager(void *arg)
        // ex) function : select, read in this thread
        pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
 
-       while(g_dp_client != NULL && g_dp_client->notify >= 0) {
-
+       while (g_dp_client != NULL && g_dp_client->notify >= 0) {
                if (g_dp_event_thread_id <= 0 ||
                                pthread_self() != g_dp_event_thread_id) {
                        TRACE_ERROR("competitive threads self:%lu global:%lu",
@@ -379,9 +377,8 @@ static void __dp_ipc_clear_garbage(int sock, const size_t length)
 {
        if (length > 0) {
                char garbage[length];
-               if (read(sock, &garbage, length) == 0) {
+               if (read(sock, &garbage, length) == 0)
                        TRACE_ERROR("sock:%d closed peer", sock);
-               }
        }
 }
 
@@ -413,16 +410,15 @@ static int __connect_to_provider()
                g_dp_client =
                        (dp_interface_ipc *)calloc(1, sizeof(dp_interface_ipc));
 
-               if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+               if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
                        TRACE_ERROR("failed to ignore SIGPIPE signal");
-               }
        }
 
        if (g_dp_client != NULL) {
 
                int connect_retry = 3;
                g_dp_client->channel = -1;
-               while(g_dp_client->channel < 0 && connect_retry-- > 0) {
+               while (g_dp_client->channel < 0 && connect_retry-- > 0) {
                        int ret = __create_socket();
                        if (ret == -1) {
                                TRACE_ERROR("failed to connect to provider(remains:%d)", connect_retry);
@@ -1190,9 +1186,8 @@ int dp_interface_set_notification_bundle(const int id, const int type, void *bun
                int result = bundle_encode_raw(bundle_param, &raw_buffer, &length);
                if (result == 0 && length > 0) {
                        errorcode = __dp_ipc_set_int(id, DP_SEC_SET, DP_PROP_NOTIFICATION_RAW, type, __FUNCTION__);
-                       if (errorcode == DOWNLOAD_ADAPTOR_ERROR_NONE) {
+                       if (errorcode == DOWNLOAD_ADAPTOR_ERROR_NONE)
                                errorcode = __dp_ipc_set_binary(id, DP_PROP_NOTIFICATION_RAW, raw_buffer, (size_t)length, __FUNCTION__);
-                       }
                } else {
                        TRACE_ERROR("failed to encode raws error:%d type:%d id:%d", result, type, id);
                        errorcode = DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER;
@@ -1287,9 +1282,8 @@ int dp_interface_set_notification_service_handle(const int id, const int type, v
                        result = bundle_encode_raw(bundle_data, &raw_buffer, &length);
                        if (result == 0 && length > 0) {
                                errorcode = __dp_ipc_set_int(id, DP_SEC_SET, DP_PROP_NOTIFICATION_RAW, type, __FUNCTION__);
-                               if (errorcode == DOWNLOAD_ADAPTOR_ERROR_NONE) {
+                               if (errorcode == DOWNLOAD_ADAPTOR_ERROR_NONE)
                                        errorcode = __dp_ipc_set_binary(id, DP_PROP_NOTIFICATION_RAW, raw_buffer, (size_t)length, __FUNCTION__);
-                               }
                        } else {
                                TRACE_ERROR("failed to encode raws error:%d type:%d id:%d", result, type, id);
                                errorcode = DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER;
@@ -1580,9 +1574,8 @@ int dp_interface_get_http_header_field_list(const int id, char ***fields,
                                                }
                                                if (errorcode != DP_ERROR_NONE) { // if error, free all allocated memories
                                                        int j = 0;
-                                                       for (; j < i; j++) {
+                                                       for (; j < i; j++)
                                                                free(recv_strings[j]);
-                                                       }
                                                        free(recv_strings);
                                                        *length = 0;
                                                        *fields = NULL;
index e9d3d59..1fd3241 100755 (executable)
@@ -29,8 +29,7 @@ extern "C"
 #endif
 
 // sync with url-download
-typedef enum
-{
+typedef enum {
        DOWNLOAD_ADPATOR_STATE_NONE,
        DOWNLOAD_ADPATOR_STATE_READY,
        DOWNLOAD_ADPATOR_STATE_QUEUED,
@@ -41,16 +40,14 @@ typedef enum
        DOWNLOAD_ADPATOR_STATE_CANCELED,
 } download_adaptor_state_e;
 
-typedef enum
-{
+typedef enum {
        DOWNLOAD_ADAPTOR_NETWORK_DATA_NETWORK,
        DOWNLOAD_ADAPTOR_NETWORK_WIFI,
        DOWNLOAD_ADAPTOR_NETWORK_WIFI_DIRECT,
        DOWNLOAD_ADAPTOR_NETWORK_ALL
 } download_adaptor_network_type_e ;
 
-typedef enum
-{
+typedef enum {
        DOWNLOAD_ADAPTOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
        DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
        DOWNLOAD_ADAPTOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
@@ -58,7 +55,7 @@ typedef enum
        DOWNLOAD_ADAPTOR_ERROR_CONNECTION_TIMED_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT, /**< Http session time-out */
        DOWNLOAD_ADAPTOR_ERROR_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
        DOWNLOAD_ADAPTOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-    DOWNLOAD_ADAPTOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,               /**< Not supported */
+       DOWNLOAD_ADAPTOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,               /**< Not supported */
        DOWNLOAD_ADAPTOR_ERROR_INVALID_STATE = TIZEN_ERROR_DOWNLOAD | 0x21, /**< Invalid state */
        DOWNLOAD_ADAPTOR_ERROR_CONNECTION_FAILED = TIZEN_ERROR_DOWNLOAD | 0x22, /**< Connection failed */
        DOWNLOAD_ADAPTOR_ERROR_INVALID_URL = TIZEN_ERROR_DOWNLOAD | 0x24, /**< Invalid URL */
@@ -68,7 +65,7 @@ typedef enum
        DOWNLOAD_ADAPTOR_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_DOWNLOAD | 0x28, /**< The download is already completed */
        DOWNLOAD_ADAPTOR_ERROR_FILE_ALREADY_EXISTS = TIZEN_ERROR_DOWNLOAD | 0x29, /**< It is failed to rename the downloaded file */
        DOWNLOAD_ADAPTOR_ERROR_CANNOT_RESUME = TIZEN_ERROR_DOWNLOAD | 0x2a, /**< It cannot resume */
-    DOWNLOAD_ADAPTOR_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_DOWNLOAD | 0x2b,           /**< Specified field not found */
+       DOWNLOAD_ADAPTOR_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_DOWNLOAD | 0x2b,           /**< Specified field not found */
        DOWNLOAD_ADAPTOR_ERROR_TOO_MANY_REDIRECTS = TIZEN_ERROR_DOWNLOAD | 0x30, /**< In case of too may redirects from http response header*/
        DOWNLOAD_ADAPTOR_ERROR_UNHANDLED_HTTP_CODE = TIZEN_ERROR_DOWNLOAD | 0x31,  /**< The download cannot handle the http status value */
        DOWNLOAD_ADAPTOR_ERROR_REQUEST_TIMEOUT = TIZEN_ERROR_DOWNLOAD | 0x32, /**< There are no action after client create a download id*/
index 3d579ca..b9f8053 100755 (executable)
@@ -23,7 +23,7 @@
 #include <sys/un.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <fcntl.h> 
+#include <fcntl.h>
 #include <signal.h>
 
 #include <aul.h>
@@ -65,7 +65,7 @@ void dp_terminate(int signo)
        close(g_dp_sock);
        g_dp_sock = -1;
        if (g_client_manager_tid > 0)
-           pthread_kill(g_client_manager_tid, SIGUSR1);
+               pthread_kill(g_client_manager_tid, SIGUSR1);
 }
 
 void dp_broadcast_signal()
@@ -91,9 +91,8 @@ char *dp_db_get_client_smack_label(const char *pkgname)
        int errorcode = DP_ERROR_NONE;
 
        CLIENT_MUTEX_LOCK(&g_db_mutex);
-       if (dp_db_get_client_property_string(g_db_handle, pkgname, DP_DB_COL_SMACK_LABEL, (unsigned char **)&smack_label, &length, &errorcode) < 0) {
+       if (dp_db_get_client_property_string(g_db_handle, pkgname, DP_DB_COL_SMACK_LABEL, (unsigned char **)&smack_label, &length, &errorcode) < 0)
                TRACE_SECURE_ERROR("failed to get smack label for %s", pkgname);
-       }
        CLIENT_MUTEX_UNLOCK(&g_db_mutex);
 
        return smack_label;
@@ -101,15 +100,14 @@ char *dp_db_get_client_smack_label(const char *pkgname)
 
 static int __dp_db_open_client_manager()
 {
-    int errorcode = DP_ERROR_NONE;
-    CLIENT_MUTEX_LOCK(&g_db_mutex);
-    if (g_db_handle == 0 || dp_db_check_connection(g_db_handle) < 0) {
-        if (dp_db_open_client_manager(&g_db_handle, &errorcode) < 0) {
-            TRACE_ERROR("failed to open database errorcode:%d", errorcode);
-        }
-    }
-    CLIENT_MUTEX_UNLOCK(&g_db_mutex);
-    return errorcode;
+       int errorcode = DP_ERROR_NONE;
+       CLIENT_MUTEX_LOCK(&g_db_mutex);
+       if (g_db_handle == 0 || dp_db_check_connection(g_db_handle) < 0) {
+               if (dp_db_open_client_manager(&g_db_handle, &errorcode) < 0)
+                       TRACE_ERROR("failed to open database errorcode:%d", errorcode);
+       }
+       CLIENT_MUTEX_UNLOCK(&g_db_mutex);
+       return errorcode;
 }
 
 static void __dp_db_free_client_manager()
@@ -128,10 +126,10 @@ static int __dp_accept_socket_new()
        int fd_base, listen_fds = sd_listen_fds(1);
        TRACE_DEBUG("sd_listen_fds:%d", listen_fds);
 
-    if(listen_fds > INT_MAX) {
-        TRACE_DEBUG("sd_listen_fds:%d", listen_fds);
-        return -1;
-    }
+       if (listen_fds > INT_MAX) {
+               TRACE_DEBUG("sd_listen_fds:%d", listen_fds);
+               return -1;
+       }
 
        for (fd_base = 0 ; fd_base < listen_fds; fd_base++) {
                if (sd_is_socket_unix(fd_base + SD_LISTEN_FDS_START, SOCK_STREAM, 1, IPC_SOCKET, 0) >= 0) {
@@ -231,11 +229,10 @@ static int __dp_manage_client_requests(dp_client_slots_fmt *clients)
                                if (dp_db_delete(g_db_handle, ids[i], DP_TABLE_CLIENTS, &errorcode) == 0) {
                                        TRACE_SECURE_ERROR("clear info for %s", pkgname);
                                        // remove database file
-                                       if (dp_db_remove_database(pkgname, time(NULL), 0) == 0) {
+                                       if (dp_db_remove_database(pkgname, time(NULL), 0) == 0)
                                                TRACE_SECURE_INFO("remove database for %s", pkgname);
-                                       } else {
+                                       else
                                                TRACE_SECURE_ERROR("failed to remove database for %s", pkgname);
-                                       }
                                }
                                free(pkgname);
                                continue;
@@ -282,9 +279,8 @@ static int __dp_manage_client_requests(dp_client_slots_fmt *clients)
                                        }
                                        request->startcount++;
                                        request->noti_type = DP_NOTIFICATION_TYPE_NONE;
-                                       if (dp_db_get_property_int(clients[slot_index].client.dbhandle, request->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, &request->noti_type, &errorcode) < 0) {
+                                       if (dp_db_get_property_int(clients[slot_index].client.dbhandle, request->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, &request->noti_type, &errorcode) < 0)
                                                TRACE_ERROR("failed to get notification type for id:%d", request->id);
-                                       }
                                        if (request->noti_type == DP_NOTIFICATION_TYPE_NONE) {
                                                TRACE_INFO("enable notification for id:%d", request->id);
                                                request->noti_type = DP_NOTIFICATION_TYPE_COMPLETE_ONLY;
@@ -312,10 +308,8 @@ static int __dp_manage_client_requests(dp_client_slots_fmt *clients)
                                                break;
                                        }
                                        // notification
-                                       if (dp_notification_manager_push_notification((void *)&clients[slot_index], (void *)request, DP_NOTIFICATION_ONGOING) < 0) {
+                                       if (dp_notification_manager_push_notification((void *)&clients[slot_index], (void *)request, DP_NOTIFICATION_ONGOING) < 0)
                                                TRACE_ERROR("failed to register notification for id:%d", request->id);
-                                       }
-
                                }
 
                                slot_index++;
@@ -334,7 +328,7 @@ static int __dp_manage_client_requests(dp_client_slots_fmt *clients)
 }
 
 static int __dp_client_run(int clientfd, dp_client_slots_fmt *slot,
-       dp_credential credential)
+               dp_credential credential)
 {
        int errorcode = DP_ERROR_NONE;
        // make notify fifo
@@ -346,15 +340,14 @@ static int __dp_client_run(int clientfd, dp_client_slots_fmt *slot,
                char *smack_label = NULL;
                if (dp_smack_is_mounted() == 1) {
                        smack_label = dp_smack_get_label_from_socket(clientfd);
-                       if (smack_label == NULL) {
+                       if (smack_label == NULL)
                                TRACE_SECURE_ERROR("smack_new_label_from_socket");
-                       }
                }
                // save client info to database
                CLIENT_MUTEX_LOCK(&g_db_mutex);
                if (dp_db_update_client_info(g_db_handle,
-                               slot->pkgname, smack_label,
-                               credential.uid, credential.gid, &errorcode) < 0) {
+                                       slot->pkgname, smack_label,
+                                       credential.uid, credential.gid, &errorcode) < 0) {
                        TRACE_ERROR("check error:%s", dp_print_errorcode(errorcode));
                }
                CLIENT_MUTEX_UNLOCK(&g_db_mutex);
@@ -364,7 +357,7 @@ static int __dp_client_run(int clientfd, dp_client_slots_fmt *slot,
 
                // create a thread for client
                if (pthread_create(&slot->thread, NULL,
-                               dp_client_request_thread, (void *)slot) != 0) {
+                                       dp_client_request_thread, (void *)slot) != 0) {
                        TRACE_ERROR("failed to create client thread slot:%d", clientfd);
                        errorcode = DP_ERROR_OUT_OF_MEMORY;
                        slot->thread = 0;
@@ -372,7 +365,7 @@ static int __dp_client_run(int clientfd, dp_client_slots_fmt *slot,
                } else {
                        pthread_detach(slot->thread);
                        TRACE_SECURE_INFO("accept client[%s] pid:%d sock:%d",
-                               slot->pkgname, credential.pid, clientfd);
+                                       slot->pkgname, credential.pid, clientfd);
                        slot->client.channel = clientfd;
                        slot->credential.pid = credential.pid;
                        slot->credential.uid = credential.uid;
@@ -384,7 +377,7 @@ static int __dp_client_run(int clientfd, dp_client_slots_fmt *slot,
 
 
 static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
-       dp_credential credential)
+               dp_credential credential)
 {
        // search in clients list.
        // if same pkgname. update it.
@@ -401,24 +394,24 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
                TRACE_ERROR("[CRITICAL] aul_app_get_appid_bypid_for_uid");
 
        pkgname = strdup(buffer);
-/*
+       /*
        //// TEST CODE ... to allow sample client ( no package name ).
        if (pkgname == NULL) {
-               //pkgname = dp_strdup("unknown_app");
-               char *temp_pkgname = (char *)calloc(41, sizeof(char));
-               if (temp_pkgname == NULL ||
-                               snprintf(temp_pkgname, 41,"unknown_app_%d", credential.pid) < 0) {
-                       pkgname = dp_strdup("unknown_app");
-               } else {
-                       pkgname = temp_pkgname;
-               }
+       //pkgname = dp_strdup("unknown_app");
+       char *temp_pkgname = (char *)calloc(41, sizeof(char));
+       if (temp_pkgname == NULL ||
+       snprintf(temp_pkgname, 41,"unknown_app_%d", credential.pid) < 0) {
+       pkgname = dp_strdup("unknown_app");
+       } else {
+       pkgname = temp_pkgname;
+       }
        }
 
        if (pkgname == NULL) {
-               TRACE_ERROR("[CRITICAL] app_manager_get_app_id");
-               return DP_ERROR_INVALID_PARAMETER;
+       TRACE_ERROR("[CRITICAL] app_manager_get_app_id");
+       return DP_ERROR_INVALID_PARAMETER;
        }
-*/
+       */
        if ((pkg_len = strlen(pkgname)) <= 0) {
                TRACE_ERROR("[CRITICAL] pkgname:%s", pkgname);
                free(pkgname);
@@ -441,13 +434,12 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
        cynara *p_cynara = NULL;
        cynara_configuration *p_conf = NULL;
        size_t cache_size = 100;
-       //cynara_configuration conf;
 
        if (CYNARA_API_SUCCESS != cynara_configuration_create(&p_conf))  { /* error */}
        if (CYNARA_API_SUCCESS != cynara_configuration_set_cache_size(p_conf, cache_size)) { /* error */ }
 
        ret = cynara_initialize(&p_cynara, NULL);
-       if(ret != CYNARA_API_SUCCESS) { /* error */ }
+       if (ret != CYNARA_API_SUCCESS) { /* error */ }
        cynara_configuration_destroy(p_conf);
 
        // Get client peer credential
@@ -455,7 +447,7 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
        ret = cynara_creds_socket_get_client(clientfd, CLIENT_METHOD_SMACK, &clientSmack);
        // In case of D-bus peer credential??
        // ret = cynara_creds_dbus_get_client(DBusConnection *connection, const char *uniqueName,CLIENT_METHOD_SMACK, &clientSmack);
-       if(ret != CYNARA_API_SUCCESS) { /* error */ }
+       if (ret != CYNARA_API_SUCCESS) { /* error */ }
 
        char *uid;
        ret = cynara_creds_socket_get_user(clientfd, USER_METHOD_UID, &uid);
@@ -464,15 +456,15 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
        if (ret != CYNARA_API_SUCCESS) { /* error */ }
 
        /* Concept of session is service-specific.
-         * Might be empty string if service does not have such concept
-         */
-       char *client_session="";
+        * Might be empty string if service does not have such concept
+        */
+       char *client_session = "";
 
        // Cynara check
 
        ret = cynara_check(p_cynara, clientSmack, client_session, uid, "http://tizen.org/privilege/download");
 
-       if(ret == CYNARA_API_ACCESS_ALLOWED) {
+       if (ret == CYNARA_API_ACCESS_ALLOWED) {
                TRACE_DEBUG("CYNARA_API_ACCESS_ALLOWED");
        } else {
                TRACE_DEBUG("DP_ERROR_PERMISSION_DENIED");
@@ -482,18 +474,18 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
 
        // Cleanup of cynara structure
        /*
-       if(clientSmack) {
-               free(clientSmack);
-       }
-
-       if(client_session) {
-               free(client_session);
-       }
-
-       if(uid) {
-               free(uid);
-       }
-        */
+          if(clientSmack) {
+          free(clientSmack);
+          }
+
+          if(client_session) {
+          free(client_session);
+          }
+
+          if(uid) {
+          free(uid);
+          }
+          */
        cynara_finish(p_cynara);
 
 #endif
@@ -505,11 +497,10 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
 
        // Have this client ever been connected before ?
        for (i = 0; i < DP_MAX_CLIENTS; i++) {
-
                int locked = CLIENT_MUTEX_TRYLOCK(&clients[i].mutex);
-               if (locked != 0) // empty or used by other thread. it would be same client, but it's busy
+               if (locked != 0) // empty or used by other thread. it would be same client, but it's busy
                        continue;
-               }
+
                TRACE_DEBUG("locked slot:%d", i);
                if (locked == 0 && clients[i].thread == 0) { // this slot has run without the client
                        if (clients[i].pkgname != NULL) {
@@ -519,7 +510,7 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
                                if (pkg_len == cname_len &&
                                                strncmp(clients[i].pkgname, pkgname, pkg_len) == 0) {
                                        TRACE_SECURE_INFO("update client[%s] slot:%d pid:%d sock:%d",
-                                               pkgname, i, credential.pid, clientfd);
+                                                       pkgname, i, credential.pid, clientfd);
                                        if (clients[i].client.channel >= 0 &&
                                                        clients[i].client.channel != clientfd) {
                                                dp_ipc_socket_free(clients[i].client.channel);
@@ -567,7 +558,7 @@ static int __dp_client_new(int clientfd, dp_client_slots_fmt *clients,
        }
 
        TRACE_SECURE_INFO("busy client[%s] pid:%d sock:%d", pkgname,
-               credential.pid, clientfd);
+                       credential.pid, clientfd);
        free(pkgname);
        return DP_ERROR_TOO_MANY_DOWNLOADS;
 }
@@ -615,16 +606,15 @@ void *dp_client_manager(void *arg)
 
        dp_client_slots_fmt *clients =
                (dp_client_slots_fmt *)calloc(DP_MAX_CLIENTS,
-                       sizeof(dp_client_slots_fmt));
+                               sizeof(dp_client_slots_fmt));
        if (clients == NULL) {
                TRACE_ERROR("failed to allocate client slots");
                g_main_loop_quit(event_loop);
                return 0;
        }
        g_dp_client_slots = clients;
-       for (i = 0; i < DP_MAX_CLIENTS; i++) {
+       for (i = 0; i < DP_MAX_CLIENTS; i++)
                dp_mutex_destroy(&clients[i].mutex); // clear mutex init
-       }
 
        int maxfd = g_dp_sock;
        FD_ZERO(&listen_fdset);
@@ -674,14 +664,14 @@ void *dp_client_manager(void *arg)
                        // blocking & timeout to prevent the lockup by client.
                        struct timeval tv_timeo = {1, 500000}; // 1.5 sec
                        if (setsockopt(clientfd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeo,
-                                       sizeof(tv_timeo)) < 0) {
-                           TRACE_ERROR("failed to set timeout in blocking socket");
-                           errorcode = DP_ERROR_IO_ERROR;
+                                               sizeof(tv_timeo)) < 0) {
+                               TRACE_ERROR("failed to set timeout in blocking socket");
+                               errorcode = DP_ERROR_IO_ERROR;
                        }
 
                        dp_ipc_fmt ipc_info;
                        memset(&ipc_info, 0x00, sizeof(dp_ipc_fmt));
-                       if (read(clientfd, &ipc_info, sizeof(dp_ipc_fmt)) <= 0 || 
+                       if (read(clientfd, &ipc_info, sizeof(dp_ipc_fmt)) <= 0 ||
                                        ipc_info.section == DP_SEC_NONE ||
                                        ipc_info.property != DP_PROP_NONE ||
                                        ipc_info.id != -1 ||
@@ -693,7 +683,7 @@ void *dp_client_manager(void *arg)
 #ifdef SO_PEERCRED // getting the info of client
                        socklen_t cr_len = sizeof(credential);
                        if (getsockopt(clientfd, SOL_SOCKET, SO_PEERCRED,
-                                       &credential, &cr_len) < 0) {
+                                               &credential, &cr_len) < 0) {
                                TRACE_ERROR("failed to cred from sock:%d", clientfd);
                                errorcode = DP_ERROR_PERMISSION_DENIED;
                        }
@@ -704,37 +694,35 @@ void *dp_client_manager(void *arg)
                        }
 #endif
 
-                       if (errorcode == DP_ERROR_NONE) {
-            errorcode = __dp_db_open_client_manager();
-                       }
+                       if (errorcode == DP_ERROR_NONE)
+                               errorcode = __dp_db_open_client_manager();
 
                        if (errorcode == DP_ERROR_NONE) {
-                if (ipc_info.section == DP_SEC_INIT) {
-
-                    // new client
-                    errorcode = __dp_client_new(clientfd, clients, credential);
-
-                } else {
-                    errorcode = DP_ERROR_INVALID_PARAMETER;
-                }
-            }
-          if (dp_ipc_query(clientfd, -1, ipc_info.section, DP_PROP_NONE, errorcode, 0) < 0) {
-                TRACE_ERROR("check ipc sock:%d", clientfd);
-            }
-
-          if (errorcode != DP_ERROR_NONE) {
-                TRACE_ERROR("sock:%d id:%d section:%s property:%s errorcode:%s size:%d",
-                        clientfd, ipc_info.id,
-                        dp_print_section(ipc_info.section),
-                        dp_print_property(ipc_info.property),
-                        dp_print_errorcode(ipc_info.errorcode),
-                        ipc_info.size);
-                close(clientfd); // ban this client
-            }
-          if (errorcode == DP_ERROR_NO_SPACE || errorcode == DP_ERROR_DISK_BUSY) {
-                TRACE_ERROR("provider can't work anymore errorcode:%s", dp_print_errorcode(errorcode));
-                //break;  // provider will be terminated after sending errorcode by each thread
-            }
+                               if (ipc_info.section == DP_SEC_INIT) {
+
+                                       // new client
+                                       errorcode = __dp_client_new(clientfd, clients, credential);
+
+                               } else {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               }
+                       }
+                       if (dp_ipc_query(clientfd, -1, ipc_info.section, DP_PROP_NONE, errorcode, 0) < 0)
+                               TRACE_ERROR("check ipc sock:%d", clientfd);
+
+                       if (errorcode != DP_ERROR_NONE) {
+                               TRACE_ERROR("sock:%d id:%d section:%s property:%s errorcode:%s size:%d",
+                                               clientfd, ipc_info.id,
+                                               dp_print_section(ipc_info.section),
+                                               dp_print_property(ipc_info.property),
+                                               dp_print_errorcode(ipc_info.errorcode),
+                                               ipc_info.size);
+                               close(clientfd); // ban this client
+                       }
+                       if (errorcode == DP_ERROR_NO_SPACE || errorcode == DP_ERROR_DISK_BUSY) {
+                               TRACE_ERROR("provider can't work anymore errorcode:%s", dp_print_errorcode(errorcode));
+                               //break;  // provider will be terminated after sending errorcode by each thread
+                       }
 
                } else {
 
index e356ec3..7d623a4 100755 (executable)
 
 char *dp_print_state(int state)
 {
-       switch(state)
-       {
-               case DP_STATE_NONE :
-                       return "NONE";
-               case DP_STATE_READY :
-                       return "READY";
-               case DP_STATE_QUEUED :
-                       return "QUEUED";
-               case DP_STATE_CONNECTING :
-                       return "CONNECTING";
-               case DP_STATE_DOWNLOADING :
-                       return "DOWNLOADING";
-               case DP_STATE_PAUSED :
-                       return "PAUSED";
-               case DP_STATE_COMPLETED :
-                       return "COMPLETED";
-               case DP_STATE_CANCELED :
-                       return "CANCELED";
-               case DP_STATE_FAILED :
-                       return "FAILED";
-               default :
-                       break;
+       switch (state) {
+       case DP_STATE_NONE:
+               return "NONE";
+       case DP_STATE_READY:
+               return "READY";
+       case DP_STATE_QUEUED:
+               return "QUEUED";
+       case DP_STATE_CONNECTING:
+               return "CONNECTING";
+       case DP_STATE_DOWNLOADING:
+               return "DOWNLOADING";
+       case DP_STATE_PAUSED:
+               return "PAUSED";
+       case DP_STATE_COMPLETED:
+               return "COMPLETED";
+       case DP_STATE_CANCELED:
+               return "CANCELED";
+       case DP_STATE_FAILED:
+               return "FAILED";
+       default:
+               break;
        }
        return "UNKNOWN";
 }
 
 char *dp_print_errorcode(int errorcode)
 {
-       switch(errorcode)
-       {
-               case DP_ERROR_NONE :
-                       return "NONE";
-               case DP_ERROR_INVALID_PARAMETER :
-                       return "INVALID_PARAMETER";
-               case DP_ERROR_OUT_OF_MEMORY :
-                       return "OUT_OF_MEMORY";
-               case DP_ERROR_IO_ERROR :
-                       return "IO_ERROR";
-               case DP_ERROR_NETWORK_UNREACHABLE :
-                       return "NETWORK_UNREACHABLE";
-               case DP_ERROR_CONNECTION_TIMED_OUT :
-                       return "CONNECTION_TIMED_OUT";
-               case DP_ERROR_NO_SPACE :
-                       return "NO_SPACE";
-               case DP_ERROR_FIELD_NOT_FOUND :
-                       return "FIELD_NOT_FOUND";
-               case DP_ERROR_INVALID_STATE :
-                       return "INVALID_STATE";
-               case DP_ERROR_CONNECTION_FAILED :
-                       return "CONNECTION_FAILED";
-               case DP_ERROR_INVALID_URL :
-                       return "INVALID_URL";
-               case DP_ERROR_INVALID_DESTINATION :
-                       return "INVALID_DESTINATION";
-               case DP_ERROR_QUEUE_FULL :
-                       return "QUEUE_FULL";
-               case DP_ERROR_ALREADY_COMPLETED :
-                       return "ALREADY_COMPLETED";
-               case DP_ERROR_FILE_ALREADY_EXISTS :
-                       return "FILE_ALREADY_EXISTS";
-               case DP_ERROR_TOO_MANY_DOWNLOADS :
-                       return "TOO_MANY_DOWNLOADS";
-               case DP_ERROR_NO_DATA :
-                       return "NO_DATA";
-               case DP_ERROR_UNHANDLED_HTTP_CODE :
-                       return "UNHANDLED_HTTP_CODE";
-               case DP_ERROR_CANNOT_RESUME :
-                       return "CANNOT_RESUME";
-               case DP_ERROR_PERMISSION_DENIED :
-                       return "PERMISSION_DENIED";
-               case DP_ERROR_RESPONSE_TIMEOUT :
-                       return "RESPONSE_TIMEOUT";
-               case DP_ERROR_REQUEST_TIMEOUT :
-                       return "REQUEST_TIMEOUT";
-               case DP_ERROR_SYSTEM_DOWN :
-                       return "SYSTEM_DOWN";
-               case DP_ERROR_CLIENT_DOWN :
-                       return "CLIENT_DOWN";
-               case DP_ERROR_DISK_BUSY:
-                       return "DISK_BUSY";
-               case DP_ERROR_ID_NOT_FOUND :
-                       return "ID_NOT_FOUND";
-               default :
+       switch (errorcode) {
+       case DP_ERROR_NONE:
+               return "NONE";
+       case DP_ERROR_INVALID_PARAMETER:
+               return "INVALID_PARAMETER";
+       case DP_ERROR_OUT_OF_MEMORY:
+               return "OUT_OF_MEMORY";
+       case DP_ERROR_IO_ERROR:
+               return "IO_ERROR";
+       case DP_ERROR_NETWORK_UNREACHABLE:
+               return "NETWORK_UNREACHABLE";
+       case DP_ERROR_CONNECTION_TIMED_OUT:
+               return "CONNECTION_TIMED_OUT";
+       case DP_ERROR_NO_SPACE:
+               return "NO_SPACE";
+       case DP_ERROR_FIELD_NOT_FOUND:
+               return "FIELD_NOT_FOUND";
+       case DP_ERROR_INVALID_STATE:
+               return "INVALID_STATE";
+       case DP_ERROR_CONNECTION_FAILED:
+               return "CONNECTION_FAILED";
+       case DP_ERROR_INVALID_URL:
+               return "INVALID_URL";
+       case DP_ERROR_INVALID_DESTINATION:
+               return "INVALID_DESTINATION";
+       case DP_ERROR_QUEUE_FULL:
+               return "QUEUE_FULL";
+       case DP_ERROR_ALREADY_COMPLETED:
+               return "ALREADY_COMPLETED";
+       case DP_ERROR_FILE_ALREADY_EXISTS:
+               return "FILE_ALREADY_EXISTS";
+       case DP_ERROR_TOO_MANY_DOWNLOADS:
+               return "TOO_MANY_DOWNLOADS";
+       case DP_ERROR_NO_DATA:
+               return "NO_DATA";
+       case DP_ERROR_UNHANDLED_HTTP_CODE:
+               return "UNHANDLED_HTTP_CODE";
+       case DP_ERROR_CANNOT_RESUME:
+               return "CANNOT_RESUME";
+       case DP_ERROR_PERMISSION_DENIED:
+               return "PERMISSION_DENIED";
+       case DP_ERROR_RESPONSE_TIMEOUT:
+               return "RESPONSE_TIMEOUT";
+       case DP_ERROR_REQUEST_TIMEOUT:
+               return "REQUEST_TIMEOUT";
+       case DP_ERROR_SYSTEM_DOWN:
+               return "SYSTEM_DOWN";
+       case DP_ERROR_CLIENT_DOWN:
+               return "CLIENT_DOWN";
+       case DP_ERROR_DISK_BUSY:
+               return "DISK_BUSY";
+       case DP_ERROR_ID_NOT_FOUND:
+               return "ID_NOT_FOUND";
+       default:
                        break;
        }
        return "UNKNOWN";
@@ -220,56 +218,55 @@ char *dp_print_property(unsigned property)
 
 static int __dp_get_download_id(dp_client_fmt *client)
 {
-    int download_id = -1;
-    int check_duplicate = 1;
-    int retry_count = 0;
-    int errorcode = DP_ERROR_NONE;
-    struct timeval tval;
-
-    if (dp_db_get_max_download_id(client->dbhandle,
-                DP_TABLE_LOGGING, &download_id, &errorcode) < 0) {
-        TRACE_ERROR("ERROR [%d]", errorcode);
-        // database is empty start with id : 1
-        download_id = DP_FIRST_DOWNLOAD_ID;
-    } else {
-        if (download_id < INT_MAX)
-            download_id++;
-    }
-
-    retry_count = 0;
-    do {
-        retry_count++;
-        if (download_id < INT_MAX) {
-            TRACE_DEBUG("download_id [%d]", download_id);
-            check_duplicate = dp_db_check_duplicated_int(client->dbhandle,
-                    DP_TABLE_LOGGING, DP_DB_COL_ID, download_id, &errorcode);
-            if (errorcode == DP_ERROR_NONE) {
-                if (check_duplicate == 0) {
-                    break;
-                }
-            } else {
-                TRACE_ERROR("ERROR [%d]", errorcode);
-            }
-            if (retry_count < 3) {
-                download_id++;
-            } else if (retry_count < 10) {
-                gettimeofday(&tval, NULL);
-                tval.tv_usec = (tval.tv_usec & 0x0fff);
-                download_id += 1171 * retry_count + tval.tv_usec;
-            } else if (retry_count < 20) {
-                gettimeofday(&tval, NULL);
-                tval.tv_usec = (tval.tv_usec & 0xff33ff) + retry_count;
-                download_id += tval.tv_usec;
-            } else {
-                TRACE_ERROR("failed to generate unique download_id [%d]", download_id);
-                return -1;
-            }
-        } else {
-            TRACE_ERROR("reached INT_MAX limit");
-            download_id = DP_FIRST_DOWNLOAD_ID;
-        }
-    } while (check_duplicate != 0);
-    return download_id;
+       int download_id = -1;
+       int check_duplicate = 1;
+       int retry_count = 0;
+       int errorcode = DP_ERROR_NONE;
+       struct timeval tval;
+
+       if (dp_db_get_max_download_id(client->dbhandle,
+                               DP_TABLE_LOGGING, &download_id, &errorcode) < 0) {
+               TRACE_ERROR("ERROR [%d]", errorcode);
+               // database is empty start with id : 1
+               download_id = DP_FIRST_DOWNLOAD_ID;
+       } else {
+               if (download_id < INT_MAX)
+                       download_id++;
+       }
+
+       retry_count = 0;
+       do {
+               retry_count++;
+               if (download_id < INT_MAX) {
+                       TRACE_DEBUG("download_id [%d]", download_id);
+                       check_duplicate = dp_db_check_duplicated_int(client->dbhandle,
+                                       DP_TABLE_LOGGING, DP_DB_COL_ID, download_id, &errorcode);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (check_duplicate == 0)
+                                       break;
+                       } else {
+                               TRACE_ERROR("ERROR [%d]", errorcode);
+                       }
+                       if (retry_count < 3) {
+                               download_id++;
+                       } else if (retry_count < 10) {
+                               gettimeofday(&tval, NULL);
+                               tval.tv_usec = (tval.tv_usec & 0x0fff);
+                               download_id += 1171 * retry_count + tval.tv_usec;
+                       } else if (retry_count < 20) {
+                               gettimeofday(&tval, NULL);
+                               tval.tv_usec = (tval.tv_usec & 0xff33ff) + retry_count;
+                               download_id += tval.tv_usec;
+                       } else {
+                               TRACE_ERROR("failed to generate unique download_id [%d]", download_id);
+                               return -1;
+                       }
+               } else {
+                       TRACE_ERROR("reached INT_MAX limit");
+                       download_id = DP_FIRST_DOWNLOAD_ID;
+               }
+       } while (check_duplicate != 0);
+       return download_id;
 }
 
 void dp_request_create(dp_client_fmt *client, dp_request_fmt *request)
@@ -308,11 +305,11 @@ static int __dp_request_create(dp_client_fmt *client, dp_ipc_fmt *ipc_info)
                return DP_ERROR_OUT_OF_MEMORY;
        }
 
-    if (dp_db_new_logging(client->dbhandle, download_id, DP_STATE_READY, DP_ERROR_NONE, &errorcode) < 0) {
-        TRACE_ERROR("new log sock:%d download-id:%d errorcode:%s", client->channel, download_id, dp_print_errorcode(errorcode));
-        free(request);
-        return errorcode;
-    }
+       if (dp_db_new_logging(client->dbhandle, download_id, DP_STATE_READY, DP_ERROR_NONE, &errorcode) < 0) {
+               TRACE_ERROR("new log sock:%d download-id:%d errorcode:%s", client->channel, download_id, dp_print_errorcode(errorcode));
+               free(request);
+               return errorcode;
+       }
 
        request->id = download_id;
        request->agent_id = -1;
@@ -374,16 +371,14 @@ void dp_client_clear_requests(void *slotp)
                                can_unload = 1;
                        } else if (tailp->state == DP_STATE_CONNECTING) { // it take 120 sec over to connect. it means zombie.
                                TRACE_ERROR("id:%d connection timeout (%d/%d)", tailp->id, tailp->access_time, now_time);
-                               if (dp_cancel_agent_download_without_update(tailp->agent_id) < 0) {
+                               if (dp_cancel_agent_download_without_update(tailp->agent_id) < 0)
                                        TRACE_ERROR("failed to cancel download(%d) id:%d", tailp->agent_id, tailp->id);
-                               }
                                tailp->state = DP_STATE_FAILED;
                                tailp->error = DP_ERROR_CONNECTION_TIMED_OUT;
                                if (tailp->noti_type == DP_NOTIFICATION_TYPE_COMPLETE_ONLY ||
                                                tailp->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-                                       if (dp_notification_manager_push_notification(slot, tailp, DP_NOTIFICATION) < 0) {
+                                       if (dp_notification_manager_push_notification(slot, tailp, DP_NOTIFICATION) < 0)
                                                TRACE_ERROR("failed to register notification for id:%d", tailp->id);
-                                       }
                                }
                        }
                } else if (tailp->state == DP_STATE_PAUSED &&
@@ -449,7 +444,7 @@ int dp_request_destroy(dp_client_fmt *client, dp_ipc_fmt *ipc_info, dp_request_f
        }
 
        TRACE_DEBUG("sock:%d id:%d errorcode:%s", client->channel,
-               (ipc_info) ? ipc_info->id : -1, dp_print_errorcode(errorcode));
+                       (ipc_info) ? ipc_info->id : -1, dp_print_errorcode(errorcode));
 
        return errorcode;
 }
@@ -536,467 +531,465 @@ static int __dp_request_get_info(dp_client_fmt *client, dp_ipc_fmt *ipc_info, dp
        int errorcode = DP_ERROR_NONE;
        switch (ipc_info->property) {
        case DP_PROP_URL:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               free(string);
-               break;
-       }
        case DP_PROP_DESTINATION:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               free(string);
-               break;
-       }
        case DP_PROP_FILENAME:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_FILENAME, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               free(string);
-               break;
-       }
-       case DP_PROP_STATE_CALLBACK:
-       {
-               int callback = 0;
-               if (requestp != NULL) {
-                       callback = requestp->state_cb;
-               } else {
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_STATE_EVENT, &callback, &errorcode) < 0) {
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_FILENAME, (unsigned char **)&string, &length, &errorcode) < 0) {
                                TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
                                errorcode = DP_ERROR_NO_DATA;
                        }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&callback, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+       case DP_PROP_STATE_CALLBACK:
+               {
+                       int callback = 0;
+                       if (requestp != NULL) {
+                               callback = requestp->state_cb;
+                       } else {
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_STATE_EVENT, &callback, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
+                       }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&callback, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_PROGRESS_CALLBACK:
-       {
-               int callback = 0;
-               if (requestp != NULL) {
-                       callback = requestp->progress_cb;
-               } else {
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROGRESS_EVENT, &callback, &errorcode) < 0) {
-                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_NO_DATA;
+               {
+                       int callback = 0;
+                       if (requestp != NULL) {
+                               callback = requestp->progress_cb;
+                       } else {
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROGRESS_EVENT, &callback, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
                        }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&callback, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&callback, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               break;
-       }
        case DP_PROP_AUTO_DOWNLOAD:
-       {
-               int autodownload = 0;
-               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_AUTO_DOWNLOAD, &autodownload, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&autodownload, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               break;
-       }
-       case DP_PROP_NETWORK_TYPE:
-       {
-               int network = 0;
-               if (requestp != NULL) {
-                       network = requestp->network_type;
-               } else {
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_TYPE, &network, &errorcode) < 0) {
+               {
+                       int autodownload = 0;
+                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_AUTO_DOWNLOAD, &autodownload, &errorcode) < 0) {
                                TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
                                errorcode = DP_ERROR_NO_DATA;
                        }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&autodownload, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&network, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+       case DP_PROP_NETWORK_TYPE:
+               {
+                       int network = 0;
+                       if (requestp != NULL) {
+                               network = requestp->network_type;
+                       } else {
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_TYPE, &network, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
+                       }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&network, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NETWORK_BONDING:
-       {
-               int network_bonding = 0;
-               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_BONDING, &network_bonding, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&network_bonding, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       int network_bonding = 0;
+                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_BONDING, &network_bonding, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&network_bonding, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_SAVED_PATH:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_SAVED_PATH, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_SAVED_PATH, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               free(string);
-               break;
-       }
        case DP_PROP_TEMP_SAVED_PATH:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_TMP_SAVED_PATH, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_TMP_SAVED_PATH, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               free(string);
-               break;
-       }
        case DP_PROP_MIME_TYPE:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_MIMETYPE, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_MIMETYPE, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               free(string);
-               break;
-       }
        case DP_PROP_RECEIVED_SIZE:
-       {
-               unsigned long long recv_size = 0;
-               if (requestp != NULL) {
-                       recv_size = requestp->received_size;
-               } else {
-                       errorcode = DP_ERROR_INVALID_STATE;
-               }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&recv_size, errorcode, sizeof(unsigned long long));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       unsigned long long recv_size = 0;
+                       if (requestp != NULL)
+                               recv_size = requestp->received_size;
+                       else
+                               errorcode = DP_ERROR_INVALID_STATE;
+
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&recv_size, errorcode, sizeof(unsigned long long));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_TOTAL_FILE_SIZE:
-       {
-               unsigned long long file_size = 0;
-               if (requestp != NULL) {
-                       file_size = requestp->file_size;
-               } else {
-                       // load content_size(INT64) from database;
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_SIZE, &file_size, &errorcode) < 0) {
-                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_NO_DATA;
+               {
+                       unsigned long long file_size = 0;
+                       if (requestp != NULL) {
+                               file_size = requestp->file_size;
+                       } else {
+                               // load content_size(INT64) from database;
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_SIZE, &file_size, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
                        }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&file_size, errorcode, sizeof(unsigned long long));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&file_size, errorcode, sizeof(unsigned long long));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               break;
-       }
        case DP_PROP_CONTENT_NAME:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               free(string);
-               break;
-       }
        case DP_PROP_HTTP_STATUS:
-       {
-               int httpstatus = 0;
-               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_HTTP_STATUS, &httpstatus, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&httpstatus, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+               {
+                       int httpstatus = 0;
+                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_HTTP_STATUS, &httpstatus, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&httpstatus, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_ETAG:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_ETAG, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               free(string);
-               break;
-       }
-       case DP_PROP_STATE:
-       {
-               int state = DP_STATE_NONE;
-               if (requestp != NULL) {
-                       state = requestp->state;
-               } else {
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_STATE, &state, &errorcode) < 0) {
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_DOWNLOAD, DP_DB_COL_ETAG, (unsigned char **)&string, &length, &errorcode) < 0) {
                                TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_ID_NOT_FOUND;
+                               errorcode = DP_ERROR_NO_DATA;
                        }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(string);
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&state, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+       case DP_PROP_STATE:
+               {
+                       int state = DP_STATE_NONE;
+                       if (requestp != NULL) {
+                               state = requestp->state;
+                       } else {
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_STATE, &state, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_ID_NOT_FOUND;
+                               }
+                       }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&state, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_ERROR:
-       {
-               int errorvalue = DP_ERROR_NONE;
-               if (requestp != NULL) {
-                       errorvalue = requestp->error;
-               } else {
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_ERRORCODE, &errorvalue, &errorcode) < 0) {
-                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_ID_NOT_FOUND;
+               {
+                       int errorvalue = DP_ERROR_NONE;
+                       if (requestp != NULL) {
+                               errorvalue = requestp->error;
+                       } else {
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_ERRORCODE, &errorvalue, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_ID_NOT_FOUND;
+                               }
                        }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&errorvalue, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&errorvalue, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               break;
-       }
        case DP_PROP_NOTIFICATION_TYPE:
-       {
-               int noti_type = 0;
-               if (requestp != NULL) {
-                       noti_type = requestp->noti_type;
-                       // if already notification, unregister from notification bar.
-               } else {
-                       if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, &noti_type, &errorcode) < 0) {
-                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_NO_DATA;
+               {
+                       int noti_type = 0;
+                       if (requestp != NULL) {
+                               noti_type = requestp->noti_type;
+                               // if already notification, unregister from notification bar.
+                       } else {
+                               if (dp_db_get_property_int(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, &noti_type, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
                        }
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&noti_type, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&noti_type, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               break;
-       }
        case DP_PROP_NOTIFICATION_SUBJECT:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               free(string);
-               break;
-       }
-       case DP_PROP_NOTIFICATION_DESCRIPTION:
-       {
-               char *string = NULL;
-               unsigned length = 0;
-               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, (unsigned char **)&string, &length, &errorcode) < 0) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_NO_DATA;
-               }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               }
-               free(string);
-               break;
-       }
-       case DP_PROP_NOTIFICATION_RAW: // read type, send raw binary for type
-       {
-               int bundle_type = -1;
-               errorcode = __dp_request_read_int(client->channel, ipc_info, &bundle_type);
-               TRACE_DEBUG("read %s type:%d", dp_print_property(ipc_info->property), bundle_type);
-               char *raw_column = NULL;
-               if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_ONGOING)
-                       raw_column = DP_DB_COL_NOTI_RAW_ONGOING;
-               else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_COMPLETE)
-                       raw_column = DP_DB_COL_NOTI_RAW_COMPLETE;
-               else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_FAILED)
-                       raw_column = DP_DB_COL_NOTI_RAW_FAIL;
-
-               if (raw_column == NULL) {
-                       errorcode = DP_ERROR_INVALID_PARAMETER;
-                       TRACE_ERROR("invalid type %s type:%d", dp_print_property(ipc_info->property), bundle_type);
-                       if (dp_ipc_query(client->channel, ipc_info->id, ipc_info->section, ipc_info->property, errorcode, 0) < 0) {
+               {
+                       char *string = NULL;
+                       unsigned length = 0;
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (unsigned char **)&string, &length, &errorcode) < 0) {
+                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_NO_DATA;
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
                                errorcode = DP_ERROR_IO_ERROR;
                                TRACE_ERROR("check ipc sock:%d", client->channel);
                        }
+                       free(string);
+                       break;
                }
-               if (errorcode == DP_ERROR_NONE) {
-                       unsigned char *raws_buffer = NULL;
+       case DP_PROP_NOTIFICATION_DESCRIPTION:
+               {
+                       char *string = NULL;
                        unsigned length = 0;
-                       // get blob binary from database by raw_column
-                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, raw_column, &raws_buffer, &length, &errorcode) < 0) {
+                       if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, (unsigned char **)&string, &length, &errorcode) < 0) {
                                TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
                                errorcode = DP_ERROR_NO_DATA;
                        }
-                       int result = __dp_request_feedback_string(client->channel, ipc_info, raws_buffer, (size_t)length, errorcode);
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
                        if (result == DP_ERROR_IO_ERROR) {
                                errorcode = DP_ERROR_IO_ERROR;
                                TRACE_ERROR("check ipc sock:%d", client->channel);
                        }
-                       free(raws_buffer);
-               }
-               break;
-       }
-       case DP_PROP_HTTP_HEADERS:
-       {
-               // 1. response
-               // 2. send the number of header fields by id
-               // 3. send response & field string for each fields
-               int field_count = dp_db_check_duplicated_int(client->dbhandle, DP_TABLE_HEADERS, DP_DB_COL_ID, ipc_info->id, &errorcode);
-               if (field_count < 0 ) {
-                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
-                       field_count = 0;
+                       free(string);
+                       break;
                }
-               int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&field_count, errorcode, sizeof(int));
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-               } else if (field_count > 0) {
-                       // get fields from database.
-                       int *ids = (int *)calloc(field_count, sizeof(int));
-                       if (ids == NULL) {
-                               TRACE_ERROR("failed to allocate the clients");
-                               errorcode = DP_ERROR_OUT_OF_MEMORY;
-                       } else {
-                               // getting ids of clients
-                               int i = 0;
-                               int rows_count = dp_db_get_cond_ids(client->dbhandle, DP_TABLE_HEADERS, DP_DB_COL_ROW_ID, DP_DB_COL_ID, ipc_info->id, ids, field_count, &errorcode);
-                               for (; i < rows_count; i++) {
-                                       char *string = NULL;
-                                       unsigned length = 0;
-                                       if (dp_db_get_cond_string(client->dbhandle, DP_TABLE_HEADERS, DP_DB_COL_ROW_ID, ids[i], DP_DB_COL_HEADER_FIELD, (unsigned char **)&string, &length, &errorcode) < 0) {
-                                               TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                                               errorcode = DP_ERROR_NO_DATA;
-                                       }
-                                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-                                       free(string);
-                                       if (result == DP_ERROR_IO_ERROR) {
-                                               errorcode = DP_ERROR_IO_ERROR;
-                                               TRACE_ERROR("check ipc sock:%d", client->channel);
-                                               break;
-                                       }
+       case DP_PROP_NOTIFICATION_RAW: // read type, send raw binary for type
+               {
+                       int bundle_type = -1;
+                       errorcode = __dp_request_read_int(client->channel, ipc_info, &bundle_type);
+                       TRACE_DEBUG("read %s type:%d", dp_print_property(ipc_info->property), bundle_type);
+                       char *raw_column = NULL;
+                       if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_ONGOING)
+                               raw_column = DP_DB_COL_NOTI_RAW_ONGOING;
+                       else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_COMPLETE)
+                               raw_column = DP_DB_COL_NOTI_RAW_COMPLETE;
+                       else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_FAILED)
+                               raw_column = DP_DB_COL_NOTI_RAW_FAIL;
+
+                       if (raw_column == NULL) {
+                               errorcode = DP_ERROR_INVALID_PARAMETER;
+                               TRACE_ERROR("invalid type %s type:%d", dp_print_property(ipc_info->property), bundle_type);
+                               if (dp_ipc_query(client->channel, ipc_info->id, ipc_info->section, ipc_info->property, errorcode, 0) < 0) {
+                                       errorcode = DP_ERROR_IO_ERROR;
+                                       TRACE_ERROR("check ipc sock:%d", client->channel);
                                }
                        }
-                       if(ids) {
-                           free(ids);
+                       if (errorcode == DP_ERROR_NONE) {
+                               unsigned char *raws_buffer = NULL;
+                               unsigned length = 0;
+                               // get blob binary from database by raw_column
+                               if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, raw_column, &raws_buffer, &length, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
+                               int result = __dp_request_feedback_string(client->channel, ipc_info, raws_buffer, (size_t)length, errorcode);
+                               if (result == DP_ERROR_IO_ERROR) {
+                                       errorcode = DP_ERROR_IO_ERROR;
+                                       TRACE_ERROR("check ipc sock:%d", client->channel);
+                               }
+                               free(raws_buffer);
                        }
+                       break;
                }
-               break;
-       }
-       case DP_PROP_HTTP_HEADER:
-       {
-               // 1. read field string
-               // 2. response with extra size
-               // 3. send string.
-               char *header_field = NULL;
-               char *string = NULL;
-               unsigned length = 0;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &header_field);
-               if (errorcode == DP_ERROR_NONE && header_field != NULL) {
-                       if (dp_db_get_header_value(client->dbhandle, ipc_info->id, header_field, (unsigned char **)&string, &length, &errorcode) < 0) {
+       case DP_PROP_HTTP_HEADERS:
+               {
+                       // 1. response
+                       // 2. send the number of header fields by id
+                       // 3. send response & field string for each fields
+                       int field_count = dp_db_check_duplicated_int(client->dbhandle, DP_TABLE_HEADERS, DP_DB_COL_ID, ipc_info->id, &errorcode);
+                       if (field_count < 0) {
                                TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_NO_DATA;
-                       }
-               } else {
-                       if (errorcode != DP_ERROR_NONE) {
-                               TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                               field_count = 0;
                        }
-                       if (header_field == NULL) {
-                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
+                       int result = __dp_request_feedback_int(client->channel, ipc_info, (void *)&field_count, errorcode, sizeof(int));
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       } else if (field_count > 0) {
+                               // get fields from database.
+                               int *ids = (int *)calloc(field_count, sizeof(int));
+                               if (ids == NULL) {
+                                       TRACE_ERROR("failed to allocate the clients");
+                                       errorcode = DP_ERROR_OUT_OF_MEMORY;
+                               } else {
+                                       // getting ids of clients
+                                       int i = 0;
+                                       int rows_count = dp_db_get_cond_ids(client->dbhandle, DP_TABLE_HEADERS, DP_DB_COL_ROW_ID, DP_DB_COL_ID, ipc_info->id, ids, field_count, &errorcode);
+                                       for (; i < rows_count; i++) {
+                                               char *string = NULL;
+                                               unsigned length = 0;
+                                               if (dp_db_get_cond_string(client->dbhandle, DP_TABLE_HEADERS, DP_DB_COL_ROW_ID, ids[i], DP_DB_COL_HEADER_FIELD, (unsigned char **)&string, &length, &errorcode) < 0) {
+                                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                                       errorcode = DP_ERROR_NO_DATA;
+                                               }
+                                               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                                               free(string);
+                                               if (result == DP_ERROR_IO_ERROR) {
+                                                       errorcode = DP_ERROR_IO_ERROR;
+                                                       TRACE_ERROR("check ipc sock:%d", client->channel);
+                                                       break;
+                                               }
+                                       }
+                               }
+                               if (ids)
+                                       free(ids);
                        }
+                       break;
                }
-               int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
-               if (result == DP_ERROR_IO_ERROR) {
-                       errorcode = DP_ERROR_IO_ERROR;
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
+       case DP_PROP_HTTP_HEADER:
+               {
+                       // 1. read field string
+                       // 2. response with extra size
+                       // 3. send string.
+                       char *header_field = NULL;
+                       char *string = NULL;
+                       unsigned length = 0;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &header_field);
+                       if (errorcode == DP_ERROR_NONE && header_field != NULL) {
+                               if (dp_db_get_header_value(client->dbhandle, ipc_info->id, header_field, (unsigned char **)&string, &length, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NO_DATA;
+                               }
+                       } else {
+                               if (errorcode != DP_ERROR_NONE)
+                                       TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+                               if (header_field == NULL) {
+                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               }
+                       }
+                       int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+                       if (result == DP_ERROR_IO_ERROR) {
+                               errorcode = DP_ERROR_IO_ERROR;
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
+                       }
+                       free(header_field);
+                       free(string);
+                       break;
                }
-               free(header_field);
-               free(string);
-               break;
-       }
        default:
                errorcode = DP_ERROR_INVALID_PARAMETER;
                break;
@@ -1028,7 +1021,7 @@ static int __dp_request_set_info(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                        errorcode = DP_ERROR_ID_NOT_FOUND;
                        // feedback
                        if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_SET,
-                                       ipc_info->property, errorcode, 0) < 0) {
+                                               ipc_info->property, errorcode, 0) < 0) {
                                TRACE_ERROR("check ipc sock:%d", client->channel);
                        }
                        return errorcode;
@@ -1039,386 +1032,381 @@ static int __dp_request_set_info(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
 
        switch (ipc_info->property) {
        case DP_PROP_URL:
-       {
-               char *recv_str = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
-               if (errorcode == DP_ERROR_NONE) {
-                       if (recv_str == NULL) {
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       } else {
-                               // write to database here
-                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       char *recv_str = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (recv_str == NULL) {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       // write to database here
+                                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                               errorcode = DP_ERROR_DISK_BUSY;
+                                       }
+                                       free(recv_str);
                                }
-                               free(recv_str);
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_DESTINATION:
-       {
-               char *recv_str = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
-               if (errorcode == DP_ERROR_NONE) {
-                       if (recv_str == NULL) {
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       } else {
-                               if (dp_smack_is_mounted() == 1) {
-                                       // check here destination is available. with checking smack
-                                       char *smack_label = dp_db_get_client_smack_label(slot->pkgname);
-                                       if (smack_label == NULL) {
-                                               TRACE_SECURE_ERROR("[SMACK][%d] no label", ipc_info->id);
-                                               errorcode = DP_ERROR_PERMISSION_DENIED;
-                                       } else if (dp_is_valid_dir(recv_str) != 0) {
-                                               errorcode = DP_ERROR_INVALID_DESTINATION;
-                                       } else if (dp_smack_is_valid_dir(slot->credential.uid, slot->credential.gid, smack_label, recv_str) != 0) {
-                                               errorcode = DP_ERROR_PERMISSION_DENIED;
+               {
+                       char *recv_str = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (recv_str == NULL) {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       if (dp_smack_is_mounted() == 1) {
+                                               // check here destination is available. with checking smack
+                                               char *smack_label = dp_db_get_client_smack_label(slot->pkgname);
+                                               if (smack_label == NULL) {
+                                                       TRACE_SECURE_ERROR("[SMACK][%d] no label", ipc_info->id);
+                                                       errorcode = DP_ERROR_PERMISSION_DENIED;
+                                               } else if (dp_is_valid_dir(recv_str) != 0) {
+                                                       errorcode = DP_ERROR_INVALID_DESTINATION;
+                                               } else if (dp_smack_is_valid_dir(slot->credential.uid, slot->credential.gid, smack_label, recv_str) != 0) {
+                                                       errorcode = DP_ERROR_PERMISSION_DENIED;
+                                               }
+                                               free(smack_label);
                                        }
-                                       free(smack_label);
-                               }
-                               if (errorcode == DP_ERROR_NONE &&
-                                               dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                       errorcode = DP_ERROR_DISK_BUSY;
+                                       if (errorcode == DP_ERROR_NONE &&
+                                                       dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                               errorcode = DP_ERROR_DISK_BUSY;
+                                       }
+                                       free(recv_str);
                                }
-                               free(recv_str);
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_TEMP_SAVED_PATH:
-       {
-               char *recv_str = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
-               if (errorcode == DP_ERROR_NONE) {
-                       if (recv_str == NULL) {
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       } else {
-                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_TEMP_FILE_PATH, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       char *recv_str = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (recv_str == NULL) {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_TEMP_FILE_PATH, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                               errorcode = DP_ERROR_DISK_BUSY;
+                                       }
+                                       free(recv_str);
                                }
-                               free(recv_str);
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_FILENAME:
-       {
-               char *recv_str = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
-               if (errorcode == DP_ERROR_NONE) {
-                       if (recv_str == NULL) {
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       } else {
-                               // write to database here
-                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_FILENAME, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       char *recv_str = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (recv_str == NULL) {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       // write to database here
+                                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_FILENAME, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                               errorcode = DP_ERROR_DISK_BUSY;
+                                       }
+                                       free(recv_str);
                                }
-                               free(recv_str);
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_STATE_CALLBACK:
-       {
-               // check state here
-               // DP_ERROR_INVALID_STATE if downloading or finished
-               // update database here
-               if (requestp != NULL) {
-                       requestp->state_cb = 1;
-               }
-               int enable_cb = 1;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_STATE_EVENT, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       // check state here
+                       // DP_ERROR_INVALID_STATE if downloading or finished
+                       // update database here
+                       if (requestp != NULL)
+                               requestp->state_cb = 1;
+
+                       int enable_cb = 1;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_STATE_EVENT, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_PROGRESS_CALLBACK:
-       {
-               // check state here
-               // DP_ERROR_INVALID_STATE if downloading or finished
-               // update database here
-               if (requestp != NULL) {
-                       requestp->progress_cb = 1;
-               }
-               int enable_cb = 1;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROGRESS_EVENT, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       // check state here
+                       // DP_ERROR_INVALID_STATE if downloading or finished
+                       // update database here
+                       if (requestp != NULL)
+                               requestp->progress_cb = 1;
+
+                       int enable_cb = 1;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROGRESS_EVENT, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_AUTO_DOWNLOAD:
-       {
-               // update autodownload property as 1 in database
-               int enable_cb = 1;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_AUTO_DOWNLOAD, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       // update autodownload property as 1 in database
+                       int enable_cb = 1;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_AUTO_DOWNLOAD, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NETWORK_TYPE:
-       {
-               int recv_int = -1;
-               errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
-               if (recv_int <= DP_NETWORK_OFF ||
-                               recv_int > DP_NETWORK_ALL) {
-                       errorcode = DP_ERROR_INVALID_PARAMETER;
-               } else {
-                       // update in database
-                       if (requestp != NULL) {
-                               if (requestp->state == DP_STATE_QUEUED) {
-                                       dp_queue_manager_clear_queue(requestp);
-                               } else {
-                                       requestp->network_type = recv_int;
-                                       if (requestp->state == DP_STATE_CONNECTING ||
-                                                       requestp->state == DP_STATE_DOWNLOADING) {
-                                               // pause & push queue
-                                               if (dp_pause_agent_download_without_update(requestp->agent_id) < 0) {
-                                                       TRACE_ERROR("failed to pause download(%d) id:%d", requestp->agent_id, ipc_info->id);
-                                               } else {
-                                                       requestp->state = DP_STATE_PAUSED;
-                                                       requestp->error = DP_ERROR_NONE;
-                                                       if (dp_queue_manager_push_queue(slot, requestp) < 0) {
-                                                               if (dp_db_update_logging(client->dbhandle, ipc_info->id, DP_STATE_FAILED, DP_ERROR_QUEUE_FULL, &errorcode) < 0) {
-                                                                       TRACE_ERROR("update log sock:%d download-id:%d", client->channel, ipc_info->id);
+               {
+                       int recv_int = -1;
+                       errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
+                       if (recv_int <= DP_NETWORK_OFF ||
+                                       recv_int > DP_NETWORK_ALL) {
+                               errorcode = DP_ERROR_INVALID_PARAMETER;
+                       } else {
+                               // update in database
+                               if (requestp != NULL) {
+                                       if (requestp->state == DP_STATE_QUEUED) {
+                                               dp_queue_manager_clear_queue(requestp);
+                                       } else {
+                                               requestp->network_type = recv_int;
+                                               if (requestp->state == DP_STATE_CONNECTING ||
+                                                               requestp->state == DP_STATE_DOWNLOADING) {
+                                                       // pause & push queue
+                                                       if (dp_pause_agent_download_without_update(requestp->agent_id) < 0) {
+                                                               TRACE_ERROR("failed to pause download(%d) id:%d", requestp->agent_id, ipc_info->id);
+                                                       } else {
+                                                               requestp->state = DP_STATE_PAUSED;
+                                                               requestp->error = DP_ERROR_NONE;
+                                                               if (dp_queue_manager_push_queue(slot, requestp) < 0) {
+                                                                       if (dp_db_update_logging(client->dbhandle, ipc_info->id, DP_STATE_FAILED, DP_ERROR_QUEUE_FULL, &errorcode) < 0)
+                                                                               TRACE_ERROR("update log sock:%d download-id:%d", client->channel, ipc_info->id);
+                                                                       requestp->state = DP_STATE_FAILED;
+                                                                       requestp->error = DP_ERROR_QUEUE_FULL;
+                                                                       errorcode = DP_ERROR_QUEUE_FULL;
                                                                }
-                                                               requestp->state = DP_STATE_FAILED;
-                                                               requestp->error = DP_ERROR_QUEUE_FULL;
-                                                               errorcode = DP_ERROR_QUEUE_FULL;
                                                        }
                                                }
                                        }
                                }
+                               int enable_cb = recv_int;
+                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_TYPE, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_DISK_BUSY;
+                               }
                        }
-                       int enable_cb = recv_int;
-                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_TYPE, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
-                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_DISK_BUSY;
-                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NETWORK_BONDING:
-       {
-               int recv_int = -1;
-               errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
-               if (errorcode == DP_ERROR_NONE) {
-                       if(requestp != NULL && requestp->network_type != DP_NETWORK_ALL) {
-                               errorcode =  DP_ERROR_INVALID_NETWORK_TYPE;
-                               TRACE_ERROR("[ERROR] wrong network type");
-                       } else if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_BONDING, (void *)&recv_int, ipc_info->size, 0, &errorcode) < 0) {
-                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       int recv_int = -1;
+                       errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (requestp != NULL && requestp->network_type != DP_NETWORK_ALL) {
+                                       errorcode =  DP_ERROR_INVALID_NETWORK_TYPE;
+                                       TRACE_ERROR("[ERROR] wrong network type");
+                               } else if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_BONDING, (void *)&recv_int, ipc_info->size, 0, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_DISK_BUSY;
+                               }
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_TYPE:
-       {
-               int recv_int = -1;
-               errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
-               if (recv_int == DP_NOTIFICATION_TYPE_NONE ||
-                               recv_int == DP_NOTIFICATION_TYPE_COMPLETE_ONLY ||
-                               recv_int == DP_NOTIFICATION_TYPE_ALL) {
-                       // check state request->state == DP_STATE_COMPLETED
-                       // DP_ERROR_INVALID_STATE
-                       // update notificatio type in database
-                       int noti_type = recv_int;
-                       if (requestp != NULL) {
-                               if (recv_int < requestp->noti_type) {
-                                       // if already notification, unregister from notification bar.
-                                       if (recv_int == DP_NOTIFICATION_TYPE_NONE) {
-                                               if (dp_notification_manager_clear_notification(slot, requestp, DP_NOTIFICATION) < 0) {
-                                                       TRACE_ERROR("failed to clear notification %s", dp_print_property(ipc_info->property));
+               {
+                       int recv_int = -1;
+                       errorcode = __dp_request_read_int(client->channel, ipc_info, &recv_int);
+                       if (recv_int == DP_NOTIFICATION_TYPE_NONE ||
+                                       recv_int == DP_NOTIFICATION_TYPE_COMPLETE_ONLY ||
+                                       recv_int == DP_NOTIFICATION_TYPE_ALL) {
+                               // check state request->state == DP_STATE_COMPLETED
+                               // DP_ERROR_INVALID_STATE
+                               // update notificatio type in database
+                               int noti_type = recv_int;
+                               if (requestp != NULL) {
+                                       if (recv_int < requestp->noti_type) {
+                                               // if already notification, unregister from notification bar.
+                                               if (recv_int == DP_NOTIFICATION_TYPE_NONE) {
+                                                       if (dp_notification_manager_clear_notification(slot, requestp, DP_NOTIFICATION) < 0)
+                                                               TRACE_ERROR("failed to clear notification %s", dp_print_property(ipc_info->property));
                                                }
+                                               if (dp_notification_manager_clear_notification(slot, requestp, DP_NOTIFICATION_ONGOING) < 0)
+                                                       TRACE_ERROR("failed to clear ongoing %s", dp_print_property(ipc_info->property));
                                        }
-                                       if (dp_notification_manager_clear_notification(slot, requestp, DP_NOTIFICATION_ONGOING) < 0) {
-                                               TRACE_ERROR("failed to clear ongoing %s", dp_print_property(ipc_info->property));
-                                       }
+                                       requestp->noti_type = recv_int;
                                }
-                               requestp->noti_type = recv_int;
-                       }
-                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, (void *)&noti_type, ipc_info->size, 0, &errorcode) < 0) {
-                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_DISK_BUSY;
+                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, (void *)&noti_type, ipc_info->size, 0, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_DISK_BUSY;
+                               }
+                       } else {
+                               errorcode = DP_ERROR_INVALID_PARAMETER;
                        }
-               } else {
-                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_SUBJECT:
-       {
-               char *recv_str = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
-               if (errorcode == DP_ERROR_NONE) {
-                       if (recv_str == NULL) {
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       } else {
-                               // write to database here
-                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       char *recv_str = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (recv_str == NULL) {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       // write to database here
+                                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                               errorcode = DP_ERROR_DISK_BUSY;
+                                       }
+                                       free(recv_str);
                                }
-                               free(recv_str);
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_DESCRIPTION:
-       {
-               char *recv_str = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
-               if (errorcode == DP_ERROR_NONE) {
-                       if (recv_str == NULL) {
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       } else {
-                               // write to database here
-                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       char *recv_str = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+                       if (errorcode == DP_ERROR_NONE) {
+                               if (recv_str == NULL) {
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               } else {
+                                       // write to database here
+                                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                               errorcode = DP_ERROR_DISK_BUSY;
+                                       }
+                                       free(recv_str);
                                }
-                               free(recv_str);
                        }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_RAW: // bundle_type(db column) + bundle_binary
-       {
-               int bundle_type = -1;
-               errorcode = __dp_request_read_int(client->channel, ipc_info, &bundle_type);
-               TRACE_DEBUG("read %s type:%d", dp_print_property(ipc_info->property), bundle_type);
-               char *raw_column = NULL;
-               if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_ONGOING)
-                       raw_column = DP_DB_COL_NOTI_RAW_ONGOING;
-               else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_COMPLETE)
-                       raw_column = DP_DB_COL_NOTI_RAW_COMPLETE;
-               else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_FAILED)
-                       raw_column = DP_DB_COL_NOTI_RAW_FAIL;
-               else
-                       errorcode = DP_ERROR_INVALID_PARAMETER;
-               // feedback
-               if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_SET,
-                               ipc_info->property, errorcode, 0) < 0) {
-                       TRACE_ERROR("check ipc sock:%d", client->channel);
-                       errorcode = DP_ERROR_IO_ERROR;
-               }
-               if (errorcode == DP_ERROR_NONE) {
-                       dp_ipc_fmt *raw_info = dp_ipc_get_fmt(client->channel);
-                       if (raw_info == NULL || raw_info->section != ipc_info->section ||
-                                       raw_info->property != ipc_info->property ||
-                                       (raw_info->id != ipc_info->id)) {
-                               TRACE_ERROR("there is a confusion waiting raw binary in %s section", dp_print_property(ipc_info->property));
+               {
+                       int bundle_type = -1;
+                       errorcode = __dp_request_read_int(client->channel, ipc_info, &bundle_type);
+                       TRACE_DEBUG("read %s type:%d", dp_print_property(ipc_info->property), bundle_type);
+                       char *raw_column = NULL;
+                       if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_ONGOING)
+                               raw_column = DP_DB_COL_NOTI_RAW_ONGOING;
+                       else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_COMPLETE)
+                               raw_column = DP_DB_COL_NOTI_RAW_COMPLETE;
+                       else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_FAILED)
+                               raw_column = DP_DB_COL_NOTI_RAW_FAIL;
+                       else
+                               errorcode = DP_ERROR_INVALID_PARAMETER;
+                       // feedback
+                       if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_SET,
+                                               ipc_info->property, errorcode, 0) < 0) {
+                               TRACE_ERROR("check ipc sock:%d", client->channel);
                                errorcode = DP_ERROR_IO_ERROR;
                        }
-                       if (raw_info != NULL && raw_info->size > 0) {
-                               unsigned char *recv_raws = (unsigned char *)calloc(raw_info->size, sizeof(unsigned char));
-                               if (recv_raws == NULL) {
-                                       TRACE_ERROR("sock:%d check memory length:%d", client->channel, raw_info->size);
-                                       errorcode = DP_ERROR_OUT_OF_MEMORY;
-                               } else {
-                                       if (dp_ipc_read(client->channel, recv_raws, raw_info->size, __FUNCTION__) <= 0) {
-                                               TRACE_ERROR("sock:%d check ipc length:%d", client->channel, raw_info->size);
-                                               errorcode = DP_ERROR_IO_ERROR;
+                       if (errorcode == DP_ERROR_NONE) {
+                               dp_ipc_fmt *raw_info = dp_ipc_get_fmt(client->channel);
+                               if (raw_info == NULL || raw_info->section != ipc_info->section ||
+                                               raw_info->property != ipc_info->property ||
+                                               (raw_info->id != ipc_info->id)) {
+                                       TRACE_ERROR("there is a confusion waiting raw binary in %s section", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_IO_ERROR;
+                               }
+                               if (raw_info != NULL && raw_info->size > 0) {
+                                       unsigned char *recv_raws = (unsigned char *)calloc(raw_info->size, sizeof(unsigned char));
+                                       if (recv_raws == NULL) {
+                                               TRACE_ERROR("sock:%d check memory length:%d", client->channel, raw_info->size);
+                                               errorcode = DP_ERROR_OUT_OF_MEMORY;
                                        } else {
-                                               TRACE_DEBUG("sock:%d length:%d raws", client->channel, raw_info->size);
-                                               // save to database
-                                               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, raw_column, (void *)recv_raws, raw_info->size, 3, &errorcode) < 0) {
-                                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                                       errorcode = DP_ERROR_DISK_BUSY;
+                                               if (dp_ipc_read(client->channel, recv_raws, raw_info->size, __FUNCTION__) <= 0) {
+                                                       TRACE_ERROR("sock:%d check ipc length:%d", client->channel, raw_info->size);
+                                                       errorcode = DP_ERROR_IO_ERROR;
+                                               } else {
+                                                       TRACE_DEBUG("sock:%d length:%d raws", client->channel, raw_info->size);
+                                                       // save to database
+                                                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, raw_column, (void *)recv_raws, raw_info->size, 3, &errorcode) < 0) {
+                                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                                               errorcode = DP_ERROR_DISK_BUSY;
+                                                       }
                                                }
+                                               free(recv_raws);
                                        }
-                                       free(recv_raws);
+                               } else {
+                                       errorcode = DP_ERROR_IO_ERROR;
                                }
-                       } else {
-                               errorcode = DP_ERROR_IO_ERROR;
+                               free(raw_info);
                        }
-                       free(raw_info);
+                       break;
                }
-               break;
-       }
        case DP_PROP_HTTP_HEADER: //  a request can have one or more fields, a fields can have only one value.
-       {
-               char *header_field = NULL;
-               char *header_value = NULL;
-               // 1. read field string
-               // 2. response after checking sql status
-               // 3. read query IPC for checking IPC
-               // 4. read value string
-               // 5. response
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &header_field);
-               if (errorcode == DP_ERROR_NONE && header_field != NULL) {
-                       // check sql
-                       int check_field = dp_db_check_duplicated_string(client->dbhandle, ipc_info->id, DP_TABLE_HEADERS, DP_DB_COL_HEADER_FIELD, 0, header_field, &errorcode);
-                       if (check_field < 0) {
-                               errorcode = DP_ERROR_DISK_BUSY;
-                       } else {
-                               errorcode = DP_ERROR_NONE;
-                               // feedback
-                               if (dp_ipc_query(client->channel, ipc_info->id, ipc_info->section,
-                                               ipc_info->property, errorcode, 0) < 0) {
-                                       TRACE_ERROR("check ipc sock:%d", client->channel);
-                                       errorcode = DP_ERROR_IO_ERROR;
+               {
+                       char *header_field = NULL;
+                       char *header_value = NULL;
+                       // 1. read field string
+                       // 2. response after checking sql status
+                       // 3. read query IPC for checking IPC
+                       // 4. read value string
+                       // 5. response
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &header_field);
+                       if (errorcode == DP_ERROR_NONE && header_field != NULL) {
+                               // check sql
+                               int check_field = dp_db_check_duplicated_string(client->dbhandle, ipc_info->id, DP_TABLE_HEADERS, DP_DB_COL_HEADER_FIELD, 0, header_field, &errorcode);
+                               if (check_field < 0) {
+                                       errorcode = DP_ERROR_DISK_BUSY;
                                } else {
-                                       dp_ipc_fmt *header_ipc = dp_ipc_get_fmt(client->channel);
-                                       if (header_ipc == NULL || header_ipc->section != ipc_info->section ||
-                                                       header_ipc->property != ipc_info->property ||
-                                                       (header_ipc->id != ipc_info->id)) {
-                                               TRACE_ERROR("there is a confusion during waiting http string in %s section", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_NONE;
+                                       // feedback
+                                       if (dp_ipc_query(client->channel, ipc_info->id, ipc_info->section,
+                                                               ipc_info->property, errorcode, 0) < 0) {
+                                               TRACE_ERROR("check ipc sock:%d", client->channel);
                                                errorcode = DP_ERROR_IO_ERROR;
                                        } else {
-                                               errorcode = __dp_request_read_string(client->channel, header_ipc, &header_value);
-                                               if (errorcode == DP_ERROR_NONE && header_value != NULL) {
-                                                       if (check_field == 0) { // insert
-                                                               if (dp_db_new_header(client->dbhandle, ipc_info->id, header_field, header_value, &errorcode) < 0) {
-                                                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                                                       errorcode = DP_ERROR_DISK_BUSY;
+                                               dp_ipc_fmt *header_ipc = dp_ipc_get_fmt(client->channel);
+                                               if (header_ipc == NULL || header_ipc->section != ipc_info->section ||
+                                                               header_ipc->property != ipc_info->property ||
+                                                               (header_ipc->id != ipc_info->id)) {
+                                                       TRACE_ERROR("there is a confusion during waiting http string in %s section", dp_print_property(ipc_info->property));
+                                                       errorcode = DP_ERROR_IO_ERROR;
+                                               } else {
+                                                       errorcode = __dp_request_read_string(client->channel, header_ipc, &header_value);
+                                                       if (errorcode == DP_ERROR_NONE && header_value != NULL) {
+                                                               if (check_field == 0) { // insert
+                                                                       if (dp_db_new_header(client->dbhandle, ipc_info->id, header_field, header_value, &errorcode) < 0) {
+                                                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                                                               errorcode = DP_ERROR_DISK_BUSY;
+                                                                       }
+                                                               } else { // update
+                                                                       if (dp_db_update_header(client->dbhandle, ipc_info->id, header_field, header_value, &errorcode) < 0) {
+                                                                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                                                               errorcode = DP_ERROR_DISK_BUSY;
+                                                                       }
                                                                }
-                                                       } else { // update
-                                                               if (dp_db_update_header(client->dbhandle, ipc_info->id, header_field, header_value, &errorcode) < 0) {
-                                                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                                                                       errorcode = DP_ERROR_DISK_BUSY;
+                                                       } else {
+                                                               if (errorcode != DP_ERROR_NONE)
+                                                                       TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+                                                               if (header_value == NULL) {
+                                                                       TRACE_ERROR("failed to set %s, do you want to run as unset?", dp_print_property(ipc_info->property));
+                                                                       errorcode = DP_ERROR_INVALID_PARAMETER;
                                                                }
                                                        }
-                                               } else {
-                                                       if (errorcode != DP_ERROR_NONE) {
-                                                               TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
-                                                       }
-                                                       if (header_value == NULL) {
-                                                               TRACE_ERROR("failed to set %s, do you want to run as unset?", dp_print_property(ipc_info->property));
-                                                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                                                       }
                                                }
+                                               free(header_ipc);
                                        }
-                                       free(header_ipc);
+                               }
+                       } else {
+                               if (errorcode != DP_ERROR_NONE)
+                                       TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+                               if (header_field == NULL) {
+                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
                                }
                        }
-               } else {
-                       if (errorcode != DP_ERROR_NONE) {
-                               TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
-                       }
-                       if (header_field == NULL) {
-                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
-                       }
+                       free(header_field);
+                       free(header_value);
+                       break;
                }
-               free(header_field);
-               free(header_value);
-               break;
-       }
        default:
                errorcode = DP_ERROR_INVALID_PARAMETER;
                break;
        }
        // feedback
        if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_SET,
-                       ipc_info->property, errorcode, 0) < 0) {
+                               ipc_info->property, errorcode, 0) < 0) {
                TRACE_ERROR("check ipc sock:%d", client->channel);
        }
        return errorcode;
@@ -1436,150 +1424,143 @@ static int __dp_request_unset_info(dp_client_fmt *client, dp_ipc_fmt *ipc_info,
        switch (ipc_info->property) {
        case DP_PROP_URL:
                // it would be run like cancel operation
-               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, &errorcode) < 0) {
+               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, &errorcode) < 0)
                        TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-               }
                break;
        case DP_PROP_DESTINATION:
                // if downloading, change destination to da_agent
-               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, &errorcode) < 0) {
+               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, &errorcode) < 0)
                        TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-               }
                break;
        case DP_PROP_FILENAME:
-               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_FILENAME, &errorcode) < 0) {
+               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_FILENAME, &errorcode) < 0)
                        TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-               }
                break;
        case DP_PROP_STATE_CALLBACK:
-       {
-               if (requestp != NULL) {
-                       requestp->state_cb = 0;
-               }
-               int enable_cb = 0;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_STATE_EVENT, (void *)&enable_cb, 0, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       if (requestp != NULL)
+                               requestp->state_cb = 0;
+
+                       int enable_cb = 0;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_STATE_EVENT, (void *)&enable_cb, 0, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_PROGRESS_CALLBACK:
-       {
-               if (requestp != NULL) {
-                       requestp->progress_cb = 0;
-               }
-               int enable_cb = 0;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROGRESS_EVENT, (void *)&enable_cb, 0, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       if (requestp != NULL)
+                               requestp->progress_cb = 0;
+
+                       int enable_cb = 0;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROGRESS_EVENT, (void *)&enable_cb, 0, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_AUTO_DOWNLOAD:
-       {
-               // update autodownload property as 0 in database
-               int enable_cb = 0;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_AUTO_DOWNLOAD, (void *)&enable_cb, 0, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       // update autodownload property as 0 in database
+                       int enable_cb = 0;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_LOGGING, DP_DB_COL_AUTO_DOWNLOAD, (void *)&enable_cb, 0, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NETWORK_TYPE:
-       {
-               // check state here
-               // update database here
-               if (requestp != NULL) {
-                       requestp->network_type = DP_NETWORK_OFF;
-               }
-               int enable_cb = DP_NETWORK_OFF;
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_TYPE, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       // check state here
+                       // update database here
+                       if (requestp != NULL)
+                               requestp->network_type = DP_NETWORK_OFF;
+
+                       int enable_cb = DP_NETWORK_OFF;
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_TYPE, (void *)&enable_cb, ipc_info->size, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_TYPE:
-       {
-               int noti_type = DP_NOTIFICATION_TYPE_NONE;
-               if (requestp != NULL) {
-                       requestp->noti_type = noti_type;
-               }
-               if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, (void *)&noti_type, ipc_info->size, 0, &errorcode) < 0) {
-                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                       errorcode = DP_ERROR_DISK_BUSY;
+               {
+                       int noti_type = DP_NOTIFICATION_TYPE_NONE;
+                       if (requestp != NULL)
+                               requestp->noti_type = noti_type;
+
+                       if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_TYPE, (void *)&noti_type, ipc_info->size, 0, &errorcode) < 0) {
+                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                               errorcode = DP_ERROR_DISK_BUSY;
+                       }
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_SUBJECT:
-       {
-               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, &errorcode) < 0) {
-                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+               {
+                       if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, &errorcode) < 0)
+                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_DESCRIPTION:
-       {
-               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, &errorcode) < 0) {
-                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+               {
+                       if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, &errorcode) < 0)
+                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                       break;
                }
-               break;
-       }
        case DP_PROP_NOTIFICATION_RAW:
-       {
-               int bundle_type = -1;
-               errorcode = __dp_request_read_int(client->channel, ipc_info, &bundle_type);
-               TRACE_DEBUG("read %s type:%d", dp_print_property(ipc_info->property), bundle_type);
-               char *raw_column = NULL;
-               if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_ONGOING)
-                       raw_column = DP_DB_COL_NOTI_RAW_ONGOING;
-               else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_COMPLETE)
-                       raw_column = DP_DB_COL_NOTI_RAW_COMPLETE;
-               else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_FAILED)
-                       raw_column = DP_DB_COL_NOTI_RAW_FAIL;
-               if (raw_column != NULL) {
-                       if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, raw_column, &errorcode) < 0) {
-                               TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+               {
+                       int bundle_type = -1;
+                       errorcode = __dp_request_read_int(client->channel, ipc_info, &bundle_type);
+                       TRACE_DEBUG("read %s type:%d", dp_print_property(ipc_info->property), bundle_type);
+                       char *raw_column = NULL;
+                       if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_ONGOING)
+                               raw_column = DP_DB_COL_NOTI_RAW_ONGOING;
+                       else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_COMPLETE)
+                               raw_column = DP_DB_COL_NOTI_RAW_COMPLETE;
+                       else if (bundle_type == DP_NOTIFICATION_BUNDLE_TYPE_FAILED)
+                               raw_column = DP_DB_COL_NOTI_RAW_FAIL;
+                       if (raw_column != NULL) {
+                               if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_NOTIFICATION, raw_column, &errorcode) < 0)
+                                       TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
+                       } else {
+                               TRACE_ERROR("invalid param set: %s type:%d", dp_print_property(ipc_info->property), bundle_type);
+                               errorcode = DP_ERROR_INVALID_PARAMETER;
                        }
-               } else {
-                       TRACE_ERROR("invalid param set: %s type:%d", dp_print_property(ipc_info->property), bundle_type);
-                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                       break;
                }
-               break;
-       }
        case DP_PROP_HTTP_HEADER: // unset value by field
-       {
-               char *header_field = NULL;
-               errorcode = __dp_request_read_string(client->channel, ipc_info, &header_field);
-               if (errorcode == DP_ERROR_NONE && header_field != NULL) {
-                       int is_present = dp_db_check_duplicated_string(client->dbhandle, ipc_info->id, DP_TABLE_HEADERS, DP_DB_COL_HEADER_FIELD, 0, header_field, &errorcode);
-                       if (is_present < 0)
-                               errorcode = DP_ERROR_DISK_BUSY;
-                       else if (is_present == 0)
-                               errorcode = DP_ERROR_FIELD_NOT_FOUND;
-                       else if (dp_db_cond_delete(client->dbhandle, ipc_info->id, DP_TABLE_HEADERS, DP_DB_COL_HEADER_FIELD, header_field, 2, &errorcode) < 0) {
-                               TRACE_ERROR("failed to unset %s for %s", dp_print_property(ipc_info->property), header_field);
-                               errorcode = DP_ERROR_DISK_BUSY;
-                       }
-               } else {
-                       if (errorcode != DP_ERROR_NONE) {
-                               TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
-                       }
-                       if (header_field == NULL) {
-                               TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
-                               errorcode = DP_ERROR_INVALID_PARAMETER;
+               {
+                       char *header_field = NULL;
+                       errorcode = __dp_request_read_string(client->channel, ipc_info, &header_field);
+                       if (errorcode == DP_ERROR_NONE && header_field != NULL) {
+                               int is_present = dp_db_check_duplicated_string(client->dbhandle, ipc_info->id, DP_TABLE_HEADERS, DP_DB_COL_HEADER_FIELD, 0, header_field, &errorcode);
+                               if (is_present < 0)
+                                       errorcode = DP_ERROR_DISK_BUSY;
+                               else if (is_present == 0)
+                                       errorcode = DP_ERROR_FIELD_NOT_FOUND;
+                               else if (dp_db_cond_delete(client->dbhandle, ipc_info->id, DP_TABLE_HEADERS, DP_DB_COL_HEADER_FIELD, header_field, 2, &errorcode) < 0) {
+                                       TRACE_ERROR("failed to unset %s for %s", dp_print_property(ipc_info->property), header_field);
+                                       errorcode = DP_ERROR_DISK_BUSY;
+                               }
+                       } else {
+                               if (errorcode != DP_ERROR_NONE)
+                                       TRACE_ERROR("failed to set %s, error:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+                               if (header_field == NULL) {
+                                       TRACE_ERROR("failed to set %s", dp_print_property(ipc_info->property));
+                                       errorcode = DP_ERROR_INVALID_PARAMETER;
+                               }
                        }
+                       free(header_field);
+                       break;
                }
-               free(header_field);
-               break;
-       }
        default:
                errorcode = DP_ERROR_INVALID_PARAMETER;
                break;
        }
        // feedback
        if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_UNSET,
-                       ipc_info->property, errorcode, 0) < 0) {
+                               ipc_info->property, errorcode, 0) < 0) {
                TRACE_ERROR("check ipc sock:%d", client->channel);
        }
        return errorcode;
@@ -1591,12 +1572,11 @@ static int __dp_call_cancel_agent(dp_request_fmt *request)
        if (request != NULL) {
                if (request->agent_id >= 0) {
                        TRACE_INFO("cancel download(%d) id: %d state:%s", request->agent_id,
-                               request->id, dp_print_state(request->state));
+                                       request->id, dp_print_state(request->state));
                        if (dp_cancel_agent_download_without_update(request->agent_id) == 0)
                                ret = 0;
                } else {
-                       TRACE_ERROR("invalid agent-id:%d id:%d", request->agent_id,
-                               request->id);
+                       TRACE_ERROR("invalid agent-id:%d id:%d", request->agent_id,     request->id);
                }
        }
        return ret;
@@ -1618,11 +1598,10 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
 
        if (ipc_info->property == DP_PROP_CREATE) {
                // check packets again
-               if (ipc_info->size != 0 || ipc_info->id != -1) {
+               if (ipc_info->size != 0 || ipc_info->id != -1)
                        errorcode = DP_ERROR_IO_ERROR;
-               } else {
+               else
                        errorcode = __dp_request_create(client, ipc_info);
-               }
        } else {
 
                // get now state.
@@ -1635,7 +1614,7 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                errorcode = DP_ERROR_ID_NOT_FOUND;
                                // feedback
                                if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_SET,
-                                               ipc_info->property, errorcode, 0) < 0) {
+                                                       ipc_info->property, errorcode, 0) < 0) {
                                        TRACE_ERROR("check ipc sock:%d", client->channel);
                                }
                                return errorcode;
@@ -1671,9 +1650,8 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                                // else push at the tail of queue.
                                                // push to queue
                                                if (dp_queue_manager_push_queue(slot, requestp) < 0) {
-                                                       if (dp_db_update_logging(client->dbhandle, ipc_info->id, DP_STATE_FAILED, DP_ERROR_QUEUE_FULL, &errorcode) < 0) {
+                                                       if (dp_db_update_logging(client->dbhandle, ipc_info->id, DP_STATE_FAILED, DP_ERROR_QUEUE_FULL, &errorcode) < 0)
                                                                TRACE_ERROR("update log sock:%d download-id:%d", client->channel, ipc_info->id);
-                                                       }
                                                        requestp->state = DP_STATE_FAILED;
                                                        requestp->error = DP_ERROR_QUEUE_FULL;
                                                        errorcode = DP_ERROR_QUEUE_FULL;
@@ -1681,9 +1659,8 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                                        dp_queue_manager_wake_up();
                                                        // notification
                                                        if (requestp->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-                                                               if (dp_notification_manager_push_notification(slot, requestp, DP_NOTIFICATION_ONGOING) < 0) {
+                                                               if (dp_notification_manager_push_notification(slot, requestp, DP_NOTIFICATION_ONGOING) < 0)
                                                                        TRACE_ERROR("failed to register notification for id:%d", ipc_info->id);
-                                                               }
                                                        }
                                                }
                                        }
@@ -1707,9 +1684,8 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                                        dp_queue_manager_clear_queue(requestp);
                                                } else if (requestp->state == DP_STATE_CONNECTING ||
                                                                requestp->state == DP_STATE_DOWNLOADING) {
-                                                       if (dp_pause_agent_download_without_update(requestp->agent_id) < 0) {
+                                                       if (dp_pause_agent_download_without_update(requestp->agent_id) < 0)
                                                                TRACE_ERROR("failed to pause download(%d) id:%d", requestp->agent_id, ipc_info->id);
-                                                       }
                                                }
                                                requestp->state = DP_STATE_PAUSED;
                                                requestp->error = DP_ERROR_NONE;
@@ -1733,18 +1709,16 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                                        dp_queue_manager_clear_queue(requestp);
                                                } else if (requestp->state == DP_STATE_CONNECTING ||
                                                                requestp->state == DP_STATE_DOWNLOADING) {
-                                                       if (__dp_call_cancel_agent(requestp) < 0) {
+                                                       if (__dp_call_cancel_agent(requestp) < 0)
                                                                TRACE_ERROR("failed to cancel download(%d) id:%d", requestp->agent_id, ipc_info->id);
-                                                       }
                                                }
                                                requestp->agent_id = -1;
                                                requestp->state = DP_STATE_CANCELED;
                                                requestp->error = DP_ERROR_NONE;
                                                if (requestp->noti_type == DP_NOTIFICATION_TYPE_COMPLETE_ONLY ||
                                                                requestp->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-                                                       if (dp_notification_manager_push_notification(slot, requestp, DP_NOTIFICATION) < 0) {
+                                                       if (dp_notification_manager_push_notification(slot, requestp, DP_NOTIFICATION) < 0)
                                                                TRACE_ERROR("failed to register notification for id:%d", ipc_info->id);
-                                                       }
                                                }
                                        }
                                }
@@ -1764,9 +1738,8 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
                                                TRACE_ERROR("update log sock:%d download-id:%d", client->channel, ipc_info->id);
                                        } else {
                                                // call da_cancel API
-                                               if (__dp_call_cancel_agent(requestp) < 0) {
+                                               if (__dp_call_cancel_agent(requestp) < 0)
                                                        TRACE_ERROR("failed to cancel download(%d) id:%d", requestp->agent_id, ipc_info->id);
-                                               }
                                        }
                                        requestp->state = DP_STATE_CANCELED;
                                }
@@ -1774,9 +1747,8 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
 
                                        if (requestp->noti_type == DP_NOTIFICATION_TYPE_COMPLETE_ONLY ||
                                                        requestp->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-                                               if (dp_notification_manager_push_notification(slot, requestp, DP_NOTIFICATION) < 0) {
+                                               if (dp_notification_manager_push_notification(slot, requestp, DP_NOTIFICATION) < 0)
                                                        TRACE_ERROR("failed to register notification for id:%d", ipc_info->id);
-                                               }
                                        }
                                }
                                requestp->agent_id = -1;
@@ -1791,7 +1763,7 @@ static int __dp_request_controls(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info
 
        // feedback
        if (dp_ipc_query(client->channel, ipc_info->id, DP_SEC_CONTROL,
-                       ipc_info->property, errorcode, 0) < 0) {
+                               ipc_info->property, errorcode, 0) < 0) {
                TRACE_ERROR("check ipc sock:%d", client->channel);
        }
 
@@ -1853,10 +1825,10 @@ static int __dp_client_requests(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info)
 
        if (errorcode != DP_ERROR_NONE) { // prechecking
                TRACE_ERROR("precheck errorcode:%s sock:%d id:%d section:%s property:%s",
-                       dp_print_errorcode(errorcode),
-                       client->channel, ipc_info->id,
-                       dp_print_section(ipc_info->section),
-                       dp_print_property(ipc_info->property));
+                               dp_print_errorcode(errorcode),
+                               client->channel, ipc_info->id,
+                               dp_print_section(ipc_info->section),
+                               dp_print_property(ipc_info->property));
 
                // clear followed packets.
                if (ipc_info->size > 0) {
@@ -1868,7 +1840,7 @@ static int __dp_client_requests(dp_client_slots_fmt *slot, dp_ipc_fmt *ipc_info)
                }
 
                if (dp_ipc_query(client->channel, ipc_info->id,
-                               ipc_info->section, ipc_info->property, errorcode, 0) < 0) {
+                                       ipc_info->section, ipc_info->property, errorcode, 0) < 0) {
                        TRACE_ERROR("check ipc sock:%d", client->channel);
                        errorcode = DP_ERROR_IO_ERROR;
                }
@@ -1905,13 +1877,11 @@ static void __dp_client_stop_all_requests(dp_client_slots_fmt *slot)
                TRACE_DEBUG("request %d stop id:%d state:%s", i, tailp->id, dp_print_state(tailp->state));
                int state = tailp->state;
                if (state == DP_STATE_CONNECTING) {
-                       if (dp_cancel_agent_download_without_update(tailp->agent_id) < 0) {
+                       if (dp_cancel_agent_download_without_update(tailp->agent_id) < 0)
                                TRACE_ERROR("failed to cancel download(%d) id:%d", tailp->agent_id, tailp->id);
-                       }
                } else if (state == DP_STATE_DOWNLOADING) {
-                       if (dp_pause_agent_download(tailp->agent_id) < 0) {
+                       if (dp_pause_agent_download(tailp->agent_id) < 0)
                                TRACE_ERROR("failed to pause download(%d) id:%d", tailp->agent_id, tailp->id);
-                       }
                }
                if (state == DP_STATE_DOWNLOADING || state == DP_STATE_CONNECTING) {
                        tailp->state = DP_STATE_QUEUED;
@@ -1919,9 +1889,8 @@ static void __dp_client_stop_all_requests(dp_client_slots_fmt *slot)
                        tailp->error = DP_ERROR_IO_EAGAIN;
                        // push to queue now
                        // in da callback, check DP_ERROR_IO_EAGAIN, then ignore.
-                       if (dp_db_update_logging(slot->client.dbhandle, tailp->id, tailp->state, DP_ERROR_NONE, &errorcode) < 0) {
+                       if (dp_db_update_logging(slot->client.dbhandle, tailp->id, tailp->state, DP_ERROR_NONE, &errorcode) < 0)
                                TRACE_ERROR("update log sock:%d download-id:%d", slot->client.channel, tailp->id);
-                       }
                        if (dp_queue_manager_push_queue(slot, tailp) < 0) {
                                TRACE_ERROR("Fail to push queueg sock:%d download-id:%d", slot->client.channel, tailp->id);
                                // FIXME later : error case. How can handle this item?
@@ -1975,11 +1944,11 @@ void *dp_client_request_thread(void *arg)
 
                memset(&timeout, 0x00, sizeof(struct timeval));
                timeout.tv_sec = DP_CARE_CLIENT_REQUEST_INTERVAL;
-               FD_ZERO(&imask );
-               FD_ZERO(&emask );
+               FD_ZERO(&imask);
+               FD_ZERO(&emask);
                FD_SET(client_sock, &imask);
                FD_SET(client_sock, &emask);
-               if (select(client_sock + 1, &imask, 0, &emask, &timeout) < 0 ) {
+               if (select(client_sock + 1, &imask, 0, &emask, &timeout) < 0) {
                        if (slot != NULL && slot->client.channel >= 0) {
                                TRACE_INFO("broadcast by client-manager");
                                CLIENT_MUTEX_LOCK(&slot->mutex);
@@ -2008,38 +1977,38 @@ void *dp_client_request_thread(void *arg)
                                errorcode = DP_ERROR_IO_ERROR;
                        } else {
                                TRACE_DEBUG("sock:%d id:%d section:%s property:%s errorcode:%s size:%d",
-                                       client_sock, ipc_info->id,
-                                       dp_print_section(ipc_info->section),
-                                       dp_print_property(ipc_info->property),
-                                       dp_print_errorcode(ipc_info->errorcode),
-                                       ipc_info->size);
+                                               client_sock, ipc_info->id,
+                                               dp_print_section(ipc_info->section),
+                                               dp_print_property(ipc_info->property),
+                                               dp_print_errorcode(ipc_info->errorcode),
+                                               ipc_info->size);
 
                                if (client->dbhandle == 0 || dp_db_check_connection(client->dbhandle) < 0) {
-                                   if (dp_db_open_client(&client->dbhandle, slot->pkgname, &errorcode) < 0) {
-                                       TRACE_ERROR("failed to open database for sock:%d errorcode:%s", client_sock, dp_print_errorcode(errorcode));
-                                       if (dp_ipc_query(client->channel, ipc_info->id,
-                                               ipc_info->section, ipc_info->property, errorcode, 0) < 0) {
-                                           TRACE_ERROR("check ipc sock:%d", client->channel);
-                                        }
-                    }
-                }
+                                       if (dp_db_open_client(&client->dbhandle, slot->pkgname, &errorcode) < 0) {
+                                               TRACE_ERROR("failed to open database for sock:%d errorcode:%s", client_sock, dp_print_errorcode(errorcode));
+                                               if (dp_ipc_query(client->channel, ipc_info->id,
+                                                                       ipc_info->section, ipc_info->property, errorcode, 0) < 0) {
+                                                       TRACE_ERROR("check ipc sock:%d", client->channel);
+                                               }
+                                       }
+                               }
 
-              if (errorcode == DP_ERROR_NONE) {
-                    // JOB
-                    errorcode = __dp_client_requests(slot, ipc_info);
-                }
+                               if (errorcode == DP_ERROR_NONE) {
+                                       // JOB
+                                       errorcode = __dp_client_requests(slot, ipc_info);
+                               }
 
                        }
                        free(ipc_info);
 
-                       pthread_setcancelstate (PTHREAD_CANCEL_ENABLE,  NULL);
+                       pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                        CLIENT_MUTEX_UNLOCK(&slot->mutex);
 
                        if (errorcode == DP_ERROR_IO_ERROR ||
                                        errorcode == DP_ERROR_OUT_OF_MEMORY ||
                                        errorcode == DP_ERROR_INVALID_PARAMETER) {
                                TRACE_ERROR("disconnect client errorcode:%s sock:%d",
-                                       dp_print_errorcode(errorcode), client_sock);
+                                               dp_print_errorcode(errorcode), client_sock);
                                break;
                        }
 
@@ -2054,15 +2023,13 @@ void *dp_client_request_thread(void *arg)
                                dp_client_clear_requests(slot);
 
                                if (client->dbhandle != 0) {
-                                   int sql_errorcode = DP_ERROR_NONE;
-                                   // 2. maintain only 1000 rows for each client
-                                   if (dp_db_limit_rows(client->dbhandle, DP_TABLE_LOGGING, DP_LOG_DB_LIMIT_ROWS, &sql_errorcode) < 0) {
-                                       TRACE_INFO("limit rows error:%s", dp_print_errorcode(sql_errorcode));
-                                   }
-                                   // 3. maintain for 48 hours
-                                   if (dp_db_limit_time(client->dbhandle, DP_TABLE_LOGGING, DP_CARE_CLIENT_INFO_PERIOD, &sql_errorcode) < 0) {
-                                       TRACE_INFO("limit rows error:%s", dp_print_errorcode(sql_errorcode));
-                                   }
+                                       int sql_errorcode = DP_ERROR_NONE;
+                                       // 2. maintain only 1000 rows for each client
+                                       if (dp_db_limit_rows(client->dbhandle, DP_TABLE_LOGGING, DP_LOG_DB_LIMIT_ROWS, &sql_errorcode) < 0)
+                                               TRACE_INFO("limit rows error:%s", dp_print_errorcode(sql_errorcode));
+                                       // 3. maintain for 48 hours
+                                       if (dp_db_limit_time(client->dbhandle, DP_TABLE_LOGGING, DP_CARE_CLIENT_INFO_PERIOD, &sql_errorcode) < 0)
+                                               TRACE_INFO("limit rows error:%s", dp_print_errorcode(sql_errorcode));
                                }
                                // 4. if no requests, exit by itself.
                                if (slot->client.requests == NULL) {
index 80185eb..eea0bd2 100755 (executable)
@@ -114,22 +114,17 @@ static int __rebuild_client_tables(sqlite3 *handle)
 
        if (__check_table(handle, DP_TABLE_LOGGING) < 0) {
                ret = sqlite3_exec(handle, DP_SCHEMA_LOGGING, 0, 0, 0);
-               if (ret == SQLITE_OK) {
+               if (ret == SQLITE_OK)
                        ret = sqlite3_exec(handle, DP_SCHEMA_LOGGING_INDEX, 0, 0, 0);
-               }
        }
-       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_DOWNLOAD) < 0) {
+       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_DOWNLOAD) < 0)
                ret = sqlite3_exec(handle, DP_SCHEMA_DOWNLOAD, 0, 0, 0);
-       }
-       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_REQUEST) < 0) {
+       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_REQUEST) < 0)
                ret = sqlite3_exec(handle, DP_SCHEMA_REQUEST, 0, 0, 0);
-       }
-       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_HEADERS) < 0) {
+       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_HEADERS) < 0)
                ret = sqlite3_exec(handle, DP_SCHEMA_HEADER, 0, 0, 0);
-       }
-       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_NOTIFICATION) < 0) {
+       if (ret == SQLITE_OK && __check_table(handle, DP_TABLE_NOTIFICATION) < 0)
                ret = sqlite3_exec(handle, DP_SCHEMA_NOTIFICATION, 0, 0, 0);
-       }
        if (ret != SQLITE_OK) {
                TRACE_ERROR("create tables:%d error:%s", ret, sqlite3_errmsg(handle));
                return -1;
@@ -140,9 +135,8 @@ static int __rebuild_client_tables(sqlite3 *handle)
 static int __rebuild_client_manager_tables(sqlite3 *handle)
 {
        int ret = SQLITE_OK;
-       if (__check_table(handle, DP_TABLE_CLIENTS) < 0) {
+       if (__check_table(handle, DP_TABLE_CLIENTS) < 0)
                ret = sqlite3_exec(handle, DP_SCHEMA_CLIENTS, 0, 0, 0);
-       }
        if (ret != SQLITE_OK) {
                TRACE_ERROR("create tables:%d error:%s", ret, sqlite3_errmsg(handle));
                return -1;
@@ -152,39 +146,39 @@ static int __rebuild_client_manager_tables(sqlite3 *handle)
 
 static int __db_open(sqlite3 **handle, char *database, int *errorcode)
 {
-    if (sqlite3_open_v2(database, handle, SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK) {
-        int sqlerrcode = sqlite3_errcode(*handle);
-        TRACE_ERROR("database open error(%d):%s", sqlerrcode, sqlite3_errmsg(*handle));
-        if (sqlerrcode == SQLITE_CORRUPT) { // remove & re-create
-            TRACE_SECURE_INFO("unlink [%s]", database);
-            unlink(database);
-            sqlerrcode = SQLITE_CANTOPEN;
-        }
-        if (sqlerrcode == SQLITE_CANTOPEN) {
-            *handle = 0;
-            // create empty database
-            if (sqlite3_open(database, handle) != SQLITE_OK ) {
-                sqlerrcode = sqlite3_errcode(*handle);
-                TRACE_SECURE_ERROR("failed to create %s error:%d", database, sqlerrcode);
-                TRACE_ERROR("database new error(%d):%s", sqlerrcode, sqlite3_errmsg(*handle));
-                if (sqlerrcode == SQLITE_FULL || sqlerrcode == SQLITE_CANTOPEN) { // can not create temporary file for connection
-                    *errorcode = DP_ERROR_NO_SPACE; // DP_ERROR_OUT_OF_MEMORY
-                } else {
-                    *errorcode = DP_ERROR_DISK_BUSY;
-                    unlink(database);
-                }
-                *handle = 0;
-                return -1;
-            }
-        } else {
-            TRACE_ERROR("can not handle this error(%d):%s", sqlerrcode, sqlite3_errmsg(*handle));
-            *errorcode = DP_ERROR_OUT_OF_MEMORY;
-            *handle = 0;
-            return -1;
-        }
-    }
-    __basic_property(*handle);
-    return 0;
+       if (sqlite3_open_v2(database, handle, SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK) {
+               int sqlerrcode = sqlite3_errcode(*handle);
+               TRACE_ERROR("database open error(%d):%s", sqlerrcode, sqlite3_errmsg(*handle));
+               if (sqlerrcode == SQLITE_CORRUPT) { // remove & re-create
+                       TRACE_SECURE_INFO("unlink [%s]", database);
+                       unlink(database);
+                       sqlerrcode = SQLITE_CANTOPEN;
+               }
+               if (sqlerrcode == SQLITE_CANTOPEN) {
+                       *handle = 0;
+                       // create empty database
+                       if (sqlite3_open(database, handle) != SQLITE_OK) {
+                               sqlerrcode = sqlite3_errcode(*handle);
+                               TRACE_SECURE_ERROR("failed to create %s error:%d", database, sqlerrcode);
+                               TRACE_ERROR("database new error(%d):%s", sqlerrcode, sqlite3_errmsg(*handle));
+                               if (sqlerrcode == SQLITE_FULL || sqlerrcode == SQLITE_CANTOPEN) { // can not create temporary file for connection
+                                       *errorcode = DP_ERROR_NO_SPACE; // DP_ERROR_OUT_OF_MEMORY
+                               } else {
+                                       *errorcode = DP_ERROR_DISK_BUSY;
+                                       unlink(database);
+                               }
+                               *handle = 0;
+                               return -1;
+                       }
+               } else {
+                       TRACE_ERROR("can not handle this error(%d):%s", sqlerrcode, sqlite3_errmsg(*handle));
+                       *errorcode = DP_ERROR_OUT_OF_MEMORY;
+                       *handle = 0;
+                       return -1;
+               }
+       }
+       __basic_property(*handle);
+       return 0;
 }
 
 int dp_db_check_connection(void *handle)
@@ -205,16 +199,16 @@ int dp_db_check_connection(void *handle)
 
 int dp_db_open_client_manager(void **handle, int *errorcode)
 {
-    if (*handle == 0) {
-        char *database = sqlite3_mprintf("%s/%s", DATABASE_DIR, DP_DBFILE_CLIENTS);
-        if (database == NULL) {
-            TRACE_ERROR("failed to make clients database file path");
-            *errorcode = DP_ERROR_OUT_OF_MEMORY;
-            return -1;
-        }
-        if (__db_open((sqlite3 **)handle, database, errorcode) < 0) {
-            TRACE_ERROR("failed to open clients database file");
-            *handle = 0;
+       if (*handle == 0) {
+               char *database = sqlite3_mprintf("%s/%s", DATABASE_DIR, DP_DBFILE_CLIENTS);
+               if (database == NULL) {
+                       TRACE_ERROR("failed to make clients database file path");
+                       *errorcode = DP_ERROR_OUT_OF_MEMORY;
+                       return -1;
+               }
+               if (__db_open((sqlite3 **)handle, database, errorcode) < 0) {
+                       TRACE_ERROR("failed to open clients database file");
+                       *handle = 0;
                } else {
                        if (__check_integrity(*handle) < 0) {
                                // recovery database file
@@ -236,7 +230,7 @@ int dp_db_open_client_manager(void **handle, int *errorcode)
                }
                sqlite3_free(database);
        }
-    return *handle ? 0 : -1;
+       return *handle ? 0 : -1;
 }
 
 static char *__dp_db_get_client_db_path(char *pkgname)
@@ -268,11 +262,10 @@ int dp_db_remove_database(char *pkgname, long now_time, long diff_time)
                        if (dp_remove_file(database_journal) < 0) {
                                TRACE_ERROR("failed to remove db journal file path");
                        } else {
-                               if (dp_remove_file(database) < 0) {
+                               if (dp_remove_file(database) < 0)
                                        TRACE_ERROR("failed to remove db file path");
-                               } else {
+                               else
                                        result = 0;
-                               }
                        }
                        sqlite3_free(database_journal);
                }
@@ -302,27 +295,27 @@ int dp_db_open_client_v2(void **handle, char *pkgname)
 
 int dp_db_open_client(void **handle, char *pkgname, int *errorcode)
 {
-    if (*handle == 0) {
-        char *database = __dp_db_get_client_db_path(pkgname);
-        if (database == NULL) {
-            TRACE_ERROR("failed to make db file path");
-            *errorcode = DP_ERROR_OUT_OF_MEMORY;
-            return -1;
-        }
-        if (__db_open((sqlite3 **)handle, database, errorcode) < 0) {
-            TRACE_SECURE_ERROR("failed to open %s", database);
-            *handle = 0;
-        } else {
-            // whenever open new handle, check all tables. it's simple
-            if (__rebuild_client_tables(*handle) < 0) {
-                *errorcode = DP_ERROR_NO_SPACE;
-                dp_db_close(*handle);
-                *handle = 0;
-            }
-        }
-        sqlite3_free(database);
-    }
-    return *handle ? 0 : -1;
+       if (*handle == 0) {
+               char *database = __dp_db_get_client_db_path(pkgname);
+               if (database == NULL) {
+                       TRACE_ERROR("failed to make db file path");
+                       *errorcode = DP_ERROR_OUT_OF_MEMORY;
+                       return -1;
+               }
+               if (__db_open((sqlite3 **)handle, database, errorcode) < 0) {
+                       TRACE_SECURE_ERROR("failed to open %s", database);
+                       *handle = 0;
+               } else {
+                       // whenever open new handle, check all tables. it's simple
+                       if (__rebuild_client_tables(*handle) < 0) {
+                               *errorcode = DP_ERROR_NO_SPACE;
+                               dp_db_close(*handle);
+                               *handle = 0;
+                       }
+               }
+               sqlite3_free(database);
+       }
+       return *handle ? 0 : -1;
 }
 
 void dp_db_close(void *handle)
@@ -375,34 +368,34 @@ int dp_db_get_errorcode(void *handle)
        if (handle == 0) {\
                TRACE_ERROR("check connection handle");\
                return -1;\
-       }\
-} while(0)
+       } \
+} while (0)
 
 #define DP_DB_BUFFER_NULL_CHECK(buffer) do {\
        if (buffer == NULL) {\
                TRACE_ERROR("check available memory");\
                return -1;\
-       }\
-} while(0)
+       } \
+} while (0)
 
 #define DP_DB_BASIC_EXCEPTION_CHECK do {\
        if (errorcode != SQLITE_OK) {\
                if ((*error = dp_db_get_errorcode(handle)) == DP_ERROR_NONE)\
-                       *error = DP_ERROR_INVALID_PARAMETER;\
+               *error = DP_ERROR_INVALID_PARAMETER;\
                __dp_finalize(stmt);\
                return -1;\
-       }\
-} while(0)
+       } \
+} while (0)
 
 #define DP_DB_WRITE_STEP_EXCEPTION_CHECK do {\
        errorcode = sqlite3_step(stmt);\
        __dp_finalize(stmt);\
        if (errorcode != SQLITE_DONE) {\
                if ((*error = dp_db_get_errorcode(handle)) == DP_ERROR_NONE)\
-                       *error = DP_ERROR_INVALID_PARAMETER;\
+               *error = DP_ERROR_INVALID_PARAMETER;\
                return -1;\
-       }\
-} while(0)
+       } \
+} while (0)
 
 int dp_db_get_ids(void *handle, const char *table, char *idcolumn, int *ids, const char *where, const int limit, char *ordercolumn, char *ordering, int *error)
 {
@@ -414,12 +407,12 @@ int dp_db_get_ids(void *handle, const char *table, char *idcolumn, int *ids, con
 
        char *order_query = NULL;
        if (ordercolumn != NULL)
-               order_query = sqlite3_mprintf("ORDER BY %s %s", ordercolumn, ( ordering == NULL ? "ASC" : ordering ));
+               order_query = sqlite3_mprintf("ORDER BY %s %s", ordercolumn, (ordering == NULL ? "ASC" : ordering));
 
        if (idcolumn == NULL)
                idcolumn = DP_DB_COL_ID;
 
-       char *query = sqlite3_mprintf("SELECT %s FROM %s %s %s LIMIT ?", idcolumn, table, ( where == NULL ? "" : where ), ( order_query == NULL ? "" : order_query ));
+       char *query = sqlite3_mprintf("SELECT %s FROM %s %s %s LIMIT ?", idcolumn, table, (where == NULL ? "" : where), (order_query == NULL ? "" : order_query));
        DP_DB_BUFFER_NULL_CHECK(query);
        errorcode = sqlite3_prepare_v2(handle, query, -1, &stmt, NULL);
        //TRACE_DEBUG("debug query:%s", query);
@@ -448,10 +441,10 @@ int dp_db_get_crashed_ids(void *handle, const char *table, int *ids, const int l
        // make where.
        //get ids if state is QUEUED, CONNECTING or DOWNLOADING with auto_download
        char *where = sqlite3_mprintf("WHERE %s IS 1 AND (%s IS %d OR %s IS %d OR %s IS %d)",
-       DP_DB_COL_AUTO_DOWNLOAD,
-       DP_DB_COL_STATE, DP_STATE_DOWNLOADING,
-       DP_DB_COL_STATE, DP_STATE_CONNECTING,
-       DP_DB_COL_STATE, DP_STATE_QUEUED);
+                       DP_DB_COL_AUTO_DOWNLOAD,
+                       DP_DB_COL_STATE, DP_STATE_DOWNLOADING,
+                       DP_DB_COL_STATE, DP_STATE_CONNECTING,
+                       DP_DB_COL_STATE, DP_STATE_QUEUED);
        if (where != NULL) {
                int rows_count = dp_db_get_ids(handle, table, DP_DB_COL_ID, ids, where, limit, NULL, NULL, error);
                sqlite3_free(where);
@@ -481,11 +474,11 @@ int dp_db_check_duplicated_int(void *handle, const char *table, const char *colu
 
        *error = DP_ERROR_NONE;
        errorcode = sqlite3_step(stmt);
-       if (errorcode == SQLITE_ROW) {
+       if (errorcode == SQLITE_ROW)
                count = sqlite3_column_int(stmt, 0);
-       } else {
+       else
                count = 0;
-       }
+
        __dp_finalize(stmt);
        return count;
 }
@@ -499,9 +492,9 @@ int dp_db_check_duplicated_string(void *handle, const int id, const char *table,
        sqlite3_stmt *stmt = NULL;
 
        char *id_check = NULL;
-       if (id >= 0) {
+       if (id >= 0)
                id_check = sqlite3_mprintf("AND %s IS ?", DP_DB_COL_ID);
-       }
+
        char *query = NULL;
        if (is_like > 0)
                query = sqlite3_mprintf("SELECT count(*) FROM %s WHERE %s LIKE ? %s", table, column, (id_check == NULL ? "" : id_check));
@@ -524,11 +517,11 @@ int dp_db_check_duplicated_string(void *handle, const int id, const char *table,
 
        *error = DP_ERROR_NONE;
        errorcode = sqlite3_step(stmt);
-       if (errorcode == SQLITE_ROW) {
+       if (errorcode == SQLITE_ROW)
                count = sqlite3_column_int(stmt, 0);
-       } else {
+       else
                count = 0;
-       }
+
        __dp_finalize(stmt);
        return count;
 }
@@ -555,7 +548,7 @@ int dp_db_update_client_info(void *handle, const char *pkgname, const char *smac
 
        if (is_update == 0)
                query = sqlite3_mprintf(
-                       "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s) VALUES (?, ?, %d, %d, 0, DATETIME('NOW'), DATETIME('NOW'))",
+                               "INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s) VALUES (?, ?, %d, %d, 0, DATETIME('NOW'), DATETIME('NOW'))",
                                DP_TABLE_CLIENTS, DP_DB_COL_SMACK_LABEL, DP_DB_COL_PACKAGE, DP_DB_COL_UID,
                                DP_DB_COL_GID, DP_DB_COL_REQUEST_COUNT,
                                DP_DB_COL_CREATE_TIME, DP_DB_COL_ACCESS_TIME, uid, gid);
@@ -823,7 +816,7 @@ int dp_db_get_property_string(void *handle, const int id, const char *table, con
                                        TRACE_ERROR("check available system memory");
                                        *error = DP_ERROR_OUT_OF_MEMORY;
                                }
-                       }else {
+                       } else {
                                TRACE_DEBUG("no data");
                                *error = DP_ERROR_NO_DATA;
                        }
@@ -1242,7 +1235,7 @@ int dp_db_get_cond_string(void *handle, const char *table, char *wherecolumn, co
                                        TRACE_ERROR("check available system memory");
                                        *error = DP_ERROR_OUT_OF_MEMORY;
                                }
-                       }else {
+                       } else {
                                TRACE_DEBUG("no data");
                                *error = DP_ERROR_NO_DATA;
                        }
@@ -1337,8 +1330,8 @@ int dp_db_get_http_headers_list(void *handle, int id, char **headers, int *error
 
        errorcode =
                sqlite3_prepare_v2(handle,
-                       "SELECT header_field, header_data FROM header WHERE id = ?",
-                       -1, &stmt, NULL);
+                               "SELECT header_field, header_data FROM header WHERE id = ?",
+                               -1, &stmt, NULL);
 
        DP_DB_BASIC_EXCEPTION_CHECK;
 
@@ -1376,45 +1369,45 @@ int dp_db_get_http_headers_list(void *handle, int id, char **headers, int *error
 
 int dp_db_get_max_download_id(void *handle, const char *table, int *pvalue, int *error)
 {
-    TRACE_DEBUG("");
-    int errorcode = SQLITE_OK;
-    sqlite3_stmt *stmt = NULL;
-    *error = DP_ERROR_NONE;
-    DP_DB_PARAM_NULL_CHECK;
-
-    char *query = sqlite3_mprintf("SELECT MAX(%s) FROM %s", DP_DB_COL_ID, table);
-    DP_DB_BUFFER_NULL_CHECK(query);
-    //TRACE_DEBUG("debug query:%s", query);
-    errorcode = sqlite3_prepare_v2(handle, query, -1, &stmt, NULL);
-    DP_DB_BASIC_EXCEPTION_CHECK;
-
-    errorcode = sqlite3_step(stmt);
-    if (errorcode == SQLITE_ROW) {
-        int data_type = sqlite3_column_type(stmt, 0);
-        if (data_type == SQLITE_INTEGER) {
-            int recv_int = sqlite3_column_int(stmt, 0);
-            *pvalue = recv_int;
-        } else if (data_type == SQLITE_NULL) {
-            /* table has no any entry */
-            TRACE_DEBUG("table has no entry");
-            *error = DP_ERROR_NO_DATA;
-        } else {
-            TRACE_ERROR("check column type:%d", data_type);
-            *error = DP_ERROR_INVALID_PARAMETER;
-        }
-    } else if (errorcode == SQLITE_DONE) {
-        TRACE_DEBUG("no data");
-        *error = DP_ERROR_NO_DATA;
-    } else {
-        if ((*error = dp_db_get_errorcode(handle)) == DP_ERROR_NONE) {
-            TRACE_ERROR("ERROR :: unknown");
-            *error = DP_ERROR_DISK_BUSY;
-        }
-    }
-    __dp_finalize(stmt);
-    if (*error != DP_ERROR_NONE)
-        return -1;
-    return 0;
+       TRACE_DEBUG("");
+       int errorcode = SQLITE_OK;
+       sqlite3_stmt *stmt = NULL;
+       *error = DP_ERROR_NONE;
+       DP_DB_PARAM_NULL_CHECK;
+
+       char *query = sqlite3_mprintf("SELECT MAX(%s) FROM %s", DP_DB_COL_ID, table);
+       DP_DB_BUFFER_NULL_CHECK(query);
+       //TRACE_DEBUG("debug query:%s", query);
+       errorcode = sqlite3_prepare_v2(handle, query, -1, &stmt, NULL);
+       DP_DB_BASIC_EXCEPTION_CHECK;
+
+       errorcode = sqlite3_step(stmt);
+       if (errorcode == SQLITE_ROW) {
+               int data_type = sqlite3_column_type(stmt, 0);
+               if (data_type == SQLITE_INTEGER) {
+                       int recv_int = sqlite3_column_int(stmt, 0);
+                       *pvalue = recv_int;
+               } else if (data_type == SQLITE_NULL) {
+                       /* table has no any entry */
+                       TRACE_DEBUG("table has no entry");
+                       *error = DP_ERROR_NO_DATA;
+               } else {
+                       TRACE_ERROR("check column type:%d", data_type);
+                       *error = DP_ERROR_INVALID_PARAMETER;
+               }
+       } else if (errorcode == SQLITE_DONE) {
+               TRACE_DEBUG("no data");
+               *error = DP_ERROR_NO_DATA;
+       } else {
+               if ((*error = dp_db_get_errorcode(handle)) == DP_ERROR_NONE) {
+                       TRACE_ERROR("ERROR :: unknown");
+                       *error = DP_ERROR_DISK_BUSY;
+               }
+       }
+       __dp_finalize(stmt);
+       if (*error != DP_ERROR_NONE)
+               return -1;
+       return 0;
 }
 
 
index 542e9d4..9916be5 100755 (executable)
@@ -46,18 +46,18 @@ int main(int argc, char **argv)
                TRACE_ERROR("failed to init network-manager");
                return 0;
        }
-    //Requested By platform team, It should be in main thread.
-    curl_global_init(CURL_GLOBAL_ALL);
+       //Requested By platform team, It should be in main thread.
+       curl_global_init(CURL_GLOBAL_ALL);
 
-    // create a thread for main thread
-    if (pthread_create(&g_client_manager_tid, NULL, dp_client_manager, (void *)event_loop) != 0) {
-        TRACE_ERROR("failed to create main thread");
-        curl_global_cleanup();
-        return 0;
-    } else {
-        pthread_detach(g_client_manager_tid);
-        TRACE_INFO("download main thread is created[%lu]", g_client_manager_tid);
-    }
+       // create a thread for main thread
+       if (pthread_create(&g_client_manager_tid, NULL, dp_client_manager, (void *)event_loop) != 0) {
+               TRACE_ERROR("failed to create main thread");
+               curl_global_cleanup();
+               return 0;
+       } else {
+               pthread_detach(g_client_manager_tid);
+               TRACE_INFO("download main thread is created[%lu]", g_client_manager_tid);
+       }
 
        TRACE_INFO("g main loop is started");
        g_main_loop_run(event_loop);
index a8b5c69..84c6d06 100755 (executable)
@@ -71,10 +71,8 @@ static int __dp_network_wifi_direct_status()
 }
 
 // support WIFI-Direct
-static void __dp_network_wifi_direct_changed_cb
-       (wifi_direct_error_e error_code,
-       wifi_direct_connection_state_e connection_state,
-       const char *mac_address, void *data)
+static void __dp_network_wifi_direct_changed_cb(wifi_direct_error_e error_code,
+               wifi_direct_connection_state_e connection_state, const char *mac_address, void *data)
 {
        pthread_mutex_lock(&g_dp_network_mutex);
        if (connection_state == WIFI_DIRECT_CONNECTION_RSP) {
@@ -113,7 +111,7 @@ static int __dp_get_network_connection_status(connection_h connection, connectio
                connection_cellular_state_e cellular_state;
                cellular_state = CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE;
                if (connection_get_cellular_state(connection,
-                               &cellular_state) != CONNECTION_ERROR_NONE) {
+                                       &cellular_state) != CONNECTION_ERROR_NONE) {
                        TRACE_ERROR("Failed connection_get_cellular_state");
                } else {
                        if (cellular_state == CONNECTION_CELLULAR_STATE_CONNECTED) {
@@ -125,7 +123,7 @@ static int __dp_get_network_connection_status(connection_h connection, connectio
                connection_ethernet_state_e ethernet_state;
                ethernet_state = CONNECTION_ETHERNET_STATE_DISCONNECTED;
                if (connection_get_ethernet_state(connection,
-                               &ethernet_state) != CONNECTION_ERROR_NONE) {
+                                       &ethernet_state) != CONNECTION_ERROR_NONE) {
                        TRACE_ERROR("Failed connection_get_ethernet_state");
                } else {
                        if (ethernet_state == CONNECTION_ETHERNET_STATE_CONNECTED) {
@@ -137,11 +135,11 @@ static int __dp_get_network_connection_status(connection_h connection, connectio
                TRACE_INFO("DISCONNECTED");
                network_type = DP_NETWORK_OFF;
        }
-    pthread_mutex_lock(&g_dp_network_mutex);
+       pthread_mutex_lock(&g_dp_network_mutex);
 
-    g_network_status = network_type;
+       g_network_status = network_type;
 
-    pthread_mutex_unlock(&g_dp_network_mutex);
+       pthread_mutex_unlock(&g_dp_network_mutex);
 
        return network_type;
 }
@@ -222,8 +220,8 @@ int dp_network_connection_init()
                return -1;
        }
        if ((retcode = connection_set_type_changed_cb(g_network_connection,
-                       __dp_network_connection_type_changed_cb, NULL)) !=
-                               CONNECTION_ERROR_NONE) {
+                                       __dp_network_connection_type_changed_cb, NULL)) !=
+                       CONNECTION_ERROR_NONE) {
                TRACE_ERROR("Failed connection_set_type_changed_cb [%d]", retcode);
                connection_destroy(g_network_connection);
                g_network_connection = 0;
@@ -231,8 +229,8 @@ int dp_network_connection_init()
        }
 
        if ((retcode = connection_set_ip_address_changed_cb
-                       (g_network_connection, __dp_network_connection_ip_changed_cb,
-                               NULL)) != CONNECTION_ERROR_NONE) {
+                               (g_network_connection, __dp_network_connection_ip_changed_cb,
+                                NULL)) != CONNECTION_ERROR_NONE) {
                TRACE_ERROR("Failed __dp_network_connection_ip_changed_cb [%d]", retcode);
                connection_destroy(g_network_connection);
                g_network_connection = 0;
index 57164fd..7e2b0ef 100644 (file)
@@ -131,9 +131,8 @@ int __dp_notification_queue_pop(dp_notification_queue_fmt **queue, void **slot,
                        TRACE_DEBUG("queue error slot:%p id:%d", popp->slot, popp->id);
                } else {
                        *slot = popp->slot;
-                       if (request != NULL) {
+                       if (request != NULL)
                                *request = popp->request;
-                       }
                        *id = popp->id;
                        *state = popp->state;
                        if (noti_priv_id != NULL)
@@ -181,9 +180,8 @@ int __dp_notification_queue_ongoing_pop(dp_notification_queue_fmt **queue, void
                        TRACE_DEBUG("queue error slot:%p id:%d", popp->slot, popp->id);
                } else {
                        *slot = popp->slot;
-                       if (request != NULL) {
+                       if (request != NULL)
                                *request = popp->request;
-                       }
                        *id = popp->id;
                        *state = popp->state;
                        if (received_size != NULL)
@@ -339,9 +337,8 @@ static void __dp_notification_manager_check_notification()
                                        if (request != NULL && request->id == download_id && request->noti_priv_id >= 0) {
                                                noti_priv_id = request->noti_priv_id;
                                                request->noti_priv_id = -1;
-                                               if (dp_db_replace_property(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_PRIV_ID, (void *)&request->noti_priv_id, 0, 0, &errorcode) < 0) {
+                                               if (dp_db_replace_property(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_PRIV_ID, (void *)&request->noti_priv_id, 0, 0, &errorcode) < 0)
                                                        TRACE_ERROR("failed to set priv_id id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                                               }
                                        }
                                        CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                }
@@ -379,12 +376,10 @@ static void __dp_notification_manager_check_notification()
                                        if (noti_priv_id < 0) {
                                                TRACE_ERROR("failed to register notification for id:%d", download_id);
                                        } else {
-                                               if (request != NULL && request->id == download_id) {
+                                               if (request != NULL && request->id == download_id)
                                                        request->noti_priv_id = noti_priv_id;
-                                               }
-                                               if (dp_db_replace_property(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_PRIV_ID, (void *)&noti_priv_id, 0, 0, &errorcode) < 0) {
+                                               if (dp_db_replace_property(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_PRIV_ID, (void *)&noti_priv_id, 0, 0, &errorcode) < 0)
                                                        TRACE_ERROR("failed to set priv_id id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                                               }
                                        }
                                        CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                }
@@ -400,9 +395,8 @@ static void __dp_notification_manager_check_notification()
                                if (CLIENT_MUTEX_CHECKLOCK(&slot->mutex) == 0) {
                                        if (request != NULL && request->id == download_id) {
                                                request_id = download_id;
-                                               if (request->noti_priv_id >= 0) {
+                                               if (request->noti_priv_id >= 0)
                                                        noti_priv_id = request->noti_priv_id;
-                                               }
                                        }
                                        CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                } else {
@@ -428,20 +422,18 @@ static void __dp_notification_manager_check_notification()
                                        unsigned length = 0;
                                        if (CLIENT_MUTEX_CHECKLOCK(&slot->mutex) == 0) {
                                                if (request != NULL) {
-                                                       if (dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (unsigned char **)&subject, &length, &errorcode) < 0) {
+                                                       if (dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (unsigned char **)&subject, &length, &errorcode) < 0)
                                                                TRACE_ERROR("failed to get subject id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                                                       } else if (subject == NULL && dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (unsigned char **)&subject, &length, &errorcode) < 0) {
+                                                       else if (subject == NULL && dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (unsigned char **)&subject, &length, &errorcode) < 0)
                                                                TRACE_ERROR("failed to get content_name id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                                                       }
                                                }
                                                CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                        }
                                }
 
                                if (noti_type > DP_NOTIFICATION_ONGOING) { // update
-                                       if (noti_priv_id >= 0 && dp_notification_ongoing_update(noti_priv_id, received_size, file_size, subject) < 0) {
+                                       if (noti_priv_id >= 0 && dp_notification_ongoing_update(noti_priv_id, received_size, file_size, subject) < 0)
                                                TRACE_ERROR("failed to update ongoing for id:%d", download_id);
-                                       }
                                } else { // new ongoing
                                        if (noti_priv_id >= 0) {
                                                TRACE_DEBUG("clear ongoing id:%d noti_priv_id:%d", download_id, noti_priv_id);
@@ -452,9 +444,8 @@ static void __dp_notification_manager_check_notification()
                                        unsigned char *raws_buffer = NULL;
                                        unsigned length = 0;
                                        if (CLIENT_MUTEX_CHECKLOCK(&slot->mutex) == 0) {
-                                               if (dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_RAW_ONGOING, &raws_buffer, &length, &errorcode) < 0) {
+                                               if (dp_db_get_property_string(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_RAW_ONGOING, &raws_buffer, &length, &errorcode) < 0)
                                                        TRACE_DEBUG("failed to get bundle raws id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                                               }
                                                CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                        }
                                        noti_priv_id = dp_notification_ongoing_new(slot->pkgname, subject, raws_buffer, length);
@@ -466,9 +457,8 @@ static void __dp_notification_manager_check_notification()
                                                if (CLIENT_MUTEX_CHECKLOCK(&slot->mutex) == 0) {
                                                        if (request != NULL)
                                                                request->noti_priv_id = noti_priv_id;
-                                                       if (dp_db_replace_property(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_PRIV_ID, (void *)&noti_priv_id, 0, 0, &errorcode) < 0) {
+                                                       if (dp_db_replace_property(slot->client.dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_PRIV_ID, (void *)&noti_priv_id, 0, 0, &errorcode) < 0)
                                                                TRACE_ERROR("failed to set priv_id id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                                                       }
                                                        CLIENT_MUTEX_UNLOCK(&slot->mutex);
                                                }
                                        }
index cf35bbb..e0ee036 100755 (executable)
 
 #define DP_MAX_ICONS_TABLE_COUNT 15
 
-char *file_icons_table[DP_MAX_ICONS_TABLE_COUNT]={
-               //unknown file type
-               DP_NOTIFICATION_UNKNOWN_ICON_PATH,
-               //image
-               DP_NOTIFICATION_IMAGE_ICON_PATH,
-               //video
-               DP_NOTIFICATION_VIDEO_ICON_PATH,
-               // audio /music
-               DP_NOTIFICATION_MUSIC_ICON_PATH,
-               // PDF
-               DP_NOTIFICATION_PDF_ICON_PATH,
-               // word
-               DP_NOTIFICATION_WORD_ICON_PATH,
-               // ppt
-               DP_NOTIFICATION_PPT_ICON_PATH,
-               // excel
-               DP_NOTIFICATION_EXCEL_ICON_PATH,
-               // html
-               DP_NOTIFICATION_HTML_ICON_PATH,
-               // txt
-               DP_NOTIFICATION_TEXT_ICON_PATH,
-               // DRM
-               DP_NOTIFICATION_DRM_ICON_PATH,
-               DP_NOTIFICATION_DRM_ICON_PATH,
-               DP_NOTIFICATION_FALSH_ICON_PATH,
-               DP_NOTIFICATION_TPK_ICON_PATH,
-               DP_NOTIFICATION_VCAL_ICON_PATH,
+char *file_icons_table[DP_MAX_ICONS_TABLE_COUNT] = {
+       //unknown file type
+       DP_NOTIFICATION_UNKNOWN_ICON_PATH,
+       //image
+       DP_NOTIFICATION_IMAGE_ICON_PATH,
+       //video
+       DP_NOTIFICATION_VIDEO_ICON_PATH,
+       // audio /music
+       DP_NOTIFICATION_MUSIC_ICON_PATH,
+       // PDF
+       DP_NOTIFICATION_PDF_ICON_PATH,
+       // word
+       DP_NOTIFICATION_WORD_ICON_PATH,
+       // ppt
+       DP_NOTIFICATION_PPT_ICON_PATH,
+       // excel
+       DP_NOTIFICATION_EXCEL_ICON_PATH,
+       // html
+       DP_NOTIFICATION_HTML_ICON_PATH,
+       // txt
+       DP_NOTIFICATION_TEXT_ICON_PATH,
+       // DRM
+       DP_NOTIFICATION_DRM_ICON_PATH,
+       DP_NOTIFICATION_DRM_ICON_PATH,
+       DP_NOTIFICATION_FALSH_ICON_PATH,
+       DP_NOTIFICATION_TPK_ICON_PATH,
+       DP_NOTIFICATION_VCAL_ICON_PATH,
 };
 
 static const char *__dp_noti_error_str(int err)
@@ -167,11 +167,11 @@ char *__dp_noti_get_sender(char *url)
                return NULL;
 
        found = strstr(url, "://");
-       if (found != NULL) {
+       if (found != NULL)
                temp = found + 3;
-       } else {
+       else
                temp = url;
-       }
+
        found = strchr(temp, '/');
        if (found != NULL) {
                int len = 0;
@@ -182,8 +182,8 @@ char *__dp_noti_get_sender(char *url)
                snprintf(sender, len + 1, "%s", temp);
        } else {
                sender = dp_strdup(temp);
-        if (sender == NULL)
-            return NULL;
+               if (sender == NULL)
+                       return NULL;
        }
 
        // For credential URL
@@ -255,9 +255,8 @@ void dp_notification_clear_ongoings()
 {
        int err = NOTIFICATION_ERROR_NONE;
        err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_DEBUG("[FAIL] clear noti [%s]", __dp_noti_error_str(err));
-       }
        return;
 }
 
@@ -280,16 +279,14 @@ int dp_notification_ongoing_new(const char *pkgname, const char *subject, unsign
                                NOTIFICATION_TEXT_TYPE_TITLE, DP_NOTIFICATION_NO_SUBJECT, NULL,
                                NOTIFICATION_VARIABLE_TYPE_NONE);
        }
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set subject error:%s", __dp_noti_error_str(err));
-       }
 
        err = notification_set_image(noti_handle,
                        NOTIFICATION_IMAGE_TYPE_ICON,
                        DP_NOTIFICATION_ONGOING_ICON_PATH);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set icon error:%s", __dp_noti_error_str(err));
-       }
 
        if (raws_buffer != NULL && raws_length > 0) {
                bundle *b = NULL;
@@ -299,18 +296,17 @@ int dp_notification_ongoing_new(const char *pkgname, const char *subject, unsign
                } else {
                        b = bundle_create();
                        if (b != NULL && pkgname != NULL) {
-                               if (appsvc_set_pkgname(b, pkgname) != APPSVC_RET_OK) {
+                               if (appsvc_set_pkgname(b, pkgname) != APPSVC_RET_OK)
                                        TRACE_ERROR("failed to set set pkgname");
-                               } else {
+                               else
                                        err = notification_set_execute_option(noti_handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);
-                               }
                        } else {
                                TRACE_ERROR("failed to create bundle");
                        }
                }
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set service error:%s", __dp_noti_error_str(err));
-               }
+
                if (b != NULL)
                        bundle_free(b);
        }
@@ -371,12 +367,11 @@ int dp_notification_ongoing_update(const int noti_priv_id, const double received
                        noti_handle = notification_load(NULL, noti_priv_id);
                        if (noti_handle != NULL) {
                                err = notification_set_text(noti_handle,
-                                       NOTIFICATION_TEXT_TYPE_TITLE, subject, NULL,
-                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+                                               NOTIFICATION_TEXT_TYPE_TITLE, subject, NULL,
+                                               NOTIFICATION_VARIABLE_TYPE_NONE);
                                err = notification_update(noti_handle);
-                               if (err != NOTIFICATION_ERROR_NONE) {
+                               if (err != NOTIFICATION_ERROR_NONE)
                                        TRACE_ERROR("failed to update by priv_id:%d", noti_priv_id);
-                               }
                                notification_free(noti_handle);
                        } else {
                                TRACE_ERROR("failed to load handle by priv_id:%d", noti_priv_id);
@@ -392,9 +387,9 @@ int dp_notification_delete_ongoing(const int noti_priv_id)
 {
        int err = NOTIFICATION_ERROR_NONE;
        err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_ONGOING, noti_priv_id);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to delete notification by priv_id:%d error:%s", noti_priv_id, __dp_noti_error_str(err));
-       }
+
        return 0;
 }
 
@@ -402,9 +397,9 @@ int dp_notification_delete(const int noti_priv_id)
 {
        int err = NOTIFICATION_ERROR_NONE;
        err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_priv_id);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to delete notification by priv_id:%d error:%s", noti_priv_id, __dp_noti_error_str(err));
-       }
+
        return 0;
 }
 
@@ -445,9 +440,9 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
 
        char *string = NULL;
        unsigned length = 0;
-       if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, (unsigned char **)&string, &length, &errorcode) < 0) {
+       if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_DESCRIPTION, (unsigned char **)&string, &length, &errorcode) < 0)
                TRACE_ERROR("failed to get description id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-       }
+
        if (string != NULL) {
 #ifdef _TIZEN_2_3_UX
                err = notification_set_text(noti_handle,
@@ -459,33 +454,29 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
                                NOTIFICATION_VARIABLE_TYPE_NONE);
 #endif
                free(string);
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set state id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
        } else {
                string = __dp_noti_status(state);
 #ifdef _TIZEN_2_3_UX
                err = notification_set_text(noti_handle,
                                NOTIFICATION_TEXT_TYPE_CONTENT, __(string), string,
-                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+                               NOTIFICATION_VARIABLE_TYPE_NONE);
 #else
                err = notification_set_text(noti_handle,
                                NOTIFICATION_TEXT_TYPE_TITLE, __(string), string,
-                                       NOTIFICATION_VARIABLE_TYPE_NONE);
+                               NOTIFICATION_VARIABLE_TYPE_NONE);
 #endif
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set state id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
        }
 
        string = NULL;
-       if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (unsigned char **)&string, &length, &errorcode) < 0) {
+       if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_SUBJECT, (unsigned char **)&string, &length, &errorcode) < 0)
                TRACE_ERROR("failed to get subject id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-       }
        err = NOTIFICATION_ERROR_NONE;
-       if (string == NULL && dp_db_get_property_string(dbhandle, download_id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (unsigned char **)&string, &length, &errorcode) < 0) {
+       if (string == NULL && dp_db_get_property_string(dbhandle, download_id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (unsigned char **)&string, &length, &errorcode) < 0)
                TRACE_ERROR("failed to get content_name id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-       }
        if (string == NULL)
                string = dp_strdup(DP_NOTIFICATION_NO_SUBJECT);
        if (string != NULL) {
@@ -500,22 +491,19 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
 #endif
                free(string);
                string = NULL;
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set state id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
        }
        err = notification_set_time(noti_handle, time(NULL));
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set time id:%d error:%s", download_id, __dp_noti_error_str(err));
-       }
 
        bundle *b = NULL;
        bundle_raw *raws_buffer = NULL;
        if (state == DP_STATE_COMPLETED) {
-
-               if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_RAW_COMPLETE, &raws_buffer, &length, &errorcode) < 0) {
+               if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_RAW_COMPLETE, &raws_buffer, &length, &errorcode) < 0)
                        TRACE_ERROR("failed to get bundle raws id:%d", download_id);
-               }
+
                if (raws_buffer != NULL) {
                        b = bundle_decode_raw(raws_buffer, length);
                        bundle_free_encoded_rawdata(&raws_buffer);
@@ -524,9 +512,9 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
                        err = notification_set_execute_option(noti_handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);
                } else {
                        b = bundle_create();
-                       if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_DOWNLOAD, DP_DB_COL_SAVED_PATH, (unsigned char **)&string, &length, &errorcode) < 0) {
+                       if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_DOWNLOAD, DP_DB_COL_SAVED_PATH, (unsigned char **)&string, &length, &errorcode) < 0)
                                TRACE_ERROR("failed to get saved_path id:%d error:%s", download_id, dp_print_errorcode(errorcode));
-                       }
+
                        if (b != NULL && string != NULL) {
                                if (appsvc_set_operation(b, APPSVC_OPERATION_VIEW) != APPSVC_RET_OK) {
                                        TRACE_ERROR("failed to set service operation id:%d", download_id);
@@ -535,7 +523,7 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
                                                TRACE_ERROR("failed to set service uri id:%d", download_id);
                                        } else {
                                                err = notification_set_execute_option(noti_handle,
-                                                       NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);
+                                                               NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "View", NULL, b);
                                        }
                                }
                        } else {
@@ -544,29 +532,26 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
                        free(string);
                        string = NULL;
                }
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set service id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
 
                char *file_type_icon = DP_NOTIFICATION_UNKNOWN_ICON_PATH;
                if (content_type > 0 && content_type < DP_MAX_ICONS_TABLE_COUNT)
                        file_type_icon = file_icons_table[content_type];
 
                err = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON, file_type_icon);
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set icon id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
+
                err = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR,
                                DP_NOTIFICATION_COMPLETED_INDICATOR_ICON_PATH);
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set icon id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
-
        } else if (state == DP_STATE_CANCELED || state == DP_STATE_FAILED) {
 
-               if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_RAW_FAIL, &raws_buffer, &length, &errorcode) < 0) {
+               if (dp_db_get_property_string(dbhandle, download_id, DP_TABLE_NOTIFICATION, DP_DB_COL_NOTI_RAW_FAIL, &raws_buffer, &length, &errorcode) < 0)
                        TRACE_ERROR("failed to get bundle raws id:%d", download_id);
-               }
+
                if (raws_buffer != NULL) {
                        b = bundle_decode_raw(raws_buffer, length);
                        bundle_free_encoded_rawdata(&raws_buffer);
@@ -586,21 +571,18 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
                                TRACE_ERROR("failed to create bundle id:%d", download_id);
                        }
                }
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set service id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
 
                err = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON,
                                DP_NOTIFICATION_FAILED_ICON_PATH);
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set icon id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
+
                err = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR,
                                DP_NOTIFICATION_FAILED_INDICATOR_ICON_PATH);
-               if (err != NOTIFICATION_ERROR_NONE) {
+               if (err != NOTIFICATION_ERROR_NONE)
                        TRACE_ERROR("failed to set icon id:%d error:%s", download_id, __dp_noti_error_str(err));
-               }
-
        }
 
        if (b != NULL)
@@ -608,20 +590,18 @@ int dp_notification_new(void *dbhandle, const int download_id, const int state,
 
        err = notification_set_property(noti_handle,
                        NOTIFICATION_PROP_DISABLE_TICKERNOTI);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set property id:%d error:%s", download_id, __dp_noti_error_str(err));
-       }
+
        err = notification_set_display_applist(noti_handle,
                        NOTIFICATION_DISPLAY_APP_ALL ^ NOTIFICATION_DISPLAY_APP_INDICATOR);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set display app all id:%d error:%s", download_id, __dp_noti_error_str(err));
-       }
 
        int priv_id = 0;
        err = notification_insert(noti_handle, &priv_id);
-       if (err != NOTIFICATION_ERROR_NONE) {
+       if (err != NOTIFICATION_ERROR_NONE)
                TRACE_ERROR("failed to set priv_id id:%d error:%s", download_id, __dp_noti_error_str(err));
-       }
 
        //TRACE_DEBUG("m_noti_id [%d]", priv_id);
        notification_free(noti_handle);
index c40245c..e2d541f 100644 (file)
@@ -33,7 +33,7 @@ static char *__dp_notify_get_path(pid_t pid)
                TRACE_ERROR("failed to alocalte fifo path pid:%d", (int)pid);
                return NULL;
        }
-       if (snprintf(notify_fifo, path_size,"%s/%d", NOTIFY_DIR, pid) < 0) {
+       if (snprintf(notify_fifo, path_size, "%s/%d", NOTIFY_DIR, pid) < 0) {
                TRACE_ERROR("failed to make fifo path pid:%d", (int)pid);
                free(notify_fifo);
                return NULL;
@@ -50,11 +50,11 @@ int dp_notify_init(pid_t pid)
        struct stat fifo_state;
        if (stat(notify_fifo, &fifo_state) == 0) // found
                unlink(notify_fifo);
-       if (mkfifo(notify_fifo, 0644/*-rwrr*/) < 0) {
+       if (mkfifo(notify_fifo, 0644/*-rwrr*/) < 0)
                TRACE_ERROR("failed to make fifo %s", notify_fifo);
-       } else {
+       else
                notify_fd = open(notify_fifo, O_RDWR | O_NONBLOCK, 0644);
-       }
+
        free(notify_fifo);
        return notify_fd;
 }
index fa7e9b2..52962d1 100755 (executable)
 typedef struct {
        const char *mime;
        int content_type;
-}mime_table_type;
+} mime_table_type;
 
 const char *ambiguous_mime_type_list[] = {
-               "text/plain",
-               "application/octet-stream"
+       "text/plain",
+       "application/octet-stream"
 };
 
-mime_table_type mime_table[]={
-               // PDF
-               {"application/pdf",DP_CONTENT_PDF},
-               // word
-               {"application/msword",DP_CONTENT_WORD},
-               {"application/vnd.openxmlformats-officedocument.wordprocessingml.document",DP_CONTENT_WORD},
-               // ppt
-               {"application/vnd.ms-powerpoint",DP_CONTENT_PPT},
-               {"application/vnd.openxmlformats-officedocument.presentationml.presentation",DP_CONTENT_PPT},
-               // excel
-               {"application/vnd.ms-excel",DP_CONTENT_EXCEL},
-               {"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",DP_CONTENT_EXCEL},
-               // html
-               {"text/html",DP_CONTENT_HTML},
-               // txt
-               {"text/txt",DP_CONTENT_TEXT},
-               {"text/plain",DP_CONTENT_TEXT},
-               // DRM
-               {"application/vnd.oma.drm.content",DP_CONTENT_SD_DRM},
-               {"application/vnd.oma.drm.message",DP_CONTENT_DRM},
-               {"application/x-shockwave-flash", DP_CONTENT_FLASH},
-               {"application/vnd.tizen.package", DP_CONTENT_TPK},
-               {"text/calendar",DP_CONTENT_VCAL},
+mime_table_type mime_table[] = {
+       // PDF
+       {"application/pdf", DP_CONTENT_PDF},
+       // word
+       {"application/msword", DP_CONTENT_WORD},
+       {"application/vnd.openxmlformats-officedocument.wordprocessingml.document", DP_CONTENT_WORD},
+       // ppt
+       {"application/vnd.ms-powerpoint", DP_CONTENT_PPT},
+       {"application/vnd.openxmlformats-officedocument.presentationml.presentation", DP_CONTENT_PPT},
+       // excel
+       {"application/vnd.ms-excel", DP_CONTENT_EXCEL},
+       {"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", DP_CONTENT_EXCEL},
+       // html
+       {"text/html", DP_CONTENT_HTML},
+       // txt
+       {"text/txt", DP_CONTENT_TEXT},
+       {"text/plain", DP_CONTENT_TEXT},
+       // DRM
+       {"application/vnd.oma.drm.content", DP_CONTENT_SD_DRM},
+       {"application/vnd.oma.drm.message", DP_CONTENT_DRM},
+       {"application/x-shockwave-flash", DP_CONTENT_FLASH},
+       {"application/vnd.tizen.package", DP_CONTENT_TPK},
+       {"text/calendar", DP_CONTENT_VCAL},
 };
 
 static void *g_da_handle = NULL;
@@ -156,11 +156,11 @@ static int __dp_da_state_feedback(dp_client_slots_fmt *slot, dp_request_fmt *req
        }
 
        TRACE_INFO("[INFO][%d] state:%s error:%s", request->id,
-               dp_print_state(request->state), dp_print_errorcode(request->error));
+                       dp_print_state(request->state), dp_print_errorcode(request->error));
 
        int errorcode = DP_ERROR_NONE;
        if (dp_db_update_logging(slot->client.dbhandle, request->id,
-                       request->state, request->error, &errorcode) < 0) {
+                               request->state, request->error, &errorcode) < 0) {
                TRACE_ERROR("logging failure id:%d error:%d", request->id, errorcode);
                return -1; // try cancel
        }
@@ -186,7 +186,7 @@ static int __precheck_request(dp_request_fmt *request, int agentid)
        }
        if (request->id < 0 || (request->agent_id != agentid)) {
                TRACE_ERROR("id-check request_id:%d agent_id:%d req_id:%d",
-                       request->id, request->agent_id, agentid);
+                               request->id, request->agent_id, agentid);
                return -1;
        }
        return 0;
@@ -208,19 +208,19 @@ static int __set_file_permission_to_client(dp_client_slots_fmt *slot, dp_request
        int errorcode = DP_ERROR_NONE;
        dp_credential cred = slot->credential;
        if (lstat(saved_path, &lstat_info) != -1) {
-               fd = open (saved_path, O_RDONLY);
+               fd = open(saved_path, O_RDONLY);
                if (fd != -1) {
                        if (fstat(fd, &fstat_info) != -1) {
                                if (lstat_info.st_mode == fstat_info.st_mode &&
-                                       lstat_info.st_ino == fstat_info.st_ino &&
-                                       lstat_info.st_dev == fstat_info.st_dev) {
-
-                                   if(strncmp(saved_path, "/opt/media/", 11) != 0){
-                                      if(fchown(fd, cred.uid, cred.gid) != 0){
-                                               TRACE_ERROR("[ERROR][%d] permission user:%d group:%d",
-                                                       request->id, cred.uid, cred.gid);
-                                               errorcode = DP_ERROR_PERMISSION_DENIED;
-                                      }
+                                               lstat_info.st_ino == fstat_info.st_ino &&
+                                               lstat_info.st_dev == fstat_info.st_dev) {
+
+                                       if (strncmp(saved_path, "/opt/media/", 11) != 0) {
+                                               if (fchown(fd, cred.uid, cred.gid) != 0) {
+                                                       TRACE_ERROR("[ERROR][%d] permission user:%d group:%d",
+                                                                       request->id, cred.uid, cred.gid);
+                                                       errorcode = DP_ERROR_PERMISSION_DENIED;
+                                               }
                                        }
                                } else {
                                        TRACE_ERROR("fstat & lstat info have not matched");
@@ -274,17 +274,15 @@ static void __finished_cb(finished_info_t *info, void *user_req_data,
        int errorcode = DP_ERROR_NONE;
 
        if (info->http_status > 0) {
-               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_HTTP_STATUS, (void *)&info->http_status, 0, 0, &errorcode) < 0) {
+               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_HTTP_STATUS, (void *)&info->http_status, 0, 0, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set http_status(%d)", request->id, info->http_status);
-               }
        }
 
        TRACE_SECURE_DEBUG("[FINISH][%d][%s]", request->id, info->saved_path);
        if (info->err == DA_RESULT_OK) {
                if (info->saved_path != NULL) {
-                       if(strncmp(DP_SDCARD_MNT_POINT, info->saved_path, strlen(DP_SDCARD_MNT_POINT)) != 0) {
+                       if (strncmp(DP_SDCARD_MNT_POINT, info->saved_path, strlen(DP_SDCARD_MNT_POINT)) != 0)
                                errorcode = __set_file_permission_to_client(slot, request, info->saved_path);
-                       }
                } else {
                        TRACE_ERROR("[ERROR][%d] No SavedPath", request->id);
                        errorcode = DP_ERROR_INVALID_DESTINATION;
@@ -326,23 +324,20 @@ static void __finished_cb(finished_info_t *info, void *user_req_data,
                }
                if (request->file_size == 0) {// missed in download_cb
                        request->file_size = request->received_size;
-                       if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_SIZE, (void *)&request->file_size, 0, 1, &errorcode) < 0) {
+                       if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_SIZE, (void *)&request->file_size, 0, 1, &errorcode) < 0)
                                TRACE_ERROR("id:%d failed to set content_size(%llu)", request->id, request->file_size);
-                       }
                }
                // update contentname, savedpath
                if (content_name != NULL) {
-                       if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (void *)content_name, 0, 2, &errorcode) < 0) {
+                       if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (void *)content_name, 0, 2, &errorcode) < 0)
                                TRACE_ERROR("id:%d failed to set content_name", request->id);
-                       }
                }
-               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_SAVED_PATH, (void *)info->saved_path, 0, 2, &errorcode) < 0) {
+               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_SAVED_PATH, (void *)info->saved_path, 0, 2, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set saved_path", request->id);
-               }
                free(content_name);
                /* update the received file size.
-               * The last received file size cannot update
-               * because of reducing update algorithm*/
+                * The last received file size cannot update
+                * because of reducing update algorithm*/
                if (request->progress_cb == 1) {
                        if (slot->client.notify < 0 ||
                                        dp_notify_feedback(slot->client.notify, slot, request->id, DP_STATE_DOWNLOADING, DP_ERROR_NONE, request->received_size) < 0) {
@@ -362,9 +357,8 @@ static void __finished_cb(finished_info_t *info, void *user_req_data,
        }
        if (request->noti_type == DP_NOTIFICATION_TYPE_COMPLETE_ONLY ||
                        request->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-               if (dp_notification_manager_push_notification(slot, request, DP_NOTIFICATION) < 0) {
+               if (dp_notification_manager_push_notification(slot, request, DP_NOTIFICATION) < 0)
                        TRACE_ERROR("failed to register notification for id:%d", request->id);
-               }
        }
        free(info->etag);
        free(info->saved_path);
@@ -418,24 +412,18 @@ static void __download_info_cb(download_info_t *info, void *user_req_data, void
        TRACE_SECURE_DEBUG("[DOWNLOAD][%d][%s]", request->id, info->tmp_saved_path);
        if (info->tmp_saved_path != NULL) {
                int errorcode = DP_ERROR_NONE;
-               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_MIMETYPE, (void *)info->file_type, 0, 2, &errorcode) < 0) {
+               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_MIMETYPE, (void *)info->file_type, 0, 2, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set mimetype", request->id);
-               }
-               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (void *)info->content_name, 0, 2, &errorcode) < 0) {
+               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_NAME, (void *)info->content_name, 0, 2, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set contentname", request->id);
-               }
-               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_TMP_SAVED_PATH, (void *)info->tmp_saved_path, 0, 2, &errorcode) < 0) {
+               if (dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_TMP_SAVED_PATH, (void *)info->tmp_saved_path, 0, 2, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set tmp_saved_path", request->id);
-               }
-               if (info->file_size > 0 && dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_SIZE, (void *)&(info->file_size), 0, 1, &errorcode) < 0) {
+               if (info->file_size > 0 && dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_CONTENT_SIZE, (void *)&(info->file_size), 0, 1, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set file size", request->id);
-               }
-               if (info->etag && dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_ETAG, (void *)info->etag, 0, 2, &errorcode) < 0) {
+               if (info->etag && dp_db_replace_property(slot->client.dbhandle, request->id, DP_TABLE_DOWNLOAD, DP_DB_COL_ETAG, (void *)info->etag, 0, 2, &errorcode) < 0)
                        TRACE_ERROR("id:%d failed to set etag", request->id);
-               }
-               if(strncmp(DP_SDCARD_MNT_POINT, info->tmp_saved_path, strlen(DP_SDCARD_MNT_POINT)) != 0) {
+               if (strncmp(DP_SDCARD_MNT_POINT, info->tmp_saved_path, strlen(DP_SDCARD_MNT_POINT)) != 0)
                        errorcode = __set_file_permission_to_client(slot, request, info->tmp_saved_path);
-               }
                request->error = errorcode;
        } else {
                request->error = DP_ERROR_IO_ERROR;
@@ -446,7 +434,7 @@ static void __download_info_cb(download_info_t *info, void *user_req_data, void
                TRACE_ERROR("id:%d try to cancel(%d)", request->id, info->download_id);
                if (dp_cancel_agent_download(request->agent_id) < 0) {
                        TRACE_ERROR("[fail][%d] cancel_agent:%d", request->id,
-                               info->download_id);
+                                       info->download_id);
                }
        } else {
                request->state = DP_STATE_DOWNLOADING;
@@ -461,14 +449,13 @@ static void __download_info_cb(download_info_t *info, void *user_req_data, void
        }
        // notification
        if (request->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-               if (dp_notification_manager_push_notification(slot, request, DP_NOTIFICATION_ONGOING_UPDATE) < 0) {
+               if (dp_notification_manager_push_notification(slot, request, DP_NOTIFICATION_ONGOING_UPDATE) < 0)
                        TRACE_ERROR("failed to register notification for id:%d", request->id);
-               }
        }
        //get the mime type for dp notification
-       if (request->noti_type > DP_NOTIFICATION_TYPE_NONE) {
+       if (request->noti_type > DP_NOTIFICATION_TYPE_NONE)
                request->content_type = __dp_get_content_type(info->file_type, info->tmp_saved_path);
-       }
+
        free(info->content_name);
        free(info->etag);
        free(info->file_type);
@@ -488,11 +475,11 @@ static void __progress_cb(int download_id, unsigned long long received_size,
        }
        CLIENT_MUTEX_LOCK(&slot->mutex);
        /*
-       if (CLIENT_MUTEX_TRYLOCK(&slot->mutex) != 0) {
-               TRACE_ERROR("slot busy agent_id:%d", download_id);
-               return ;
-       }
-       */
+          if (CLIENT_MUTEX_TRYLOCK(&slot->mutex) != 0) {
+          TRACE_ERROR("slot busy agent_id:%d", download_id);
+          return ;
+          }
+          */
        if (__precheck_request(request, download_id) < 0) {
                TRACE_ERROR("error request agent_id:%d", download_id);
                if (dp_cancel_agent_download(download_id) < 0)
@@ -515,9 +502,9 @@ static void __progress_cb(int download_id, unsigned long long received_size,
                request->received_size = received_size;
                time_t tt = time(NULL);
                struct tm localTime ;
-               if(localtime_r(&tt,&localTime)==NULL){
-                   TRACE_ERROR("Error localtime_r");
-                   return;
+               if (localtime_r(&tt, &localTime) == NULL) {
+                       TRACE_ERROR("Error localtime_r");
+                       return;
                }
                // send event every 1 second.
                if (request->progress_lasttime != localTime.tm_sec) {
@@ -534,9 +521,8 @@ static void __progress_cb(int download_id, unsigned long long received_size,
                        }
 
                        if (request->noti_type == DP_NOTIFICATION_TYPE_ALL) {
-                               if (dp_notification_manager_push_notification(slot, request, DP_NOTIFICATION_ONGOING_PROGRESS) < 0) {
+                               if (dp_notification_manager_push_notification(slot, request, DP_NOTIFICATION_ONGOING_PROGRESS) < 0)
                                        TRACE_ERROR("failed to register notification for id:%d", request->id);
-                               }
                        }
 
                }
@@ -553,7 +539,7 @@ static int __dp_is_ambiguous_mime_type(const char *mime_type)
        int listSize = sizeof(ambiguous_mime_type_list) / sizeof(const char *);
        for (index = 0; index < listSize; index++) {
                if (0 == strncmp(mime_type, ambiguous_mime_type_list[index],
-                               strlen(ambiguous_mime_type_list[index]))) {
+                                       strlen(ambiguous_mime_type_list[index]))) {
                        TRACE_DEBUG("It is ambiguous");
                        return 0;
                }
@@ -590,7 +576,7 @@ static dp_content_type __dp_get_content_type(const char *mime, const char *file_
 
        /* Search a content type from mime table. */
        for (i = 0; i < DP_MAX_MIME_TABLE_NUM; i++) {
-               if (strncmp(mime_table[i].mime, temp_mime, strlen(temp_mime)) == 0){
+               if (strncmp(mime_table[i].mime, temp_mime, strlen(temp_mime)) == 0) {
                        type = mime_table[i].content_type;
                        break;
                }
@@ -601,12 +587,12 @@ static dp_content_type __dp_get_content_type(const char *mime, const char *file_
                unaliased_mime = xdg_mime_unalias_mime_type(temp_mime);
 
                if (unaliased_mime != NULL) {
-                       TRACE_SECURE_DEBUG("unaliased mime type[%s]",unaliased_mime);
-                       if (strstr(unaliased_mime,"video/") != NULL)
+                       TRACE_SECURE_DEBUG("unaliased mime type[%s]", unaliased_mime);
+                       if (strstr(unaliased_mime, "video/") != NULL)
                                type = DP_CONTENT_VIDEO;
-                       else if (strstr(unaliased_mime,"audio/") != NULL)
+                       else if (strstr(unaliased_mime, "audio/") != NULL)
                                type = DP_CONTENT_MUSIC;
-                       else if (strstr(unaliased_mime,"image/") != NULL)
+                       else if (strstr(unaliased_mime, "image/") != NULL)
                                type = DP_CONTENT_IMAGE;
                }
        }
@@ -628,7 +614,7 @@ int dp_init_agent()
        dlerror();    /* Clear any existing error */
 
        *(void **) (&download_agent_init) = dlsym(g_da_handle, "da_init");
-       if (download_agent_init == NULL ) {
+       if (download_agent_init == NULL) {
                TRACE_ERROR("[dlsym] da_init:%s", dlerror());
                dlclose(g_da_handle);
                g_da_handle = NULL;
@@ -636,7 +622,7 @@ int dp_init_agent()
        }
 
        *(void **) (&download_agent_deinit) = dlsym(g_da_handle, "da_deinit");
-       if (download_agent_deinit == NULL ) {
+       if (download_agent_deinit == NULL) {
                TRACE_ERROR("[dlsym] da_deinit:%s", dlerror());
                dlclose(g_da_handle);
                g_da_handle = NULL;
@@ -644,8 +630,8 @@ int dp_init_agent()
        }
 
        *(void **) (&download_agent_is_alive) =
-                       dlsym(g_da_handle, "da_is_valid_download_id");
-       if (download_agent_is_alive == NULL ) {
+               dlsym(g_da_handle, "da_is_valid_download_id");
+       if (download_agent_is_alive == NULL) {
                TRACE_ERROR("[dlsym] da_is_valid_download_id:%s", dlerror());
                dlclose(g_da_handle);
                g_da_handle = NULL;
@@ -653,8 +639,8 @@ int dp_init_agent()
        }
 
        *(void **) (&download_agent_suspend) =
-                       dlsym(g_da_handle, "da_suspend_download");
-       if (download_agent_suspend == NULL ) {
+               dlsym(g_da_handle, "da_suspend_download");
+       if (download_agent_suspend == NULL) {
                TRACE_ERROR("[dlsym] da_suspend_download:%s", dlerror());
                dlclose(g_da_handle);
                g_da_handle = NULL;
@@ -662,7 +648,7 @@ int dp_init_agent()
        }
 
        *(void **) (&download_agent_resume) =
-                       dlsym(g_da_handle, "da_resume_download");
+               dlsym(g_da_handle, "da_resume_download");
        if (download_agent_resume == NULL) {
                TRACE_ERROR("[dlsym] da_resume_download:%s", dlerror());
                dlclose(g_da_handle);
@@ -670,9 +656,9 @@ int dp_init_agent()
                return DP_ERROR_OUT_OF_MEMORY;
        }
 
-//     *(void **) (&download_agent_cancel) = dlsym(g_da_handle, "da_cancel_download_without_update");
+       //      *(void **) (&download_agent_cancel) = dlsym(g_da_handle, "da_cancel_download_without_update");
        *(void **) (&download_agent_cancel) =
-                       dlsym(g_da_handle, "da_cancel_download");
+               dlsym(g_da_handle, "da_cancel_download");
        if (download_agent_cancel == NULL) {
                TRACE_ERROR("[dlsym] da_cancel_download:%s", dlerror());
                dlclose(g_da_handle);
@@ -681,7 +667,7 @@ int dp_init_agent()
        }
 
        *(void **) (&download_agent_start) =
-                       dlsym(g_da_handle, "da_start_download");
+               dlsym(g_da_handle, "da_start_download");
        if (download_agent_start == NULL) {
                TRACE_ERROR("[dlsym] da_start_download:%s", dlerror());
                dlclose(g_da_handle);
@@ -707,9 +693,8 @@ int dp_init_agent()
 
        int da_ret = -1;
        da_ret = (*download_agent_init)();
-       if (da_ret != DA_RESULT_OK) {
+       if (da_ret != DA_RESULT_OK)
                return DP_ERROR_OUT_OF_MEMORY;
-       }
        return DP_ERROR_NONE;
 }
 
@@ -878,7 +863,7 @@ int dp_start_agent_download(void *slot, void *request)
                } else
                        req_data->file_name = filename;
                if (dp_db_get_property_string(base_slot->client.dbhandle, base_req->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, (unsigned char **)&destination, &length, &errorcode) < 0 ||
-                       destination == NULL) {
+                               destination == NULL) {
                        TRACE_DEBUG("destination id:%d NO_DATA", base_req->id);
                } else
                        req_data->install_path = destination;
@@ -901,14 +886,14 @@ int dp_start_agent_download(void *slot, void *request)
                        /* FIXME later : It is better to handle the unlink function in download agaent module
                         * or in upload the request data to memory after the download provider process is restarted */
                        TRACE_SECURE_INFO("try to restart id:%d remove tmp file:%s",
-                               base_req->id, tmp_saved_path);
+                                       base_req->id, tmp_saved_path);
                        if (dp_is_file_exist(tmp_saved_path) == 0) {
                                if (unlink(tmp_saved_path) != 0)
                                        TRACE_ERROR("failed to remove file id:%d", base_req->id);
                        }
                }
        }
-       ifdp_db_get_property_int(base_slot->client.dbhandle, base_req->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_BONDING, (int *)&user_network_bonding, &errorcode) < 0 ||
+       if (dp_db_get_property_int(base_slot->client.dbhandle, base_req->id, DP_TABLE_REQUEST, DP_DB_COL_NETWORK_BONDING, (int *)&user_network_bonding, &errorcode) < 0 ||
                        user_network_bonding < 0) {
                TRACE_DEBUG("unable to get network bonding value for id:%d", base_req->id);
        } else
@@ -921,9 +906,9 @@ int dp_start_agent_download(void *slot, void *request)
        if (headers_count > 0) {
                req_data->request_header = calloc(headers_count, sizeof(char *));
                if (req_data->request_header != NULL) {
-                               headers_count = dp_db_get_http_headers_list(base_slot->client.dbhandle, base_req->id, (char **)req_data->request_header, &errorcode);
-                               if (headers_count > 0)
-                                       req_data->request_header_count = headers_count;
+                       headers_count = dp_db_get_http_headers_list(base_slot->client.dbhandle, base_req->id, (char **)req_data->request_header, &errorcode);
+                       if (headers_count > 0)
+                               req_data->request_header_count = headers_count;
                }
        }
 
@@ -938,9 +923,8 @@ int dp_start_agent_download(void *slot, void *request)
                int i = 0;
                len = req_data->request_header_count;
                if (req_data->request_header != NULL) {
-                   for (i = 0; i < len; i++){
-                       free((void *)(req_data->request_header[i]));
-                   }
+                       for (i = 0; i < len; i++)
+                               free((void *)(req_data->request_header[i]));
                }
                free(req_data->request_header);
        }
index 9d60077..e4e001e 100644 (file)
 
 static char *__print_pthread_error(int code)
 {
-       switch(code)
-       {
-               case 0:
-                       return "NONE";
-               case EINVAL:
-                       return "EINVAL";
-               case ENOMEM:
-                       return "ENOMEM";
-               case EBUSY:
-                       return "EBUSY";
-               case EDEADLK:
-                       return "EDEADLK";
+       switch (code) {
+       case 0:
+               return "NONE";
+       case EINVAL:
+               return "EINVAL";
+       case ENOMEM:
+               return "ENOMEM";
+       case EBUSY:
+               return "EBUSY";
+       case EDEADLK:
+               return "EDEADLK";
        }
        return "UNKNOWN";
 }
@@ -102,7 +101,7 @@ void dp_mutex_destroy(pthread_mutex_t *mutex)
        int ret = pthread_mutex_destroy(mutex);
        if (ret != 0) {
                TRACE_ERROR("error:%d.%s", ret, __print_pthread_error(ret));
-               if(EBUSY == ret) {
+               if (EBUSY == ret) {
                        if (pthread_mutex_unlock(mutex) == 0)
                                pthread_mutex_destroy(mutex);
                }
index 317f84a..ad927eb 100644 (file)
@@ -42,7 +42,7 @@ static dp_queue_fmt *g_dp_queue_network_wifi_direct = NULL;
 
 static dp_queue_fmt **__dp_queue_manager_get_queue(int network)
 {
-       switch(network) {
+       switch (network) {
        case DP_NETWORK_ALL:
                //TRACE_DEBUG("network all");
                return &g_dp_queue_network_all;
@@ -199,9 +199,8 @@ static int __dp_queue_manager_check_queue(dp_queue_fmt **queue)
                        if (dp_queue_push(queue, slot, request) < 0) {
                                TRACE_ERROR("failed to push to queue id:%d", request->id);
                                int errorcode = DP_ERROR_NONE;
-                               if (dp_db_update_logging(slot->client.dbhandle, request->id, DP_STATE_FAILED, DP_ERROR_QUEUE_FULL, &errorcode) < 0) {
+                               if (dp_db_update_logging(slot->client.dbhandle, request->id, DP_STATE_FAILED, DP_ERROR_QUEUE_FULL, &errorcode) < 0)
                                        TRACE_ERROR("failed to update log id:%d", request->id);
-                               }
                                request->state = DP_STATE_FAILED;
                                request->error = DP_ERROR_QUEUE_FULL;
                        }
@@ -246,9 +245,8 @@ static void *__dp_queue_manager(void *arg)
                                        TRACE_ERROR("download-agent is busy, try again after 15 seconds");
                                } else {
                                        dp_queue_fmt **queue = __dp_queue_manager_get_queue(network_status);
-                                       if (__dp_queue_manager_check_queue(queue) < 0) {
+                                       if (__dp_queue_manager_check_queue(queue) < 0)
                                                TRACE_ERROR("download-agent is busy, try again after 15 seconds");
-                                       }
                                }
                        }
                }
index e863b1a..7c0b7d9 100644 (file)
 
 static int __dp_smack_is_transmute(char *path)
 {
-    char *dir_label = NULL;
-    int ret = -1;
-    if (smack_getlabel(path, &dir_label, SMACK_LABEL_TRANSMUTE) == 0 && dir_label != NULL) {
-        if (strncmp(dir_label, "TRUE", strlen(dir_label)) == 0) {
-            ret = 0;
-        }
-    }
+       char *dir_label = NULL;
+       int ret = -1;
+       if (smack_getlabel(path, &dir_label, SMACK_LABEL_TRANSMUTE) == 0 && dir_label != NULL) {
+               if (strncmp(dir_label, "TRUE", strlen(dir_label)) == 0)
+                       ret = 0;
+       }
 
-    if (smack_getlabel(path, &dir_label, SMACK_LABEL_ACCESS) == 0 && dir_label != NULL) {
-        if (strncmp(dir_label, "*", strlen(dir_label)) == 0) {
-            ret = 0;
-        }
-    }
+       if (smack_getlabel(path, &dir_label, SMACK_LABEL_ACCESS) == 0 && dir_label != NULL) {
+               if (strncmp(dir_label, "*", strlen(dir_label)) == 0)
+                       ret = 0;
+       }
 
-    free(dir_label);
-    return ret;
+       free(dir_label);
+       return ret;
 }
 
 int dp_smack_is_mounted()
@@ -61,9 +59,8 @@ int dp_smack_is_mounted()
                TRACE_ERROR("[SMACK ERROR]");
                return -1;
        }
-       if (sfs.f_type == SMACKFS_MAGIC) {
+       if (sfs.f_type == SMACKFS_MAGIC)
                return 1;
-       }
        TRACE_ERROR("[SMACK DISABLE]");
        return 0;
 }
@@ -151,9 +148,8 @@ int dp_is_valid_dir(const char *dirpath)
                return -1;
        }
        stat_ret = stat(dirpath, &dir_state);
-       if (stat_ret == 0 && S_ISDIR(dir_state.st_mode)) {
+       if (stat_ret == 0 && S_ISDIR(dir_state.st_mode))
                return 0;
-       }
        return -1;
 }
 
@@ -162,9 +158,8 @@ void dp_rebuild_dir(const char *dirpath, mode_t mode)
        if (dp_is_valid_dir(dirpath) < 0) {
                if (mkdir(dirpath, mode) == 0) {
                        TRACE_INFO("check directory:%s", dirpath);
-                       if (smack_setlabel(dirpath, "_", SMACK_LABEL_ACCESS) != 0) {
+                       if (smack_setlabel(dirpath, "_", SMACK_LABEL_ACCESS) != 0)
                                TRACE_SECURE_ERROR("failed to set smack label:%s", dirpath);
-                       }
                } else {
                        TRACE_ERROR("failed to create directory:%s", dirpath);
                }
index cca3914..b4b8a7f 100755 (executable)
@@ -27,7 +27,7 @@
 #if defined(LOGD) && defined(TIZEN_DEBUG_ENABLE)
 #define TRACE_DEBUG(format, ARG...) LOGD(format, ##ARG)
 #else
-#define TRACE_DEBUG(...) do { } while(0)
+#define TRACE_DEBUG(...) do { } while (0)
 #endif
 #define TRACE_ERROR(format, ARG...) LOGE(format, ##ARG)
 #define TRACE_STRERROR(format, ARG...) LOGE(format" [%s]", ##ARG)
 #if defined(SECURE_LOGD) && defined(TIZEN_DEBUG_ENABLE)
 #define TRACE_SECURE_DEBUG(format, ARG...) SECURE_LOGD(format, ##ARG)
 #else
-#define TRACE_SECURE_DEBUG(...) do { } while(0)
+#define TRACE_SECURE_DEBUG(...) do { } while (0)
 #endif
 #if defined(SECURE_LOGI) && defined(TIZEN_DEBUG_ENABLE)
 #define TRACE_SECURE_INFO(format, ARG...) SECURE_LOGI(format, ##ARG)
 #else
-#define TRACE_SECURE_INFO(...) do { } while(0)
+#define TRACE_SECURE_INFO(...) do { } while (0)
 #endif
 #if defined(SECURE_LOGE) && defined(TIZEN_DEBUG_ENABLE)
 #define TRACE_SECURE_ERROR(format, ARG...) SECURE_LOGE(format, ##ARG)
 #else
-#define TRACE_SECURE_ERROR(...) do { } while(0)
+#define TRACE_SECURE_ERROR(...) do { } while (0)
 #endif
 
 #else
-#define TRACE_DEBUG(...) do { } while(0)
-#define TRACE_ERROR(...) do { } while(0)
-#define TRACE_ERROR(...) do { } while(0)
-#define TRACE_INFO(...) do { } while(0)
-#define TRACE_WARN(...) do { } while(0)
-#define TRACE_SECURE_DEBUG(...) do { } while(0)
-#define TRACE_SECURE_INFO(...) do { } while(0)
-#define TRACE_SECURE_ERROR(...) do { } while(0)
+#define TRACE_DEBUG(...) do { } while (0)
+#define TRACE_ERROR(...) do { } while (0)
+#define TRACE_ERROR(...) do { } while (0)
+#define TRACE_INFO(...) do { } while (0)
+#define TRACE_WARN(...) do { } while (0)
+#define TRACE_SECURE_DEBUG(...) do { } while (0)
+#define TRACE_SECURE_INFO(...) do { } while (0)
+#define TRACE_SECURE_ERROR(...) do { } while (0)
 #endif
 
 #endif