--- /dev/null
+Kwangmin Bang <justine.bang@samsung.com>\r
+Jungki Kwak <jungki.kwak@samsung.com>\r
SET(CMAKE_INSTALL_PREFIX /usr)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
SET(INC_DIR include)
+SET(DOC_DIR doc)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(requires "dlog capi-base-common bundle capi-appfw-app-manager capi-appfw-application download-provider")
+SET(requires "dlog capi-base-common capi-appfw-application download-provider-interface")
MESSAGE(STATUS "PACKAGES : ${requires}")
SET(pc_requires "capi-base-common capi-appfw-application")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
IF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS(-DDP_SUPPORT_DBUS_ACTIVATION)
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-SET(SOURCES src/url_download_provider.c)
+SET(SOURCES src/download-wrapping.c)
MESSAGE(STATUS "SOURCES : ${SOURCES}")
ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+SET_TARGET_PROPERTIES(${fw_name} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${fw_name} PROPERTIES SOVERSION ${VERSION_MAJOR})
-INSTALL(TARGETS ${fw_name} DESTINATION lib)
-INSTALL(
- DIRECTORY ${INC_DIR}/ DESTINATION include/web
- FILES_MATCHING
- PATTERN "*_private.h" EXCLUDE
- PATTERN "${INC_DIR}/*.h"
- )
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${INC_DIR}/download.h DESTINATION include/web/)
+INSTALL(FILES ${DOC_DIR}/download_doc.h DESTINATION include/web/)
SET(PC_NAME ${fw_name})
SET(PC_REQUIRED ${pc_requires})
${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
@ONLY
)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+CONFIGURE_FILE(
+ LICENSE
+ ${fw_name}
+ @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name} DESTINATION share/license)
IF(UNIX)
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
- Apache License\r
- Version 2.0, January 2004\r
- http://www.apache.org/licenses/\r
-\r
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
-\r
- 1. Definitions.\r
-\r
- "License" shall mean the terms and conditions for use, reproduction,\r
- and distribution as defined by Sections 1 through 9 of this document.\r
-\r
- "Licensor" shall mean the copyright owner or entity authorized by\r
- the copyright owner that is granting the License.\r
-\r
- "Legal Entity" shall mean the union of the acting entity and all\r
- other entities that control, are controlled by, or are under common\r
- control with that entity. For the purposes of this definition,\r
- "control" means (i) the power, direct or indirect, to cause the\r
- direction or management of such entity, whether by contract or\r
- otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
- outstanding shares, or (iii) beneficial ownership of such entity.\r
-\r
- "You" (or "Your") shall mean an individual or Legal Entity\r
- exercising permissions granted by this License.\r
-\r
- "Source" form shall mean the preferred form for making modifications,\r
- including but not limited to software source code, documentation\r
- source, and configuration files.\r
-\r
- "Object" form shall mean any form resulting from mechanical\r
- transformation or translation of a Source form, including but\r
- not limited to compiled object code, generated documentation,\r
- and conversions to other media types.\r
-\r
- "Work" shall mean the work of authorship, whether in Source or\r
- Object form, made available under the License, as indicated by a\r
- copyright notice that is included in or attached to the work\r
- (an example is provided in the Appendix below).\r
-\r
- "Derivative Works" shall mean any work, whether in Source or Object\r
- form, that is based on (or derived from) the Work and for which the\r
- editorial revisions, annotations, elaborations, or other modifications\r
- represent, as a whole, an original work of authorship. For the purposes\r
- of this License, Derivative Works shall not include works that remain\r
- separable from, or merely link (or bind by name) to the interfaces of,\r
- the Work and Derivative Works thereof.\r
-\r
- "Contribution" shall mean any work of authorship, including\r
- the original version of the Work and any modifications or additions\r
- to that Work or Derivative Works thereof, that is intentionally\r
- submitted to Licensor for inclusion in the Work by the copyright owner\r
- or by an individual or Legal Entity authorized to submit on behalf of\r
- the copyright owner. For the purposes of this definition, "submitted"\r
- means any form of electronic, verbal, or written communication sent\r
- to the Licensor or its representatives, including but not limited to\r
- communication on electronic mailing lists, source code control systems,\r
- and issue tracking systems that are managed by, or on behalf of, the\r
- Licensor for the purpose of discussing and improving the Work, but\r
- excluding communication that is conspicuously marked or otherwise\r
- designated in writing by the copyright owner as "Not a Contribution."\r
-\r
- "Contributor" shall mean Licensor and any individual or Legal Entity\r
- on behalf of whom a Contribution has been received by Licensor and\r
- subsequently incorporated within the Work.\r
-\r
- 2. Grant of Copyright License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- copyright license to reproduce, prepare Derivative Works of,\r
- publicly display, publicly perform, sublicense, and distribute the\r
- Work and such Derivative Works in Source or Object form.\r
-\r
- 3. Grant of Patent License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- (except as stated in this section) patent license to make, have made,\r
- use, offer to sell, sell, import, and otherwise transfer the Work,\r
- where such license applies only to those patent claims licensable\r
- by such Contributor that are necessarily infringed by their\r
- Contribution(s) alone or by combination of their Contribution(s)\r
- with the Work to which such Contribution(s) was submitted. If You\r
- institute patent litigation against any entity (including a\r
- cross-claim or counterclaim in a lawsuit) alleging that the Work\r
- or a Contribution incorporated within the Work constitutes direct\r
- or contributory patent infringement, then any patent licenses\r
- granted to You under this License for that Work shall terminate\r
- as of the date such litigation is filed.\r
-\r
- 4. Redistribution. You may reproduce and distribute copies of the\r
- Work or Derivative Works thereof in any medium, with or without\r
- modifications, and in Source or Object form, provided that You\r
- meet the following conditions:\r
-\r
- (a) You must give any other recipients of the Work or\r
- Derivative Works a copy of this License; and\r
-\r
- (b) You must cause any modified files to carry prominent notices\r
- stating that You changed the files; and\r
-\r
- (c) You must retain, in the Source form of any Derivative Works\r
- that You distribute, all copyright, patent, trademark, and\r
- attribution notices from the Source form of the Work,\r
- excluding those notices that do not pertain to any part of\r
- the Derivative Works; and\r
-\r
- (d) If the Work includes a "NOTICE" text file as part of its\r
- distribution, then any Derivative Works that You distribute must\r
- include a readable copy of the attribution notices contained\r
- within such NOTICE file, excluding those notices that do not\r
- pertain to any part of the Derivative Works, in at least one\r
- of the following places: within a NOTICE text file distributed\r
- as part of the Derivative Works; within the Source form or\r
- documentation, if provided along with the Derivative Works; or,\r
- within a display generated by the Derivative Works, if and\r
- wherever such third-party notices normally appear. The contents\r
- of the NOTICE file are for informational purposes only and\r
- do not modify the License. You may add Your own attribution\r
- notices within Derivative Works that You distribute, alongside\r
- or as an addendum to the NOTICE text from the Work, provided\r
- that such additional attribution notices cannot be construed\r
- as modifying the License.\r
-\r
- You may add Your own copyright statement to Your modifications and\r
- may provide additional or different license terms and conditions\r
- for use, reproduction, or distribution of Your modifications, or\r
- for any such Derivative Works as a whole, provided Your use,\r
- reproduction, and distribution of the Work otherwise complies with\r
- the conditions stated in this License.\r
-\r
- 5. Submission of Contributions. Unless You explicitly state otherwise,\r
- any Contribution intentionally submitted for inclusion in the Work\r
- by You to the Licensor shall be under the terms and conditions of\r
- this License, without any additional terms or conditions.\r
- Notwithstanding the above, nothing herein shall supersede or modify\r
- the terms of any separate license agreement you may have executed\r
- with Licensor regarding such Contributions.\r
-\r
- 6. Trademarks. This License does not grant permission to use the trade\r
- names, trademarks, service marks, or product names of the Licensor,\r
- except as required for reasonable and customary use in describing the\r
- origin of the Work and reproducing the content of the NOTICE file.\r
-\r
- 7. Disclaimer of Warranty. Unless required by applicable law or\r
- agreed to in writing, Licensor provides the Work (and each\r
- Contributor provides its Contributions) on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
- implied, including, without limitation, any warranties or conditions\r
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
- PARTICULAR PURPOSE. You are solely responsible for determining the\r
- appropriateness of using or redistributing the Work and assume any\r
- risks associated with Your exercise of permissions under this License.\r
-\r
- 8. Limitation of Liability. In no event and under no legal theory,\r
- whether in tort (including negligence), contract, or otherwise,\r
- unless required by applicable law (such as deliberate and grossly\r
- negligent acts) or agreed to in writing, shall any Contributor be\r
- liable to You for damages, including any direct, indirect, special,\r
- incidental, or consequential damages of any character arising as a\r
- result of this License or out of the use or inability to use the\r
- Work (including but not limited to damages for loss of goodwill,\r
- work stoppage, computer failure or malfunction, or any and all\r
- other commercial damages or losses), even if such Contributor\r
- has been advised of the possibility of such damages.\r
-\r
- 9. Accepting Warranty or Additional Liability. While redistributing\r
- the Work or Derivative Works thereof, You may choose to offer,\r
- and charge a fee for, acceptance of support, warranty, indemnity,\r
- or other liability obligations and/or rights consistent with this\r
- License. However, in accepting such obligations, You may act only\r
- on Your own behalf and on Your sole responsibility, not on behalf\r
- of any other Contributor, and only if You agree to indemnify,\r
- defend, and hold each Contributor harmless for any liability\r
- incurred by, or claims asserted against, such Contributor by reason\r
- of your accepting any such warranty or additional liability.\r
-\r
- END OF TERMS AND CONDITIONS\r
-\r
- APPENDIX: How to apply the Apache License to your work.\r
-\r
- To apply the Apache License to your work, attach the following\r
- boilerplate notice, with the fields enclosed by brackets "[]"\r
- replaced with your own identifying information. (Don't include\r
- the brackets!) The text should be enclosed in the appropriate\r
- comment syntax for the file format. We also recommend that a\r
- file or class name and description of purpose be included on the\r
- same "printed page" as the copyright notice for easier\r
- identification within third-party archives.\r
-\r
- Copyright [yyyy] [name of copyright owner]\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
-\r
-\r
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
--- /dev/null
+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.
--- /dev/null
+# Customize below path information
+TET_INSTALL_PATH=/home/warmtree/git_private/DTS/TETware
+TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+
+export ARCH=target
+export TET_ROOT=$TET_TARGET_PATH
+export PATH=$TET_ROOT/bin:$PATH
+export LD_LIBRARY_PATH=$TET_ROOT/lib/tet3:$LD_LIBRARY_PATH
--- /dev/null
+# Customize below path information
+TET_INSTALL_PATH=/mnt/dts/TETware
+TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+
+export ARCH=target
+export TET_ROOT=$TET_TARGET_PATH
+export PATH=$TET_ROOT/bin:$PATH
+export LD_LIBRARY_PATH=$TET_ROOT/lib/tet3:$LD_LIBRARY_PATH
--- /dev/null
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+#!/bin/sh
+
+. ./_export_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+RESULT_DIR=results
+
+tcc -c -p ./ # executing tcc, with clean option (-c)
+rm -r $RESULT_DIR
+rm -r tet_tmp_dir
+rm testcase/tet_captured
--- /dev/null
+PKG_NAME=capi-web-url-download
+TET_INSTALL_HOST_PATH=/var/tmp/dts_fw/TC/TETware
+TET_INSTALL_TARGET_PATH=/opt/home/$PKG_NAME/TETware
--- /dev/null
+#!/bin/sh
+
+. ./_export_target_env.sh # setting environment variables
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+include ../config
+
+CC ?= gcc
+
+C_FILES = $(shell ls *.c)
+
+PKGS = $(PKG_NAME)
+PKGS += glib-2.0
+PKGS += gobject-2.0
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+TCS := $(shell ls -1 *.c | cut -d. -f1)
+
+all: $(TCS)
+
+%: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TCS)
--- /dev/null
+/testcase/utc_download_set_auto_download_negative
+/testcase/utc_download_set_auto_download_positive
+/testcase/utc_download_get_auto_download_negative
+/testcase/utc_download_get_auto_download_positive
+/testcase/utc_download_get_http_header_field_list_negative
+/testcase/utc_download_get_http_header_field_list_positive
+/testcase/utc_download_get_mime_type_negative
+/testcase/utc_download_get_mime_type_positive
+/testcase/utc_download_get_downloaded_file_path_negative
+/testcase/utc_download_get_downloaded_file_path_positive
+/testcase/utc_download_get_file_name_negative
+/testcase/utc_download_get_file_name_positive
+/testcase/utc_download_set_file_name_negative
+/testcase/utc_download_set_file_name_positive
+/testcase/utc_download_get_temp_path_negative
+/testcase/utc_download_get_temp_path_positive
+/testcase/utc_download_get_content_name_negative
+/testcase/utc_download_get_content_name_positive
+/testcase/utc_download_get_content_size_negative
+/testcase/utc_download_get_content_size_positive
+/testcase/utc_download_get_error_negative
+/testcase/utc_download_get_error_positive
+/testcase/utc_download_get_http_status_negative
+/testcase/utc_download_get_http_status_positive
+/testcase/utc_download_set_network_type_negative
+/testcase/utc_download_set_network_type_positive
+/testcase/utc_download_get_network_type_negative
+/testcase/utc_download_get_network_type_positive
+/testcase/utc_download_set_network_bonding_negative
+/testcase/utc_download_set_network_bonding_positive
+/testcase/utc_download_get_network_bonding_negative
+/testcase/utc_download_get_network_bonding_positive
+/testcase/utc_download_start_negative
+/testcase/utc_download_start_positive
+/testcase/utc_download_create_negative
+/testcase/utc_download_create_positive
+/testcase/utc_download_destroy_negative
+/testcase/utc_download_destroy_positive
+/testcase/utc_download_add_http_header_field_negative
+/testcase/utc_download_add_http_header_field_positive
+/testcase/utc_download_get_destination_negative
+/testcase/utc_download_get_destination_positive
+/testcase/utc_download_get_http_header_field_negative
+/testcase/utc_download_get_http_header_field_positive
+/testcase/utc_download_get_state_negative
+/testcase/utc_download_get_state_positive
+/testcase/utc_download_get_url_negative
+/testcase/utc_download_get_url_positive
+/testcase/utc_download_pause_negative
+/testcase/utc_download_pause_positive
+/testcase/utc_download_remove_http_header_field_negative
+/testcase/utc_download_remove_http_header_field_positive
+/testcase/utc_download_set_destination_negative
+/testcase/utc_download_set_destination_positive
+/testcase/utc_download_set_url_negative
+/testcase/utc_download_set_url_positive
+/testcase/utc_download_set_notification_title_negative
+/testcase/utc_download_set_notification_title_positive
+/testcase/utc_download_get_notification_title_negative
+/testcase/utc_download_get_notification_title_positive
+/testcase/utc_download_set_notification_description_negative
+/testcase/utc_download_set_notification_description_positive
+/testcase/utc_download_get_notification_description_negative
+/testcase/utc_download_get_notification_description_positive
+/testcase/utc_download_set_notification_type_negative
+/testcase/utc_download_set_notification_type_positive
+/testcase/utc_download_get_notification_type_negative
+/testcase/utc_download_get_notification_type_positive
+/testcase/utc_download_set_notification_bundle_negative
+/testcase/utc_download_set_notification_bundle_positive
+/testcase/utc_download_get_notification_bundle_negative
+/testcase/utc_download_get_notification_bundle_positive
+/testcase/utc_download_set_state_changed_cb_negative
+/testcase/utc_download_set_state_changed_cb_positive
+/testcase/utc_download_set_progress_cb_negative
+/testcase/utc_download_set_progress_cb_positive
+/testcase/utc_download_unset_state_changed_cb_negative
+/testcase/utc_download_unset_state_changed_cb_positive
+/testcase/utc_download_unset_progress_cb_negative
+/testcase/utc_download_unset_progress_cb_positive
+/testcase/utc_download_get_etag_positive
+/testcase/utc_download_get_etag_negative
+/testcase/utc_download_set_temp_file_path_negative
+/testcase/utc_download_set_temp_file_path_positive
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_add_http_header_field_negative1(void);
+static void utc_download_add_http_header_field_negative2(void);
+static void utc_download_add_http_header_field_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_add_http_header_field_negative1, 1},
+ {utc_download_add_http_header_field_negative2, 2},
+ {utc_download_add_http_header_field_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_add_http_header_field_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_add_http_header_field(-1, "field", "value");
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_add_http_header_field_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_add_http_header_field(id, NULL, "value");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_add_http_header_field_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_add_http_header_field(id, "field", NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_add_http_header_field_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_add_http_header_field_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_add_http_header_field_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_add_http_header_field(id, "field", "value");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_create_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_create_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_create_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_create(NULL);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_create_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_create_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_create_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ retcode = download_create(&id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE) {
+ download_destroy(id);
+ dts_pass(TC_NAME, "retcode has no error");
+ }
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_destroy_negative1(void);
+struct tet_testlist tet_testlist[] = {
+ {utc_download_destroy_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_destroy_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ retcode = download_destroy(-1);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_destroy_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_destroy_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_destroy_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ retcode = download_create(&id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ retcode = download_destroy(id);
+ else {
+ dts_fail(TC_NAME, "create failed");
+ return;
+ }
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_auto_download_negative1(void);\r
+static void utc_download_get_auto_download_negative2(void);\r
+static void utc_download_get_auto_download_negative3(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_auto_download_negative1, 1},\r
+ {utc_download_get_auto_download_negative2, 2},\r
+ {utc_download_get_auto_download_negative3, 3},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_auto_download_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ bool get_enable = false;\r
+\r
+ retcode = download_get_auto_download(-1, &get_enable);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_auto_download_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ \r
+ download_create(&id);\r
+ retcode = download_get_auto_download(id, NULL);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_auto_download_negative3(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+\r
+ retcode = download_get_auto_download(-1, NULL);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_auto_download_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_auto_download_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_auto_download_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ bool enable = true;\r
+ bool getenable = false;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ download_set_auto_download(id, enable);\r
+ retcode = download_get_auto_download(id, &getenable);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE && (enable == getenable))\r
+ dts_pass(TC_NAME, "retcode has no error and the auto nofication status of set API is same as of get API ");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error or the auto notification status of set API is not same as of get API");\r
+}\r
+\r
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_content_name_negative1(void);
+static void utc_download_get_content_name_negative2(void);
+static void utc_download_get_content_name_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_content_name_negative1, 1},
+ {utc_download_get_content_name_negative2, 2},
+ {utc_download_get_content_name_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_content_name_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+
+ retcode = download_get_content_name(-1, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_content_name_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_content_name(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_content_name_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_content_name(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_content_name_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_content_name_positive1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop* gloop = NULL;
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_DOWNLOADING)
+ g_main_loop_quit(gloop);
+
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+}
+
+static void cleanup(void)
+{
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+
+void utc_download_get_content_name_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+
+ retcode = download_get_content_name(id, &output);
+
+ download_unset_state_changed_cb(id);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && output)
+ dts_pass(TC_NAME, "retcode has no error and content exists");
+ else
+ dts_fail(TC_NAME, "retcode has error or content does not exists");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_content_size_negative1(void);
+static void utc_download_get_content_size_negative2(void);
+static void utc_download_get_content_size_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_content_size_negative1, 1},
+ {utc_download_get_content_size_negative2, 2},
+ {utc_download_get_content_size_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_content_size_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ unsigned long long output = 0;
+
+ retcode = download_get_content_size(-1, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_content_size_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_content_size(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_content_size_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_content_size(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_content_size_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_content_size_positive1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop* gloop = NULL;
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_DOWNLOADING)
+ g_main_loop_quit(gloop);
+
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+}
+
+static void cleanup(void)
+{
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+
+void utc_download_get_content_size_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ unsigned long long output = 0;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+
+ retcode = download_get_content_size(id, &output);
+ if ( retcode != DOWNLOAD_ERROR_NONE )
+ dts_message(TC_NAME,"Fail to get content name");
+
+ retcode = download_unset_state_changed_cb(id);
+ if ( retcode != DOWNLOAD_ERROR_NONE )
+ dts_message(TC_NAME,"Fail to unset callback");
+
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && (output > 0))
+ dts_pass(TC_NAME, "retcode has no error and size is valid");
+ else
+ dts_fail(TC_NAME, "retcode has error or size not valid");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_destination_negative1(void);
+static void utc_download_get_destination_negative2(void);
+static void utc_download_get_destination_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_destination_negative1, 1},
+ {utc_download_get_destination_negative2, 2},
+ {utc_download_get_destination_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_destination_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+
+ retcode = download_get_destination(-1, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_destination_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "URL";
+ int id = 0;
+
+ download_create(&id);
+ download_set_destination(id, input);
+ retcode = download_get_destination(id, NULL);
+
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_destination_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_destination(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_destination_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_destination_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_destination_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "/opt/usr/media/Downloads";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_set_destination(id, input);
+ retcode = download_get_destination(id, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(input, output))
+ dts_pass(TC_NAME, "retcode has no error and the destination of set API is same to destination of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the destination of set API is not same to destination of get API");
+}
+
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_downloaded_file_path_negative1(void);\r
+static void utc_download_get_downloaded_file_path_negative2(void);\r
+static void utc_download_get_downloaded_file_path_negative3(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_downloaded_file_path_negative1, 1},\r
+ {utc_download_get_downloaded_file_path_negative2, 2},\r
+ {utc_download_get_downloaded_file_path_negative3, 3},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_downloaded_file_path_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char *output = NULL;\r
+\r
+ retcode = download_get_downloaded_file_path(-1, &output);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_downloaded_file_path_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ \r
+ download_create(&id);\r
+ retcode = download_get_downloaded_file_path(id, NULL);\r
+\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_downloaded_file_path_negative3(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+\r
+ retcode = download_get_downloaded_file_path(-1, NULL);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+#include <glib.h>\r
+#include <glib-object.h>\r
+\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_downloaded_file_path_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_downloaded_file_path_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static GMainLoop* gloop = NULL;\r
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"\r
+\r
+static void state_cb (int download_id, download_state_e state, void *user_data)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ download_error_e err = DOWNLOAD_ERROR_NONE;\r
+ if (state == DOWNLOAD_STATE_COMPLETED)\r
+ g_main_loop_quit(gloop);\r
+ \r
+ retcode = download_get_error(download_id, &err);\r
+ if (retcode != DOWNLOAD_ERROR_NONE) {\r
+ dts_fail(TC_NAME, "Fail to get error");\r
+ g_main_loop_quit(gloop);\r
+ return;\r
+ }\r
+ dts_message(TC_NAME, "err[%d]", err);\r
+ if (err == DOWNLOAD_ERROR_INVALID_URL)\r
+ dts_message(TC_NAME, "invaild url err");\r
+ else\r
+ dts_message(TC_NAME, "another error[%d]", err);\r
+}\r
+\r
+\r
+static void startup(void)\r
+{\r
+ g_type_init();\r
+ gloop = g_main_loop_new (NULL, 0);\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ g_main_loop_unref(gloop);\r
+ gloop = NULL;\r
+}\r
+\r
+\r
+void utc_download_get_downloaded_file_path_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char *output = NULL;\r
+ int id = 0;\r
+\r
+ retcode = download_create(&id);\r
+ if (retcode != DOWNLOAD_ERROR_NONE) {\r
+ dts_fail(TC_NAME,"Fail to create download handle");\r
+ return;\r
+ }\r
+ retcode = download_set_url(id, TEST_URL);\r
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {\r
+ dts_fail(TC_NAME,"Fail to set url");\r
+ return;\r
+ }\r
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);\r
+ if (retcode != DOWNLOAD_ERROR_NONE)\r
+ dts_fail(TC_NAME, "Fail to set callback");\r
+\r
+ retcode = download_start(id);\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ g_main_loop_run(gloop);\r
+\r
+ retcode = download_get_downloaded_file_path(id, &output);\r
+ if ( retcode != DOWNLOAD_ERROR_NONE )\r
+ dts_message(TC_NAME,"Fail to get content name");\r
+\r
+ download_unset_state_changed_cb(id);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has no error");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error");\r
+}\r
+\r
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_error_negative1(void);
+static void utc_download_get_error_negative2(void);
+static void utc_download_get_error_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_error_negative1, 1},
+ {utc_download_get_error_negative2, 2},
+ {utc_download_get_error_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_error_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+
+ retcode = download_get_error(-1, &err);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_error_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_error(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_error_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_error(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_error_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_error_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_error_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_error(id, &err);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error and temp path exists");
+ else
+ dts_fail(TC_NAME, "retcode has error or temp path does not exists");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_etag_negative1(void);
+static void utc_download_get_etag_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_etag_negative1, 1},
+ {utc_download_get_etag_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_etag_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *etag = NULL;
+
+ retcode = download_get_etag(-1,&etag);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_etag_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_etag(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_etag_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_etag_positive1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop* gloop = NULL;
+#define TEST_URL "http://download.tizen.org/sdk/InstallManager/tizen-sdk-2.2.1/tizen-sdk-ubuntu32-v2.2.71.bin"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_DOWNLOADING)
+ g_main_loop_quit(gloop);
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+}
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+}
+
+static void cleanup(void)
+{
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+ /* end of TC */
+}
+
+void utc_download_get_etag_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *etag = NULL;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+
+ retcode = download_get_etag(id, &etag);
+ download_cancel(id);
+ download_unset_state_changed_cb(id);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_file_name_negative1(void);\r
+static void utc_download_get_file_name_negative2(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_file_name_negative1, 1},\r
+ {utc_download_get_file_name_negative2, 2},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_file_name_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char *file_name = NULL;\r
+\r
+ retcode = download_get_file_name(-1,&file_name);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_file_name_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ retcode = download_get_file_name(id, NULL);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_file_name_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_file_name_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_file_name_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char *file_name1 = "file";\r
+ char *file_name2 = NULL;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ download_set_file_name(id, file_name1);\r
+ retcode = download_get_file_name(id, &file_name2);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(file_name1,file_name2))\r
+ dts_pass(TC_NAME, "retcode has no error and file name of set API is same as file name of get API");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error or file_name of set API and get API are not same");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_http_header_field_list_negative1(void);\r
+static void utc_download_get_http_header_field_list_negative2(void);\r
+static void utc_download_get_http_header_field_list_negative3(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_http_header_field_list_negative1, 1},\r
+ {utc_download_get_http_header_field_list_negative2, 2},\r
+ {utc_download_get_http_header_field_list_negative3, 3},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_http_header_field_list_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ int length=0;\r
+ \r
+ download_create(&id);\r
+ download_add_http_header_field(id, "field1","value1");\r
+ retcode = download_get_http_header_field_list(id, NULL, &length);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_http_header_field_list_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ char **fields = NULL;\r
+ \r
+ download_create(&id);\r
+ download_add_http_header_field(id, "field1","value1");\r
+ retcode = download_get_http_header_field_list(id, &fields, NULL);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_http_header_field_list_negative3(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char **fields = NULL;\r
+ int length = 0;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ download_add_http_header_field(id, "field1","value1");\r
+ retcode = download_get_http_header_field_list(-1, &fields, &length);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_http_header_field_list_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_http_header_field_list_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_http_header_field_list_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char **fields = NULL;\r
+ int length = 0;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ download_add_http_header_field(id, "field1","value1");\r
+ download_add_http_header_field(id, "field2","value2");\r
+ retcode =download_get_http_header_field_list(id, &fields,&length);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has no error");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error");\r
+}\r
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_http_header_field_negative1(void);
+static void utc_download_get_http_header_field_negative2(void);
+static void utc_download_get_http_header_field_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_http_header_field_negative1, 1},
+ {utc_download_get_http_header_field_negative2, 2},
+ {utc_download_get_http_header_field_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_http_header_field_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "field";
+ char *input = "input";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_add_http_header_field(id, field, input);
+ retcode = download_get_http_header_field(id, NULL, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_http_header_field_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "field";
+ char *input = "input";
+ int id = 0;
+
+ download_create(&id);
+ download_add_http_header_field(id, field, input);
+ retcode = download_get_http_header_field(id, field, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_http_header_field_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "field";
+ char *input = "input";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_add_http_header_field(id, field, input);
+ retcode = download_get_http_header_field(-1, field, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_http_header_field_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_http_header_field_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_http_header_field_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "field";
+ char *input = "input";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_add_http_header_field(id, field, input);
+ retcode = download_get_http_header_field(id, field, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(input, output))
+ dts_pass(TC_NAME, "retcode has no error and the http header of set API is same to http header of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the http header of set API is not same to http header of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_http_status_negative1(void);
+static void utc_download_get_http_status_negative2(void);
+static void utc_download_get_http_status_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_http_status_negative1, 1},
+ {utc_download_get_http_status_negative2, 2},
+ {utc_download_get_http_status_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_http_status_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int status = 0;
+
+ retcode = download_get_http_status(-1, &status);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_http_status_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_http_status(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_http_status_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_http_status(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_http_status_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_http_status_positive1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop* gloop = NULL;
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_DOWNLOADING)
+ g_main_loop_quit(gloop);
+
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+}
+
+static void cleanup(void)
+{
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+
+void utc_download_get_http_status_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int status = 0;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+
+ retcode = download_get_http_status(id, &status);
+
+ download_unset_state_changed_cb(id);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_mime_type_negative1(void);\r
+static void utc_download_get_mime_type_negative2(void);\r
+static void utc_download_get_mime_type_negative3(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_mime_type_negative1, 1},\r
+ {utc_download_get_mime_type_negative2, 2},\r
+ {utc_download_get_mime_type_negative3, 3},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_mime_type_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char *output = NULL;\r
+\r
+ retcode = download_get_mime_type(-1, &output);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_mime_type_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ \r
+ download_create(&id);\r
+ retcode = download_get_mime_type(id, NULL);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_mime_type_negative3(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+\r
+ retcode = download_get_mime_type(-1, NULL);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+#include <glib.h>\r
+#include <glib-object.h>\r
+\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_mime_type_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_mime_type_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static GMainLoop* gloop = NULL;\r
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"\r
+\r
+static void state_cb (int download_id, download_state_e state, void *user_data)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ download_error_e err = DOWNLOAD_ERROR_NONE;\r
+ if (state == DOWNLOAD_STATE_DOWNLOADING)\r
+ g_main_loop_quit(gloop);\r
+ \r
+ retcode = download_get_error(download_id, &err);\r
+ if (retcode != DOWNLOAD_ERROR_NONE) {\r
+ dts_fail(TC_NAME, "Fail to get error");\r
+ g_main_loop_quit(gloop);\r
+ return;\r
+ }\r
+ dts_message(TC_NAME, "err[%d]", err);\r
+ if (err == DOWNLOAD_ERROR_INVALID_URL)\r
+ dts_message(TC_NAME, "invaild url err");\r
+ else\r
+ dts_message(TC_NAME, "another error[%d]", err);\r
+}\r
+\r
+\r
+static void startup(void)\r
+{\r
+ g_type_init();\r
+ gloop = g_main_loop_new (NULL, 0);\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ g_main_loop_unref(gloop);\r
+ gloop = NULL;\r
+}\r
+\r
+void utc_download_get_mime_type_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ char *output = NULL;\r
+ int id = 0;\r
+\r
+ retcode = download_create(&id);\r
+ if (retcode != DOWNLOAD_ERROR_NONE) {\r
+ dts_fail(TC_NAME,"Fail to create download handle");\r
+ return;\r
+ }\r
+ retcode = download_set_url(id, TEST_URL);\r
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {\r
+ dts_fail(TC_NAME,"Fail to set url");\r
+ return;\r
+ }\r
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);\r
+ if (retcode != DOWNLOAD_ERROR_NONE)\r
+ dts_fail(TC_NAME, "Fail to set callback");\r
+\r
+ retcode = download_start(id);\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ g_main_loop_run(gloop);\r
+ \r
+ retcode = download_get_mime_type(id, &output);\r
+ if ( retcode != DOWNLOAD_ERROR_NONE )\r
+ dts_message(TC_NAME,"Fail to get content name");\r
+ \r
+ download_unset_state_changed_cb(id);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has no error");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_network_bonding_negative1(void);\r
+static void utc_download_get_network_bonding_negative2(void);\r
+static void utc_download_get_network_bonding_negative3(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_network_bonding_negative1, 1},\r
+ {utc_download_get_network_bonding_negative2, 2},\r
+ {utc_download_get_network_bonding_negative3, 3},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_network_bonding_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ bool get_enable = false;\r
+\r
+ retcode = download_get_network_bonding(-1, &get_enable);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_network_bonding_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ \r
+ download_create(&id);\r
+ retcode = download_get_network_bonding(id, NULL);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_get_network_bonding_negative3(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+\r
+ retcode = download_get_network_bonding(-1, NULL);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_get_network_bonding_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_get_network_bonding_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_get_network_bonding_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ bool enable = true;\r
+ bool getenable = false;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ download_set_network_bonding(id, enable);\r
+ retcode = download_get_network_bonding(id, &getenable);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE && (enable == getenable))\r
+ dts_pass(TC_NAME, "retcode has no error and the network bonding status of set API is same as of get API ");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error or the network bonding status of set API is not same as of get API");\r
+}\r
+\r
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_network_type_negative1(void);
+static void utc_download_get_network_type_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_network_type_negative1, 1},
+ {utc_download_get_network_type_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_network_type_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_network_type_e type = DOWNLOAD_NETWORK_DATA_NETWORK;
+
+ retcode = download_get_network_type(-1, &type);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_network_type_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_network_type(id, NULL);
+ download_destroy(id);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has error");
+ else
+ dts_fail(TC_NAME, "retcode does not have error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_network_type_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_network_type_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_network_type_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_network_type_e output;
+ int id = 0;
+
+ download_create(&id);
+ download_set_network_type(id, DOWNLOAD_NETWORK_DATA_NETWORK);
+ retcode = download_get_network_type(id, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && (output == DOWNLOAD_NETWORK_DATA_NETWORK))
+ dts_pass(TC_NAME, "retcode has no error and the type of set API is same to type of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the type of set API is not same to type of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_bundle_negative1(void);
+static void utc_download_get_notification_bundle_negative2(void);
+static void utc_download_get_notification_bundle_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_bundle_negative1, 1},
+ {utc_download_get_notification_bundle_negative2, 2},
+ {utc_download_get_notification_bundle_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_bundle_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ bundle *b = NULL;
+
+ retcode = download_get_notification_bundle(-1, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, &b);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_bundle_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_bundle_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+ bundle *b = NULL;
+
+ download_create(&id);
+ retcode = download_get_notification_bundle(id, 4, &b);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has error");
+ else
+ dts_fail(TC_NAME, "retcode does not have error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_bundle_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_bundle_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_bundle_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "ongoing";
+ char *output = NULL;
+ int id = 0;
+ bundle *b = bundle_create();
+ bundle *b_db = NULL;
+ bundle_add(b, "key", input);
+
+ download_create(&id);
+ download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, b);
+ retcode = download_get_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, &b_db);
+ output = bundle_get_val(b_db, "key");
+ download_destroy(id);
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(input, output))
+ dts_pass(TC_NAME, "retcode has no error and the bundle of set API is same to bundle of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the bundle of set API is not same to bundle of get API");
+ bundle_free(b);
+ bundle_free(b_db);
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_description_negative1(void);
+static void utc_download_get_notification_description_negative2(void);
+static void utc_download_get_notification_description_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_description_negative1, 1},
+ {utc_download_get_notification_description_negative2, 2},
+ {utc_download_get_notification_description_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_description_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+
+ retcode = download_get_notification_description(-1, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_description_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_notification_description(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_description_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_notification_description(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_description_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_description_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_description_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "description";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_set_notification_description(id, input);
+ retcode = download_get_notification_description(id, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(input, output))
+ dts_pass(TC_NAME, "retcode has no error and the description of set API is same to description of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the description of set API is not same to description of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_title_negative1(void);
+static void utc_download_get_notification_title_negative2(void);
+static void utc_download_get_notification_title_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_title_negative1, 1},
+ {utc_download_get_notification_title_negative2, 2},
+ {utc_download_get_notification_title_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_title_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+
+ retcode = download_get_notification_title(-1, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_title_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_notification_title(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_title_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_notification_title(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_title_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_title_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_title_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "title";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_set_notification_title(id, input);
+ retcode = download_get_notification_title(id, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(input, output))
+ dts_pass(TC_NAME, "retcode has no error and the title of set API is same to title of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the title of set API is not same to title of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_type_negative1(void);
+static void utc_download_get_notification_type_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_type_negative1, 1},
+ {utc_download_get_notification_type_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_type_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_notification_type_e *type = NULL;
+
+ retcode = download_get_notification_type(-1, &type);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_notification_type_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_notification_type(id, NULL);
+ download_destroy(id);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has error");
+ else
+ dts_fail(TC_NAME, "retcode does not have error");
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_notification_type_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_notification_type_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_notification_type_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_notification_type_e output;
+ int id = 0;
+
+ download_create(&id);
+ download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_NONE);
+ retcode = download_get_notification_type(id, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && (output == DOWNLOAD_NOTIFICATION_TYPE_NONE))
+ dts_pass(TC_NAME, "retcode has no error and the type of set API is same to type of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the type of set API is not same to type of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_state_negative1(void);
+static void utc_download_get_state_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_state_negative1, 1},
+ {utc_download_get_state_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_download_get_state_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_state_e state = 0;
+
+ retcode = download_get_state(-1, &state);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+static void utc_download_get_state_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_state(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_state_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_state_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_download_get_state_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+ download_state_e state = 0;
+
+ download_create(&id);
+ retcode = download_get_state(id, &state);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && state == DOWNLOAD_STATE_READY)
+ dts_pass(TC_NAME, "retcode has no error and the url of set API is same to url of get API");
+ else
+ dts_fail(TC_NAME, "retcode has error or the url of set API is not same to url of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_temp_path_negative1(void);
+static void utc_download_get_temp_path_negative2(void);
+static void utc_download_get_temp_path_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_temp_path_negative1, 1},
+ {utc_download_get_temp_path_negative2, 2},
+ {utc_download_get_temp_path_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_temp_path_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+
+ retcode = download_get_temp_path(-1, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_temp_path_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_get_temp_path(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_temp_path_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_temp_path(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_temp_path_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_temp_path_positive1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop* gloop = NULL;
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_DOWNLOADING)
+ g_main_loop_quit(gloop);
+
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+}
+
+static void cleanup(void)
+{
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+
+
+void utc_download_get_temp_path_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+
+ retcode = download_get_temp_path(id, &output);
+
+ download_unset_state_changed_cb(id);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_url_negative1(void);
+static void utc_download_get_url_negative2(void);
+static void utc_download_get_url_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_url_negative1, 1},
+ {utc_download_get_url_negative2, 2},
+ {utc_download_get_url_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_url_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *output = NULL;
+
+ retcode = download_get_url(NULL, &output);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_url_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "URL";
+ int id = 0;
+
+ download_create(&id);
+ download_set_url(id, input);
+ retcode = download_get_url(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_get_url_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_get_url(NULL, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_get_url_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_get_url_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_get_url_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *input = "URL";
+ char *output = NULL;
+ int id = 0;
+
+ download_create(&id);
+ download_set_url(id, input);
+ retcode = download_get_url(id, &output);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE && !strcmp(input, output))
+ dts_pass(TC_NAME, "retcode has no error and the url of set API is same to url of get API ");
+ else
+ dts_fail(TC_NAME, "retcode has error or the url of set API is not same to url of get API");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_pause_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_pause_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_download_pause_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_pause(-1);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_pause_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_pause_positive1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop* gloop = NULL;
+static int is_pause_success = false;
+static int is_started = false;
+
+#define TEST_URL "http://cdn.naver.com/naver/NanumFont/setup/NanumFontSetup_TTF_GOTHIC_hangeulcamp.exe"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_COMPLETED)
+ g_main_loop_quit(gloop);
+ else if(state == DOWNLOAD_STATE_PAUSED) {
+ is_pause_success = true;
+ g_main_loop_quit(gloop);
+ } else if(state == DOWNLOAD_STATE_DOWNLOADING)
+ is_started = true;
+
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+ is_pause_success = true;
+}
+
+static void cleanup(void)
+{
+ is_pause_success = false;
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+
+static void utc_download_pause_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_message(TC_NAME,"Fail to start download");
+ is_started = false;
+ }
+
+ if (is_started) {
+ sleep(1);
+ retcode = download_pause(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+ else {
+ dts_message(TC_NAME,"Fail to pause download");
+ is_pause_success = false;
+ }
+ }
+
+ retcode = download_unset_state_changed_cb(id);
+ if ( retcode != DOWNLOAD_ERROR_NONE )
+ dts_message(TC_NAME,"Fail to unset callback");
+
+ download_destroy(id);
+
+ if (is_pause_success)
+ dts_pass(TC_NAME, "It is success to pause download content");
+ else
+ dts_fail(TC_NAME, "It is not success to pause download content");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_remove_http_header_field_negative1(void);
+static void utc_download_remove_http_header_field_negative2(void);
+static void utc_download_remove_http_header_field_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_remove_http_header_field_negative1, 1},
+ {utc_download_remove_http_header_field_negative2, 2},
+ {utc_download_remove_http_header_field_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_remove_http_header_field_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "negativefield1";
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_remove_http_header_field(id, field);
+ download_destroy(id);
+
+ dts_message(TC_NAME, "retcode[%d]",retcode);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has error about no found field");
+ else
+ dts_fail(TC_NAME, "retcode does not have error about no found field");
+}
+
+void utc_download_remove_http_header_field_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "negativefield2";
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_remove_http_header_field(-1, field);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_remove_http_header_field_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_remove_http_header_field(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_remove_http_header_field_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_remove_http_header_field_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_remove_http_header_field_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ char *field = "field";
+ char *input = "input";
+ int id = 0;
+
+ download_create(&id);
+ download_add_http_header_field(id, field, input);
+ retcode = download_remove_http_header_field(id, field);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_set_auto_download_negative1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_set_auto_download_negative1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_set_auto_download_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ bool enable = false;\r
+\r
+ retcode = download_set_auto_download(-1,enable );\r
+\r
+ if (retcode != DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_set_auto_download_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_set_auto_download_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_set_auto_download_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ bool enable = true;\r
+\r
+ download_create(&id);\r
+ retcode = download_set_auto_download(id, enable);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has no error");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error");\r
+}\r
+\r
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_destination_negative1(void);
+static void utc_download_set_destination_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_destination_negative1, 1},
+ {utc_download_set_destination_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_destination_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_destination(-1, "destination");
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_destination_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_destination(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_destination_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_destination_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_destination_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_destination(id, "/opt/usr/media/Downloads");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_set_file_name_negative1(void);\r
+static void utc_download_set_file_name_negative2(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_set_file_name_negative1, 1},\r
+ {utc_download_set_file_name_negative2, 2},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_set_file_name_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+\r
+ retcode = download_set_file_name(-1, "file1");\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
+void utc_download_set_file_name_negative2(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ retcode = download_set_file_name(id, NULL);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_set_file_name_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_set_file_name_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_set_file_name_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+\r
+ download_create(&id);\r
+ retcode = download_set_file_name(id, "file1");\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has no error");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_set_network_bonding_negative1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_set_network_bonding_negative1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_set_network_bonding_negative1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ bool enable = false;\r
+\r
+ retcode = download_set_network_bonding(-1,enable );\r
+\r
+ if (retcode != DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has invalid parameter");\r
+ else\r
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <tet_api.h>\r
+#include <download.h>\r
+\r
+static void startup(void);\r
+static void cleanup(void);\r
+\r
+void (*tet_startup)(void) = startup;\r
+void (*tet_cleanup)(void) = cleanup;\r
+\r
+static void utc_download_set_network_bonding_positive1(void);\r
+\r
+struct tet_testlist tet_testlist[] = {\r
+ {utc_download_set_network_bonding_positive1, 1},\r
+ {NULL, 0},\r
+};\r
+\r
+static void startup(void)\r
+{\r
+\r
+}\r
+\r
+static void cleanup(void)\r
+{\r
+ /* end of TC */\r
+}\r
+\r
+void utc_download_set_network_bonding_positive1(void)\r
+{\r
+ const char *TC_NAME = __FUNCTION__;\r
+ int retcode = 0;\r
+ int id = 0;\r
+ bool enable = true;\r
+\r
+ download_create(&id);\r
+ retcode = download_set_network_bonding(id, enable);\r
+ download_destroy(id);\r
+\r
+ if (retcode == DOWNLOAD_ERROR_NONE)\r
+ dts_pass(TC_NAME, "retcode has no error");\r
+ else\r
+ dts_fail(TC_NAME, "retcode has error");\r
+}\r
+\r
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_network_type_negative1(void);
+static void utc_download_set_network_type_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_network_type_negative1, 1},
+ {utc_download_set_network_type_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_network_type_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_network_type(-1, DOWNLOAD_NETWORK_DATA_NETWORK);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_network_type_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_network_type(id, 10);
+ download_destroy(id);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has error");
+ else
+ dts_fail(TC_NAME, "retcode does not have error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_network_type_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_network_type_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_network_type_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_network_type(id, DOWNLOAD_NETWORK_DATA_NETWORK);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_bundle_negative1(void);
+static void utc_download_set_notification_bundle_negative2(void);
+static void utc_download_set_notification_bundle_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_bundle_negative1, 1},
+ {utc_download_set_notification_bundle_negative2, 2},
+ {utc_download_set_notification_bundle_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_bundle_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ bundle *b = bundle_create();
+
+ bundle_add(b, "key", "ongoing");
+ retcode = download_set_notification_bundle(-1, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, b);
+ bundle_free(b);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_bundle_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_bundle_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+ bundle *b = bundle_create();
+ bundle_add(b, "key", "ongoing");
+
+ download_create(&id);
+ retcode = download_set_notification_bundle(id, 4, b);
+ download_destroy(id);
+ bundle_free(b);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_bundle_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_bundle_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_bundle_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+ bundle *b = bundle_create();
+ bundle_add(b, "key", "ongoing");
+
+ download_create(&id);
+ retcode = download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING, b);
+ download_destroy(id);
+ bundle_free(b);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_description_negative1(void);
+static void utc_download_set_notification_description_negative2(void);
+static void utc_download_set_notification_description_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_description_negative1, 1},
+ {utc_download_set_notification_description_negative2, 2},
+ {utc_download_set_notification_description_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_description_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_notification_description(-1, "description");
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_description_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_description(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_description_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_description(id, "");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_description_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_description_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_description_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_title(id, "description");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_title_negative1(void);
+static void utc_download_set_notification_title_negative2(void);
+static void utc_download_set_notification_title_negative3(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_title_negative1, 1},
+ {utc_download_set_notification_title_negative2, 2},
+ {utc_download_set_notification_title_negative3, 3},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_title_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_notification_title(-1, "title");
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_title_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_title(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_title_negative3(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_title(id, "");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_title_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_title_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_title_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_title(id, "title");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_type_negative1(void);
+static void utc_download_set_notification_type_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_type_negative1, 1},
+ {utc_download_set_notification_type_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_type_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_notification_type(-1, DOWNLOAD_NOTIFICATION_TYPE_NONE);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_notification_type_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_type(id, 5);
+ download_destroy(id);
+
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has error");
+ else
+ dts_fail(TC_NAME, "retcode does not have error");
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_notification_type_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_notification_type_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_notification_type_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_NONE);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_progress_cb_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_progress_cb_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void on_url_download_progess(int id, unsigned long long received, unsigned long long total, void *user_data)
+{
+
+}
+
+static void utc_download_set_progress_cb_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_progress_cb(-1, on_url_download_progess, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_progress_cb_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_progress_cb_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void on_url_download_progess(int id, unsigned long long received, unsigned long long total, void *user_data)
+{
+
+}
+
+static void utc_download_set_progress_cb_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_progress_cb(id, on_url_download_progess, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_state_changed_cb_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_state_changed_cb_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void on_url_download_state_changed(int download_id, download_state_e state, void *user_data)
+{
+
+}
+
+static void utc_download_set_state_changed_cb_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_state_changed_cb(-1, on_url_download_state_changed, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_state_changed_cb_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_state_changed_cb_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void on_url_download_state_changed(int download_id, download_state_e state, void *user_data)
+{
+
+}
+
+static void utc_download_set_state_changed_cb_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_state_changed_cb(id, on_url_download_state_changed, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_temp_file_path_negative1(void);
+static void utc_download_set_temp_file_path_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_temp_file_path_negative1, 1},
+ {utc_download_set_temp_file_path_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_temp_file_path_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_temp_file_path(-1, "temp_file");
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_temp_file_path_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_temp_file_path(-1, NULL);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_temp_file_path_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_temp_file_path_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_temp_file_path_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_temp_file_path(id,
+ "/opt/usr/media/Downloads/.temp_download/abc.txt");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_url_negative1(void);
+static void utc_download_set_url_negative2(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_url_negative1, 1},
+ {utc_download_set_url_negative2, 2},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_url_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_set_url(-1, "URL");
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
+void utc_download_set_url_negative2(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_url(id, NULL);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_set_url_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_set_url_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+void utc_download_set_url_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ retcode = download_set_url(id, "URL");
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_start_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_start_negative1, 1},
+ {NULL, 0},
+};
+
+static GMainLoop *gloop = NULL;
+static int is_download_failed = 0;
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+ is_download_failed = false;
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+ is_download_failed = false;
+ g_main_loop_quit(gloop);
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_FAILED || state == DOWNLOAD_STATE_CANCELED) {
+ is_download_failed = true;
+ g_main_loop_quit(gloop);
+ }
+ else
+ is_download_failed = false;
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+static void utc_download_start_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to create download id");
+ retcode = download_set_url(id, "abc.com");
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set url");
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+
+ retcode = download_unset_state_changed_cb(id);
+ if ( retcode != DOWNLOAD_ERROR_NONE )
+ dts_message(TC_NAME,"Fail to unset callback");
+ download_destroy(id);
+
+ if (is_download_failed)
+ dts_pass(TC_NAME, "retcode has invalid url");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid url");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+#include <glib.h>
+#include <glib-object.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_start_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_start_positive1, 1},
+ {NULL, 0},
+};
+
+//static url_download_h handle = NULL;
+static GMainLoop* gloop = NULL;
+static int is_download_success = true;
+
+#define TEST_URL "http://static.campaign.naver.com/0/hangeul/2011/img/img_family.gif"
+//#define TEST_URL "http://cdn.naver.com/naver/NanumFont/setup/NanumFontSetup_TTF_GOTHICLIGHT_hangeulcamp.exe"
+
+static void state_cb (int download_id, download_state_e state, void *user_data)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ download_error_e err = DOWNLOAD_ERROR_NONE;
+ if (state == DOWNLOAD_STATE_COMPLETED || state == DOWNLOAD_STATE_DOWNLOADING) {
+ is_download_success = true;
+ g_main_loop_quit(gloop);
+ } else
+ is_download_success = false;
+
+ retcode = download_get_error(download_id, &err);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME, "Fail to get error");
+ g_main_loop_quit(gloop);
+ return;
+ }
+ dts_message(TC_NAME, "err[%d]", err);
+ if (err == DOWNLOAD_ERROR_INVALID_URL)
+ dts_message(TC_NAME, "invaild url err");
+ else
+ dts_message(TC_NAME, "another error[%d]", err);
+}
+
+static void startup(void)
+{
+ g_type_init();
+ gloop = g_main_loop_new (NULL, 0);
+ is_download_success = true;
+}
+
+static void cleanup(void)
+{
+ is_download_success = false;
+ g_main_loop_unref(gloop);
+ gloop = NULL;
+}
+
+static void utc_download_start_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ retcode = download_create(&id);
+ if (retcode != DOWNLOAD_ERROR_NONE) {
+ dts_fail(TC_NAME,"Fail to create download handle");
+ return;
+ }
+ retcode = download_set_url(id, TEST_URL);
+ if ( retcode != DOWNLOAD_ERROR_NONE ) {
+ dts_fail(TC_NAME,"Fail to set url");
+ return;
+ }
+ retcode = download_set_state_changed_cb(id, state_cb, NULL);
+ if (retcode != DOWNLOAD_ERROR_NONE)
+ dts_fail(TC_NAME, "Fail to set callback");
+
+ retcode = download_start(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ g_main_loop_run(gloop);
+ else
+ is_download_success = false;
+
+ retcode = download_unset_state_changed_cb(id);
+ if ( retcode != DOWNLOAD_ERROR_NONE )
+ dts_message(TC_NAME,"Fail to unset callback");
+ download_destroy(id);
+
+ if (is_download_success)
+ dts_pass(TC_NAME, "download content is success");
+ else
+ dts_fail(TC_NAME, "download content is not success");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_unset_progress_cb_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_unset_progress_cb_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_download_unset_progress_cb_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_unset_progress_cb(-1);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_download_unset_progress_cb_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_download_unset_progress_cb_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void on_url_download_progess(int id, unsigned long long received, unsigned long long total, void *user_data)
+{
+
+}
+
+static void utc_download_unset_progress_cb_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ download_set_progress_cb(id, on_url_download_progess, NULL);
+ retcode = download_unset_progress_cb(id);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_url_download_unset_state_changed_cb_negative1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_url_download_unset_state_changed_cb_negative1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void utc_url_download_unset_state_changed_cb_negative1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+
+ retcode = download_unset_state_changed_cb(-1);
+
+ if (retcode == DOWNLOAD_ERROR_INVALID_PARAMETER)
+ dts_pass(TC_NAME, "retcode has invalid parameter");
+ else
+ dts_fail(TC_NAME, "retcode does not have invalid parameter");
+
+}
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <tet_api.h>
+#include <download.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_url_download_unset_state_changed_cb_positive1(void);
+
+struct tet_testlist tet_testlist[] = {
+ {utc_url_download_unset_state_changed_cb_positive1, 1},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+
+}
+
+static void cleanup(void)
+{
+ /* end of TC */
+}
+
+static void on_url_download_state_changed(int download_id, download_state_e state, void *user_data)
+{
+
+}
+
+static void utc_url_download_unset_state_changed_cb_positive1(void)
+{
+ const char *TC_NAME = __FUNCTION__;
+ int retcode = 0;
+ int id = 0;
+
+ download_create(&id);
+ download_set_state_changed_cb(id, on_url_download_state_changed, NULL);
+ retcode = download_unset_state_changed_cb(id);
+ download_destroy(id);
+
+ if (retcode == DOWNLOAD_ERROR_NONE)
+ dts_pass(TC_NAME, "retcode has no error");
+ else
+ dts_fail(TC_NAME, "retcode has error");
+}
+
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/testcase/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=True # capture option for build operation checking
+TET_BUILD_TOOL=make # build with using make command
+TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build
+TET_API_COMPLIANT=True # use TET API in Test Case ?
+TET_PASS_TC_NAME=True # report passed TC name in Journal file?
--- /dev/null
+TET_OUTPUT_CAPTURE=True # capture option
+TET_CLEAN_TOOL= make clean # clean tool
+TET_CLEAN_FILE= Makefile # file for clean
+TET_API_COMPLIANT=True # TET API useage
+TET_PASS_TC_NAME=True # showing name , passed TC
--- /dev/null
+TET_OUTPUT_CAPTURE=True # capturing execution or not
+TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional
+TET_EXEC_FILE= # ex) exectool : execution file/ Optional
+TET_API_COMPLIANT=True # Test case or Tool usesTET API?
+TET_PASS_TC_NAME=True # showing Passed TC name ?
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+
prefix=@PREFIX@
exec_prefix=/usr
-libdir=/usr/lib
+libdir=@LIB_INSTALL_DIR@
includedir=/usr/include/web
Name: @PC_NAME@
+++ /dev/null
-/usr/include/*
-/usr/include/*/*
-/usr/lib/pkgconfig/*.pc
-
+++ /dev/null
-/usr/lib/lib*.so*
+++ /dev/null
-capi-web-url-download (0.0.5-0) unstable; urgency=low
-
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.5-0
-
- * Change to request cancel according to state
- * Add exception handling code at start function
- * Add initialize the callback data when destroying
- * Add error code about max downloading item.
- * Remove unused variable and modify wrong API name.
- * Modify a make file to define the list of test case's source code.
-
- -- Jungki Kwak <jungki.kwak@samsung.com> Thu, 10 May 2012 10:46:37 +0900
-
-capi-web-url-download (0.0.4-0) unstable; urgency=low
-
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.4-0
-
- * Add a service operation define for the download manager application.
-
- -- Jungki Kwak <jungki.kwak@samsung.com> Fri, 23 Mar 2012 18:02:24 +0900
-
-capi-web-url-download (0.0.3-0) unstable; urgency=low
-
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.3-0
-
- * Renew TC cases for DTS
- - According to guideline of DTS TC, each test cases are seperated at each tc file one by one
- * Change build configuration file.
- - The mischaracter and dependency is changed at debian control file
-
- -- Jungki Kwak <jungki.kwak@samsung.com> Thu, 15 Mar 2012 23:25:44 +0900
-
-capi-web-url-download (0.0.2-1) unstable; urgency=low
-
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.2-1
-
- * Rollback the code about unsigned long int type.
- * Rename the spec file for rpm build
-
- -- Jungki Kwak <jungki.kwak@samsung.com> Thu, 08 Mar 2012 18:19:09 +0900
-
-capi-web-url-download (0.0.2-0) unstable; urgency=low
-
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.2-0
-
- * Change the type of file size.
- * Create spec file for rpm build.
- * Implement sample code for url download CAPI.
- * Use linked list for storing downloading items.
- * Available to cancel an download item regardless of the state.
- * Modify configurations of Test cases.
- * Add comments about g_type_init() at a header file.
- *
-
- -- Jungki Kwak <jungki.kwak@samsung.com> Wed, 07 Mar 2012 15:41:03 +0900
-
-capi-web-url-download (0.0.1-2) unstable; urgency=low
-
- * Bug fixed : memory leak
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.1-2
-
- -- Junghyuk Park <junghyuk.park@samsung.com> Tue, 21 Feb 2012 14:51:04 +0900
-
-capi-web-url-download (0.0.1-1) unstable; urgency=low
-
- * Initial upload
- * Git: slp/api/url-download
- * Tag: capi-web-url-download_0.0.1-1
-
- -- Junghyuk Park <junghyuk.park@samsung.com> Thu, 16 Feb 2012 15:21:27 +0900
-
-
+++ /dev/null
-
-Source: capi-web-url-download
-Section: libs
-Priority: extra
-Maintainer: Woongsuk Cho <ws77.cho@samsung.com>, junghyuk park <junghyuk.park@samsung.com>, JungKi Kwak <jungki.kwak@samsung.com>, InBum Chang <ibchang@samsung.com>
-Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libdownload-agent-dev, libbundle-dev
-
-Package: capi-web-url-download
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: A URL Download library in Tizen Native API
-
-Package: capi-web-url-download-dev
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-web-url-download (= ${Source-Version}), capi-base-common-dev
-Description: A URL Download library in Tizen Native API (DEV)
-
-Package: capi-web-url-download-dbg
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-web-url-download (= ${Source-Version})
-Description: A URL Download library in Tizen Native API (DBG)
-
+++ /dev/null
-#!/usr/bin/make -f
-
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-CMAKE_ROOT_DIR ?= $(CURDIR)
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake ..
- touch configure-stamp
-
-
-build: build-stamp
-build-stamp: configure-stamp
- dh_testdir
- cd $(CMAKE_BUILD_DIR) && $(MAKE)
- touch $@
-
-clean:
- cd $(CMAKE_ROOT_DIR)
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- rm -f `find . -name *.pc`
- rm -rf $(CMAKE_BUILD_DIR)
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-binary-indep: build install
-
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
- dh_installman
- dh_link
- dh_strip --dbg-package=capi-web-url-download-dbg
- dh_fixperms
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
-
--- /dev/null
+/*
+ * 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.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 @a download_id from download_create(), other APIs use @a download_id as parameter.
+ * - Even if the device is off, @a download_id is available for 48 hours if the user does not call download_destroy().
+ * - Supports the callback that is called whenever the status of download changes.
+ * - Even if the client process is terminated, download is going on.
+ * If you want to stop a download, download_cancel() or download_destroy() should be called.
+ *
+ * @section CAPI_WEB_DOWNLOAD_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.telephony\n
+ * - http://tizen.org/feature/network.wifi\n
+ * - http://tizen.org/feature/network.wifi.direct\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * 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>
+ *
+ */
+
+#endif /* __TIZEN_WEB_DOWNLOAD_DOC_H__ */
--- /dev/null
+/*
+ * 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_H__
+#define __TIZEN_WEB_DOWNLOAD_H__
+
+#include <tizen.h>
+#include <app_control.h>
+
+#ifndef DEPRECATED
+ #define DEPRECATED __attribute__((deprecated))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file download.h
+ */
+
+ /**
+ * @addtogroup CAPI_WEB_DOWNLOAD_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for error codes of URL download.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ DOWNLOAD_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ DOWNLOAD_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ DOWNLOAD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ DOWNLOAD_ERROR_NETWORK_UNREACHABLE = TIZEN_ERROR_NETWORK_UNREACHABLE, /**< Network is unreachable */
+ DOWNLOAD_ERROR_CONNECTION_TIMED_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT, /**< HTTP session time-out */
+ DOWNLOAD_ERROR_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
+ DOWNLOAD_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ DOWNLOAD_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ DOWNLOAD_ERROR_INVALID_STATE = TIZEN_ERROR_DOWNLOAD | 0x21, /**< Invalid state */
+ DOWNLOAD_ERROR_CONNECTION_FAILED = TIZEN_ERROR_DOWNLOAD | 0x22, /**< Connection failed */
+ DOWNLOAD_ERROR_INVALID_URL = TIZEN_ERROR_DOWNLOAD | 0x24, /**< Invalid URL */
+ DOWNLOAD_ERROR_INVALID_DESTINATION = TIZEN_ERROR_DOWNLOAD | 0x25, /**< Invalid destination */
+ DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS = TIZEN_ERROR_DOWNLOAD | 0x26, /**< Too many simultaneous downloads */
+ DOWNLOAD_ERROR_QUEUE_FULL = TIZEN_ERROR_DOWNLOAD | 0x27, /**< Download server queue is full*/
+ DOWNLOAD_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_DOWNLOAD | 0x28, /**< The download is already completed */
+ DOWNLOAD_ERROR_FILE_ALREADY_EXISTS = TIZEN_ERROR_DOWNLOAD | 0x29, /**< Failed to rename the downloaded file */
+ DOWNLOAD_ERROR_CANNOT_RESUME = TIZEN_ERROR_DOWNLOAD | 0x2a, /**< Cannot resume */
+ DOWNLOAD_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_DOWNLOAD | 0x2b, /**< Specified field not found */
+ DOWNLOAD_ERROR_TOO_MANY_REDIRECTS = TIZEN_ERROR_DOWNLOAD | 0x30, /**< Too many redirects from HTTP response header*/
+ DOWNLOAD_ERROR_UNHANDLED_HTTP_CODE = TIZEN_ERROR_DOWNLOAD | 0x31, /**< The download cannot handle the HTTP status value */
+ DOWNLOAD_ERROR_REQUEST_TIMEOUT = TIZEN_ERROR_DOWNLOAD | 0x32, /**< No action after client creates a download ID*/
+ DOWNLOAD_ERROR_RESPONSE_TIMEOUT = TIZEN_ERROR_DOWNLOAD | 0x33, /**< No call to start API for some time although the download is created*/
+ DOWNLOAD_ERROR_SYSTEM_DOWN = TIZEN_ERROR_DOWNLOAD | 0x34, /**< No response from client after rebooting download daemon*/
+ DOWNLOAD_ERROR_ID_NOT_FOUND = TIZEN_ERROR_DOWNLOAD | 0x35, /**< Download ID does not exist in download service module*/
+ DOWNLOAD_ERROR_INVALID_NETWORK_TYPE = TIZEN_ERROR_DOWNLOAD | 0x36, /**< Network bonding is set but network type is not set as DOWNLOAD_NETWORK_ALL*/
+ DOWNLOAD_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data because the set API is not called */
+ DOWNLOAD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR , /**< Internal I/O error */
+} download_error_e;
+
+
+/**
+ * @brief Enumeration for download states.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ DOWNLOAD_STATE_NONE, /**< Unhandled exception */
+ DOWNLOAD_STATE_READY, /**< Ready to download */
+ DOWNLOAD_STATE_QUEUED, /**< Queued to start downloading */
+ DOWNLOAD_STATE_DOWNLOADING, /**< Currently downloading */
+ DOWNLOAD_STATE_PAUSED, /**< The download is waiting to resume */
+ DOWNLOAD_STATE_COMPLETED, /**< The download is completed */
+ DOWNLOAD_STATE_FAILED, /**< The download failed */
+ DOWNLOAD_STATE_CANCELED, /**< User canceled the download item */
+} download_state_e;
+
+/**
+ * @brief Enumeration for network type for downloading.
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+ DOWNLOAD_NETWORK_DATA_NETWORK, /**< Download is available through data network */
+ DOWNLOAD_NETWORK_WIFI, /**< Download is available through WiFi */
+ DOWNLOAD_NETWORK_WIFI_DIRECT, /**< Download is available through WiFi-Direct */
+ DOWNLOAD_NETWORK_ALL /**< Download is available through either data network or WiFi */
+} download_network_type_e;
+
+
+/**
+ * @brief Enumeration for notification types when a client wants to register.
+ * @since_tizen 2.3
+ *
+ * @see download_set_notification_type()
+ * @see download_get_notification_type()
+ */
+typedef enum
+{
+ DOWNLOAD_NOTIFICATION_TYPE_NONE = 0, /**< Do not register notification */
+ DOWNLOAD_NOTIFICATION_TYPE_COMPLETE_ONLY, /**< Completion notification for success state and failed state */
+ DOWNLOAD_NOTIFICATION_TYPE_ALL /**< All download notifications for ongoing state, success state and failed state */
+} download_notification_type_e;
+
+
+/**
+ * @brief Enumeration for the type of notification app control action which the client wants to set when registering notification.
+ * @since_tizen 2.3
+ *
+ * @see download_set_notification_app_control()
+ * @see download_get_notification_app_control()
+ */
+typedef enum
+{
+ DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_ONGOING = 0, /**< App control action for failed and ongoing notification */
+ DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_COMPLETE, /**< App control action for completed notification */
+ DOWNLOAD_NOTIFICATION_APP_CONTROL_TYPE_FAILED /**< App control action for failed notification*/
+} download_notification_app_control_type_e;
+
+/**
+ * @brief Called when a download state is changed.
+ *
+ * @since_tizen 2.3
+ *
+ * @param[in] download_id The download ID
+ * @param[in] state The state of download
+ * @param[in] user_data The user data passed from download_set_state_changed_cb()
+ *
+ * @pre download_start() will invoke this callback if you register this callback using download_set_state_changed_cb().
+ *
+ * @see download_set_state_changed_cb()
+ * @see download_unset_state_changed_cb()
+ */
+typedef void (*download_state_changed_cb) (int download_id,
+ download_state_e state, void *user_data);
+
+/**
+ * @brief Called when the progress of download changes.
+ *
+ * @since_tizen 2.3
+ *
+ * @remarks This callback function is only invoked in the downloading state.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] received The size of the data received in bytes
+ * @param[in] user_data The user data passed from download_set_progress_cb()
+ *
+ * @pre This callback function is invoked if you register this callback using download_set_progress_cb().
+ *
+ * @see download_cancel()
+ * @see download_set_progress_cb()
+ * @see download_unset_progress_cb()
+ */
+typedef void (*download_progress_cb) (int download_id, unsigned long long received, void *user_data);
+
+/**
+ * @brief Creates a new download request and return its download ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The @a download_id is released with download_destroy() by client.
+ *
+ * @param[out] download_id The download ID that is newly created on success
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_QUEUE_FULL Download server queue is full
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @post The download state will be #DOWNLOAD_STATE_READY.
+ *
+ * @see download_destroy()
+ */
+int download_create(int *download_id);
+
+
+/**
+ * @brief Unloads all data concerning a download ID from memory.
+ *
+ * @details After calling this API, a download ID is existed at DB in certain time.
+ * Within that time, it is able to use the other API with the download ID.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ *
+ * @remarks If #DOWNLOAD_ERROR_ID_NOT_FOUND is returned, it means that the download ID is completely removed from DB.
+ *
+ * @param[in] download_id The download ID
+ *
+ * @return @c 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_create()
+ */
+int download_destroy(int download_id);
+
+
+/**
+ * @brief Sets the URL to download.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ * @param[in] url The URL to download \n
+ * If @a url is @c NULL, it clears the previous value.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @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 be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_url()
+ */
+int download_set_url(int download_id, const char *url);
+
+
+/**
+ * @brief Gets the URL to download.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks You must release @a url using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[out] url The URL to download
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_set_url()
+ */
+int download_get_url(int download_id, char **url);
+
+
+/**
+ * @brief Sets the allowed network type for the downloaded file.
+ *
+ * @details The file can be downloaded only under the allowed network.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ * @param[in] net_type The network type that the client prefers
+ *
+ * @return @c 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
+ * @retval #DOWNLOAD_ERROR_NOT_SUPPORTED Not supported
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_network_type()
+ * @see #download_network_type_e
+ */
+int download_set_network_type(int download_id, download_network_type_e net_type);
+
+
+/**
+ * @brief Gets the network type for the downloaded file.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] net_type The network type that is defined by client
+ *
+ * @return @c 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_type()
+ * @see #download_network_type_e
+ */
+int download_get_network_type(int download_id, download_network_type_e *net_type);
+
+/**
+ * @brief Sets the destination for the downloaded file.
+ *
+ * @details The file will be downloaded to the specified destination.
+ * The downloaded file is saved to an auto-generated file name in the destination.
+ * If the destination is not specified, the file will be downloaded to default storage (see the @ref CAPI_SYSTEM_STORAGE_MODULE API).
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ * @param[in] path The absolute path to the downloaded file \n
+ * If @a path is @c NULL, it clears the previous value.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @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 be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_destination()
+ */
+int download_set_destination(int download_id, const char *path);
+
+
+/**
+ * @brief Gets the destination path for the downloaded file.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks You must release @a path using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[out] path The absolute path to the downloaded file
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_set_destination()
+ */
+int download_get_destination(int download_id, char **path);
+
+
+/**
+ * @brief Sets the name for the downloaded file.
+ *
+ * @details The file will be saved in the specified destination with the given file name.
+ * If the file name is not specified, the downloaded file will be saved with an auto-generated file name in the destination.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ * @param[in] file_name The file name for the downloaded file \n
+ * If @a name is @c NULL it clears the previous value.
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @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 be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_file_name()
+ */
+int download_set_file_name(int download_id, const char *file_name);
+
+/**
+ * @brief Gets the name of the downloaded file set previously by download_set_file_name().
+ *
+ * @details If the name is not set, @c NULL is returned.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks You must release @a file_name using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[out] file_name The file name which is set by user
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_set_file_name()
+ */
+int download_get_file_name(int download_id, char **file_name);
+
+
+/**
+ * @brief Gets the absolute path to save the downloaded file.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download is not completed.
+ * You must release @a path using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[out] path The absolute path to the downloaded file
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The download state must be #DOWNLOAD_STATE_COMPLETED.
+ *
+ * @see download_set_file_name()
+ * @see download_set_destination()
+ */
+int download_get_downloaded_file_path(int download_id, char **path);
+
+
+/**
+ * @brief Gets the MIME type of the downloaded content.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download has not been started.
+ * You must release @a mime_type using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[out] mime_type The MIME type of the downloaded file
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_set_file_name()
+ * @see download_set_destination()
+ * @see download_get_downloaded_file_path()
+ */
+int download_get_mime_type(int download_id, char **mime_type);
+
+
+/**
+ * @brief Enables or disables auto download.
+ * @details If this option is enabled,
+ * the previous downloading item is restarted automatically as soon as the download daemon is restarted.
+ * The download progress continues after the client process is terminated.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The client should call download_set_notification() and download_set_notification_extra_param() after calling this API.
+ * If it is not done, the user will not receive the download result in case the client process is not alive. \n
+ * The default value is @c false.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] enable Set @c true to enable auto download,
+ * otherwise set @c false to disable auto download
+ *
+ * @return @c 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
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_auto_download()
+ * @see download_set_notification()
+ * @see download_set_notification_extra_param()
+ *
+ */
+int download_set_auto_download(int download_id, bool enable);
+
+
+/**
+ * @brief Checks whether auto download is enabled.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] enable @c true if auto download is enabled,
+ * otherwise @c false if auto download is disabled
+ *
+ * @return @c 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_auto_download()
+ */
+int download_get_auto_download(int download_id, bool *enable);
+
+
+/**
+ * @brief Adds a HTTP header field to the download request.
+ *
+ * @details The given HTTP header field will be included with the HTTP request of the download request.
+ * For more information, see <a href="HTTP://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1: HTTP Message Headers</a>.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ * This function replaces any existing value for the given key.
+ * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if @a field or @a value is a zero-length string.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] field The name of the HTTP header field
+ * @param[in] value The value associated with given field
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_http_header_field()
+ * @see download_remove_http_header_field()
+ */
+int download_add_http_header_field(int download_id, const char *field, const char *value);
+
+
+/**
+ * @brief Gets a value associated with a given HTTP header field from the download.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if @a field is zero-length string.
+ * You must release @a value using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[in] field The name of the HTTP header field
+ * @param[out] value The value associated with given field
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_add_http_header_field()
+ * @see download_remove_http_header_field()
+ */
+int download_get_http_header_field(int download_id, const char *field, char **value);
+
+/**
+ * @brief Gets all the HTTP header fields added to the download request.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks You must release @a value using free().
+ *
+ * @param[in] download_id The download ID
+ * @param[out] fields The array of the HTTP header fields
+ * @param[out] length The number of the HTTP header fields
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_add_http_header_field()
+ * @see download_remove_http_header_field()
+ */
+int download_get_http_header_field_list(int download_id, char ***fields, int *length);
+
+/**
+ * @brief Removes a given HTTP header field from the download.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] field The name of the HTTP header field
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_add_http_header_field()
+ * @see download_get_http_header_field()
+ */
+int download_remove_http_header_field(int download_id, const char *field);
+
+
+/**
+ * @brief Registers a callback function to be invoked when a download state is changed.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 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
+ *
+ * @post download_state_changed_cb() will be invoked.
+ *
+ * @see download_unset_state_changed_cb()
+ * @see download_state_changed_cb()
+*/
+int download_set_state_changed_cb(int download_id, download_state_changed_cb callback, void* user_data);
+
+
+/**
+ * @brief Unregisters the download state change callback function.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ *
+ * @return @c 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_state_changed_cb()
+ * @see download_state_changed_cb()
+*/
+int download_unset_state_changed_cb(int download_id);
+
+
+/**
+ * @brief Registers a callback function to be invoked when progress of the download changes.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 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
+ *
+ * @post download_progress_cb() will be invoked.
+ *
+ * @see download_unset_progress_cb()
+ * @see download_progress_cb()
+*/
+int download_set_progress_cb(int download_id, download_progress_cb callback, void *user_data);
+
+
+/**
+ * @brief Unregisters the download progress change callback function.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks This function should be called before downloading (see download_start()).
+ *
+ * @param[in] download_id The download ID
+ *
+ * @return @c 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
+ *
+ * @see download_set_progress_cb()
+ * @see download_progress_cb()
+*/
+int download_unset_progress_cb(int download_id);
+
+
+/**
+ * @brief Starts or resumes the download, asynchronously.
+ *
+ * @details This function starts to download the current URL, or resumes the download if paused.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The URL is the mandatory information to start the download.
+ * @remarks It should call download_set_progress_cb() and download_set_state_changed_cb() again
+ * after the client process is restarted or download_destroy() is called.
+ *
+ * @param[in] download_id The download ID
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_INVALID_URL Invalid URL
+ * @retval #DOWNLOAD_ERROR_INVALID_DESTINATION Invalid destination
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_QUEUE_FULL Download server queue is full
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The download state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_PAUSED, #DOWNLOAD_STATE_CANCELED, or #DOWNLOAD_STATE_FAILED.
+ * @post The download state will be #DOWNLOAD_STATE_QUEUED or #DOWNLOAD_STATE_DOWNLOADING.
+ *
+ * @see download_set_url()
+ * @see download_pause()
+ * @see download_cancel()
+ */
+int download_start(int download_id);
+
+
+/**
+ * @brief Pauses the download, asynchronously.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The paused download can be restarted with download_start() or cancelled with download_cancel().
+ *
+ * @param[in] download_id The download ID
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The download state must be #DOWNLOAD_STATE_DOWNLOADING.
+ * @post The download state will be #DOWNLOAD_STATE_PAUSED.
+ *
+ * @see download_start()
+ * @see download_cancel()
+ */
+int download_pause(int download_id);
+
+
+/**
+ * @brief Cancels the download, asynchronously.
+ *
+ * @details This function cancels the running download and its state will be #DOWNLOAD_STATE_READY.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The canceled download can be restarted with download_start().
+ *
+ * @param[in] download_id The download ID
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No download ID
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The download state must be #DOWNLOAD_STATE_QUEUED, #DOWNLOAD_STATE_DOWNLOADING, or #DOWNLOAD_STATE_PAUSED.
+ * @post The download state will be #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_start()
+ */
+int download_cancel(int download_id);
+
+
+/**
+ * @brief Gets the current state of the download.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] state The current state of the download
+ *
+ * @return @c 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_state_e
+ */
+int download_get_state(int download_id, download_state_e *state);
+
+
+/**
+ * @brief Gets the full path of the temporary file to store downloaded content.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] temp_path The full path of temporary file
+ *
+ * @return @c 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
+ *
+ * @pre The download state must be one of the states after #DOWNLOAD_STATE_DOWNLOADING.
+ *
+ * @see download_set_state_changed_cb()
+ * @see download_unset_state_changed_cb()
+ * @see download_start()
+ */
+int download_get_temp_path(int download_id, char **temp_path);
+
+
+/**
+ * @brief Sets the directory path of the temporary file used in the previous download request.
+ * @details This is only useful when resuming download to make HTTP request header at the client side.
+ * Otherwise, the path should be ignored internally.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks If the etag value is not present in the download database, it is useless to set the temporary path. \n
+ * When resuming download, the data is attached at the end of this temporary file.
+ *
+ * @param[in] download_id The download ID
+ * @param[out] path The full path of temporary file
+ *
+ * @return @c 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
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_get_etag()
+ */
+int download_set_temp_file_path(int download_id, char *path);
+
+
+/**
+ * @brief Gets the content name of downloaded file.
+ *
+ * @details This can be defined with reference of HTTP response header data.
+ * The content name can be received when HTTP response header is received.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] content_name The content name for displaying to user
+ *
+ * @return @c 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
+ *
+ * @pre The download state must be one of the states after #DOWNLOAD_STATE_DOWNLOADING.
+ *
+ * @see download_set_state_changed_cb()
+ * @see download_unset_state_changed_cb()
+ * @see download_start()
+ */
+int download_get_content_name(int download_id, char **content_name);
+
+
+/**
+ * @brief Gets the total size of downloaded content.
+ *
+ * @details This information is received from the server. If the server does not send the total size of the content, @a content_size is set to zero.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] content_size The content size for displaying to user
+ *
+ * @return @c 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
+ *
+ * @pre The download state must be one of the states after #DOWNLOAD_STATE_DOWNLOADING.
+ *
+ * @see download_set_state_changed_cb()
+ * @see download_unset_state_changed_cb()
+ * @see download_start()
+ */
+int download_get_content_size(int download_id, unsigned long long *content_size);
+
+
+/**
+ * @brief Gets an error value when the download fails.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] error The error value
+ *
+ * @return @c 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
+ *
+ * @pre The download state must be #DOWNLOAD_STATE_FAILED.
+ * @pre The download state must be #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_set_state_changed_cb()
+ * @see download_unset_state_changed_cb()
+ * @see download_start()
+ * @see download_error_e
+ */
+int download_get_error(int download_id, download_error_e *error);
+
+
+/**
+ * @brief Gets a HTTP status code when a download error occurs.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] HTTP_status The HTTP status code defined in RFC 2616
+ *
+ * @return @c 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
+ *
+ * @pre The download state must be #DOWNLOAD_STATE_FAILED.
+ *
+ * @see download_set_download_status_cb()
+ * @see download_unset_download_status_cb()
+ * @see download_start()
+ */
+int download_get_http_status(int download_id, int *HTTP_status);
+
+
+/**
+ * @brief Sets an app control handle to register notification messages.
+ * @details Three types of notification message can be posted: completion, failed and ongoing type.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks When the notification message is clicked, the action to take is decided by the app control handle. \n
+ * If the app control handle is not set, the following default operation is executed when the notification message is clicked: \n
+ * 1) download completed state - the viewer application is executed according to extension name of downloaded content, \n
+ * 2) download failed state and ongoing state - the client application is executed. \n
+ * This function should be called before starting the download. \n
+ * The app control handle MUST BE FREED by the client when it is not used any more.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] type The enumeration type \n
+ * See #download_notification_app_control_type_e.
+ * @param[in] handle The app control handle pointer value
+ *
+ * @return @c 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
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_set_notification_type()
+ * @see download_get_notification_app_control()
+ */
+int download_set_notification_app_control(int download_id, download_notification_app_control_type_e type, app_control_h handle);
+
+
+/**
+ * @brief Gets the app control handle (used previously to register notification messages) which is set by download_set_notification_app_control().
+ *
+ * @details When the notification message is clicked, the action is decided by the app control handle.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The app control handle MUST BE FREED by the client when it is not used any more.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] type The enumeration type \n
+ * See #download_notification_app_control_type_e.
+ * @param[out] handle The app control handle pointer value
+ *
+ * @return @c 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_NO_DATA The app control handle has not been set
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @see download_set_notification_app_control()
+ */
+int download_get_notification_app_control(int download_id, download_notification_app_control_type_e type, app_control_h *handle);
+
+
+/**
+ * @brief Sets the title of a notification.
+ *
+ * @details When registering a notification, the title is displayed in the title area of the notification message.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[in] title The title for displaying to user
+ *
+ * @return @c 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
+ *
+ * @pre If a notification option is not enabled, this title is not shown to user.
+ *
+ * @see download_set_notification_type()
+ * @see download_get_notification_title()
+ */
+int download_set_notification_title(int download_id, const char *title);
+
+
+/**
+ * @brief Gets the title of the notification set by download_set_notification_title().
+ *
+ * @details When registering a notification, the title is displayed in the title area of the notification message.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] title The title for displaying to user
+ *
+ * @return @c 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_NO_DATA The title has not been set
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre It can get the title value before calling this API.
+ *
+ * @see download_set_notification_title()
+ */
+int download_get_notification_title(int download_id, char **title);
+
+
+/**
+ * @brief Sets the description of a notification.
+ *
+ * @details When registering a notification, the description is displayed in the description area of the notification message.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[in] description The description for displaying to user
+ *
+ * @return @c 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
+ *
+ * @pre If the notification option is not enabled, this description is not shown to user.
+ *
+ * @see download_set_notification_type()
+ * @see download_get_notification_description()
+ */
+int download_set_notification_description(int download_id, const char *description);
+
+
+/**
+ * @brief Gets the description of a notification set by download_set_notification_description().
+ *
+ * @details When registering a notification, the description is displayed in the description area of the notification message.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @param[in] download_id The download ID
+ * @param[out] description The description for displaying to user
+ *
+ * @return @c 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_NO_DATA The description has not been set
+ * @retval #DOWNLOAD_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre It can get the title value before calling this API.
+ *
+ * @see download_set_notification_description()
+ */
+int download_get_notification_description(int download_id, char **description);
+
+
+/**
+ * @brief Sets an option value to register notification messages.
+ * @details Three types of notification message can be posted: completion, failed and ongoing type.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks When the notification message is clicked, the action to take is decided by the app control handle (set by download_set_notification_app_control()). \n
+ * If the app control is not set, the following default operation is executed when the notification message is clicked: \n
+ * 1) download completed state - the viewer application is executed according to extension name of downloaded content, \n
+ * 2) download failed state and ongoing state - the client application is executed. \n
+ * The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE. \n
+ * This function should be called before starting the download.
+ *
+ * @param[in] download_id The download ID
+ * @param[in] type The enumeration type \n
+ * See #download_notification_type_e.
+ *
+ * @return @c 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
+ *
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, or #DOWNLOAD_STATE_CANCELED.
+ *
+ * @see download_set_notification_app_control()
+ * @see download_get_notification_type()
+ */
+int download_set_notification_type(int download_id, download_notification_type_e type);
+
+
+/**
+ * @brief Gets an option value to register notification messages set by download_set_notification_type().
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks When the notification message is clicked, the action is decided by the app control from download_set_notification_app_control(). \n
+ * The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
+ *
+ * @param[in] download_id The download ID
+ * @param[out] type The enumeration type \n
+ * See #download_notification_type_e.
+ *
+ * @return @c 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_notification_type()
+ */
+int download_get_notification_type(int download_id, download_notification_type_e *type);
+
+
+/**
+ * @brief Gets an etag value from the HTTP response header when making a HTTP request for resume.
+ *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @remarks The etag value is available or not depending on the web server. \n
+ * After download is started, it can get the etag value.
+ *
+ * @param[in] download_id The download ID
+ * @param[out] etag The etag value
+ *
+ * @return @c 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_temp_file_path()
+ */
+int download_get_etag(int download_id, char **etag);
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_WEB_DOWNLOAD_H__ */
+++ /dev/null
-/*
- * 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_URL_DOWNLOAD_H__
-#define __TIZEN_WEB_URL_DOWNLOAD_H__
-
-#include <tizen.h>
-#include <app.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /**
- * @addtogroup CAPI_WEB_URL_DOWNLOAD_MODULE
- * @{
- */
-
-/**
- * @brief Name for download service operation. Download Manager application is launched.
- */
-#define SERVICE_OPERATION_DOWNLOAD "http://tizen.org/appcontrol/operation/download"
-
-
-/**
- * @brief URL download handle.
- */
-typedef struct url_download_s *url_download_h;
-
-
-/**
- * @brief Enumeration of error code for URL download
- */
-typedef enum
-{
- URL_DOWNLOAD_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- URL_DOWNLOAD_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- URL_DOWNLOAD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- URL_DOWNLOAD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR , /**< Internal I/O error */
- URL_DOWNLOAD_ERROR_NETWORK_UNREACHABLE = TIZEN_ERROR_NETWORK_UNREACHABLE, /**< Network is unreachable */
- URL_DOWNLOAD_ERROR_CONNECTION_TIMED_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT, /**< Connection timed out */
- URL_DOWNLOAD_ERROR_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
- URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Specified field not found */
- URL_DOWNLOAD_ERROR_INVALID_STATE = TIZEN_ERROR_WEB_CLASS | 0x21, /**< Invalid state */
- URL_DOWNLOAD_ERROR_CONNECTION_FAILED = TIZEN_ERROR_WEB_CLASS | 0x22, /**< Connection failed */
- URL_DOWNLOAD_ERROR_SSL_FAILED = TIZEN_ERROR_WEB_CLASS | 0x23, /**< SSL negotiation failed */
- URL_DOWNLOAD_ERROR_INVALID_URL = TIZEN_ERROR_WEB_CLASS | 0x24, /**< Invalid URL */
- URL_DOWNLOAD_ERROR_INVALID_DESTINATION = TIZEN_ERROR_WEB_CLASS | 0x25, /**< Invalid destination */
- URL_DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS = TIZEN_ERROR_WEB_CLASS | 0x26, /**< Full of available downloading items */
- URL_DOWNLOAD_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_WEB_CLASS | 0x27, /**< The download is already completed */
- URL_DOWNLOAD_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data */
-} url_download_error_e;
-
-
-/**
- * @brief Enumerations of state of download
- */
-typedef enum
-{
- URL_DOWNLOAD_STATE_READY, /**< It is ready to download */
- URL_DOWNLOAD_STATE_DOWNLOADING, /**< The download is currently running */
- URL_DOWNLOAD_STATE_PAUSED, /**< The download is waiting to resume or stop */
- URL_DOWNLOAD_STATE_COMPLETED, /**< The download is completed. */
- URL_DOWNLOAD_STATE_FAILED, /**< The download failed. */
-} url_download_state_e;
-
-
-/**
- * @brief Called when the download is started.
- *
- * @param [in] download The download handle
- * @param [in] content_name The content name to display at UI layer
- * @param [in] mime_type The MIME type string
- * @param [in] user_data The user data passed from url_download_set_started_cb()
- * @pre url_download_start() will cause this callback if you register this callback using url_download_set_started_cb()
- * @see url_download_start()
- * @see url_download_set_started_cb()
- * @see url_download_unset_started_cb()
- */
-typedef void (*url_download_started_cb) (url_download_h download,
- const char *content_name, const char *mime_type, void *user_data);
-
-
-/**
- * @brief Called when the download is paused.
- *
- * @param [in] download The download handle
- * @param [in] user_data The user data passed from url_download_set_paused_cb()
- * @pre url_download_pause() will cause this callback if you register this callback using url_download_set_paused_cb()
- * @see url_download_pause()
- * @see url_download_set_paused_cb()
- * @see url_download_unset_paused_cb()
- */
-typedef void (*url_download_paused_cb) (url_download_h download, void *user_data);
-
-
-/**
- * @brief Called when the download is completed.
- *
- * @param [in] download The download handle
- * @param [in] installed_path The absolute path to the downloaded file
- * @param [in] user_data The user data passed from url_download_set_completed_cb()
- * @pre This callback function will be invoked when the download is completed if you register this callback using url_download_set_paused_cb()
- * @see url_download_set_completed_cb()
- * @see url_download_unset_completed_cb()
- */
-typedef void (*url_download_completed_cb) (url_download_h download, const char *installed_path, void *user_data);
-
-
-/**
- * @brief Called when the download is stopped.
- *
- * @remarks This callback function is invoked when the download is explicitly stopped by url_download_stop(). \n
- * And this callback function is also invoked when the download failed from either downloading or paused state.
- * @param [in] download The download handle
- * @param [in] error The error code \n
- * If the download is stopped with url_download_stop(), the error code is #URL_DOWNLOAD_ERROR_NONE
- * @param [in] user_data The user data passed from url_download_set_stopped_cb()
- * @pre This callback function is invoked if you register this callback using url_download_set_stopped_cb().
- * @see url_download_stop()
- * @see url_download_set_stopped_cb()
- * @see url_download_unset_stopped_cb()
- */
-typedef void (*url_download_stopped_cb) (url_download_h download, url_download_error_e error, void *user_data);
-
-
-/**
- * @brief Called when the progress of download changes.
- *
- * @remarks This callback function is only invoked in the downloading state.
- * @param [in] download The download handle
- * @param [in] received The size of the data received in bytes
- * @param [in] total The total size of the data to receive in bytes
- * @param [in] user_data The user data passed from url_download_set_progress_cb()
- * @pre This callback function is invoked if you register this callback using url_download_set_progress_cb().
- * @see url_download_stop()
- * @see url_download_set_progress_cb()
- * @see url_download_unset_progress_cb()
- */
-typedef void (*url_download_progress_cb) (url_download_h download, unsigned long long received, unsigned long long total, void *user_data);
-
-
-/**
-* @brief Called to retrieve the HTTP header field to be included with the download
-*
-* @remarks The @a field must not be deallocated by an application.
-* @param [in] download The download handle
-* @param [in] field The HTTP header field
-* @param [in] user_data The user data passed from the foreach function
-* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
-* @pre url_download_foreach_http_header_field() will invoke this callback.
-* @see url_download_foreach_http_header_field()
-*/
-typedef bool (*url_download_http_header_field_cb)(url_download_h download, const char *field, void *user_data);
-
-
-/**
- * @brief Creates a download handle.
- *
- * @remarks The @a download must be released with url_download_destroy() by you.\n
- * The g_type_init() should be called when creating a main loop by user side. \n
- * Because the libsoup, which is http stack library of download module, use gobject internally.
- * @param [out] download A download handle to be newly created on success
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @post The download state will be #URL_DOWNLOAD_STATE_READY
- * @see url_download_destroy()
- */
-int url_download_create(url_download_h *download);
-
-
-/**
- * @brief Creates a download handle with the given identifier
- *
- * @remarks The @a download must be released with url_download_destroy() by you.\n
- * The g_type_init() should be called when creating a main loop by user side. \n
- * Because the libsoup, which is http stack library of download module, use gobject internally.
- * @param [in] id The identifier for the download unique within the application.
- * @param [out] download A download handle to be newly created on success
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @post The download state will be #URL_DOWNLOAD_STATE_READY
- * @see url_download_create()
- * @see url_download_destroy()
- */
-int url_download_create_by_id(int id, url_download_h *download);
-
-
-/**
- * @brief Destroys the URL download handle.
- *
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @see url_download_create()
- */
-int url_download_destroy(url_download_h download);
-
-
-/**
- * @brief Sets the URL to download.
- *
- * @remarks This function should be called before downloading (See url_download_start())
- * @param [in] download The download handle
- * @param [in] url The URL to download \n
- * If the @a url is NULL, it clears the previous value.
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_get_url()
- */
-int url_download_set_url(url_download_h download, const char *url);
-
-
-/**
- * @brief Gets the URL to download.
- *
- * @remarks The @a url must be released with free() by you.
- * @param [in] download The download handle
- * @param [out] url The URL to download
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @see url_download_set_url()
- */
-int url_download_get_url(url_download_h download, char **url);
-
-
-/**
- * @brief Sets the destination for the downloaded file.
- *
- * @details The file will be downloaded to the specified destination.
- * The downloaded file is saved to an auto-generated file name in the destination. (See url_download_completed_cb())
- * If the destination is not specified, the file will be downloaded to default storage. (See the @ref CAPI_STORAGE_MODULE API)
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] path The absolute path to the downloaded file
- * If the @a path is NULL, it clears the previous value.
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_get_destination()
- */
-int url_download_set_destination(url_download_h download, const char *path);
-
-
-/**
- * @brief Gets the destination for the downloaded file.
- *
- * @remarks The @a path must be released with free() by you.
- * @param [in] download The download handle
- * @param [out] path The absolute path to the downloaded file
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @see url_download_set_destination()
- */
-int url_download_get_destination(url_download_h download, char **path);
-
-
-/**
- * @brief Sets the name for the downloaded file.
- *
- * @details The file will be downloaded to the specified destination as the given file name.
- * If the file name is not specified, the downloaded file is saved to an auto-generated file name in the destination.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] file_name The file name for the downloaded file
- * If the @a name is NULL, it clears the previous value.
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_get_file_name()
- */
-int url_download_set_file_name(url_download_h download, const char *file_name);
-
-
-/**
- * @brief Gets the name for the downloaded file.
- *
- * @remarks The @a file_name must be released with free() by you.
- * @param [in] download The download handle
- * @param [out] file_name The file name for the downloaded file
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @see url_download_set_file_name()
- */
-int url_download_get_file_name(url_download_h download, char **file_name);
-
-
-/**
- * @brief Sets the service to launch when the notification for the download is selected from the notification tray.
- * @details When the notification for the download is selected from the notification tray, the application which is described by the specified service is launched. \n
- * If you want to launch the current application, use the explicit launch of the @ref CAPI_SERVICE_MODULE API
- * @remarks If the service is not set, the selected notification will be cleared from both the notification tray and the status bar without any action.
- * @param[in] download The download handle
- * @param[in] service The service handle to launch when the notification for the download is selected \n
- * If the @a service is NULL, it clears the previous value.
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @see url_download_get_notification()
- * @see service_create()
- */
-int url_download_set_notification(url_download_h download, service_h service);
-
-/**
- * @brief Gets the service to launch when the notification for the download is selected from the notification tray
- * @remarks The @a service must be released with service_destroy() by you.
- * @param[in] download The download handle
- * @param[out] service The service handle to launch when the notification is selected
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @see url_download_set_notification()
- */
-int url_download_get_notification(url_download_h download, service_h *service);
-
-
-/**
- * @brief Gets the absolute path to the downloaded file
- *
- * @remarks This function returns #URL_DOWNLOAD_ERROR_INVALID_STATE if the download is not completed. \n
- * The @a path must be released with free() by you.
- * @param [in] download The download handle
- * @param [out] path The absolute path to the downloaded file
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @pre The download state must be #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_set_file_name()
- * @see url_download_set_destination()
- */
-int url_download_get_downloaded_file(url_download_h download, char **path);
-
-
-/**
- * @brief Gets the MIME type of the downloaded file
- *
- * @remarks This function returns #URL_DOWNLOAD_ERROR_INVALID_STATE if the download has not been started. \n
- * The @a mime_type must be released with free() by you.
- * @param [in] download The download handle
- * @param [out] mime_type The MIME type of the downloaded file
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @see url_download_set_file_name()
- * @see url_download_set_destination()
- * @see url_download_get_downloaded_file()
- */
-int url_download_get_mime(url_download_h download, char **mime_type);
-
-
-/**
- * @brief Adds an HTTP header field to the download request
- *
- * @details The given HTTP header field will be included with the HTTP request of the download request. \n
- * Refer to the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1: HTTP Message Headers</a>
- * @remarks This function should be called before downloading (see url_download_start()) \n
- * This function replaces any existing value for the given key. \n
- * This function returns #URL_DOWNLOAD_ERROR_INVALID_PARAMETER if field or value is zero-length string.
- * @param [in] download The download handle
- * @param [in] field The name of the HTTP header field
- * @param [in] value The value associated with given field
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_get_http_header_field()
- * @see url_download_remove_http_header_field()
- */
-int url_download_add_http_header_field(url_download_h download, const char *field, const char *value);
-
-
-/**
- * @brief Gets the value associated with given HTTP header field from the download
- *
- * @remarks This function returns #URL_DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string. \n
- * The @a value must be released with free() by you.
- * @param [in] download The download handle
- * @param [in] field The name of the HTTP header field
- * @param [out] value The value associated with given field
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @retval #URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
- * @see url_download_add_http_header_field()
- * @see url_download_remove_http_header_field()
- */
-int url_download_get_http_header_field(url_download_h download, const char *field, char **value);
-
-
-/**
- * @brief Removes the given HTTP header field from the download
- *
- * @remarks This function should be called before downloading (see url_download_start()) \n
- * This function returns #URL_DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string.
- * @param [in] download The download handle
- * @param [in] field The name of the HTTP header field
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @retval #URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @see url_download_add_http_header_field()
- * @see url_download_get_http_header_field()
- */
-int url_download_remove_http_header_field(url_download_h download, const char *field);
-
-
-/**
- * @brief Registers a callback function to be invoked when the download starts.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] callback The callback function to register
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @post url_download_started_cb() will be invoked.
- * @see url_download_unset_started_cb()
- * @see url_download_started_cb()
-*/
-int url_download_set_started_cb(url_download_h download, url_download_started_cb callback, void* user_data);
-
-
-/**
- * @brief Unregisters the callback function.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_set_started_cb()
- * @see url_download_started_cb()
-*/
-int url_download_unset_started_cb(url_download_h download);
-
-
-/**
- * @brief Registers a callback function to be invoked when the download is paused.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] callback The callback function to register
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @post url_download_paused_cb() will be invoked.
- * @see url_download_unset_paused_cb()
- * @see url_download_paused_cb()
-*/
-int url_download_set_paused_cb(url_download_h download, url_download_paused_cb callback, void* user_data);
-
-
-/**
- * @brief Unregisters the callback function.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_set_paused_cb()
- * @see url_download_paused_cb()
-*/
-int url_download_unset_paused_cb(url_download_h download);
-
-
-/**
- * @brief Registers a callback function to be invoked when the download completed.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] callback The callback function to register
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @post url_download_completed_cb() will be invoked.
- * @see url_download_unset_completed_cb()
- * @see url_download_completed_cb()
-*/
-int url_download_set_completed_cb(url_download_h download, url_download_completed_cb callback, void* user_data);
-
-
-/**
- * @brief Unregisters the callback function.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_set_completed_cb()
- * @see url_download_completed_cb()
-*/
-int url_download_unset_completed_cb(url_download_h download);
-
-
-/**
- * @brief Registers a callback function to be invoked when the download is stopped.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] callback The callback function to register
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @post url_download_stopped_cb() will be invoked.
- * @see url_download_unset_stopped_cb()
- * @see url_download_stopped_cb()
-*/
-int url_download_set_stopped_cb(url_download_h download, url_download_stopped_cb callback, void* user_data);
-
-
-/**
- * @brief Unregisters the callback function.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_set_stopped_cb()
- * @see url_download_stopped_cb()
-*/
-int url_download_unset_stopped_cb(url_download_h download);
-
-
-/**
- * @brief Registers a callback function to be invoked when progress of the download changes
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @param [in] callback The callback function to register
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @post url_download_progress_cb() will be invoked.
- * @see url_download_unset_progress_cb()
- * @see url_download_progress_cb()
-*/
-int url_download_set_progress_cb(url_download_h download, url_download_progress_cb callback, void *user_data);
-
-
-/**
- * @brief Unregisters the callback function.
- *
- * @remarks This function should be called before downloading (see url_download_start())
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY or #URL_DOWNLOAD_STATE_COMPLETED.
- * @see url_download_set_progress_cb()
- * @see url_download_progress_cb()
-*/
-int url_download_unset_progress_cb(url_download_h download);
-
-
-/**
- * @brief Starts or resumes the download, asynchronously.
- *
- * @details This function starts to download the current URL, or resumes the download if paused.
- *
- * @remarks The URL is the mandatory information to start the download.
- * @param [in] download The download handle
- * @param [out] id The identifier for the download unique within the application.
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @retval #URL_DOWNLOAD_ERROR_URL Invalid URL
- * @retval #URL_DOWNLOAD_ERROR_DESTINATION Invalid destination
- * @pre The download state must be #URL_DOWNLOAD_STATE_READY, #URL_DOWNLOAD_STATE_PAUSED or #URL_DOWNLOAD_STATE_COMPLETED.
- * @post The download state will be #URL_DOWNLOAD_STATE_DOWNLOADING
- * @see url_download_set_url()
- * @see url_download_pause()
- * @see url_download_stop()
- * @see url_download_set_started_cb()
- * @see url_download_unset_started_cb()
- * @see url_download_started_cb()
- */
-int url_download_start(url_download_h download, int *id);
-
-
-/**
- * @brief Pauses the download, asynchronously.
- *
- * @remarks The paused download can be restarted with url_download_start() or canceled with url_download_stop()
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @pre The download state must be #URL_DOWNLOAD_STATE_DOWNLOADING.
- * @post The download state will be #URL_DOWNLOAD_STATE_PAUSED.
- * @see url_download_start()
- * @see url_download_stop()
- * @see url_download_set_paused_cb()
- * @see url_download_unset_paused_cb()
- * @see url_download_paused_cb()
- */
-int url_download_pause(url_download_h download);
-
-/**
- * @brief Stops the download, asynchronously.
- *
- * @details This function cancels the running download and its state will be #URL_DOWNLOAD_STATE_READY
- * @remarks The stopped download can be restarted with url_download_start().
- * @param [in] download The download handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #URL_DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #URL_DOWNLOAD_ERROR_INVALID_STATE Invalid state
- * @retval #URL_DOWNLOAD_ERROR_IO_ERROR Internal I/O error
- * @pre The download state must be #URL_DOWNLOAD_STATE_DOWNLOADING.
- * @post url_download_stopped_cb() will be invoked if it is registered with url_download_set_stopped_cb()
- * @post The download state will be #URL_DOWNLOAD_STATE_READY.
- * @see url_download_start()
- * @see url_download_stop()
- * @see url_download_set_stopped_cb()
- * @see url_download_unset_stopped_cb()
- * @see url_download_stopped_cb()
- */
-int url_download_stop(url_download_h download);
-
-/**
- * @brief Gets the download's current state.
- *
- * @param [in] download The download handle
- * @param [out] state The current state of the download
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @see #url_download_state_e
- */
-int url_download_get_state(url_download_h download, url_download_state_e *state);
-
-/**
- * @brief Retrieves all HTTP header fields to be included with the download
- * @details This function calls url_download_http_header_field_cb() once for each HTTP header field added.\n
- * If url_download_http_header_field_cb() callback function returns false, then iteration will be finished.
- *
- * @param [in] download The download handle
- * @param [in] callback The iteration callback function
- * @param [in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #URL_DOWNLOAD_ERROR_NONE Successful
- * @retval #URL_DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
- * @post This function invokes url_download_http_header_field_cb().
- * @see url_download_http_header_field_cb()
- */
-int url_download_foreach_http_header_field(url_download_h download, url_download_http_header_field_cb callback, void *user_data);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_WEB_URL_DOWNLOAD_H__ */
+++ /dev/null
-/*
- * 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_URL_DOWNLOAD_PRIVATE_H__
-#define __TIZEN_WEB_URL_DOWNLOAD_PRIVATE_H__
-
-#include <bundle.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/**
- * url_download_cb_s
- */
-struct url_download_cb_s {
- url_download_started_cb started;
- void *started_user_data;
-
- url_download_paused_cb paused;
- void *paused_user_data;
-
- url_download_completed_cb completed;
- void *completed_user_data;
-
- url_download_stopped_cb stopped;
- void *stopped_user_data;
-
- url_download_progress_cb progress;
- void *progress_user_data;
-};
-
-struct url_download_s {
- uint id;
- uint enable_notification;
- int requestid;
- struct url_download_cb_s callback;
- url_download_state_e state;
- char *url;
- char *destination;
- bundle *http_header;
- char *completed_path;
- char *content_name;
- char *mime_type;
- bundle_raw *service_data;
- int service_data_len;
- uint file_size;
- int sockfd;
- int slot_index;
-};
-
-#define MAX_DOWNLOAD_HANDLE_COUNT 5
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_WEB_URL_DOWNLOAD_PRIVATE_H__ */
Name: capi-web-url-download
Summary: CAPI for content download with web url
-Version: 0.0.8
-Release: 9
+Version: 1.2.6
+Release: 0
Group: Development/Libraries
-License: TO_BE_FILLED_IN
-URL: Apache
+License: Apache-2.0
+URL: N/A
Source0: %{name}-%{version}.tar.gz
BuildRequires: pkgconfig(capi-base-common)
-BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(download-provider)
+BuildRequires: pkgconfig(download-provider-interface)
BuildRequires: cmake
-BuildRequires: expat-devel
%description
CAPI for the content download
%setup -q
%build
-cmake . -DCMAKE_INSTALL_PREFIX="/"
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%cmake .
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%make_install
+mkdir -p %{buildroot}/usr/share/license
%post -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
-%{_libdir}/libcapi-web-url-download.so
+%manifest capi-web-url-download.manifest
+%{_libdir}/libcapi-web-url-download.so.*
+/usr/share/license/%{name}
%files devel
%defattr(-,root,root,-)
+%manifest capi-web-url-download.manifest
%{_libdir}/libcapi-web-url-download.so
%{_libdir}/pkgconfig/capi-web-url-download.pc
-/usr/include/web/url_download.h
-
-%changelog
-* Fri Sep 07 2012 Kwangmin Bang <justine.bang@samsung.com>
-- fix timeout thread can run exactly
-
-* Thu Sep 06 2012 Kwangmin Bang <justine.bang@samsung.com>
-- check the state before clear socket
-- add limitation in already completed state
-- add checking INVALID_STATE error
-
-* Tue Sep 04 2012 Jungki Kwak <jungki.kwak@samsung.com>
-- Remove unused code which is base on libdownload-agent
-- Change the name of application operation
-- Add exception handling for non requestid
-- Call clear_provider after getting the state
-- url_download_get_state return IO error
-- Resolve prevent defects
-
-* Mon Sep 03 2012 Kwangmin Bang <justine.bang@samsung.com>
-- stop the download even if no socket or callback
-- pause/resume the download even if no socket or callback
-- calling stopped callback in error case
-- request STOP for free after finished download
-
-* Thu Aug 30 2012 Kwangmin Bang <justine.bang@samsung.com>
-- maxfd should be updated before created event thread
-
-* Thu Aug 30 2012 Kwangmin Bang <justine.bang@samsung.com>
-- remove duplicated call for creating socket
-- fix the crash regarding pthread_kill
-- allow to call url_download_stop in case of PAUSED state
-
-* Mon Aug 27 2012 Kwangmin Bang <justine.bang@samsung.com>
-- one thread model for event
-- get state info from download-provider even if no connection
-- fix the bug take a long time to receive first event
-
-* Tue Aug 22 2012 Jungki Kwak <jungki.kwak@samsung.com>
-- Enhance the exception handling in event thread
-- Resolve a bug about state
-- Add to pass service handle data to download daemon
-
-* Mon Aug 17 2012 Jungki Kwak <jungki.kwak@samsung.com>
-- Resolve a bug when getting a state
-- Add error case for invalid id
-
-* Mon Aug 16 2012 Jungki Kwak <jungki.kwak@samsung.com>
-- Add new APIs for notification function
-- The TC is changed due to change of url_download_start
-- When unseting the callback function, the callback should be initialized although the error is happened.
-- It remove the stop function when is called twice when destroying handle
-- Add pc requries for app.h
-
-* Mon Aug 08 2012 Jungki Kwak <jungki.kwak@samsung.com>
-- Change requestid to INTEGER from String
-
-* Mon Aug 06 2012 Jungki Kwak <jungki.kwak@samsung.com>
-- The base model is changed to download provider daemon
+%{_includedir}/web/download.h
+%{_includedir}/web/download_doc.h
+++ /dev/null
-#!/bin/sh
-
-gcc -o url_download_test test.c -I./ `pkg-config --cflags --libs capi-web-url-download ecore gobject-2.0` -g
-
-
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "web/url_download.h"
-#include "log.h"
-
-bool exit_process_flag = false;
-
-void download_manager_started_cb (url_download_h download, void *user_data)
-{
- TRACE_DEBUG_MSG("started");
-}
-void download_manager_completed_cb (url_download_h download, const char * path, void *user_data)
-{
- TRACE_DEBUG_MSG("download_manager_completed_cb (%s)",path);
- exit_process_flag = true;
-}
-void download_manager_progress_cb (url_download_h download, unsigned long long received, unsigned long long total, void *user_data)
-{
- TRACE_DEBUG_MSG("progress (%d/%d)",received,total);
-}
-
-int main(int argc, char** argv)
-{
- url_download_h download;
- exit_process_flag = false;
- // create download.
- url_download_create(&download);
- url_download_set_url(download, "abcdefghigk");
- url_download_set_destination(download, "1234567890everywhere");
-
- url_download_set_started_cb(download, download_manager_started_cb, NULL);
- url_download_set_completed_cb(download, download_manager_completed_cb, NULL);
- url_download_set_progress_cb(download, download_manager_progress_cb, NULL);
-
- // start....
- url_download_start(download);
- while(!exit_process_flag)
- {
- sleep(5);
- }
- // pasuse
- //url_download_pause(&download);
- // resume
- //url_download_stop(&download);
-
- url_download_destroy(download);
- TRACE_DEBUG_MSG("exit...........");
- exit(EXIT_SUCCESS);
-}
+++ /dev/null
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <Ecore.h>
-#include <url_download.h>
-
-#define LOGD(fmt, ...) \
- do { printf("[D][L:%3d] " fmt, __LINE__, ##__VA_ARGS__); \
- printf("\n"); \
- } while(0);
-#define LOGE(fmt, ...) \
- do { printf("[E][L:%3d] " fmt, __LINE__, ##__VA_ARGS__); \
- printf("\n"); \
- } while(0);
-#define LOGC(fmt, ...) \
- do { printf("[C][L:%3d] " fmt, __LINE__, ##__VA_ARGS__); \
- printf("\n"); \
- } while(0);
-
-#define STRINGFY(xx) #xx
-
-#define TEST_URL "http://cdn.naver.com/naver/NanumFont/setupmac/NanumFontSetup_ECO_OTF_Ver1.0.app.zip"
-#define TEST_URL2 "http://builds.nightly.webkit.org/files/trunk/src/WebKit-r109693.tar.bz2"
-
-#define TEST_GALAXY_UA "Mozilla/5.0 (Linux; U; Android 2.3.3; ko-kr; SHW-M250S Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
-#define TEST_UA "AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
-
-url_download_h handle = NULL;
-
-void print_state_str()
-{
- int ret = 0;
- url_download_state_e state = 0;
- ret = url_download_get_state(handle, &state);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to get state");
- return;
- }
-
- switch (state)
- {
- case URL_DOWNLOAD_STATE_READY:
- LOGD("State : Ready");
- break;
- case URL_DOWNLOAD_STATE_COMPLETED:
- LOGD("State : Competed");
- break;
- case URL_DOWNLOAD_STATE_PAUSED:
- LOGD("State : Paused");
- break;
- case URL_DOWNLOAD_STATE_DOWNLOADING:
- LOGD("State : Downloading");
- break;
- }
-}
-
-void print_error_str(url_download_error_e err)
-{
- switch (err)
- {
- case URL_DOWNLOAD_ERROR_NONE:
- LOGD("%s",STRINGFY(URL_DOWNLOAD_ERROR_NONE));
- break;
- case URL_DOWNLOAD_ERROR_INVALID_PARAMETER:
- LOGD("Err:%s",STRINGFY(URL_DOWNLOAD_ERROR_INVALID_PARAMETER));
- break;
- case URL_DOWNLOAD_ERROR_OUT_OF_MEMORY:
- LOGD("Err:%s",STRINGFY(URL_DOWNLOAD_ERROR_OUT_OF_MEMORY));
- break;
- case URL_DOWNLOAD_ERROR_IO_ERROR:
- LOGD("Err:%s",STRINGFY(URL_DOWNLOAD_ERROR_IO_ERROR));
- break;
- case URL_DOWNLOAD_ERROR_NETWORK_UNREACHABLE:
- LOGD("Err:%s",STRINGFY(URL_DOWNLOAD_ERROR_NETWORK_UNREACHABLE));
- break;
- case URL_DOWNLOAD_ERROR_CONNECTION_TIMED_OUT:
- LOGD("Err:%s",STRINGFY(URL_DOWNLOAD_ERROR_CONNECTION_TIMED_OUT));
- break;
- case URL_DOWNLOAD_ERROR_NO_SPACE:
- LOGD("Err:%s", STRINGFY(URL_DOWNLOAD_ERROR_NO_SPACE));
- break;
- case URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND:
- LOGD("Err:%s", STRINGFY(URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND));
- break;
- case URL_DOWNLOAD_ERROR_INVALID_STATE:
- LOGD("Err:%s", STRINGFY(URL_DOWNLOAD_ERROR_INVALID_STATE));
- break;
- case URL_DOWNLOAD_ERROR_CONNECTION_FAILED:
- LOGD("Err:%s", STRINGFY(URL_DOWNLOAD_ERROR_CONNECTION_FAILED));
- break;
- case URL_DOWNLOAD_ERROR_SSL_FAILED:
- LOGD("Err:%s", STRINGFY(URL_DOWNLOAD_ERROR_SSL_FAILED));
- break;
- case URL_DOWNLOAD_ERROR_INVALID_URL:
- LOGD("Err:%s", STRINGFY(URL_DOWNLOAD_ERROR_INVALID_URL));
- break;
- default:
- LOGD("No Error");
- break;
- }
-}
-
-void completed_cb(url_download_h download, const char *path, void *user_data)
-{
- LOGD("===Completed Callback===");
- print_state_str();
- if (path)
- LOGD("Downloaded Path:%s", path);
- ecore_main_loop_quit();
- LOGD("========================");
-}
-
-void progress_cb(url_download_h download, unsigned long long received, unsigned long long total, void *user_data)
-{
- LOGD("===Progress Callback===");
- print_state_str();
- LOGD("received[%llu] total[%llu]",received, total);
- LOGD("=======================");
-}
-
-void stopped_cb(url_download_h download, url_download_error_e error, void *user_data)
-{
- LOGD("===Stoped Callback===");
- print_state_str();
- print_error_str(error);
- LOGD("=====================");
-}
-
-void started_cb(url_download_h download, void *user_data)
-{
- LOGD("===Started Callback===");
- print_state_str();
- LOGD("======================");
-}
-
-bool http_header_cb(url_download_h download, const char *field, void *user_data)
-{
- print_state_str();
- if (field)
- LOGD("HTTP header field : %s",field);
-}
-
-void init()
-{
- int ret = 0;
- ret = url_download_create(&handle);
- if (ret != URL_DOWNLOAD_ERROR_NONE)
- {
- LOGE("Fail to create download handle");
- return;
- }
- ret = url_download_set_url(handle, TEST_URL);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to set url");
- return;
- }
-
- ret = url_download_set_destination (handle, "./");
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to set install directory");
- return;
- }
- ret = url_download_add_http_header_field(handle, "User-Agent", TEST_UA);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to add http header");
- return;
- }
-
- ret = url_download_set_completed_cb(handle, completed_cb, NULL);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to set completed callback");
- return;
- }
-
- ret = url_download_set_stopped_cb(handle, stopped_cb, NULL);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to set stopped callback");
- return;
- }
-
- ret = url_download_set_progress_cb(handle, progress_cb, NULL);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to set progress callback");
- return;
- }
-
- ret = url_download_set_started_cb(handle, started_cb, NULL);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to set started callback");
- return;
- }
-
- ret = url_download_foreach_http_header_field(handle, http_header_cb, NULL);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to start download");
- return;
- }
-
- ret = url_download_start(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to start download");
- return;
- }
-}
-
-Eina_Bool request_start(void *data)
-{
- int ret = 0;
- url_download_state_e state;
-
- LOGD("#REQUEST Start#");
- ret = url_download_get_state(handle, &state);
- if (state != URL_DOWNLOAD_STATE_PAUSED &&
- state != URL_DOWNLOAD_STATE_COMPLETED &&
- state != URL_DOWNLOAD_STATE_READY)
- {
- LOGE("Cannot stop at present state");
- return 1;
- }
-
- ret = url_download_start(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to start download");
- }
- return 0;
-}
-
-Eina_Bool request_stop(void *data)
-{
- int ret = 0;
- url_download_state_e state;
-
- LOGD("#REQUEST Stop#");
- ret = url_download_get_state(handle, &state);
- if (state != URL_DOWNLOAD_STATE_PAUSED &&
- state != URL_DOWNLOAD_STATE_DOWNLOADING)
- {
- LOGC("Cannot stop at present state");
- return 1;
- }
-
- ret = url_download_stop(handle);
- if (ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to stop download");
- }
- return 0;
-}
-
-Eina_Bool request_pause(void *data)
-{
- int ret = 0;
- url_download_state_e state;
-
- LOGD("#REQUEST Pause#");
- ret = url_download_get_state(handle, &state);
- if (state != URL_DOWNLOAD_STATE_DOWNLOADING)
- {
- LOGC("Cannot stop at present state");
- return 1;
- }
-
- ret = url_download_pause(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to pause download");
- }
- return 0;
-}
-
-void deinit()
-{
- int ret = 0;
- char **value = NULL;
- char **url = NULL;
- char **destination = NULL;
-
- ret = url_download_get_http_header_field(handle, "User-Agent", value);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to get the value of the http field");
- return;
- }
-
- if (value)
- {
- int i = 0;
- int num = sizeof(value)/sizeof(char *);
- LOGD("num[%d] size[%d] size[%d]", num, sizeof(value), sizeof(char *));
- for (i = 0; i < num; i++)
- {
- LOGD("Value[%d]:%s",i+1,value[i]);
- }
- }
-
- ret = url_download_get_url(handle, url);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to get url");
- return;
- }
- if (url && *url)
- LOGD("URL:%s", *url)
-
- ret = url_download_get_destination(handle, destination);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to remove the value of the http field");
- return;
- }
- if (destination && *destination)
- LOGD("Detination Path:%s", *destination);
-
-
- ret = url_download_remove_http_header_field(handle, "User-Agent");
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to remove the value of the http field");
- return;
- }
-
- ret = url_download_unset_completed_cb(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to unset completed callback");
- return;
- }
-
- ret = url_download_unset_stopped_cb(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to unset stopped callback");
- return;
- }
-
- ret = url_download_unset_progress_cb(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to unset progress callback");
- return;
- }
-
- ret = url_download_unset_started_cb(handle);
- if ( ret != URL_DOWNLOAD_ERROR_NONE )
- {
- LOGE("Fail to unset started callback");
- return;
- }
- ret = url_download_destroy(handle);
- if (ret != URL_DOWNLOAD_ERROR_NONE)
- {
- LOGE("Fail to destroy download handle");
- return;
- }
-}
-
-int main()
-{
- Ecore_Timer *t1 = NULL;
- Ecore_Timer *t2 = NULL;
- Ecore_Timer *t3 = NULL;
- Ecore_Timer *t4 = NULL;
- /* Should this function because libsoup use gobejct.
- * If appcore_init() is used, g_type_init() is not needed.
- * This is called internally in appcore_init().
- */
- g_type_init();
- ecore_init();
- init();
- t1 = ecore_timer_add(2.0, request_stop, NULL);
- t2 = ecore_timer_add(5.0, request_start, NULL);
- t3 = ecore_timer_add(8.0, request_pause, NULL);
- t4 = ecore_timer_add(11.0, request_start, NULL);
- ecore_main_loop_begin();
- ecore_shutdown();
- LOGD("Program Exit");
-}
--- /dev/null
+Title
+
+[Title]
+[Issue#] N/A
+[Problem] N/A
+[Cause] N/A
+[Solution] N/A
+
+# please fill the each items.
+# If this is the commit to fix issue, please replace N/A to the number of issue.
+
--- /dev/null
+#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-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_create(int *download_id)
+{
+ TRACE_INFO("");
+ if (download_id == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_create(download_id);
+}
+
+int download_destroy(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_destroy(download_id);
+}
+
+int download_start(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_start(download_id);
+}
+
+int download_pause(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_pause(download_id);
+}
+
+int download_cancel(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_cancel(download_id);
+}
+
+
+int download_set_url(int download_id, const char *url)
+{
+ TRACE_INFO("");
+ if (url == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_url(download_id, url);
+}
+
+
+int download_get_url(int download_id, char **url)
+{
+ TRACE_INFO("");
+ if (url == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_url(download_id, url);
+}
+
+int download_set_network_type(int download_id,
+ download_network_type_e net_type)
+{
+ TRACE_INFO("");
+ return dp_interface_set_network_type(download_id, (int)net_type);
+}
+
+int download_get_network_type(int download_id,
+ download_network_type_e *net_type)
+{
+ TRACE_INFO("");
+
+ if (net_type == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int network_type = DOWNLOAD_ADAPTOR_NETWORK_ALL;
+ int ret = dp_interface_get_network_type(download_id, &network_type);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *net_type = network_type;
+ 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("");
+ if (path == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_destination(download_id, path);
+}
+
+
+int download_get_destination(int download_id, char **path)
+{
+ TRACE_INFO("");
+ if (path == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_destination(download_id, path);
+}
+
+int download_set_file_name(int download_id, const char *file_name)
+{
+ TRACE_INFO("");
+ if (file_name == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_file_name(download_id, file_name);
+}
+
+int download_get_file_name(int download_id, char **file_name)
+{
+ TRACE_INFO("");
+ if (file_name == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_file_name(download_id, file_name);
+}
+
+int download_get_downloaded_file_path(int download_id, char **path)
+{
+ TRACE_INFO("");
+ if (path == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_downloaded_file_path(download_id, path);
+}
+
+int download_add_http_header_field(int download_id, const char *field,
+ const char *value)
+{
+ TRACE_INFO("");
+ if (field == NULL || value == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return
+ dp_interface_add_http_header_field(download_id, field, value);
+}
+
+int download_get_http_header_field(int download_id,
+ const char *field, char **value)
+{
+ TRACE_INFO("");
+ if (field == NULL || value == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return
+ dp_interface_get_http_header_field(download_id, field, value);
+}
+
+int download_get_http_header_field_list(int download_id, char ***fields,
+ int *length)
+{
+ TRACE_INFO("");
+ if (fields == NULL || length == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_http_header_field_list(download_id, fields,
+ length);
+}
+
+int download_remove_http_header_field(int download_id,
+ const char *field)
+{
+ TRACE_INFO("");
+ if (field == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_remove_http_header_field(download_id, field);
+}
+
+// download_state_changed_cb is different with dp_interface_state_changed_cb.
+int download_set_state_changed_cb(int download_id,
+ download_state_changed_cb callback, void* user_data)
+{
+ TRACE_INFO("");
+ return dp_interface_set_state_changed_cb(download_id,
+ (dp_interface_state_changed_cb)callback, user_data);
+}
+
+int download_unset_state_changed_cb(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_unset_state_changed_cb(download_id);
+}
+
+// download_progress_cb is same with dp_interface_progress_cb.
+int download_set_progress_cb(int download_id,
+ download_progress_cb callback, void *user_data)
+{
+ TRACE_INFO("");
+ return dp_interface_set_progress_cb(download_id,
+ (dp_interface_progress_cb)callback, user_data);
+}
+
+int download_unset_progress_cb(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_unset_progress_cb(download_id);
+}
+
+int download_get_state(int download_id, download_state_e *state)
+{
+ int statecode = 0;
+ TRACE_INFO("");
+ if (state == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_state(download_id, &statecode);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *state = statecode;
+ return ret;
+}
+
+int download_get_temp_path(int download_id, char **temp_path)
+{
+ TRACE_INFO("");
+ if (temp_path == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_temp_path(download_id, temp_path);
+}
+
+int download_get_content_name(int download_id, char **content_name)
+{
+ TRACE_INFO("");
+ if (content_name == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_content_name(download_id, content_name);
+}
+
+int download_get_content_size(int download_id,
+ unsigned long long *content_size)
+{
+ TRACE_INFO("");
+ if (content_size == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_content_size(download_id, content_size);
+}
+
+int download_get_mime_type(int download_id, char **mime_type)
+{
+ TRACE_INFO("");
+ if (mime_type == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_mime_type(download_id, mime_type);
+}
+
+int download_set_auto_download(int download_id, bool enable)
+{
+ TRACE_INFO("");
+ return dp_interface_set_auto_download(download_id, (int)enable);
+}
+
+int download_get_auto_download(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_auto_download(download_id, &is_set);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *enable = (bool)is_set;
+ return ret;
+}
+
+int download_get_error(int download_id, download_error_e *error)
+{
+ int errorcode = 0;
+ TRACE_INFO("");
+ if (error == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_error(download_id, &errorcode);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *error = errorcode;
+ return ret;
+}
+
+int download_get_http_status(int download_id, int *http_status)
+{
+ TRACE_INFO("");
+ if (http_status == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_http_status(download_id, http_status);
+}
+
+int download_set_notification_app_control(int download_id, download_notification_app_control_type_e type, app_control_h handle)
+{
+ TRACE_INFO("");
+ if (handle == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_notification_service_handle(download_id, (int)type, handle);
+}
+
+int download_get_notification_app_control(int download_id, download_notification_app_control_type_e type, app_control_h *handle)
+{
+ TRACE_INFO("");
+ if (handle == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_notification_service_handle(download_id, (int)type, handle);
+}
+
+int download_set_notification_title(int download_id, const char *title)
+{
+ TRACE_INFO("");
+ if (title == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_notification_title(download_id, title);
+}
+
+int download_get_notification_title(int download_id, char **title)
+{
+ TRACE_INFO("");
+ if (title == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_notification_title(download_id, title);
+}
+
+int download_set_notification_description(int download_id, const char *description)
+{
+ TRACE_INFO("");
+ if (description == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_notification_description(download_id, description);
+}
+
+int download_get_notification_description(int download_id, char **description)
+{
+ TRACE_INFO("");
+ if (description == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_notification_description(download_id, description);
+}
+
+int download_set_notification_type(int download_id, download_notification_type_e type)
+{
+ TRACE_INFO("");
+ return dp_interface_set_notification_type(download_id, (int)type);
+}
+
+int download_get_notification_type(int download_id, download_notification_type_e *type)
+{
+ int noti_type = 0;
+ TRACE_INFO("");
+ if (type == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_notification_type(download_id, ¬i_type);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *type = (download_notification_type_e)noti_type;
+ return ret;
+}
+
+int download_get_etag(int download_id, char **etag)
+{
+ TRACE_INFO("");
+ if (etag == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_get_etag(download_id, etag);
+}
+
+int download_set_temp_file_path(int download_id, char *path)
+{
+ TRACE_INFO("");
+ if (path == NULL)
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ return dp_interface_set_temp_file_path(download_id, path);
+}
+++ /dev/null
-#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 <pthread.h>
-#include <signal.h>
-
-#include <app_manager.h>
-
-#include <dlog.h>
-#include <url_download.h>
-#include <url_download_private.h>
-#include <download-provider.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_URL_DOWNLOAD"
-
-#define STATE_IS_RUNNING(_download_) \
- (_download_->state == URL_DOWNLOAD_STATE_DOWNLOADING \
- || _download_->state == URL_DOWNLOAD_STATE_PAUSED)
-
-
-#define STRING_IS_INVALID(_string_) \
- (_string_ == NULL || _string_[0] == '\0')
-
-static int url_download_resume(url_download_h download);
-static int url_download_get_all_http_header_fields(
- url_download_h download, char ***fields, int *fields_length);
-
-// one event thread model.
-int g_download_maxfd = 0;
-fd_set g_download_socket_readset;
-fd_set g_download_socket_exceptset;
-static url_download_h g_download_handle_list[MAX_DOWNLOAD_HANDLE_COUNT] = {0,};
-
-url_download_state_e url_download_provider_state(int state)
-{
- switch (state) {
- case DOWNLOAD_STATE_STOPPED:
- LOGI("DOWNLOAD_STATE_STOPPED");
- return URL_DOWNLOAD_STATE_READY;
- case DOWNLOAD_STATE_DOWNLOADING:
- LOGI("DOWNLOAD_STATE_DOWNLOADING");
- return URL_DOWNLOAD_STATE_DOWNLOADING;
- case DOWNLOAD_STATE_PAUSE_REQUESTED:
- LOGI("DOWNLOAD_STATE_PAUSE_REQUESTED");
- return URL_DOWNLOAD_STATE_PAUSED;
- case DOWNLOAD_STATE_PAUSED:
- LOGI("DOWNLOAD_STATE_PAUSED");
- return URL_DOWNLOAD_STATE_PAUSED;
- case DOWNLOAD_STATE_FINISHED:
- LOGI("DOWNLOAD_STATE_FINISHED");
- return URL_DOWNLOAD_STATE_COMPLETED;
- /* For state when downlad is stared */
- case DOWNLOAD_STATE_READY:
- LOGI("DOWNLOAD_STATE_READY");
- return URL_DOWNLOAD_STATE_DOWNLOADING;
- case DOWNLOAD_STATE_INSTALLING:
- LOGI("DOWNLOAD_STATE_INSTALLING");
- return URL_DOWNLOAD_STATE_DOWNLOADING;
- case DOWNLOAD_STATE_FAILED:
- LOGI("DOWNLOAD_STATE_FAILED");
- return URL_DOWNLOAD_STATE_FAILED;
- default:
- LOGI("Not exist state [%d]", state);
- return URL_DOWNLOAD_STATE_READY;
- }
-}
-
-url_download_error_e url_download_provider_error(int error)
-{
- switch (error) {
- case DOWNLOAD_ERROR_NONE:
- return URL_DOWNLOAD_ERROR_NONE;
-
- case DOWNLOAD_ERROR_CONNECTION_FAILED:
- return URL_DOWNLOAD_ERROR_CONNECTION_FAILED;
-
- case DOWNLOAD_ERROR_NETWORK_UNREACHABLE:
- return URL_DOWNLOAD_ERROR_NETWORK_UNREACHABLE;
-
- case DOWNLOAD_ERROR_CONNECTION_TIMED_OUT:
- return URL_DOWNLOAD_ERROR_CONNECTION_TIMED_OUT;
-
- case DOWNLOAD_ERROR_INVALID_DESTINATION:
- return URL_DOWNLOAD_ERROR_INVALID_DESTINATION;
-
- case DOWNLOAD_ERROR_NO_SPACE:
- return URL_DOWNLOAD_ERROR_NO_SPACE;
-
- case DOWNLOAD_ERROR_INVALID_URL:
- return URL_DOWNLOAD_ERROR_INVALID_URL;
-
- case DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS:
- return URL_DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS;
-
- case DOWNLOAD_ERROR_ALREADY_COMPLETED:
- return URL_DOWNLOAD_ERROR_ALREADY_COMPLETED;
-
- default:
- return URL_DOWNLOAD_ERROR_IO_ERROR;
- }
-}
-
-const char* url_download_error_to_string(int error_code)
-{
- char *error_name = NULL;
-
- switch (error_code) {
- case URL_DOWNLOAD_ERROR_NONE:
- error_name = "ERROR_NONE";
- break;
- case URL_DOWNLOAD_ERROR_INVALID_PARAMETER:
- error_name = "INVALID_PARAMETER";
- break;
- case URL_DOWNLOAD_ERROR_OUT_OF_MEMORY:
- error_name = "OUT_OF_MEMORY";
- break;
- case URL_DOWNLOAD_ERROR_IO_ERROR:
- error_name = "IO_ERROR";
- break;
- case URL_DOWNLOAD_ERROR_NETWORK_UNREACHABLE:
- error_name = "NETWORK_UNREACHABLE";
- break;
- case URL_DOWNLOAD_ERROR_CONNECTION_TIMED_OUT:
- error_name = "CONNECTION_TIMED_OUT";
- break;
- case URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND:
- error_name = "FIELD_NOT_FOUND";
- break;
- case URL_DOWNLOAD_ERROR_NO_SPACE:
- error_name = "NO_SPACE";
- break;
- case URL_DOWNLOAD_ERROR_INVALID_STATE:
- error_name = "INVALID_STATE";
- break;
- case URL_DOWNLOAD_ERROR_CONNECTION_FAILED:
- error_name = "CONNECTION_FAILED";
- break;
- case URL_DOWNLOAD_ERROR_SSL_FAILED:
- error_name = "SSL_FAILED";
- break;
- case URL_DOWNLOAD_ERROR_INVALID_URL:
- error_name = "INVALID_URL";
- break;
- case URL_DOWNLOAD_ERROR_INVALID_DESTINATION:
- error_name = "INVALID_DESTINATION";
- break;
- case URL_DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS:
- error_name = "FULL_OF_MAX_DOWNLOAD_ITEMS";
- break;
- case URL_DOWNLOAD_ERROR_ALREADY_COMPLETED:
- error_name = "ALREADY_COMPLETED";
- break;
- default:
- error_name = "UNKNOWN";
- break;
- }
- return error_name;
-}
-
-int url_download_error(const char *function, int error_code, const char *description)
-{
- const char *error_name = NULL;
-
- error_name = url_download_error_to_string(error_code);
- if (description)
- LOGE("[%s] %s(0x%08x) : %s", function, error_name, error_code, description);
- else
- LOGE("[%s] %s(0x%08x)", function, error_name, error_code);
-
- return error_code;
-}
-
-const char* url_download_state_to_string(url_download_state_e state)
-{
- switch (state)
- {
- case URL_DOWNLOAD_STATE_READY:
- return "READY";
-
- case URL_DOWNLOAD_STATE_DOWNLOADING:
- return "DOWNLOADING";
-
- case URL_DOWNLOAD_STATE_PAUSED:
- return "PAUSED";
-
- case URL_DOWNLOAD_STATE_COMPLETED:
- return "COMPLETED";
-
- default:
- return "INVALID";
- }
-}
-
-int url_download_error_invalid_state(const char *function, url_download_h download)
-{
- LOGE("[%s] INVALID_STATE(0x%08x) : state(%s)",
- function, URL_DOWNLOAD_ERROR_INVALID_STATE, url_download_state_to_string(download->state));
-
- return URL_DOWNLOAD_ERROR_INVALID_STATE;
-}
-
-int ipc_receive_header(int fd)
-{
- if(fd <= 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- download_controls msgheader = 0;
- if (read(fd, &msgheader, sizeof(download_controls)) < 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- LOGI("[%s] header : %d",__FUNCTION__, msgheader);
- return msgheader;
-}
-
-int ipc_send_download_control(int sockfd, download_controls type)
-{
- if (sockfd <= 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- // send control
- if (send(sockfd, &type, sizeof(download_controls), 0) < 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- return type;
-}
-
-int ipc_send_request_stateinfo(int sockfd, download_request_info *requestMsg)
-{
- if (sockfd <= 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- if (send(sockfd, requestMsg, sizeof(download_request_info), 0) < 0) {
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-void _clear_socket(int sockfd)
-{
- if (sockfd <= 0)
- return;
- FD_CLR(sockfd, &g_download_socket_readset);
- FD_CLR(sockfd, &g_download_socket_exceptset);
- close(sockfd);
-}
-
-int _connect_download_provider()
-{
- int sockfd = -1;
- struct sockaddr_un clientaddr;
- if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- LOGE("[%s]socket system error : %s",__FUNCTION__,strerror(errno));
- return -1;
- }
-
- bzero(&clientaddr, sizeof clientaddr);
- clientaddr.sun_family = AF_UNIX;
- strncpy(clientaddr.sun_path, DOWNLOAD_PROVIDER_IPC, strlen(DOWNLOAD_PROVIDER_IPC));
- if (connect(sockfd, (struct sockaddr*)&clientaddr, sizeof(clientaddr)) < 0) {
- LOGE("[%s]connect system error : %s",__FUNCTION__,strerror(errno));
- return -1;
- }
- return sockfd;
-}
-
-// send stop msg to free the download job
-int _clear_download_provider(int sockfd)
-{
- LOGE("[%s][%d]",__FUNCTION__, __LINE__);
- if (sockfd > 0)
- ipc_send_download_control(sockfd, DOWNLOAD_CONTROL_STOP);
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-void _terminate_event_server_if_no_download()
-{
- // manage event thread
- int i = 0;
- for (i = 0; i < MAX_DOWNLOAD_HANDLE_COUNT; i++) {
- if (g_download_handle_list[i])
- break;
- }
- if (i >= MAX_DOWNLOAD_HANDLE_COUNT) {
- LOGE("[%s][%d] shutdown event thread",__FUNCTION__, __LINE__);
- FD_ZERO(&g_download_socket_readset);
- FD_ZERO(&g_download_socket_exceptset);
- g_download_maxfd = 0;
- }
-}
-
-void *run_event_server(void *args)
-{
- LOGE("[%s][%d]",__FUNCTION__, __LINE__);
- fd_set readset, exceptset;
- struct timeval timeout;
- download_state_info stateinfo;
- download_content_info downloadinfo;
- downloading_state_info downloadinginfo;
- download_request_state_info requeststateinfo;
- unsigned i;
- unsigned is_timeout = 1;
-
- LOGI("[%s][%d] g_download_maxfd [%d]",__FUNCTION__, __LINE__, g_download_maxfd);
- while(g_download_maxfd > 0) {
-
- readset = g_download_socket_readset;
- exceptset = g_download_socket_exceptset;
- memset(&timeout, 0x00, sizeof(struct timeval));
- timeout.tv_sec = 1;
- is_timeout = 1;
-
- if (select((g_download_maxfd+1), &readset, 0, &exceptset, &timeout) < 0) {
- LOGE("[%s]pthread_create : %s",__FUNCTION__,strerror(errno));
- }
-
- for (i = 0; i < MAX_DOWNLOAD_HANDLE_COUNT; i++) {
- if (!g_download_handle_list[i])
- continue;
- if (g_download_handle_list[i]->sockfd <= 0)
- continue;
- if (FD_ISSET(g_download_handle_list[i]->sockfd, &readset) > 0) {
- is_timeout = 0;
- url_download_h download = g_download_handle_list[i];
- switch(ipc_receive_header(download->sockfd)) {
- case DOWNLOAD_CONTROL_GET_REQUEST_STATE_INFO :
- LOGI("[%s] DOWNLOAD_CONTROL_GET_REQUEST_STATE_INFO (started pended request)",__FUNCTION__);
- memset(&requeststateinfo, 0x00, sizeof(download_request_state_info));
- if (download->sockfd <= 0
- || read(download->sockfd, &requeststateinfo,
- sizeof(download_request_state_info)) < 0) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- }
- if (requeststateinfo.requestid > 0) {
- if (requeststateinfo.requestid != download->requestid)
- break;
- download->requestid = requeststateinfo.requestid;
- if (requeststateinfo.stateinfo.state == DOWNLOAD_STATE_FAILED) {
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- } else
- download->state = URL_DOWNLOAD_STATE_DOWNLOADING;
- } else {
- LOGE("[%s]Not Found request id (Wrong message)", __FUNCTION__);
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- }
- break;
- case DOWNLOAD_CONTROL_GET_DOWNLOAD_INFO :
- memset(&downloadinfo, 0x00, sizeof(download_content_info));
- if (download->sockfd <= 0
- || read(download->sockfd, &downloadinfo, sizeof(download_content_info)) < 0) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
- }
- LOGI("[%s] DOWNLOAD_CONTROL_GET_DOWNLOAD_INFO [%d]%",__FUNCTION__, downloadinfo.file_size);
- download->state = URL_DOWNLOAD_STATE_DOWNLOADING;
- download->file_size = downloadinfo.file_size;
- if (strlen(downloadinfo.mime_type) > 0)
- download->mime_type = strdup(downloadinfo.mime_type);
- if (strlen(downloadinfo.content_name) > 0) {
- download->content_name = strdup(downloadinfo.content_name);
- LOGI("content_name[%s] %", downloadinfo.content_name);
- }
- if (download->callback.started) {
- download->callback.started(
- download, download->content_name, download->mime_type,
- download->callback.started_user_data);
- }
- break;
- case DOWNLOAD_CONTROL_GET_DOWNLOADING_INFO :
- memset(&downloadinginfo, 0x00, sizeof(downloading_state_info));
- if (download->sockfd <= 0
- || read(download->sockfd, &downloadinginfo, sizeof(downloading_state_info)) < 0) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
- }
- // call the function by download-callbacks table.
- LOGI("[%s] DOWNLOAD_CONTROL_GET_DOWNLOADING_INFO [%d]%",__FUNCTION__, downloadinginfo.received_size);
- if (download->callback.progress) {
- download->callback.progress(
- download,
- downloadinginfo.received_size, download->file_size,
- download->callback.progress_user_data);
- }
- if (strlen(downloadinginfo.saved_path) > 0) {
- LOGI("[%s] saved path [%s]",__FUNCTION__, downloadinginfo.saved_path);
- download->completed_path = strdup(downloadinginfo.saved_path);
- }
- break;
- case DOWNLOAD_CONTROL_GET_STATE_INFO :
- memset(&stateinfo, 0x00, sizeof(download_state_info));
- if (download->sockfd <= 0
- || read(download->sockfd, &stateinfo, sizeof(download_state_info)) < 0) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- }
- // call the function by download-callbacks table.
- LOGI("[%s] DOWNLOAD_CONTROL_GET_STATE_INFO state[%d]",__FUNCTION__, stateinfo.state);
- switch (stateinfo.state) {
- case DOWNLOAD_STATE_STOPPED:
- LOGI("DOWNLOAD_STATE_STOPPED");
- download->state = URL_DOWNLOAD_STATE_READY;
- if (download->callback.stopped) {
- download->callback.stopped(download,
- url_download_provider_error(stateinfo.err),
- download->callback.stopped_user_data);
- }
- // check state again,
- // some client may change the state in callback
- if (download
- && (download->state == URL_DOWNLOAD_STATE_COMPLETED
- || download->state == URL_DOWNLOAD_STATE_FAILED
- || download->state == URL_DOWNLOAD_STATE_READY)) {
- _clear_download_provider(download->sockfd);
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
-
- case DOWNLOAD_STATE_DOWNLOADING:
- download->state = URL_DOWNLOAD_STATE_DOWNLOADING;
- LOGI("DOWNLOAD_STATE_DOWNLOADING");
- break;
- case DOWNLOAD_STATE_PAUSE_REQUESTED:
- LOGI("DOWNLOAD_STATE_PAUSE_REQUESTED");
- break;
- case DOWNLOAD_STATE_PAUSED:
- LOGI("DOWNLOAD_STATE_PAUSED");
- download->state = URL_DOWNLOAD_STATE_PAUSED;
- if (download->callback.paused)
- download->callback.paused(download, download->callback.paused_user_data);
- break;
-
- case DOWNLOAD_STATE_FINISHED:
- LOGI("DOWNLOAD_STATE_FINISHED");
- download->state = URL_DOWNLOAD_STATE_COMPLETED;
- if (download->callback.completed)
- download->callback.completed(download, download->completed_path, download->callback.completed_user_data);
- // check state again,
- // some client may change the state in callback
- if (download
- && (download->state == URL_DOWNLOAD_STATE_COMPLETED
- || download->state == URL_DOWNLOAD_STATE_FAILED)) {
- _clear_download_provider(download->sockfd);
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
- case DOWNLOAD_STATE_READY:
- LOGI("DOWNLOAD_STATE_READY");
- break;
- case DOWNLOAD_STATE_INSTALLING:
- LOGI("DOWNLOAD_STATE_INSTALLING");
- break;
- case DOWNLOAD_STATE_FAILED:
- LOGI("DOWNLOAD_STATE_FAILED");
- download->state = URL_DOWNLOAD_STATE_FAILED;
- if (download->callback.stopped) {
- download->callback.stopped(download,
- url_download_provider_error(stateinfo.err),
- download->callback.stopped_user_data);
- }
- // check state again,
- // some client may change the state in callback
- if (download
- && (download->state == URL_DOWNLOAD_STATE_COMPLETED
- || download->state == URL_DOWNLOAD_STATE_FAILED)) {
- _clear_download_provider(download->sockfd);
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
- default:
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, "invalid state change event");
- url_download_stop(download);
- if (download->callback.stopped) {
- download->state = URL_DOWNLOAD_STATE_FAILED;
- download->callback.stopped(download,
- URL_DOWNLOAD_ERROR_IO_ERROR,
- download->callback.stopped_user_data);
- }
- if (download) {
- _clear_download_provider(download->sockfd);
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
- }
-
- break;
-
- default :
- is_timeout = 0;
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, "Invalid message");
- LOGI("[%s]download[%p] slot[%d]",__FUNCTION__, download, download->slot_index);
- // download-provider closed socket, just clear it from fd_set
- if (download) {
- _clear_socket(download->sockfd);
- download->sockfd = 0;
- }
- break;
- } // switch
- } else if (FD_ISSET(g_download_handle_list[i]->sockfd, &exceptset) > 0) {
- is_timeout = 0;
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, "IO Exception");
- url_download_stop(g_download_handle_list[i]);
- if (g_download_handle_list[i]->callback.stopped) {
- g_download_handle_list[i]->state = URL_DOWNLOAD_STATE_FAILED;
- g_download_handle_list[i]->callback.stopped(
- g_download_handle_list[i],
- URL_DOWNLOAD_ERROR_IO_ERROR,
- g_download_handle_list[i]->callback.stopped_user_data);
- }
- if (g_download_handle_list[i] != NULL) {
- _clear_socket(g_download_handle_list[i]->sockfd);
- g_download_handle_list[i]->sockfd = 0;
- }
- }
- } // MAX_CLIENT
- if (is_timeout) // timeout with no event
- _terminate_event_server_if_no_download();
- }
- return 0;
-}
-
-int _get_empty_download_slot_index()
-{
- int i = 0;
- for (; i < MAX_DOWNLOAD_HANDLE_COUNT; i++) {
- if (g_download_handle_list[i] == NULL) {
- return i;
- }
- }
- return MAX_DOWNLOAD_HANDLE_COUNT;
-}
-
-// fill the reqeust info.
-int url_download_create(url_download_h *download)
-{
- url_download_h download_new;
-
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- int empty_slot = _get_empty_download_slot_index(g_download_handle_list);
- if (empty_slot >= MAX_DOWNLOAD_HANDLE_COUNT) {
- LOGE("[%s][%d] slot is full",__FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS, "Too many created handles");
- }
-
- download_new = (url_download_h)calloc(1, sizeof(struct url_download_s));
- if (download_new == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
-
- download_new->http_header = bundle_create();
-
- if (!download_new->http_header) {
- url_download_destroy(download_new);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, "failed to initialize a bundle");
- }
-
- download_new->state = URL_DOWNLOAD_STATE_READY;
- download_new->sockfd = 0;
- download_new->slot_index = empty_slot;
- *download = download_new;
-
- g_download_handle_list[empty_slot] = *download;
- LOGI("[%s]download[%p] *download[%p] slot[%d]",__FUNCTION__, download, *download, empty_slot);
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_create_by_id(int id, url_download_h *download)
-{
- int errorcode = URL_DOWNLOAD_ERROR_NONE;
- if (id <= 0)
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
- errorcode = url_download_create(download);
- if (errorcode == URL_DOWNLOAD_ERROR_NONE)
- (*download)->requestid = id;
- return errorcode;
-}
-
-// disconnect from download-provider
-int url_download_destroy(url_download_h download)
-{
- LOGI("[%s][%d]",__FUNCTION__, __LINE__);
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- url_download_stop(download);
-
- if (download->sockfd > 0)
- _clear_download_provider(download->sockfd);
-
- _clear_socket(download->sockfd);
- download->sockfd = 0;
-
- g_download_handle_list[download->slot_index] = NULL;
- download->slot_index = -1;
-
- if (download->url)
- free(download->url);
- if (download->destination)
- free(download->destination);
- if (download->http_header)
- free(download->http_header);
- if (download->mime_type)
- free(download->mime_type);
- if (download->content_name)
- free(download->content_name);
- if (download->completed_path)
- free(download->completed_path);
- if (download->service_data)
- bundle_free_encoded_rawdata(&(download->service_data));
- memset(&(download->callback), 0x00, sizeof(struct url_download_cb_s));
- download->id = -1;
- free(download);
-
- download = NULL;
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-extern int service_export_as_bundle(service_h service, bundle **data);
-// connect to download-provider. then send request info.
-int url_download_start(url_download_h download, int *id)
-{
- char **headers = NULL;
- int header_length = 0;
-
- if (!download || !download->url)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->state == URL_DOWNLOAD_STATE_DOWNLOADING)
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (download->state == URL_DOWNLOAD_STATE_COMPLETED)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_ALREADY_COMPLETED, NULL);
-
- if (download->state == URL_DOWNLOAD_STATE_PAUSED)
- return url_download_resume(download);
-
- _clear_socket(download->sockfd);
-
- download->sockfd = _connect_download_provider();
- if (download->sockfd < 0) {
- LOGE("[%s]socket system error : %s",__FUNCTION__,strerror(errno));
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
-
- download_request_info requestMsg;
- memset(&requestMsg, 0x00, sizeof(download_request_info));
- requestMsg.callbackinfo.started = (download->callback.started ? 1 : 0);
- requestMsg.callbackinfo.paused = (download->callback.paused ? 1 : 0);
- requestMsg.callbackinfo.completed = (download->callback.completed ? 1 : 0);
- requestMsg.callbackinfo.stopped = (download->callback.stopped ? 1 : 0);
- requestMsg.callbackinfo.progress = (download->callback.progress ? 1 : 0);
- requestMsg.notification = download->enable_notification;
-
- if (download->requestid > 0)
- requestMsg.requestid = download->requestid;
-
- if (download->url && strlen(download->url) < DP_MAX_URL_LEN)
- requestMsg.url.length = strlen(download->url);
-
- if (download->destination && strlen(download->destination) < DP_MAX_PATH_LEN)
- requestMsg.install_path.length = strlen(download->destination);
-
- if (download->content_name && strlen(download->content_name) < DP_MAX_STR_LEN)
- requestMsg.filename.length = strlen(download->content_name);
-
- if (download->service_data_len > 0) {
- requestMsg.service_data.length = download->service_data_len;
- }
-
- // headers test
- if (url_download_get_all_http_header_fields(download, &headers, &header_length) !=
- URL_DOWNLOAD_ERROR_NONE) {
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- if (header_length > 0) {
- int i=0;
- requestMsg.headers.rows = header_length;
- requestMsg.headers.str = (download_flexible_string*)calloc(requestMsg.headers.rows,
- sizeof(download_flexible_string));
- for(i=0; i < requestMsg.headers.rows; i++)
- requestMsg.headers.str[i].length = strlen(headers[i]);
- }
-
- char *app_pkgname = NULL;
- pid_t client_pid = getpid();
- int errcode = app_manager_get_package(client_pid, &app_pkgname);
- if (errcode == APP_MANAGER_ERROR_NONE
- && app_pkgname
- && strlen(app_pkgname) < DP_MAX_STR_LEN)
- requestMsg.client_packagename.length = strlen(app_pkgname);
- else
- LOGE("[%s] Failed to get app_pkgname app_manager_get_package",__FUNCTION__);
-
- if (ipc_send_download_control(download->sockfd, DOWNLOAD_CONTROL_START)
- != DOWNLOAD_CONTROL_START) {
- LOGE("[%s] [%d] URL_DOWNLOAD_ERROR_IO_ERROR", __FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
-
- if (ipc_send_request_stateinfo(download->sockfd, &requestMsg)
- != URL_DOWNLOAD_ERROR_NONE) {
- if (app_pkgname)
- free(app_pkgname);
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- if (requestMsg.client_packagename.length && app_pkgname) {
- if (send(download->sockfd, app_pkgname,
- requestMsg.client_packagename.length * sizeof(char), 0) < 0) {
- free(app_pkgname);
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- }
- if (app_pkgname)
- free(app_pkgname);
-
- if (requestMsg.url.length && download->url) {
- if (send(download->sockfd, download->url,
- requestMsg.url.length * sizeof(char), 0) < 0) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- }
- if (requestMsg.install_path.length && download->destination) {
- if (send(download->sockfd, download->destination,
- requestMsg.install_path.length * sizeof(char), 0) < 0) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- }
-
- if (requestMsg.filename.length && download->content_name) {
- if (send(download->sockfd, download->content_name,
- requestMsg.filename.length * sizeof(char), 0) < 0) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- }
-
- if (requestMsg.service_data.length && download->service_data) {
- if (send(download->sockfd, download->service_data,
- requestMsg.service_data.length * sizeof(char), 0) < 0) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- }
-
- if (requestMsg.headers.rows) {
- int i=0;
- for(i=0; i < requestMsg.headers.rows; i++) {
- if (send(download->sockfd, &requestMsg.headers.str[i],
- sizeof(download_flexible_string), 0) < 0) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__,strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- if (send(download->sockfd, headers[i],
- requestMsg.headers.str[i].length * sizeof(char), 0) < 0) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__,strerror(errno));
- return url_download_error(__FUNCTION__,
- URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- }
- free(requestMsg.headers.str);
- }
-
- // Sync style
- if (ipc_receive_header(download->sockfd) == DOWNLOAD_CONTROL_GET_REQUEST_STATE_INFO) {
- download_request_state_info requeststateinfo;
- memset(&requeststateinfo, 0x00, sizeof(download_request_state_info));
- if (read(download->sockfd, &requeststateinfo, sizeof(download_request_state_info)) < 0) {
- LOGE("[%s]receive read error",__FUNCTION__);
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- return -1;
- }
- if (requeststateinfo.requestid > 0) {
- download->requestid = requeststateinfo.requestid;
- (*id) = requeststateinfo.requestid;
- }
- if (requeststateinfo.stateinfo.state == DOWNLOAD_STATE_DOWNLOADING) {
- // started download normally.
- download->state = URL_DOWNLOAD_STATE_DOWNLOADING;
- }
- // check invalid id case
- if (requeststateinfo.stateinfo.err == DOWNLOAD_ERROR_INVALID_PARAMETER) {
- LOGE("[%s]invalid id",__FUNCTION__);
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
- return URL_DOWNLOAD_ERROR_INVALID_PARAMETER;
- }
- } else {
- LOGE("[%s]receive header :error",__FUNCTION__);
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- url_download_stop(download);
-
- return URL_DOWNLOAD_ERROR_IO_ERROR;
- }
-
- // capi need the thread for listening message from download-provider; this will deal the callbacks.
- if (download->callback.completed
- || download->callback.stopped
- || download->callback.progress
- || download->callback.paused) {
- if (g_download_maxfd <= 0) {
- pthread_attr_t thread_attr;
- LOGI("[%s][%d] initialize fd_set",__FUNCTION__, __LINE__);
- FD_ZERO(&g_download_socket_readset);
- FD_ZERO(&g_download_socket_exceptset);
- LOGI("[%s][%d] add socket[%d] to FD_SET",__FUNCTION__, __LINE__, download->sockfd);
- // add socket to FD_SET
- FD_SET(download->sockfd, &g_download_socket_readset); // add new descriptor to set
- FD_SET(download->sockfd, &g_download_socket_exceptset);
- if (download->sockfd > g_download_maxfd )
- g_download_maxfd = download->sockfd;
- if (pthread_attr_init(&thread_attr) != 0) {
- LOGE("[%s]pthread_attr_init : %s",__FUNCTION__,strerror(errno));
- g_download_maxfd = 0;
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- }
- if (pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED) != 0) {
- LOGE("[%s]pthread_attr_setdetachstate : %s",__FUNCTION__,strerror(errno));
- g_download_maxfd = 0;
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- }
- LOGI("[%s][%d] create event thread",__FUNCTION__, __LINE__);
- pthread_t thread_pid;
- if (pthread_create(&thread_pid,
- &thread_attr,
- run_event_server,
- NULL) != 0) {
- LOGE("[%s][%d] pthread_create : %s",__FUNCTION__, __LINE__,strerror(errno));
- g_download_maxfd = 0;
- return URL_DOWNLOAD_ERROR_IO_ERROR;
- }
- } else {
- LOGI("[%s][%d] add socket[%d] to FD_SET",__FUNCTION__, __LINE__, download->sockfd);
- // add socket to FD_SET
- FD_SET(download->sockfd, &g_download_socket_readset); // add new descriptor to set
- FD_SET(download->sockfd, &g_download_socket_exceptset);
- if (download->sockfd > g_download_maxfd )
- g_download_maxfd = download->sockfd;
- }
- }
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-// send pause message
-int url_download_pause(url_download_h download)
-{
- if (download == NULL || download->requestid <= 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->state != URL_DOWNLOAD_STATE_DOWNLOADING)
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (download->sockfd > 0) {
- if (ipc_send_download_control(download->sockfd, DOWNLOAD_CONTROL_PAUSE)
- != DOWNLOAD_CONTROL_PAUSE) {
- LOGE("[%s] [%d] URL_DOWNLOAD_ERROR_IO_ERROR", __FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- if (!(download->callback.completed
- || download->callback.stopped
- || download->callback.progress
- || download->callback.paused)) { // if no callback
- // Sync style
- if (ipc_receive_header(download->sockfd) == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(download->sockfd, &stateinfo, sizeof(download_state_info)) < 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- download->state = url_download_provider_state(stateinfo.state);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- } else { // if no socket
- int sockfd = _connect_download_provider();
- if (sockfd > 0) {
- if (ipc_send_download_control(sockfd, DOWNLOAD_CONTROL_PAUSE)
- == DOWNLOAD_CONTROL_PAUSE) {
- download_request_info requestMsg;
- memset(&requestMsg, 0x00, sizeof(download_request_info));
- requestMsg.requestid = download->requestid;
- if (ipc_send_request_stateinfo(sockfd, &requestMsg)
- != URL_DOWNLOAD_ERROR_NONE) {
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- _clear_socket(sockfd);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // Sync style
- if (ipc_receive_header(sockfd)
- == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(sockfd, &stateinfo, sizeof(download_state_info)) < 0) {
- LOGE("[%s][%d] read failure",__FUNCTION__, __LINE__);
- _clear_download_provider(sockfd);
- _clear_socket(sockfd);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- download->state
- = url_download_provider_state(stateinfo.state);
- }
- } else {
- _clear_socket(sockfd);
- LOGE("[%s][%d] ipc_send_download_control failure",__FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // alert download-provider can free memory
- _clear_download_provider(sockfd);
- // close socket.
- _clear_socket(sockfd);
- }
- }
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_resume(url_download_h download)
-{
- if (download == NULL || download->requestid <= 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->state != URL_DOWNLOAD_STATE_PAUSED)
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (download->sockfd > 0) {
- if (ipc_send_download_control(download->sockfd, DOWNLOAD_CONTROL_RESUME)
- != DOWNLOAD_CONTROL_RESUME) {
- LOGE("[%s] [%d] URL_DOWNLOAD_ERROR_IO_ERROR", __FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- if (!(download->callback.completed
- || download->callback.stopped
- || download->callback.progress
- || download->callback.paused)) { // if no callback
- // Sync style
- if (ipc_receive_header(download->sockfd) == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(download->sockfd, &stateinfo, sizeof(download_state_info)) < 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- download->state = url_download_provider_state(stateinfo.state);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- } else { // if no socket
- int sockfd = _connect_download_provider();
- if (sockfd > 0) {
- if (ipc_send_download_control(sockfd, DOWNLOAD_CONTROL_RESUME)
- == DOWNLOAD_CONTROL_RESUME) {
- download_request_info requestMsg;
- memset(&requestMsg, 0x00, sizeof(download_request_info));
- requestMsg.requestid = download->requestid;
- if (ipc_send_request_stateinfo(sockfd, &requestMsg)
- != URL_DOWNLOAD_ERROR_NONE) {
- _clear_socket(sockfd);
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // Sync style
- if (ipc_receive_header(sockfd)
- == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(sockfd, &stateinfo, sizeof(download_state_info)) < 0) {
- LOGE("[%s][%d] read failure",__FUNCTION__, __LINE__);
- _clear_download_provider(sockfd);
- _clear_socket(sockfd);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- download->state
- = url_download_provider_state(stateinfo.state);
- }
- } else {
- _clear_socket(sockfd);
- LOGE("[%s][%d] ipc_send_download_control failure",__FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // alert download-provider can free memory
- _clear_download_provider(sockfd);
- // close socket.
- _clear_socket(sockfd);
- }
- }
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-// send stop message
-int url_download_stop(url_download_h download)
-{
- if (download == NULL || download->requestid <= 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->state != URL_DOWNLOAD_STATE_DOWNLOADING
- && download->state != URL_DOWNLOAD_STATE_PAUSED)
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (download->sockfd > 0) {
- if (ipc_send_download_control(download->sockfd, DOWNLOAD_CONTROL_STOP)
- != DOWNLOAD_CONTROL_STOP) {
- LOGE("[%s] [%d] URL_DOWNLOAD_ERROR_IO_ERROR", __FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- if (!(download->callback.completed
- || download->callback.stopped
- || download->callback.progress
- || download->callback.paused)) { // if no callback
- // Sync style
- if (ipc_receive_header(download->sockfd) == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(download->sockfd, &stateinfo, sizeof(download_state_info)) < 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- download->state = url_download_provider_state(stateinfo.state);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- } else { // if no socket
- int sockfd = _connect_download_provider();
- if (sockfd > 0) {
- if (ipc_send_download_control(sockfd, DOWNLOAD_CONTROL_STOP)
- == DOWNLOAD_CONTROL_STOP) {
- download_request_info requestMsg;
- memset(&requestMsg, 0x00, sizeof(download_request_info));
- requestMsg.requestid = download->requestid;
- if (ipc_send_request_stateinfo(sockfd, &requestMsg)
- != URL_DOWNLOAD_ERROR_NONE) {
- _clear_socket(sockfd);
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // Sync style
- if (ipc_receive_header(sockfd)
- == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(sockfd, &stateinfo, sizeof(download_state_info)) < 0) {
- LOGE("[%s][%d] read failure",__FUNCTION__, __LINE__);
- _clear_download_provider(sockfd);
- _clear_socket(sockfd);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- download->state
- = url_download_provider_state(stateinfo.state);
- }
- } else {
- _clear_socket(sockfd);
- LOGE("[%s][%d] ipc_send_download_control failure",__FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // alert download-provider can free memory
- _clear_download_provider(sockfd);
- // close socket.
- _clear_socket(sockfd);
- }
- }
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_get_state(url_download_h download, url_download_state_e *state)
-{
- if (download == NULL || state == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->requestid <= 0) {
- *state = download->state;
- return URL_DOWNLOAD_ERROR_NONE;
- }
-
- if (download->sockfd > 0) {
- if (!(download->callback.completed
- || download->callback.stopped
- || download->callback.progress
- || download->callback.paused)) {// only when does not use the callback.
-
- if (ipc_send_download_control(download->sockfd, DOWNLOAD_CONTROL_GET_STATE_INFO)
- == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- // Sync style
- if (ipc_receive_header(download->sockfd) == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(download->sockfd, &stateinfo, sizeof(download_state_info)) < 0)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- download->state = url_download_provider_state(stateinfo.state);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- } // check callback
- } else { // create new connection temporary, get info from provider.
- int sockfd = _connect_download_provider();
- if (sockfd > 0) {
- if (ipc_send_download_control(sockfd, DOWNLOAD_CONTROL_GET_STATE_INFO)
- == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_request_info requestMsg;
- memset(&requestMsg, 0x00, sizeof(download_request_info));
- requestMsg.requestid = download->requestid;
- if (ipc_send_request_stateinfo(sockfd, &requestMsg)
- != URL_DOWNLOAD_ERROR_NONE) {
- _clear_socket(sockfd);
- LOGE("[%s]request send system error : %s",
- __FUNCTION__, strerror(errno));
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // Sync style
- if (ipc_receive_header(sockfd)
- == DOWNLOAD_CONTROL_GET_STATE_INFO) {
- download_state_info stateinfo;
- if (read(sockfd, &stateinfo, sizeof(download_state_info)) < 0) {
- LOGE("[%s][%d] read failure",__FUNCTION__, __LINE__);
- _clear_download_provider(sockfd);
- _clear_socket(sockfd);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- download->state
- = url_download_provider_state(stateinfo.state);
- }
- // else means NONE
- download->state = URL_DOWNLOAD_STATE_READY;
- } else {
- _clear_socket(sockfd);
- LOGE("[%s][%d] ipc_send_download_control failure",__FUNCTION__, __LINE__);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- // alert download-provider can free memory
- _clear_download_provider(sockfd);
- // close socket.
- _clear_socket(sockfd);
- }
- }
- *state = download->state;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_set_url(url_download_h download, const char *url)
-{
- char *url_dup = NULL;
-
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (url != NULL) {
- url_dup = strndup(url, strlen(url));
-
- if (url_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- }
-
- if (download->url != NULL)
- free(download->url);
-
- download->url = url_dup;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_get_url(url_download_h download, char **url)
-{
- char *url_dup = NULL;
-
- if (download == NULL || url == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->url != NULL) {
- url_dup = strdup(download->url);
-
- if (url_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_NO_DATA, NULL);
-
- *url = url_dup;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_set_destination(url_download_h download, const char *path)
-{
- char *path_dup = NULL;
-
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (path != NULL) {
- path_dup = strdup(path);
-
- if (path_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- }
-
- if (download->destination != NULL)
- free(download->destination);
-
- download->destination = path_dup;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_get_destination(url_download_h download, char **path)
-{
- char *path_dup = NULL;
-
- if (download == NULL || path == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->destination != NULL) {
- path_dup = strdup(download->destination);
-
- if (path_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_NO_DATA, NULL);
-
- *path = path_dup;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_set_file_name(url_download_h download, const char *file_name)
-{
- if (download == NULL || file_name == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->content_name)
- free(download->content_name);
- download->content_name = strdup(file_name);
- if (download->content_name == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_get_file_name(url_download_h download, char **file_name)
-{
- char *filename_dup = NULL;
-
- if (download == NULL || file_name == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->content_name != NULL) {
- filename_dup = strdup(download->content_name);
-
- if (filename_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_NO_DATA, NULL);
-
- *file_name = filename_dup;
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_set_notification(url_download_h download, service_h service)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
- if (service == NULL) {
- download->enable_notification = 0;
- } else {
- download->enable_notification = 1;
- int len = 0;
- bundle *b = NULL;
- bundle_raw *raw_data = NULL;
- b = bundle_create();
- if (!b) {
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- }
- if (service_export_as_bundle(service, &b) < 0) {
- bundle_free(b);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
- }
- if (bundle_encode(b, &raw_data, &len) < 0) {
- bundle_free(b);
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
- }
- download->service_data = raw_data;
- download->service_data_len = len;
- bundle_free(b);
- }
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_get_notification(url_download_h download, service_h *service)
-{
- int errorcode = URL_DOWNLOAD_ERROR_NONE;
- return errorcode;
-}
-
-int url_download_get_downloaded_file(url_download_h download, char **path)
-{
- char *path_dup = NULL;
-
- if (download == NULL || path == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->completed_path != NULL) {
- path_dup = strdup(download->completed_path);
-
- if (path_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_STATE, NULL);
-
- *path = path_dup;
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_get_mime(url_download_h download, char **mime_type)
-{
- char *mime_dup = NULL;
-
- if (download == NULL || mime_type == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (download->mime_type != NULL) {
- mime_dup = strdup(download->mime_type);
-
- if (mime_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- } else
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_STATE, NULL);
-
- *mime_type = mime_dup;
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-int url_download_add_http_header_field(url_download_h download, const char *field, const char *value)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STRING_IS_INVALID(field) || STRING_IS_INVALID(value))
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (bundle_get_val(download->http_header, field))
- bundle_del(download->http_header, field);
-
- if (bundle_add(download->http_header, field, value))
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_get_http_header_field(url_download_h download, const char *field, char **value)
-{
- const char *bundle_value;
- char *field_value_dup;
-
- if (download == NULL || value == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STRING_IS_INVALID(field))
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- bundle_value = bundle_get_val(download->http_header, field);
-
- if (bundle_value == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND, NULL);
-
- field_value_dup = strdup(bundle_value);
-
- if (field_value_dup == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
-
- *value = field_value_dup;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_remove_http_header_field(url_download_h download, const char *field)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STRING_IS_INVALID(field))
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, "invalid field");
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- if (!bundle_get_val(download->http_header, field))
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_FIELD_NOT_FOUND, NULL);
-
- if (bundle_del(download->http_header, field))
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_IO_ERROR, NULL);
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_set_started_cb(url_download_h download, url_download_started_cb callback, void* user_data)
-{
- if (download == NULL || callback == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.started = callback;
- download->callback.started_user_data = user_data;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_unset_started_cb(url_download_h download)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
-// return url_download_error_invalid_state(__FUNCTION__, download);
- url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.started = NULL;
- download->callback.started_user_data = NULL;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_set_paused_cb(url_download_h download, url_download_paused_cb callback, void* user_data)
-{
- if (download == NULL || callback == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.paused = callback;
- download->callback.paused_user_data = user_data;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_unset_paused_cb(url_download_h download)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
-// return url_download_error_invalid_state(__FUNCTION__, download);
- url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.paused = NULL;
- download->callback.paused_user_data = NULL;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_set_completed_cb(url_download_h download, url_download_completed_cb callback, void* user_data)
-{
- if (download == NULL || callback == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.completed = callback;
- download->callback.completed_user_data = user_data;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_unset_completed_cb(url_download_h download)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
-// return url_download_error_invalid_state(__FUNCTION__, download);
- url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.completed = NULL;
- download->callback.completed_user_data = NULL;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_set_stopped_cb(url_download_h download, url_download_stopped_cb callback, void* user_data)
-{
- if (download == NULL || callback == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.stopped = callback;
- download->callback.stopped_user_data = user_data;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_unset_stopped_cb(url_download_h download)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
-// return url_download_error_invalid_state(__FUNCTION__, download);
- url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.stopped = NULL;
- download->callback.stopped_user_data = NULL;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_set_progress_cb(url_download_h download, url_download_progress_cb callback, void *user_data)
-{
- if (download == NULL || callback == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
- return url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.progress = callback;
- download->callback.progress_user_data = user_data;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-
-int url_download_unset_progress_cb(url_download_h download)
-{
- if (download == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- if (STATE_IS_RUNNING(download))
-// return url_download_error_invalid_state(__FUNCTION__, download);
- url_download_error_invalid_state(__FUNCTION__, download);
-
- download->callback.progress = NULL;
- download->callback.progress_user_data = NULL;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-typedef struct http_field_array_s{
- char **array;
- int array_length;
- int position;
-} http_field_array_t;
-
-void url_download_get_all_http_header_fields_iterator(const char *field_name, const char *field_value, void *user_data)
-{
- http_field_array_t *http_field_array;
- char *field_buffer;
- int field_buffer_length;
- const char *field_delimiters = ": ";
-
- http_field_array = user_data;
-
- if (http_field_array == NULL) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
- return;
- }
-
- // REF : http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
- field_buffer_length = strlen(field_name) + strlen(field_delimiters) + strlen(field_value) + 1;
-
- field_buffer = calloc(field_buffer_length, sizeof(char));
-
- if (field_buffer == NULL) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
- return;
- }
-
- int len = snprintf(field_buffer, field_buffer_length, "%s%s%s", field_name, field_delimiters, field_value);
- if (len == -1) {
- if (field_buffer)
- free(field_buffer);
- return;
- } else if ( len > 0 )
- field_buffer[len] = '\0';
-
- http_field_array->array[http_field_array->position] = field_buffer;
- http_field_array->position++;
-
-}
-
-int url_download_get_all_http_header_fields(url_download_h download, char ***fields, int *fields_length)
-{
- http_field_array_t http_field_array;
-
- if (download == NULL || fields == NULL || fields_length == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- http_field_array.position = 0;
- http_field_array.array_length = bundle_get_count(download->http_header);
- http_field_array.array = calloc(http_field_array.array_length, sizeof(char*));
-
- if (http_field_array.array == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_OUT_OF_MEMORY, NULL);
-
- bundle_iterate(download->http_header, url_download_get_all_http_header_fields_iterator, &http_field_array);
-
- *fields = http_field_array.array;
- *fields_length = http_field_array.array_length;
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-
-typedef struct {
- url_download_h download;
- url_download_http_header_field_cb callback;
- void* user_data;
- bool foreach_break;
-} foreach_context_http_header_field_t;
-
-static void url_download_foreach_http_header_field_iterator(const char *field_name, const char *field_value, void *user_data)
-{
- foreach_context_http_header_field_t *foreach_context;
-
- foreach_context = user_data;
-
- if (foreach_context == NULL) {
- url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
- return;
- }
-
-
- if (foreach_context->foreach_break == true)
- return;
-
- if (foreach_context->callback != NULL)
- foreach_context->foreach_break = !foreach_context->callback(foreach_context->download,
- field_name, foreach_context->user_data);
-}
-
-int url_download_foreach_http_header_field(url_download_h download, url_download_http_header_field_cb callback, void *user_data)
-{
- foreach_context_http_header_field_t foreach_context = {
- .download = download,
- .callback = callback,
- .user_data = user_data,
- .foreach_break = false
- };
-
- if (download == NULL || callback == NULL)
- return url_download_error(__FUNCTION__, URL_DOWNLOAD_ERROR_INVALID_PARAMETER, NULL);
-
- bundle_iterate(download->http_header, url_download_foreach_http_header_field_iterator, &foreach_context);
-
- return URL_DOWNLOAD_ERROR_NONE;
-}
-