tizen 2.4 release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20151029.034322 submit/tizen_2.4/20151028.063731 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:27:40 +0000 (16:27 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:27:40 +0000 (16:27 +0900)
14 files changed:
CMakeLists.txt
LICENSE.APLv2 [moved from LICENSE with 100% similarity]
NOTICE
TC/testcase/utc_download_get_notification_bundle_positive.c
TC/testcase/utc_download_set_notification_bundle_negative.c
TC/testcase/utc_download_set_notification_bundle_positive.c
doc/download_doc.h
doc_prod/download_doc.h [new file with mode: 0644]
include/download_product.h [new file with mode: 0644]
packaging/capi-web-url-download.spec
src/download-product-wrapping.c [new file with mode: 0644]
src/download-wrapping.c
testcase/CMakeLists.txt [new file with mode: 0644]
testcase/url-download-tc.c [new file with mode: 0644]

index 94a2b23..9675bb0 100644 (file)
@@ -36,7 +36,11 @@ ADD_DEFINITIONS(-DDP_SUPPORT_DBUS_ACTIVATION)
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
-SET(SOURCES src/download-wrapping.c)
+SET(SOURCES 
+                       src/download-wrapping.c
+                       src/download-product-wrapping.c
+)
+                       
 MESSAGE(STATUS "SOURCES : ${SOURCES}")
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
 
@@ -46,6 +50,7 @@ SET_TARGET_PROPERTIES(${fw_name} PROPERTIES SOVERSION ${VERSION_MAJOR})
 
 INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
 INSTALL(FILES ${INC_DIR}/download.h DESTINATION include/web/)
+INSTALL(FILES ${INC_DIR}/download_product.h DESTINATION include/web/)
 INSTALL(FILES ${DOC_DIR}/download_doc.h DESTINATION include/web/)
 
 SET(PC_NAME ${fw_name})
@@ -59,7 +64,7 @@ CONFIGURE_FILE(
     @ONLY
 )
 CONFIGURE_FILE(
-       LICENSE
+       LICENSE.APLv2
     ${fw_name}
     @ONLY
 )
@@ -97,3 +102,4 @@ ADD_CUSTOM_COMMAND(
 
 ENDIF(UNIX)
 
+ADD_SUBDIRECTORY(testcase/)
similarity index 100%
rename from LICENSE
rename to LICENSE.APLv2
diff --git a/NOTICE b/NOTICE
index dc6f246..6220b80 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1,13 +1,3 @@
-Copyright 2014 Samsung Electronics Co., Ltd.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
index a3b41b6..e1b73df 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <tet_api.h>
 #include <download.h>
+#include <bundle_internal.h>
 
 static void startup(void);
 static void cleanup(void);
index bdba4dd..e6ce44f 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <tet_api.h>
 #include <download.h>
+#include <bundle_internal.h>
 
 static void startup(void);
 static void cleanup(void);
index 2d73537..dc1a303 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <tet_api.h>
 #include <download.h>
+#include <bundle_internal.h>
 
 static void startup(void);
 static void cleanup(void);
index 03b06ce..05e4de2 100644 (file)
@@ -47,7 +47,7 @@
  *
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
  *
- * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tools/native-tools/manifest-text-editor#feature"></a>
  *
  */
 
diff --git a/doc_prod/download_doc.h b/doc_prod/download_doc.h
new file mode 100644 (file)
index 0000000..a86796f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_WEB_DOWNLOAD_DOC_H__
+#define __TIZEN_WEB_DOWNLOAD_DOC_H__
+
+/**
+ * @ingroup CAPI_CONTENT_FRAMEWORK
+ * @defgroup CAPI_WEB_DOWNLOAD_MODULE Download
+ * @brief  The DOWNLOAD API provides functions to create and manage one or more download requests.
+ *
+ * @section CAPI_WEB_DOWNLOAD_MODULE_HEADER Required Header
+ *   \#include <download_product.h>
+ *
+ * @section CAPI_WEB_DOWNLOAD_MODULE_OVERVIEW Overview
+ * The DOWNLOAD API provides functions to create and manage one or more download requests.
+ *
+ * Major features :
+ * - After getting download_id from download_create(), other APIs use download_id as parameter.
+ * - Even if the device is off, download_id is available for 48 hours if user did't call download_destroy().
+ * - support the callback that called whenever changed the status of download.
+ * - Even if the client process is terminated, download is going on.
+ *   If wanna stop a download, download_cancel() or download_destroy() should be called.
+ *
+ */
+
+#endif /* __TIZEN_WEB_DOWNLOAD_DOC_H__ */
diff --git a/include/download_product.h b/include/download_product.h
new file mode 100644 (file)
index 0000000..a854338
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_WEB_DOWNLOAD_PRODUCT_H__
+#define __TIZEN_WEB_DOWNLOAD_PRODUCT_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @internal
+ * @addtogroup CAPI_WEB_DOWNLOAD_MODULE
+ * @brief download product APIs
+ * @{
+ */
+
+/**
+ * @brief Sets the 'enabled' state of the network bonding feature.
+ *
+ * @details This is only available depending on specific platform.
+ *"Network bonding" feature use both data network and wifi network concurrently,
+ *if the content size is over than specific size.
+ *
+ * @since_tizen 2.3
+ * @privlevel public 
+ * @privilege %http://tizen.org/privilege/download
+ * @remarks This function should be called before downloading (see download_start()).
+ * @remarks If the network type is not set as DOWNLOAD_NETWORK_ALL, the error is happened.
+ * @param[in] download_id The download id
+ * @param[in] enable The enable value
+ * @return 0 on success, otherwise a negative error value
+ * @retval #DOWNLOAD_ERROR_NONE              Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE     Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND      No Download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ * @pre The state must not be #DOWNLOAD_STATE_DOWNLOADING, #DOWNLOAD_STATE_COMPLETED.
+ * @see download_get_network_bonding()
+  */
+int download_set_network_bonding(int download_id, bool enable);
+
+
+/**
+ * @brief Gets the 'enabled' state of the network bonding feature.
+ *
+ * @since_tizen 2.3
+ * @privlevel public 
+ * @privilege %http://tizen.org/privilege/download
+ * @param[in] download_id The download id
+ * @param[out] enable The enable value
+ * @return 0 on success, otherwise a negative error value
+ * @retval #DOWNLOAD_ERROR_NONE              Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND      No Download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ * @see download_set_network_bonding()
+ */
+int download_get_network_bonding(int download_id, bool *enable);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_WEB_DOWNLOAD_PRODUCT_H__ */
index fe48846..98c9a95 100755 (executable)
@@ -56,5 +56,7 @@ mkdir -p %{buildroot}/usr/share/license
 %{_libdir}/libcapi-web-url-download.so
 %{_libdir}/pkgconfig/capi-web-url-download.pc
 %{_includedir}/web/download.h
+%{_includedir}/web/download_product.h
 %{_includedir}/web/download_doc.h
+/usr/bin/url-download-tc
 
diff --git a/src/download-product-wrapping.c b/src/download-product-wrapping.c
new file mode 100644 (file)
index 0000000..c058d47
--- /dev/null
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <dlog.h>
+#include <download.h>
+#include <download_product.h>
+#include <download-provider-interface.h>
+
+#define DEBUG_MSG
+#ifdef DEBUG_MSG
+#include <dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_URL_DOWNLOAD"
+#define TRACE_ERROR(format, ARG...)  \
+{ \
+LOGE(format, ##ARG); \
+}
+#define TRACE_STRERROR(format, ARG...)  \
+{ \
+LOGE(format" [%s]", ##ARG, strerror(errno)); \
+}
+#define TRACE_INFO(format, ARG...)  \
+{ \
+LOGI(format, ##ARG); \
+}
+#else
+#define TRACE_DEBUG_MSG(format, ARG...) ;
+#endif
+
+/////////////////////// APIs /////////////////////////////////
+
+int download_set_network_bonding(int download_id, bool enable)
+{
+       TRACE_INFO("");
+       return dp_interface_set_network_bonding(download_id, (int)enable);
+}
+
+int download_get_network_bonding(int download_id, bool *enable)
+{
+       int is_set = 0;
+       TRACE_INFO("");
+       if (enable == NULL) {
+               TRACE_ERROR("Parameter NULL Check");
+               return DOWNLOAD_ERROR_INVALID_PARAMETER;
+       }
+       int ret = dp_interface_get_network_bonding(download_id, &is_set);
+       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+               *enable = (bool)is_set;
+       return ret;
+}
index fcb4d33..8c4aaaf 100755 (executable)
@@ -110,26 +110,6 @@ int download_get_network_type(int download_id,
        return ret;
 }
 
-int download_set_network_bonding(int download_id, bool enable)
-{
-       TRACE_INFO("");
-       return dp_interface_set_network_bonding(download_id, (int)enable);
-}
-
-int download_get_network_bonding(int download_id, bool *enable)
-{
-       int is_set = 0;
-       TRACE_INFO("");
-       if (enable == NULL) {
-               TRACE_ERROR("Parameter NULL Check");
-               return DOWNLOAD_ERROR_INVALID_PARAMETER;
-       }
-       int ret = dp_interface_get_network_bonding(download_id, &is_set);
-       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
-               *enable = (bool)is_set;
-       return ret;
-}
-
 int download_set_destination(int download_id, const char *path)
 {
        TRACE_INFO("");
diff --git a/testcase/CMakeLists.txt b/testcase/CMakeLists.txt
new file mode 100644 (file)
index 0000000..30bb6df
--- /dev/null
@@ -0,0 +1,16 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+## PROJECT NAME
+PROJECT(url-download-tc C)
+
+## INCLUDES
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall")
+
+ADD_EXECUTABLE(${PROJECT_NAME}
+       ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.c )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} capi-web-url-download)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+
diff --git a/testcase/url-download-tc.c b/testcase/url-download-tc.c
new file mode 100644 (file)
index 0000000..ee9ff81
--- /dev/null
@@ -0,0 +1,463 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <time.h>
+
+#include <download.h>
+#include <app_control.h>
+
+#define TRACE_DEBUG_MSG(format, ARG...)  \
+{ \
+printf("[url-download][%s:%d] "format"\n", __FUNCTION__, __LINE__, ##ARG); \
+}
+
+#define TRACE_ERROR_MSG(format, ARG...)  \
+{ \
+printf("[url-download][ERROR][%s:%d] "format"\n", __FUNCTION__, __LINE__, ##ARG); \
+}
+
+static char *g_tc_storage = "/opt/usr/media/.url-download-tc";
+
+static char *__print_state(int state)
+{
+       switch (state) {
+       case DOWNLOAD_STATE_READY:
+               return "READY";
+       case DOWNLOAD_STATE_QUEUED:
+               return "QUEUED";
+       case DOWNLOAD_STATE_DOWNLOADING:
+               return "DOWNLOADING";
+       case DOWNLOAD_STATE_PAUSED:
+               return "PAUSED";
+       case DOWNLOAD_STATE_COMPLETED:
+               return "COMPLETED";
+       case DOWNLOAD_STATE_FAILED:
+               return "FAILED";
+       case DOWNLOAD_STATE_CANCELED:
+               return "CANCELED";
+       default:
+               break;
+       }
+       return "UNKNOWN";
+}
+
+static char *__print_errorcode(int errorcode)
+{
+       switch (errorcode) {
+       case DOWNLOAD_ERROR_NONE:
+               return "NONE";
+       case DOWNLOAD_ERROR_INVALID_PARAMETER:
+               return "INVALID_PARAMETER";
+       case DOWNLOAD_ERROR_OUT_OF_MEMORY:
+               return "OUT_OF_MEMORY";
+       case DOWNLOAD_ERROR_IO_ERROR:
+               return "IO_ERROR";
+       case DOWNLOAD_ERROR_NETWORK_UNREACHABLE:
+               return "NETWORK_UNREACHABLE";
+       case DOWNLOAD_ERROR_NO_SPACE:
+               return "NO_SPACE";
+       case DOWNLOAD_ERROR_FIELD_NOT_FOUND:
+               return "FIELD_NOT_FOUND";
+       case DOWNLOAD_ERROR_INVALID_STATE:
+               return "INVALID_STATE";
+       case DOWNLOAD_ERROR_CONNECTION_TIMED_OUT:
+               return "CONNECTION_TIMED_OUT";
+       case DOWNLOAD_ERROR_INVALID_URL:
+               return "INVALID_URL";
+       case DOWNLOAD_ERROR_INVALID_DESTINATION:
+               return "INVALID_DESTINATION";
+       case DOWNLOAD_ERROR_PERMISSION_DENIED:
+               return "PERMISSION_DENIED";
+       case DOWNLOAD_ERROR_QUEUE_FULL:
+               return "QUEUE_FULL";
+       case DOWNLOAD_ERROR_ALREADY_COMPLETED:
+               return "ALREADY_COMPLETED";
+       case DOWNLOAD_ERROR_FILE_ALREADY_EXISTS:
+               return "FILE_ALREADY_EXISTS";
+       case DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS:
+               return "TOO_MANY_DOWNLOADS";
+       case DOWNLOAD_ERROR_NO_DATA:
+               return "NO_DATA";
+       case DOWNLOAD_ERROR_UNHANDLED_HTTP_CODE:
+               return "UNHANDLED_HTTP_CODE";
+       case DOWNLOAD_ERROR_CANNOT_RESUME:
+               return "CANNOT_RESUME";
+       case DOWNLOAD_ERROR_ID_NOT_FOUND:
+               return "ID_NOT_FOUND";
+       default:
+               break;
+       }
+       return "UNKOWN";
+}
+
+static void __download_get_content_name(int download_id)
+{
+       char *str = NULL;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_content_name(download_id, &str);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d content_name error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d content_name (%s)", download_id, str);
+       }
+       free(str);
+}
+
+static void __download_get_mime_type(int download_id)
+{
+       char *str = NULL;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_mime_type(download_id, &str);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d mime_type error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d mime_type (%s)", download_id, str);
+       }
+       free(str);
+}
+
+static void __download_get_file_name(int download_id)
+{
+       char *str = NULL;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_file_name(download_id, &str);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d file_name error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d file_name (%s)", download_id, str);
+       }
+       free(str);
+}
+
+static void __download_get_temp_path(int download_id)
+{
+       char *str = NULL;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_temp_path(download_id, &str);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               download_get_error(download_id, &errorcode);
+               TRACE_ERROR_MSG("download:%d temp_path error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d temp_path (%s)", download_id, str);
+       }
+       free(str);
+}
+
+static void __download_get_destination(int download_id)
+{
+       char *str = NULL;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_destination(download_id, &str);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d destination error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d destination (%s)", download_id, str);
+       }
+       free(str);
+}
+
+static void __download_get_content_size(int download_id)
+{
+       unsigned long long content_size = 0;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_content_size(download_id, &content_size);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d content_size error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d content_size (%lld)", download_id, content_size);
+       }
+}
+
+static download_state_e __download_get_state(int download_id)
+{
+       download_state_e state = DOWNLOAD_STATE_NONE;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_state(download_id, &state);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d state error:%s",download_id, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d state(%s:%d)", download_id, __print_state(state), state);
+       }
+       return state;
+}
+
+static void __download_manager_progress_cb (int download_id, unsigned long long received, void *user_data)
+{
+       // ignore log. too many
+       //TRACE_DEBUG_MSG("download:%d progress(%lld)", download_id, received);
+}
+
+static void __download_manager_state_changed_cb (int download_id, download_state_e state, void *user_data)
+{
+       TRACE_DEBUG_MSG("download:%d state(%s:%d)", download_id, __print_state(state), state);
+       __download_get_state(download_id);
+       if (state == DOWNLOAD_STATE_FAILED) {
+               download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+               download_get_error(download_id, &errorcode);
+               TRACE_DEBUG_MSG("download:%d check error:%s", download_id, __print_errorcode(errorcode));
+       }
+       if (state == DOWNLOAD_STATE_DOWNLOADING) {
+               __download_get_content_name(download_id);
+               __download_get_mime_type(download_id);
+               __download_get_content_size(download_id);
+       }
+       if (state == DOWNLOAD_STATE_PAUSED) {
+       }
+       if (state == DOWNLOAD_STATE_COMPLETED) {
+               __download_get_content_name(download_id);
+               __download_get_mime_type(download_id);
+               __download_get_temp_path(download_id);
+               __download_get_file_name(download_id);
+               __download_get_destination(download_id);
+               __download_get_content_size(download_id);
+       }
+       if (state == DOWNLOAD_STATE_FAILED || state == DOWNLOAD_STATE_COMPLETED || state == DOWNLOAD_STATE_CANCELED)
+       {
+               download_destroy(download_id);
+               TRACE_DEBUG_MSG("download:%d is finished", download_id);
+       }
+}
+
+static int __download_start(char *url, int force)
+{
+       int download_id = 0;
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+
+       errorcode = download_create(&download_id);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d create error:%s", download_id, __print_errorcode(errorcode));
+       } else {
+               errorcode = download_set_state_changed_cb(download_id, __download_manager_state_changed_cb, NULL);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d set_state_changed_cb error:%s", download_id, __print_errorcode(errorcode));
+               }
+               errorcode = download_set_progress_cb(download_id, __download_manager_progress_cb, NULL);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d set_progress_cb error:%s", download_id, __print_errorcode(errorcode));
+               }
+               errorcode = download_set_destination(download_id, g_tc_storage);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d set_destination error:%s", download_id, __print_errorcode(errorcode));
+               }
+               errorcode = download_set_url(download_id, url);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d set_url error:%s", download_id, __print_errorcode(errorcode));
+               }
+               if (force > 0) {
+                       errorcode = download_set_auto_download(download_id, 1);
+                       if (errorcode != DOWNLOAD_ERROR_NONE) {
+                               TRACE_ERROR_MSG("download:%d set_auto error:%s", download_id, __print_errorcode(errorcode));
+                       }
+               }
+               errorcode = download_set_notification_type(download_id, DOWNLOAD_NOTIFICATION_TYPE_ALL);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d et_notification error:%s", download_id, __print_errorcode(errorcode));
+               }
+               errorcode = download_start(download_id);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d start error:%s", download_id, __print_errorcode(errorcode));
+               }
+       }
+       return download_id;
+}
+
+
+int main(int argc, char** argv)
+{
+       download_error_e errorcode = DOWNLOAD_ERROR_NONE;
+       download_state_e state = DOWNLOAD_STATE_NONE;
+       int download_id_state = 0;
+       int download_id_api = 0;
+
+       TRACE_DEBUG_MSG("url-download-tc : start");
+
+       // video content, sometimes network error
+       __download_start("http://wap2.samsungmobile.com/weblogic/TestContentsDownload/avi__MP4_352x288_30fps_araw_2ch_44khz.avi/video_avi/MP4_352x288_30fps_araw_2ch_44khz.avi", 0);
+       // big binary 1.7G from tizen.org
+       download_id_api = __download_start("http://download.tizen.org/sdk/sdk-images/2.2/tizen-sdk-image-2.2.0-windows32.zip", 1);
+       // big tar file 1.2G from webkit.org
+       download_id_state = __download_start("http://nightly.webkit.org/files/WebKit-SVN-source.tar.bz2", 1);
+
+       //stop
+       errorcode = download_cancel(download_id_state);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d stop error:%s", download_id_state, __print_errorcode(errorcode));
+       } else {
+               // start again
+               errorcode = download_start(download_id_state);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d start error:%s", download_id_state, __print_errorcode(errorcode));
+               } else {
+                       // pause
+                       errorcode = download_pause(download_id_state);
+                       if (errorcode != DOWNLOAD_ERROR_NONE) {
+                               TRACE_ERROR_MSG("download:%d pause error:%s", download_id_state, __print_errorcode(errorcode));
+                       } else {
+                               // resume
+                               errorcode = download_start(download_id_state);
+                               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                                       TRACE_ERROR_MSG("download:%d resume error:%s", download_id_state, __print_errorcode(errorcode));
+                               }
+                       }
+               }
+       }
+
+
+       // API test.
+       errorcode = download_set_notification_type(download_id_api, DOWNLOAD_NOTIFICATION_TYPE_ALL);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d stop error:%s", download_id_api, __print_errorcode(errorcode));
+       }
+       const char *notivalues[3] = {"test1","test2","test3"};
+       app_control_h h;
+       if (app_control_create(&h) != APP_CONTROL_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d fail to create app control handle", download_id_api);
+       }
+       if (app_control_add_extra_data(h, "__APP_SVC_PKG_NAME__", "com.samsung.test-app") < 0) {
+               TRACE_ERROR_MSG("download:%d fail to set test pkg name", download_id_api);
+       }
+       if (app_control_add_extra_data_array(h,(const char *)"test-notification-extra-param", notivalues, 3) < 0) {
+               TRACE_ERROR_MSG("download:%d fail to add data to app control handle", download_id_api);
+       }
+       errorcode = download_set_notification_app_control(download_id_api, DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_ONGOING, h);
+       errorcode = download_set_notification_app_control(download_id_api, DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_FAILED, h);
+       if (h != NULL)
+               app_control_destroy(h);
+       h = NULL;
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d set_notification_app_control error:%s", download_id_api, __print_errorcode(errorcode));
+               download_set_notification_title(download_id_api, "test subject");
+               download_set_notification_description(download_id_api, "test description");
+       } else {
+               char **noti_value = NULL;
+               int values_count = 0;
+               errorcode = download_get_notification_app_control(download_id_api, DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_ONGOING, &h);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d get_notification_app_control error:%s", download_id_api, __print_errorcode(errorcode));
+               } else {
+                       app_control_get_extra_data_array(h, "test-notification-extra-param", &noti_value, &values_count);
+                       if (!noti_value) {
+                               TRACE_ERROR_MSG("download:%d fail to get data to app_control", download_id_api);
+                       } else {
+                               int i = 0;
+                               for (; i < values_count; i++) {
+                                       TRACE_DEBUG_MSG("noti_value[%d] : %s", i, noti_value[i]);
+                                       free(noti_value[i]);
+                               }
+                       }
+               }
+               app_control_destroy(h);
+               noti_value = NULL;
+       }
+       state = __download_get_state(download_id_api);
+       download_error_e download_errorcode = DOWNLOAD_ERROR_NONE;
+       errorcode = download_get_error(download_id_api, &download_errorcode);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d check error:%s", download_id_api, __print_errorcode(errorcode));
+       } else {
+               TRACE_DEBUG_MSG("download:%d check error:%s", download_id_api, __print_errorcode(download_errorcode));
+       }
+       errorcode = download_add_http_header_field(download_id_api, "test-header-field1", "test-header-data1");
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d add_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+       }
+       errorcode = download_add_http_header_field(download_id_api, "test-header-field3", "test-header-data3");
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d add_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+       }
+       errorcode = download_add_http_header_field(download_id_api, "test-header-field4", "test-header-data4");
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d add_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+       }
+       errorcode = download_add_http_header_field(download_id_api, "test-header-field2", "test-header-data2");
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d add_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+       } else {
+               char *header_value = NULL;
+               errorcode = download_get_http_header_field(download_id_api, "test-header-field2", &header_value);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d get_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+               } else {
+                       if (header_value == NULL)
+                               TRACE_ERROR_MSG("download:%d get_http_header_field value null", download_id_api);
+                       if (header_value != NULL && strncmp(header_value, "test-header-data2", strlen(header_value)) != 0) {
+                               TRACE_ERROR_MSG("download:%d get_http_header_field return wrong value", download_id_api);
+                       }
+               }
+               free(header_value);
+               header_value = NULL;
+               errorcode = download_remove_http_header_field(download_id_api, "test-header-field2");
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d remove_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+               } else {
+                       // after removing , get_http_header_field must be failed. expected errorcode : DOWNLOAD_ERROR_NO_DATA
+                       errorcode = download_get_http_header_field(download_id_api, "test-header-field2", &header_value);
+                       if (errorcode != DOWNLOAD_ERROR_NONE) {
+                               TRACE_DEBUG_MSG("download:%d get_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+                               if (errorcode != DOWNLOAD_ERROR_NO_DATA)
+                                       TRACE_DEBUG_MSG("download:%d get_http_header_field error:%s", download_id_api, __print_errorcode(errorcode));
+                       } else {
+                               TRACE_ERROR_MSG("download:%d get_http_header_field after deleting return value:%s", download_id_api, header_value);
+                       }
+               }
+       }
+
+       char **fields = NULL;
+       int length = 0;
+       errorcode = download_get_http_header_field_list(download_id_api, &fields, &length);
+       if (errorcode != DOWNLOAD_ERROR_NONE) {
+               TRACE_ERROR_MSG("download:%d get_http_header_field_list error:%s", download_id_api, __print_errorcode(errorcode));
+       } else {
+               if (fields == NULL) {
+                       TRACE_ERROR_MSG("download:%d get_http_header_field_list array null, length:%d", download_id_api, length);
+               } else {
+                       int i = 0;
+                       for (; i < length; i++) {
+                               TRACE_DEBUG_MSG("download:%d get_http_header_field_list %d:%s, length:%d", download_id_api, i, fields[i], length);
+                               free(fields[i]);
+                       }
+                       free(fields);
+               }
+       }
+
+       state = __download_get_state(download_id_api);
+       if (state == DOWNLOAD_STATE_DOWNLOADING) {
+               // in downloading, set_url api must be failed. expected errorcode : DOWNLOAD_ERROR_INVALID_STATE
+               errorcode = download_set_url(download_id_api, "http://test.com");
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_DEBUG_MSG("download:%d set_url error:%s", download_id_api, __print_errorcode(errorcode));
+                       if (errorcode != DOWNLOAD_ERROR_INVALID_STATE)
+                               TRACE_ERROR_MSG("download:%d set_url error:%s", download_id_api, __print_errorcode(errorcode));
+               } else {
+                       TRACE_ERROR_MSG("download:%d set_url in doownloading wrong action", download_id_api);
+               }
+       }
+
+       // 3.8M from tizen.org
+       int download_id = __download_start("http://download.tizen.org/sdk/InstallManager/tizen-sdk-2.2/tizen-sdk-ubuntu32-v2.2.32.bin", 1);
+       struct timespec ts;
+       ts.tv_sec = 0;
+       ts.tv_nsec = 100000;
+       do {
+               nanosleep(&ts, NULL);
+               errorcode = download_get_state(download_id, &state);
+               if (errorcode != DOWNLOAD_ERROR_NONE) {
+                       TRACE_ERROR_MSG("download:%d state error:%s",download_id, __print_errorcode(errorcode));
+                       break;
+               }
+               if (state == DOWNLOAD_STATE_QUEUED || state == DOWNLOAD_STATE_DOWNLOADING) {
+                       sleep(1);
+               }
+       } while (!(state == DOWNLOAD_STATE_FAILED || state == DOWNLOAD_STATE_COMPLETED || state == DOWNLOAD_STATE_CANCELED));
+
+       download_destroy(download_id);
+       download_destroy(download_id_api);
+       download_destroy(download_id_state);
+
+       TRACE_DEBUG_MSG("url-download-tc : finished");
+       exit(EXIT_SUCCESS);
+}